InputDispatcher: Establish 1:1 relation between eventId and EventEntry
Previously, one event could be dispatched as events with different
actions and flags to different windows. For example, a HOVER_MOVE
event can technically be dispatched as HOVER_ENTER, HOVER_MOVE, or
HOVER_EXIT. We achieved this by "overriding" the action and flags
in the EventEntry using the DispatchEntry. This was further complicated
by the fact that we wanted to generate a new eventId in some cases
and not in others.
To simplify this logic, we will establish a 1:1 relationship between
eventId and EventEntry, so that eventIds will never be overridden
during dispatch. We will also simplify things further by using a new
eventId (therefore also creating a new EventEntry) whenever the action
of an event is to change. There will no longer be an action override
in DispatchEntry either.
Even after this change, there are still fields that will need to be
modified for each DispatchEntry, namely the flags and coordinates
that take the window/display transforms into account, so this change
is not intended to create a 1:1 relation between eventId and outbound
events from InputDispatcher.
Bug: 210460522
Test: atest inputflinger_tests
Change-Id: I158267081814d856d7fedf05c02c284717533d6c
diff --git a/services/inputflinger/dispatcher/Entry.cpp b/services/inputflinger/dispatcher/Entry.cpp
index ebc04cf..cc0d49c 100644
--- a/services/inputflinger/dispatcher/Entry.cpp
+++ b/services/inputflinger/dispatcher/Entry.cpp
@@ -287,21 +287,15 @@
rawTransform(rawTransform),
globalScaleFactor(globalScaleFactor),
deliveryTime(0),
- resolvedAction(0),
resolvedFlags(0) {
switch (this->eventEntry->type) {
case EventEntry::Type::KEY: {
const KeyEntry& keyEntry = static_cast<const KeyEntry&>(*this->eventEntry);
- resolvedEventId = keyEntry.id;
- resolvedAction = keyEntry.action;
resolvedFlags = keyEntry.flags;
-
break;
}
case EventEntry::Type::MOTION: {
const MotionEntry& motionEntry = static_cast<const MotionEntry&>(*this->eventEntry);
- resolvedEventId = motionEntry.id;
- resolvedAction = motionEntry.action;
resolvedFlags = motionEntry.flags;
break;
}
@@ -321,24 +315,9 @@
}
std::ostream& operator<<(std::ostream& out, const DispatchEntry& entry) {
- out << "DispatchEntry{resolvedAction=";
- switch (entry.eventEntry->type) {
- case EventEntry::Type::KEY: {
- out << KeyEvent::actionToString(entry.resolvedAction);
- break;
- }
- case EventEntry::Type::MOTION: {
- out << MotionEvent::actionToString(entry.resolvedAction);
- break;
- }
- default: {
- out << "<invalid, not a key or a motion>";
- break;
- }
- }
std::string transform;
entry.transform.dump(transform, "transform");
- out << ", resolvedFlags=" << entry.resolvedFlags
+ out << "DispatchEntry{resolvedFlags=" << entry.resolvedFlags
<< ", targetFlags=" << entry.targetFlags.string() << ", transform=" << transform
<< "} original: " << entry.eventEntry->getDescription();
return out;