diff options
author | Siarhei Vishniakou <svv@google.com> | 2023-12-27 23:31:32 +0000 |
---|---|---|
committer | Siarhei Vishniakou <svv@google.com> | 2023-12-28 01:03:04 +0000 |
commit | b32ea72cf741cbfca72a1bf0b0ebb2ebb3e3b6e1 (patch) | |
tree | 6fa3ee26d324846e74df3c0fc736aba07853d4fb /services | |
parent | 767bb25c593706ddd2b8a143effba253930b1c03 (diff) | |
download | native-b32ea72cf741cbfca72a1bf0b0ebb2ebb3e3b6e1.tar.gz |
Only prune non-pointer events
The "pruning input queue" functionality is present in order to prevent
the dispatcher from being blocked. However, only focus-dispatched events
(like keys and joystick events) can block the dispatcher, because they
require a focused window. Pointer events, like touches, go to the
touched window, and are not blocked.
Furthermore, dropping pointer events is not a good idea, because it can
cause inconsistent input streams to be processed inside the dispatcher.
In this CL, we prevent pointer events from being dropped. This resolves
a crash in InputDispatcher, because an inconsistent input stream would
lead to unexpected behaviour later on in the pipeline.
To reproduce the original crash:
1) Set device to 3-button navigation mode
2) Launch an app, then quickly press the back button
3) Then, quickly touch the app again
The WM would not yet send the "setFocusedApplication" call to match the
newly launched app (maybe it's slow, or it's just a bug). The dispatcher
would be waiting for a focused window, and the touch into the newly
launched app would cause the dispatcher to drop events because "the user
is interacting with a different app than the one that's currently
focused". And finally, since the navigation bar listens for outside
touches, the dispatcher would try to send an ACTION_OUTSIDE event to the
navigation bar, and this would conflict with the current dispatcher
state because there's already a pointer inside navigation bar (and the
dispatcher dropped the ACTION_UP event instead of processing it).
Bug: 308531018
Test: TEST=inputflinger_tests; m $TEST && $ANDROID_HOST_OUT/nativetest64/$TEST/$TEST
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:99e407b0e7e748cbb82bdaa2e21c740c308d60b3)
Merged-In: I7ac5f7bd607c7411e3917977888d1cfeaf96615c
Change-Id: I7ac5f7bd607c7411e3917977888d1cfeaf96615c
Change-Id: I81b31824c85a3dc0b43165d527772d8b89e38781
Diffstat (limited to 'services')
-rw-r--r-- | services/inputflinger/dispatcher/InputDispatcher.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp index 7981e9acb5..2dbb653542 100644 --- a/services/inputflinger/dispatcher/InputDispatcher.cpp +++ b/services/inputflinger/dispatcher/InputDispatcher.cpp @@ -1058,7 +1058,10 @@ void InputDispatcher::dispatchOnceInnerLocked(nsecs_t* nextWakeupTime) { dropReason = DropReason::STALE; } if (dropReason == DropReason::NOT_DROPPED && mNextUnblockedEvent) { - dropReason = DropReason::BLOCKED; + if (!isFromSource(motionEntry->source, AINPUT_SOURCE_CLASS_POINTER)) { + // Only drop events that are focus-dispatched. + dropReason = DropReason::BLOCKED; + } } done = dispatchMotionLocked(currentTime, motionEntry, &dropReason, nextWakeupTime); break; |