InputDispatcher: Reset touched window dispatch mode to AS_IS
After generating input targets for an event, reset all touched windows'
dispatch mode to AS_IS, since the dispatch mode in touched window should
only be used for generating the targets.
Bug: 210460522
Test: atest inpuflinger_tests
Change-Id: I7288b24fe232a780d5dc283420d6f2b103ef0691
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index a4529e6..b8cdb3d 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -2682,11 +2682,10 @@
outInjectionResult = InputEventInjectionResult::SUCCEEDED;
+ // Now that we have generated all of the input targets for this event, reset the dispatch
+ // mode for all touched window to AS_IS.
for (TouchedWindow& touchedWindow : tempTouchState.windows) {
- // Targets that we entered in a slippery way will now become AS-IS targets
- if (touchedWindow.dispatchMode == InputTarget::DispatchMode::SLIPPERY_ENTER) {
- touchedWindow.dispatchMode = InputTarget::DispatchMode::AS_IS;
- }
+ touchedWindow.dispatchMode = InputTarget::DispatchMode::AS_IS;
}
// Update final pieces of touch state if the injector had permission.
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index e220133..e230a91 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -4320,6 +4320,12 @@
// Therefore, we should offset them by (100, 100) relative to the screen's top left corner.
outsideWindow->consumeMotionEvent(
AllOf(WithMotionAction(ACTION_OUTSIDE), WithCoords(-50, -50)));
+
+ // Ensure outsideWindow doesn't get any more events for the gesture.
+ mDispatcher->notifyMotion(generateMotionArgs(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
+ ADISPLAY_ID_DEFAULT, {PointF{51, 51}}));
+ window->consumeMotionMove();
+ outsideWindow->assertNoEvents();
}
/**