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
Merged-In: I3c561b03b0ba75c22115ae020e6b41855686ab64
(cherry picked from commit ff1f1bb99489fd372c57908dafdd3817a33db0c5)
diff --git a/services/inputflinger/dispatcher/InputState.cpp b/services/inputflinger/dispatcher/InputState.cpp
index 7fa9e09..386056d 100644
--- a/services/inputflinger/dispatcher/InputState.cpp
+++ b/services/inputflinger/dispatcher/InputState.cpp
@@ -16,9 +16,11 @@
#include "InputState.h"
+#include "InputDispatcher.h"
+
namespace android::inputdispatcher {
-InputState::InputState() {}
+InputState::InputState(const IdGenerator& idGenerator) : mIdGenerator(idGenerator) {}
InputState::~InputState() {}
@@ -268,7 +270,7 @@
std::vector<EventEntry*> events;
for (KeyMemento& memento : mKeyMementos) {
if (shouldCancelKey(memento, options)) {
- events.push_back(new KeyEntry(SYNTHESIZED_EVENT_ID, currentTime, memento.deviceId,
+ events.push_back(new KeyEntry(mIdGenerator.nextId(), currentTime, memento.deviceId,
memento.source, memento.displayId, memento.policyFlags,
AKEY_EVENT_ACTION_UP,
memento.flags | AKEY_EVENT_FLAG_CANCELED, memento.keyCode,
@@ -281,7 +283,7 @@
if (shouldCancelMotion(memento, options)) {
const int32_t action = memento.hovering ? AMOTION_EVENT_ACTION_HOVER_EXIT
: AMOTION_EVENT_ACTION_CANCEL;
- events.push_back(new MotionEntry(SYNTHESIZED_EVENT_ID, currentTime, memento.deviceId,
+ events.push_back(new MotionEntry(mIdGenerator.nextId(), currentTime, memento.deviceId,
memento.source, memento.displayId, memento.policyFlags,
action, 0 /*actionButton*/, memento.flags, AMETA_NONE,
0 /*buttonState*/, MotionClassification::NONE,
@@ -331,7 +333,7 @@
: AMOTION_EVENT_ACTION_POINTER_DOWN
| (i << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT);
- events.push_back(new MotionEntry(SYNTHESIZED_EVENT_ID, currentTime, memento.deviceId,
+ events.push_back(new MotionEntry(mIdGenerator.nextId(), currentTime, memento.deviceId,
memento.source, memento.displayId, memento.policyFlags,
action, 0 /*actionButton*/, memento.flags, AMETA_NONE,
0 /*buttonState*/, MotionClassification::NONE,