InputTracer: Trace injected events with history as separate events

If an injected event is batched, it is split into separate events and
each historical event is injected individually. When this happens, the
historical events were not being traced, which is a bug. Trace them.

It is difficult to test batching from InputDispatcher_tests because we
are polling for events rather than responding to them, so avoid adding a
test for now.

Bug: 210460522
Test: atest inputflinger_tests
Change-Id: I7062f97181bcde614e43e68e127583690efa70b2
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 057b996..1725e48 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -4815,6 +4815,10 @@
                                                                         pointerCount));
                 transformMotionEntryForInjectionLocked(*nextInjectedEntry,
                                                        motionEvent.getTransform());
+                if (mTracer) {
+                    nextInjectedEntry->traceTracker =
+                            mTracer->traceInboundEvent(*nextInjectedEntry);
+                }
                 injectedEntries.push(std::move(nextInjectedEntry));
             }
             break;