Prevent targeted injection into non-owned windows
Before this CL, it was possible to send ACTION_OUTSIDE events to
non-owned windows even during targeted injection.
However:
1) It's not clear why we actually need this behaviour, and it requires
extra work to support this
2) The block of code that we used to "support" this didn't actually do
anything.
3) During targeted injection, you should only be allowed to affect owned
windows. If you want to affect the entire system, you:
a) Should use global rather than targeted injection
b) Must be very careful to clean up any remaining state that you
cause
In this CL, we remove the block of code that did nothing, and also add
an explicit target pass to remove any non-owned windows.
This should allow further future refactors.
Bug: 211379801
Fixes: 281091008
Test: m inputflinger_tests && $ANDROID_HOST_OUT/nativetest64/inputflinger_tests/inputflinger_tests
Change-Id: Ib065d39ab162188bf2f6e73601e2bb7e2c5d0409
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index 92e7f43..8b74b25 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -9777,7 +9777,7 @@
window->assertNoEvents();
}
-TEST_F(InputDispatcherTargetedInjectionTest, CanGenerateActionOutsideToOtherUids) {
+TEST_F(InputDispatcherTargetedInjectionTest, CannotGenerateActionOutsideToOtherUids) {
auto owner = User(mDispatcher, 10, 11);
auto window = owner.createWindow();
@@ -9787,11 +9787,11 @@
randosWindow->setWatchOutsideTouch(true);
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {randosWindow, window}}});
- // We allow generation of ACTION_OUTSIDE events into windows owned by different uids.
+ // Do not allow generation of ACTION_OUTSIDE events into windows owned by different uids.
EXPECT_EQ(InputEventInjectionResult::SUCCEEDED,
owner.injectTargetedMotion(AMOTION_EVENT_ACTION_DOWN));
window->consumeMotionDown();
- randosWindow->consumeMotionOutside();
+ randosWindow->assertNoEvents();
}
} // namespace android::inputdispatcher