Loading services/inputflinger/dispatcher/InputDispatcher.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -1247,9 +1247,10 @@ void InputDispatcher::dispatchPointerCaptureChangedLocked( nsecs_t currentTime, const std::shared_ptr<PointerCaptureChangedEntry>& entry, DropReason& dropReason) { const bool haveWindowWithPointerCapture = mWindowTokenWithPointerCapture != nullptr; if (entry->pointerCaptureEnabled == haveWindowWithPointerCapture) { LOG_ALWAYS_FATAL_IF(mFocusedWindowRequestedPointerCapture, "The Pointer Capture state has already been dispatched to the window."); if (entry->pointerCaptureEnabled && haveWindowWithPointerCapture) { LOG_ALWAYS_FATAL("Pointer Capture has already been enabled for the window."); } if (!entry->pointerCaptureEnabled && !haveWindowWithPointerCapture) { // Pointer capture was already forcefully disabled because of focus change. dropReason = DropReason::NOT_DROPPED; return; Loading services/inputflinger/tests/InputDispatcher_test.cpp +23 −0 Original line number Diff line number Diff line Loading @@ -4217,4 +4217,27 @@ TEST_F(InputDispatcherPointerCaptureTests, UnexpectedStateChangeDisablesPointerC mWindow->assertNoEvents(); } TEST_F(InputDispatcherPointerCaptureTests, OutOfOrderRequests) { requestAndVerifyPointerCapture(mWindow, true); // The first window loses focus. setFocusedWindow(mSecondWindow); mFakePolicy->waitForSetPointerCapture(false); mWindow->consumeCaptureEvent(false); // Request Pointer Capture from the second window before the notification from InputReader // arrives. mDispatcher->requestPointerCapture(mSecondWindow->getToken(), true); mFakePolicy->waitForSetPointerCapture(true); // InputReader notifies Pointer Capture was disabled (because of the focus change). notifyPointerCaptureChanged(false); // InputReader notifies Pointer Capture was enabled (because of mSecondWindow's request). notifyPointerCaptureChanged(true); mSecondWindow->consumeFocusEvent(true); mSecondWindow->consumeCaptureEvent(true); } } // namespace android::inputdispatcher Loading
services/inputflinger/dispatcher/InputDispatcher.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -1247,9 +1247,10 @@ void InputDispatcher::dispatchPointerCaptureChangedLocked( nsecs_t currentTime, const std::shared_ptr<PointerCaptureChangedEntry>& entry, DropReason& dropReason) { const bool haveWindowWithPointerCapture = mWindowTokenWithPointerCapture != nullptr; if (entry->pointerCaptureEnabled == haveWindowWithPointerCapture) { LOG_ALWAYS_FATAL_IF(mFocusedWindowRequestedPointerCapture, "The Pointer Capture state has already been dispatched to the window."); if (entry->pointerCaptureEnabled && haveWindowWithPointerCapture) { LOG_ALWAYS_FATAL("Pointer Capture has already been enabled for the window."); } if (!entry->pointerCaptureEnabled && !haveWindowWithPointerCapture) { // Pointer capture was already forcefully disabled because of focus change. dropReason = DropReason::NOT_DROPPED; return; Loading
services/inputflinger/tests/InputDispatcher_test.cpp +23 −0 Original line number Diff line number Diff line Loading @@ -4217,4 +4217,27 @@ TEST_F(InputDispatcherPointerCaptureTests, UnexpectedStateChangeDisablesPointerC mWindow->assertNoEvents(); } TEST_F(InputDispatcherPointerCaptureTests, OutOfOrderRequests) { requestAndVerifyPointerCapture(mWindow, true); // The first window loses focus. setFocusedWindow(mSecondWindow); mFakePolicy->waitForSetPointerCapture(false); mWindow->consumeCaptureEvent(false); // Request Pointer Capture from the second window before the notification from InputReader // arrives. mDispatcher->requestPointerCapture(mSecondWindow->getToken(), true); mFakePolicy->waitForSetPointerCapture(true); // InputReader notifies Pointer Capture was disabled (because of the focus change). notifyPointerCaptureChanged(false); // InputReader notifies Pointer Capture was enabled (because of mSecondWindow's request). notifyPointerCaptureChanged(true); mSecondWindow->consumeFocusEvent(true); mSecondWindow->consumeCaptureEvent(true); } } // namespace android::inputdispatcher