InputTracer: Wait to trace dispatch events to the backend

... until event processing is complete. This is because we need to wait
until processing complete to get information about the targets and
sensitivity of an event, which is required to write the dispatch event
to the backend.

Bug: 210460522
Test: atest inputflinger_tests
Change-Id: I227c207d6a5667f9297e74b4c8be9f8e980d6d13
diff --git a/services/inputflinger/dispatcher/trace/InputTracer.h b/services/inputflinger/dispatcher/trace/InputTracer.h
index 529c0fa..8da9632 100644
--- a/services/inputflinger/dispatcher/trace/InputTracer.h
+++ b/services/inputflinger/dispatcher/trace/InputTracer.h
@@ -52,6 +52,8 @@
 private:
     std::unique_ptr<InputTracingBackendInterface> mBackend;
 
+    using WindowDispatchArgs = InputTracingBackendInterface::WindowDispatchArgs;
+
     // The state of a tracked event, shared across all events derived from the original event.
     struct EventState {
         explicit inline EventState(InputTracer& tracer) : tracer(tracer){};
@@ -62,6 +64,8 @@
         InputTracer& tracer;
         std::vector<const TracedEvent> events;
         bool isEventProcessingComplete{false};
+        // A queue to hold dispatch args from being traced until event processing is complete.
+        std::vector<const WindowDispatchArgs> pendingDispatchArgs;
         // TODO(b/210460522): Add additional args for tracking event sensitivity and
         //  dispatch target UIDs.
     };