InputDispatcher: Assert that all spy windows are trusted overlays
Bug: 162194035
Test: atest inputflinger_tests
Change-Id: I6491a08ff4403db685562a37694d37e0f51581f6
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index b2d0fb8..76d9fee 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -6300,6 +6300,7 @@
sp<FakeWindowHandle> spy =
new FakeWindowHandle(application, mDispatcher, name.c_str(), ADISPLAY_ID_DEFAULT);
spy->setInputFeatures(WindowInfo::Feature::SPY);
+ spy->setTrustedOverlay(true);
spy->addFlags(flags);
return spy;
}
@@ -6318,6 +6319,16 @@
};
/**
+ * Adding a spy window that is not a trusted overlay causes Dispatcher to abort.
+ */
+TEST_F(InputDispatcherSpyWindowTest, UntrustedSpy_AbortsDispatcher) {
+ auto spy = createSpy(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ spy->setTrustedOverlay(false);
+ ASSERT_DEATH(mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {spy}}}),
+ ".* not a trusted overlay");
+}
+
+/**
* Input injection into a display with a spy window but no foreground windows should succeed.
*/
TEST_F(InputDispatcherSpyWindowTest, NoForegroundWindow) {
@@ -6477,28 +6488,6 @@
}
/**
- * When configured to block untrusted touches, events will not be dispatched to windows below a spy
- * window if it is not a trusted overly.
- */
-TEST_F(InputDispatcherSpyWindowTest, BlockUntrustedTouches) {
- mDispatcher->setBlockUntrustedTouchesMode(android::os::BlockUntrustedTouchesMode::BLOCK);
-
- auto window = createForeground();
- auto spy = createSpy(WindowInfo::Flag::NOT_TOUCH_MODAL);
- window->setOwnerInfo(111, 111);
- spy->setOwnerInfo(222, 222);
- spy->setTouchOcclusionMode(TouchOcclusionMode::BLOCK_UNTRUSTED);
- mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {spy, window}}});
-
- // Inject an event outside the spy window's frame and touchable region.
- ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT))
- << "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- spy->consumeMotionDown();
- window->assertNoEvents();
-}
-
-/**
* A spy window can pilfer pointers. When this happens, touch gestures that are currently sent to
* any other windows - including other spy windows - will also be cancelled.
*/