Loading services/inputflinger/dispatcher/InputDispatcher.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -5562,7 +5562,7 @@ InputDispatcher::findTouchStateWindowAndDisplayLocked(const sp<IBinder>& token) return std::make_tuple(nullptr, nullptr, ADISPLAY_ID_DEFAULT); } bool InputDispatcher::transferTouchFocus(const sp<IBinder>& fromToken, const sp<IBinder>& toToken, bool InputDispatcher::transferTouchGesture(const sp<IBinder>& fromToken, const sp<IBinder>& toToken, bool isDragDrop) { if (fromToken == toToken) { if (DEBUG_FOCUS) { Loading Loading @@ -5597,7 +5597,7 @@ bool InputDispatcher::transferTouchFocus(const sp<IBinder>& fromToken, const sp< } if (DEBUG_FOCUS) { ALOGD("transferTouchFocus: fromWindowHandle=%s, toWindowHandle=%s", ALOGD("%s: fromWindowHandle=%s, toWindowHandle=%s", __func__, touchedWindow->windowHandle->getName().c_str(), toWindowHandle->getName().c_str()); } Loading Loading @@ -5683,7 +5683,8 @@ sp<WindowInfoHandle> InputDispatcher::findTouchedForegroundWindowLocked(int32_t } // Binder call bool InputDispatcher::transferTouch(const sp<IBinder>& destChannelToken, int32_t displayId) { bool InputDispatcher::transferTouchOnDisplay(const sp<IBinder>& destChannelToken, int32_t displayId) { sp<IBinder> fromToken; { // acquire lock std::scoped_lock _l(mLock); Loading @@ -5703,7 +5704,7 @@ bool InputDispatcher::transferTouch(const sp<IBinder>& destChannelToken, int32_t fromToken = from->getToken(); } // release lock return transferTouchFocus(fromToken, destChannelToken); return transferTouchGesture(fromToken, destChannelToken); } void InputDispatcher::resetAndDropEverythingLocked(const char* reason) { Loading services/inputflinger/dispatcher/InputDispatcher.h +3 −3 Original line number Diff line number Diff line Loading @@ -124,9 +124,9 @@ public: int32_t displayId) override; void setMaximumObscuringOpacityForTouch(float opacity) override; bool transferTouchFocus(const sp<IBinder>& fromToken, const sp<IBinder>& toToken, bool transferTouchGesture(const sp<IBinder>& fromToken, const sp<IBinder>& toToken, bool isDragDrop = false) override; bool transferTouch(const sp<IBinder>& destChannelToken, int32_t displayId) override; bool transferTouchOnDisplay(const sp<IBinder>& destChannelToken, int32_t displayId) override; base::Result<std::unique_ptr<InputChannel>> createInputChannel( const std::string& name) override; Loading services/inputflinger/dispatcher/include/InputDispatcherInterface.h +9 −8 Original line number Diff line number Diff line Loading @@ -141,21 +141,22 @@ public: virtual void setMaximumObscuringOpacityForTouch(float opacity) = 0; /** * Transfers touch focus from one window to another window. Transferring touch focus will not * Transfers a touch gesture from one window to another window. Transferring touch will not * have any effect on the focused window. * * Returns true on success. False if the window did not actually have touch focus. * Returns true on success. False if the window did not actually have an active touch gesture. */ virtual bool transferTouchFocus(const sp<IBinder>& fromToken, const sp<IBinder>& toToken, virtual bool transferTouchGesture(const sp<IBinder>& fromToken, const sp<IBinder>& toToken, bool isDragDrop) = 0; /** * Transfer touch focus to the provided channel, no matter where the current touch is. * Transferring touch focus will not have any effect on the focused window. * Transfer a touch gesture to the provided channel, no matter where the current touch is. * Transferring touch will not have any effect on the focused window. * * Return true on success, false if there was no on-going touch. * Returns true on success, false if there was no on-going touch on the display. * @deprecated */ virtual bool transferTouch(const sp<IBinder>& destChannelToken, int32_t displayId) = 0; virtual bool transferTouchOnDisplay(const sp<IBinder>& destChannelToken, int32_t displayId) = 0; /** * Sets focus on the specified window. Loading services/inputflinger/tests/InputDispatcher_test.cpp +44 −42 Original line number Diff line number Diff line Loading @@ -5181,7 +5181,7 @@ TEST_F(InputDispatcherDisplayProjectionTest, SynthesizeDownWithCorrectCoordinate // The pointer is transferred to the second window, and the second window receives it in the // correct coordinate space. mDispatcher->transferTouchFocus(firstWindow->getToken(), secondWindow->getToken()); mDispatcher->transferTouchGesture(firstWindow->getToken(), secondWindow->getToken()); firstWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_CANCEL), WithCoords(100, 400))); secondWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_DOWN), WithCoords(-100, -400))); } Loading Loading @@ -5419,16 +5419,16 @@ TEST_P(TransferTouchFixture, TransferTouch_OnePointer) { } /** * When 'transferTouch' API is invoked, dispatcher needs to find the "best" window to take touch * from. When we have spy windows, there are several windows to choose from: either spy, or the * 'real' (non-spy) window. Always prefer the 'real' window because that's what would be most * When 'transferTouchGesture' API is invoked, dispatcher needs to find the "best" window to take * touch from. When we have spy windows, there are several windows to choose from: either spy, or * the 'real' (non-spy) window. Always prefer the 'real' window because that's what would be most * natural to the user. * In this test, we are sending a pointer to both spy window and first window. We then try to * transfer touch to the second window. The dispatcher should identify the first window as the * one that should lose the gesture, and therefore the action should be to move the gesture from * the first window to the second. * The main goal here is to test the behaviour of 'transferTouch' API, but it's still valid to test * the other API, as well. * The main goal here is to test the behaviour of 'transferTouchGesture' API, but it's still valid * to test the other API, as well. */ TEST_P(TransferTouchFixture, TransferTouch_MultipleWindowsWithSpy) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); Loading @@ -5455,7 +5455,7 @@ TEST_P(TransferTouchFixture, TransferTouch_MultipleWindowsWithSpy) { firstWindow->consumeMotionDown(); // Transfer touch to the second window. Non-spy window should be preferred over the spy window // if f === 'transferTouch'. // if f === 'transferTouchGesture'. TransferFunction f = GetParam(); const bool success = f(mDispatcher, firstWindow->getToken(), secondWindow->getToken()); ASSERT_TRUE(success); Loading Loading @@ -5593,22 +5593,23 @@ TEST_P(TransferTouchFixture, TransferTouch_MultipleWallpapers) { } // For the cases of single pointer touch and two pointers non-split touch, the api's // 'transferTouch' and 'transferTouchFocus' are equivalent in behaviour. They only differ // 'transferTouchGesture' and 'transferTouchOnDisplay' are equivalent in behaviour. They only differ // for the case where there are multiple pointers split across several windows. INSTANTIATE_TEST_SUITE_P(InputDispatcherTransferFunctionTests, TransferTouchFixture, INSTANTIATE_TEST_SUITE_P( InputDispatcherTransferFunctionTests, TransferTouchFixture, ::testing::Values( [&](const std::unique_ptr<InputDispatcher>& dispatcher, sp<IBinder> /*ignored*/, sp<IBinder> destChannelToken) { return dispatcher->transferTouch(destChannelToken, [&](const std::unique_ptr<InputDispatcher>& dispatcher, sp<IBinder> /*ignored*/, sp<IBinder> destChannelToken) { return dispatcher->transferTouchOnDisplay(destChannelToken, ADISPLAY_ID_DEFAULT); }, [&](const std::unique_ptr<InputDispatcher>& dispatcher, sp<IBinder> from, sp<IBinder> to) { return dispatcher->transferTouchFocus(from, to, [&](const std::unique_ptr<InputDispatcher>& dispatcher, sp<IBinder> from, sp<IBinder> to) { return dispatcher->transferTouchGesture(from, to, /*isDragAndDrop=*/false); })); TEST_F(InputDispatcherTest, TransferTouchFocus_TwoPointersSplitTouch) { TEST_F(InputDispatcherTest, TransferTouch_TwoPointersSplitTouch) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> firstWindow = Loading Loading @@ -5644,8 +5645,8 @@ TEST_F(InputDispatcherTest, TransferTouchFocus_TwoPointersSplitTouch) { firstWindow->consumeMotionMove(); secondWindow->consumeMotionDown(); // Transfer touch focus to the second window mDispatcher->transferTouchFocus(firstWindow->getToken(), secondWindow->getToken()); // Transfer touch to the second window mDispatcher->transferTouchGesture(firstWindow->getToken(), secondWindow->getToken()); // The first window gets cancel and the new gets pointer down (it already saw down) firstWindow->consumeMotionCancel(); secondWindow->consumeMotionPointerDown(1, ADISPLAY_ID_DEFAULT, Loading @@ -5668,11 +5669,11 @@ TEST_F(InputDispatcherTest, TransferTouchFocus_TwoPointersSplitTouch) { secondWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); } // Same as TransferTouchFocus_TwoPointersSplitTouch, but using 'transferTouch' api. // Unlike 'transferTouchFocus', calling 'transferTouch' when there are two windows receiving // touch is not supported, so the touch should continue on those windows and the transferred-to // window should get nothing. TEST_F(InputDispatcherTest, TransferTouch_TwoPointersSplitTouch) { // Same as TransferTouch_TwoPointersSplitTouch, but using 'transferTouchOnDisplay' api. // Unlike 'transferTouchGesture', calling 'transferTouchOnDisplay' when there are two windows // receiving touch is not supported, so the touch should continue on those windows and the // transferred-to window should get nothing. TEST_F(InputDispatcherTest, TransferTouchOnDisplay_TwoPointersSplitTouch) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> firstWindow = Loading Loading @@ -5710,8 +5711,8 @@ TEST_F(InputDispatcherTest, TransferTouch_TwoPointersSplitTouch) { // Transfer touch focus to the second window const bool transferred = mDispatcher->transferTouch(secondWindow->getToken(), ADISPLAY_ID_DEFAULT); // The 'transferTouch' call should not succeed, because there are 2 touched windows mDispatcher->transferTouchOnDisplay(secondWindow->getToken(), ADISPLAY_ID_DEFAULT); // The 'transferTouchOnDisplay' call should not succeed, because there are 2 touched windows ASSERT_FALSE(transferred); firstWindow->assertNoEvents(); secondWindow->assertNoEvents(); Loading @@ -5734,9 +5735,9 @@ TEST_F(InputDispatcherTest, TransferTouch_TwoPointersSplitTouch) { } // This case will create two windows and one mirrored window on the default display and mirror // two windows on the second display. It will test if 'transferTouchFocus' works fine if we put // two windows on the second display. It will test if 'transferTouchGesture' works fine if we put // the windows info of second display before default display. TEST_F(InputDispatcherTest, TransferTouchFocus_CloneSurface) { TEST_F(InputDispatcherTest, TransferTouch_CloneSurface) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> firstWindowInPrimary = sp<FakeWindowHandle>::make(application, mDispatcher, "D_1_W1", ADISPLAY_ID_DEFAULT); Loading Loading @@ -5771,8 +5772,8 @@ TEST_F(InputDispatcherTest, TransferTouchFocus_CloneSurface) { // Window should receive motion event. firstWindowInPrimary->consumeMotionDown(ADISPLAY_ID_DEFAULT); // Transfer touch focus ASSERT_TRUE(mDispatcher->transferTouchFocus(firstWindowInPrimary->getToken(), // Transfer touch ASSERT_TRUE(mDispatcher->transferTouchGesture(firstWindowInPrimary->getToken(), secondWindowInPrimary->getToken())); // The first window gets cancel. firstWindowInPrimary->consumeMotionCancel(); Loading @@ -5795,9 +5796,9 @@ TEST_F(InputDispatcherTest, TransferTouchFocus_CloneSurface) { secondWindowInPrimary->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); } // Same as TransferTouchFocus_CloneSurface, but this touch on the secondary display and use // 'transferTouch' api. TEST_F(InputDispatcherTest, TransferTouch_CloneSurface) { // Same as TransferTouch_CloneSurface, but this touch on the secondary display and use // 'transferTouchOnDisplay' api. TEST_F(InputDispatcherTest, TransferTouchOnDisplay_CloneSurface) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> firstWindowInPrimary = sp<FakeWindowHandle>::make(application, mDispatcher, "D_1_W1", ADISPLAY_ID_DEFAULT); Loading Loading @@ -5834,7 +5835,8 @@ TEST_F(InputDispatcherTest, TransferTouch_CloneSurface) { firstWindowInSecondary->consumeMotionDown(SECOND_DISPLAY_ID); // Transfer touch focus ASSERT_TRUE(mDispatcher->transferTouch(secondWindowInSecondary->getToken(), SECOND_DISPLAY_ID)); ASSERT_TRUE(mDispatcher->transferTouchOnDisplay(secondWindowInSecondary->getToken(), SECOND_DISPLAY_ID)); // The first window gets cancel. firstWindowInSecondary->consumeMotionCancel(SECOND_DISPLAY_ID); Loading Loading @@ -10520,7 +10522,7 @@ protected: // Transfer touch focus to the drag window bool transferred = mDispatcher->transferTouchFocus(mWindow->getToken(), mDragWindow->getToken(), mDispatcher->transferTouchGesture(mWindow->getToken(), mDragWindow->getToken(), /*isDragDrop=*/true); if (transferred) { mWindow->consumeMotionCancel(); Loading
services/inputflinger/dispatcher/InputDispatcher.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -5562,7 +5562,7 @@ InputDispatcher::findTouchStateWindowAndDisplayLocked(const sp<IBinder>& token) return std::make_tuple(nullptr, nullptr, ADISPLAY_ID_DEFAULT); } bool InputDispatcher::transferTouchFocus(const sp<IBinder>& fromToken, const sp<IBinder>& toToken, bool InputDispatcher::transferTouchGesture(const sp<IBinder>& fromToken, const sp<IBinder>& toToken, bool isDragDrop) { if (fromToken == toToken) { if (DEBUG_FOCUS) { Loading Loading @@ -5597,7 +5597,7 @@ bool InputDispatcher::transferTouchFocus(const sp<IBinder>& fromToken, const sp< } if (DEBUG_FOCUS) { ALOGD("transferTouchFocus: fromWindowHandle=%s, toWindowHandle=%s", ALOGD("%s: fromWindowHandle=%s, toWindowHandle=%s", __func__, touchedWindow->windowHandle->getName().c_str(), toWindowHandle->getName().c_str()); } Loading Loading @@ -5683,7 +5683,8 @@ sp<WindowInfoHandle> InputDispatcher::findTouchedForegroundWindowLocked(int32_t } // Binder call bool InputDispatcher::transferTouch(const sp<IBinder>& destChannelToken, int32_t displayId) { bool InputDispatcher::transferTouchOnDisplay(const sp<IBinder>& destChannelToken, int32_t displayId) { sp<IBinder> fromToken; { // acquire lock std::scoped_lock _l(mLock); Loading @@ -5703,7 +5704,7 @@ bool InputDispatcher::transferTouch(const sp<IBinder>& destChannelToken, int32_t fromToken = from->getToken(); } // release lock return transferTouchFocus(fromToken, destChannelToken); return transferTouchGesture(fromToken, destChannelToken); } void InputDispatcher::resetAndDropEverythingLocked(const char* reason) { Loading
services/inputflinger/dispatcher/InputDispatcher.h +3 −3 Original line number Diff line number Diff line Loading @@ -124,9 +124,9 @@ public: int32_t displayId) override; void setMaximumObscuringOpacityForTouch(float opacity) override; bool transferTouchFocus(const sp<IBinder>& fromToken, const sp<IBinder>& toToken, bool transferTouchGesture(const sp<IBinder>& fromToken, const sp<IBinder>& toToken, bool isDragDrop = false) override; bool transferTouch(const sp<IBinder>& destChannelToken, int32_t displayId) override; bool transferTouchOnDisplay(const sp<IBinder>& destChannelToken, int32_t displayId) override; base::Result<std::unique_ptr<InputChannel>> createInputChannel( const std::string& name) override; Loading
services/inputflinger/dispatcher/include/InputDispatcherInterface.h +9 −8 Original line number Diff line number Diff line Loading @@ -141,21 +141,22 @@ public: virtual void setMaximumObscuringOpacityForTouch(float opacity) = 0; /** * Transfers touch focus from one window to another window. Transferring touch focus will not * Transfers a touch gesture from one window to another window. Transferring touch will not * have any effect on the focused window. * * Returns true on success. False if the window did not actually have touch focus. * Returns true on success. False if the window did not actually have an active touch gesture. */ virtual bool transferTouchFocus(const sp<IBinder>& fromToken, const sp<IBinder>& toToken, virtual bool transferTouchGesture(const sp<IBinder>& fromToken, const sp<IBinder>& toToken, bool isDragDrop) = 0; /** * Transfer touch focus to the provided channel, no matter where the current touch is. * Transferring touch focus will not have any effect on the focused window. * Transfer a touch gesture to the provided channel, no matter where the current touch is. * Transferring touch will not have any effect on the focused window. * * Return true on success, false if there was no on-going touch. * Returns true on success, false if there was no on-going touch on the display. * @deprecated */ virtual bool transferTouch(const sp<IBinder>& destChannelToken, int32_t displayId) = 0; virtual bool transferTouchOnDisplay(const sp<IBinder>& destChannelToken, int32_t displayId) = 0; /** * Sets focus on the specified window. Loading
services/inputflinger/tests/InputDispatcher_test.cpp +44 −42 Original line number Diff line number Diff line Loading @@ -5181,7 +5181,7 @@ TEST_F(InputDispatcherDisplayProjectionTest, SynthesizeDownWithCorrectCoordinate // The pointer is transferred to the second window, and the second window receives it in the // correct coordinate space. mDispatcher->transferTouchFocus(firstWindow->getToken(), secondWindow->getToken()); mDispatcher->transferTouchGesture(firstWindow->getToken(), secondWindow->getToken()); firstWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_CANCEL), WithCoords(100, 400))); secondWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_DOWN), WithCoords(-100, -400))); } Loading Loading @@ -5419,16 +5419,16 @@ TEST_P(TransferTouchFixture, TransferTouch_OnePointer) { } /** * When 'transferTouch' API is invoked, dispatcher needs to find the "best" window to take touch * from. When we have spy windows, there are several windows to choose from: either spy, or the * 'real' (non-spy) window. Always prefer the 'real' window because that's what would be most * When 'transferTouchGesture' API is invoked, dispatcher needs to find the "best" window to take * touch from. When we have spy windows, there are several windows to choose from: either spy, or * the 'real' (non-spy) window. Always prefer the 'real' window because that's what would be most * natural to the user. * In this test, we are sending a pointer to both spy window and first window. We then try to * transfer touch to the second window. The dispatcher should identify the first window as the * one that should lose the gesture, and therefore the action should be to move the gesture from * the first window to the second. * The main goal here is to test the behaviour of 'transferTouch' API, but it's still valid to test * the other API, as well. * The main goal here is to test the behaviour of 'transferTouchGesture' API, but it's still valid * to test the other API, as well. */ TEST_P(TransferTouchFixture, TransferTouch_MultipleWindowsWithSpy) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); Loading @@ -5455,7 +5455,7 @@ TEST_P(TransferTouchFixture, TransferTouch_MultipleWindowsWithSpy) { firstWindow->consumeMotionDown(); // Transfer touch to the second window. Non-spy window should be preferred over the spy window // if f === 'transferTouch'. // if f === 'transferTouchGesture'. TransferFunction f = GetParam(); const bool success = f(mDispatcher, firstWindow->getToken(), secondWindow->getToken()); ASSERT_TRUE(success); Loading Loading @@ -5593,22 +5593,23 @@ TEST_P(TransferTouchFixture, TransferTouch_MultipleWallpapers) { } // For the cases of single pointer touch and two pointers non-split touch, the api's // 'transferTouch' and 'transferTouchFocus' are equivalent in behaviour. They only differ // 'transferTouchGesture' and 'transferTouchOnDisplay' are equivalent in behaviour. They only differ // for the case where there are multiple pointers split across several windows. INSTANTIATE_TEST_SUITE_P(InputDispatcherTransferFunctionTests, TransferTouchFixture, INSTANTIATE_TEST_SUITE_P( InputDispatcherTransferFunctionTests, TransferTouchFixture, ::testing::Values( [&](const std::unique_ptr<InputDispatcher>& dispatcher, sp<IBinder> /*ignored*/, sp<IBinder> destChannelToken) { return dispatcher->transferTouch(destChannelToken, [&](const std::unique_ptr<InputDispatcher>& dispatcher, sp<IBinder> /*ignored*/, sp<IBinder> destChannelToken) { return dispatcher->transferTouchOnDisplay(destChannelToken, ADISPLAY_ID_DEFAULT); }, [&](const std::unique_ptr<InputDispatcher>& dispatcher, sp<IBinder> from, sp<IBinder> to) { return dispatcher->transferTouchFocus(from, to, [&](const std::unique_ptr<InputDispatcher>& dispatcher, sp<IBinder> from, sp<IBinder> to) { return dispatcher->transferTouchGesture(from, to, /*isDragAndDrop=*/false); })); TEST_F(InputDispatcherTest, TransferTouchFocus_TwoPointersSplitTouch) { TEST_F(InputDispatcherTest, TransferTouch_TwoPointersSplitTouch) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> firstWindow = Loading Loading @@ -5644,8 +5645,8 @@ TEST_F(InputDispatcherTest, TransferTouchFocus_TwoPointersSplitTouch) { firstWindow->consumeMotionMove(); secondWindow->consumeMotionDown(); // Transfer touch focus to the second window mDispatcher->transferTouchFocus(firstWindow->getToken(), secondWindow->getToken()); // Transfer touch to the second window mDispatcher->transferTouchGesture(firstWindow->getToken(), secondWindow->getToken()); // The first window gets cancel and the new gets pointer down (it already saw down) firstWindow->consumeMotionCancel(); secondWindow->consumeMotionPointerDown(1, ADISPLAY_ID_DEFAULT, Loading @@ -5668,11 +5669,11 @@ TEST_F(InputDispatcherTest, TransferTouchFocus_TwoPointersSplitTouch) { secondWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); } // Same as TransferTouchFocus_TwoPointersSplitTouch, but using 'transferTouch' api. // Unlike 'transferTouchFocus', calling 'transferTouch' when there are two windows receiving // touch is not supported, so the touch should continue on those windows and the transferred-to // window should get nothing. TEST_F(InputDispatcherTest, TransferTouch_TwoPointersSplitTouch) { // Same as TransferTouch_TwoPointersSplitTouch, but using 'transferTouchOnDisplay' api. // Unlike 'transferTouchGesture', calling 'transferTouchOnDisplay' when there are two windows // receiving touch is not supported, so the touch should continue on those windows and the // transferred-to window should get nothing. TEST_F(InputDispatcherTest, TransferTouchOnDisplay_TwoPointersSplitTouch) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> firstWindow = Loading Loading @@ -5710,8 +5711,8 @@ TEST_F(InputDispatcherTest, TransferTouch_TwoPointersSplitTouch) { // Transfer touch focus to the second window const bool transferred = mDispatcher->transferTouch(secondWindow->getToken(), ADISPLAY_ID_DEFAULT); // The 'transferTouch' call should not succeed, because there are 2 touched windows mDispatcher->transferTouchOnDisplay(secondWindow->getToken(), ADISPLAY_ID_DEFAULT); // The 'transferTouchOnDisplay' call should not succeed, because there are 2 touched windows ASSERT_FALSE(transferred); firstWindow->assertNoEvents(); secondWindow->assertNoEvents(); Loading @@ -5734,9 +5735,9 @@ TEST_F(InputDispatcherTest, TransferTouch_TwoPointersSplitTouch) { } // This case will create two windows and one mirrored window on the default display and mirror // two windows on the second display. It will test if 'transferTouchFocus' works fine if we put // two windows on the second display. It will test if 'transferTouchGesture' works fine if we put // the windows info of second display before default display. TEST_F(InputDispatcherTest, TransferTouchFocus_CloneSurface) { TEST_F(InputDispatcherTest, TransferTouch_CloneSurface) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> firstWindowInPrimary = sp<FakeWindowHandle>::make(application, mDispatcher, "D_1_W1", ADISPLAY_ID_DEFAULT); Loading Loading @@ -5771,8 +5772,8 @@ TEST_F(InputDispatcherTest, TransferTouchFocus_CloneSurface) { // Window should receive motion event. firstWindowInPrimary->consumeMotionDown(ADISPLAY_ID_DEFAULT); // Transfer touch focus ASSERT_TRUE(mDispatcher->transferTouchFocus(firstWindowInPrimary->getToken(), // Transfer touch ASSERT_TRUE(mDispatcher->transferTouchGesture(firstWindowInPrimary->getToken(), secondWindowInPrimary->getToken())); // The first window gets cancel. firstWindowInPrimary->consumeMotionCancel(); Loading @@ -5795,9 +5796,9 @@ TEST_F(InputDispatcherTest, TransferTouchFocus_CloneSurface) { secondWindowInPrimary->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); } // Same as TransferTouchFocus_CloneSurface, but this touch on the secondary display and use // 'transferTouch' api. TEST_F(InputDispatcherTest, TransferTouch_CloneSurface) { // Same as TransferTouch_CloneSurface, but this touch on the secondary display and use // 'transferTouchOnDisplay' api. TEST_F(InputDispatcherTest, TransferTouchOnDisplay_CloneSurface) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> firstWindowInPrimary = sp<FakeWindowHandle>::make(application, mDispatcher, "D_1_W1", ADISPLAY_ID_DEFAULT); Loading Loading @@ -5834,7 +5835,8 @@ TEST_F(InputDispatcherTest, TransferTouch_CloneSurface) { firstWindowInSecondary->consumeMotionDown(SECOND_DISPLAY_ID); // Transfer touch focus ASSERT_TRUE(mDispatcher->transferTouch(secondWindowInSecondary->getToken(), SECOND_DISPLAY_ID)); ASSERT_TRUE(mDispatcher->transferTouchOnDisplay(secondWindowInSecondary->getToken(), SECOND_DISPLAY_ID)); // The first window gets cancel. firstWindowInSecondary->consumeMotionCancel(SECOND_DISPLAY_ID); Loading Loading @@ -10520,7 +10522,7 @@ protected: // Transfer touch focus to the drag window bool transferred = mDispatcher->transferTouchFocus(mWindow->getToken(), mDragWindow->getToken(), mDispatcher->transferTouchGesture(mWindow->getToken(), mDragWindow->getToken(), /*isDragDrop=*/true); if (transferred) { mWindow->consumeMotionCancel();