Let InputFlinger generate event IDs.

Also send event IDs via InputMessage and add some atrace calls to form a
complete chain of input event processing.

Bug: 144889238
Test: systrace shows correct event IDs.
Test: atest inputflinger_tests
Change-Id: I3c561b03b0ba75c22115ae020e6b41855686ab64
diff --git a/services/inputflinger/dispatcher/Entry.h b/services/inputflinger/dispatcher/Entry.h
index c58ae23..ab481bd 100644
--- a/services/inputflinger/dispatcher/Entry.h
+++ b/services/inputflinger/dispatcher/Entry.h
@@ -29,9 +29,6 @@
 
 namespace android::inputdispatcher {
 
-// Sequence number for synthesized or injected events.
-constexpr int32_t SYNTHESIZED_EVENT_ID = 0;
-
 struct EventEntry {
     enum class Type {
         CONFIGURATION_CHANGED,
@@ -78,7 +75,9 @@
      * Key repeat is a synthesized event, because it is related to an actual hardware state
      * (a key is currently pressed), but the repeat itself is generated by the framework.
      */
-    inline bool isSynthesized() const { return isInjected() || id == SYNTHESIZED_EVENT_ID; }
+    inline bool isSynthesized() const {
+        return isInjected() || IdGenerator::getSource(id) != IdGenerator::Source::INPUT_READER;
+    }
 
     void release();
 
@@ -199,7 +198,8 @@
     float windowYScale = 1.0f;
     nsecs_t deliveryTime; // time when the event was actually delivered
 
-    // Set to the resolved action and flags when the event is enqueued.
+    // Set to the resolved ID, action and flags when the event is enqueued.
+    int32_t resolvedEventId;
     int32_t resolvedAction;
     int32_t resolvedFlags;