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/InputState.h b/services/inputflinger/dispatcher/InputState.h
index 686c432..b0e4209 100644
--- a/services/inputflinger/dispatcher/InputState.h
+++ b/services/inputflinger/dispatcher/InputState.h
@@ -41,16 +41,15 @@
// Records tracking information for a key event that has just been published.
// Returns true if the event should be delivered, false if it is inconsistent
// and should be skipped.
- bool trackKey(const KeyEntry& entry, int32_t action, int32_t flags);
+ bool trackKey(const KeyEntry& entry, int32_t flags);
// Records tracking information for a motion event that has just been published.
// Returns true if the event should be delivered, false if it is inconsistent
// and should be skipped.
- bool trackMotion(const MotionEntry& entry, int32_t action, int32_t flags);
+ bool trackMotion(const MotionEntry& entry, int32_t flags);
// Create cancel events for the previous stream if the current motionEntry requires it.
- std::unique_ptr<EventEntry> cancelConflictingInputStream(const MotionEntry& motionEntry,
- int32_t resolvedAction);
+ std::unique_ptr<EventEntry> cancelConflictingInputStream(const MotionEntry& motionEntry);
// Synthesizes cancelation events for the current state and resets the tracked state.
std::vector<std::unique_ptr<EventEntry>> synthesizeCancelationEvents(
@@ -127,7 +126,7 @@
static bool shouldCancelKey(const KeyMemento& memento, const CancelationOptions& options);
static bool shouldCancelMotion(const MotionMemento& memento, const CancelationOptions& options);
- bool shouldCancelPreviousStream(const MotionEntry& motionEntry, int32_t resolvedAction) const;
+ bool shouldCancelPreviousStream(const MotionEntry& motionEntry) const;
std::unique_ptr<MotionEntry> createCancelEntryForMemento(const MotionMemento& memento,
nsecs_t eventTime) const;