Loading services/inputflinger/dispatcher/InputDispatcher.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -6330,6 +6330,13 @@ void InputDispatcher::onWindowInfosChanged(const std::vector<WindowInfo>& window { // acquire lock std::scoped_lock _l(mLock); // Ensure that we have an entry created for all existing displays so that if a displayId has // no windows, we can tell that the windows were removed from the display. for (const auto& [displayId, _] : mWindowHandlesByDisplay) { handlesPerDisplay[displayId]; } mDisplayInfos.clear(); for (const auto& displayInfo : displayInfos) { mDisplayInfos.emplace(displayInfo.displayId, displayInfo); Loading services/inputflinger/tests/InputDispatcher_test.cpp +29 −0 Original line number Diff line number Diff line Loading @@ -2293,6 +2293,35 @@ TEST_F(InputDispatcherTest, ActionOutsideSentOnlyWhenAWindowIsTouched) { thirdWindow->consumeMotionDown(); } TEST_F(InputDispatcherTest, OnWindowInfosChanged_RemoveAllWindowsOnDisplay) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> window = new FakeWindowHandle(application, mDispatcher, "Fake Window", ADISPLAY_ID_DEFAULT); window->setFocusable(true); mDispatcher->onWindowInfosChanged({*window->getInfo()}, {}); setFocusedWindow(window); window->consumeFocusEvent(true); NotifyKeyArgs keyDown = generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT); NotifyKeyArgs keyUp = generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT); mDispatcher->notifyKey(&keyDown); mDispatcher->notifyKey(&keyUp); window->consumeKeyDown(ADISPLAY_ID_DEFAULT); window->consumeKeyUp(ADISPLAY_ID_DEFAULT); // All windows are removed from the display. Ensure that we can no longer dispatch to it. mDispatcher->onWindowInfosChanged({}, {}); window->consumeFocusEvent(false); mDispatcher->notifyKey(&keyDown); mDispatcher->notifyKey(&keyUp); window->assertNoEvents(); } /** * Ensure the correct coordinate spaces are used by InputDispatcher. * Loading Loading
services/inputflinger/dispatcher/InputDispatcher.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -6330,6 +6330,13 @@ void InputDispatcher::onWindowInfosChanged(const std::vector<WindowInfo>& window { // acquire lock std::scoped_lock _l(mLock); // Ensure that we have an entry created for all existing displays so that if a displayId has // no windows, we can tell that the windows were removed from the display. for (const auto& [displayId, _] : mWindowHandlesByDisplay) { handlesPerDisplay[displayId]; } mDisplayInfos.clear(); for (const auto& displayInfo : displayInfos) { mDisplayInfos.emplace(displayInfo.displayId, displayInfo); Loading
services/inputflinger/tests/InputDispatcher_test.cpp +29 −0 Original line number Diff line number Diff line Loading @@ -2293,6 +2293,35 @@ TEST_F(InputDispatcherTest, ActionOutsideSentOnlyWhenAWindowIsTouched) { thirdWindow->consumeMotionDown(); } TEST_F(InputDispatcherTest, OnWindowInfosChanged_RemoveAllWindowsOnDisplay) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> window = new FakeWindowHandle(application, mDispatcher, "Fake Window", ADISPLAY_ID_DEFAULT); window->setFocusable(true); mDispatcher->onWindowInfosChanged({*window->getInfo()}, {}); setFocusedWindow(window); window->consumeFocusEvent(true); NotifyKeyArgs keyDown = generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT); NotifyKeyArgs keyUp = generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT); mDispatcher->notifyKey(&keyDown); mDispatcher->notifyKey(&keyUp); window->consumeKeyDown(ADISPLAY_ID_DEFAULT); window->consumeKeyUp(ADISPLAY_ID_DEFAULT); // All windows are removed from the display. Ensure that we can no longer dispatch to it. mDispatcher->onWindowInfosChanged({}, {}); window->consumeFocusEvent(false); mDispatcher->notifyKey(&keyDown); mDispatcher->notifyKey(&keyUp); window->assertNoEvents(); } /** * Ensure the correct coordinate spaces are used by InputDispatcher. * Loading