diff options
| -rw-r--r-- | services/inputflinger/reader/mapper/TouchInputMapper.cpp | 4 | ||||
| -rw-r--r-- | services/inputflinger/tests/InputReader_test.cpp | 12 |
2 files changed, 14 insertions, 2 deletions
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.cpp b/services/inputflinger/reader/mapper/TouchInputMapper.cpp index 637b1cb263..2acbb0a034 100644 --- a/services/inputflinger/reader/mapper/TouchInputMapper.cpp +++ b/services/inputflinger/reader/mapper/TouchInputMapper.cpp @@ -1053,6 +1053,10 @@ void TouchInputMapper::configureInputDevice(nsecs_t when, bool* outResetNeeded) mPointerController->fade(PointerControllerInterface::Transition::IMMEDIATE); } } else { + if (mPointerController != nullptr && mDeviceMode == DeviceMode::DIRECT && + !mConfig.showTouches) { + mPointerController->clearSpots(); + } mPointerController.reset(); } diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp index a26a0bcf67..d51ce3599a 100644 --- a/services/inputflinger/tests/InputReader_test.cpp +++ b/services/inputflinger/tests/InputReader_test.cpp @@ -219,7 +219,7 @@ private: mSpotsByDisplay[displayId] = newSpots; } - void clearSpots() override {} + void clearSpots() override { mSpotsByDisplay.clear(); } std::map<int32_t, std::vector<int32_t>> mSpotsByDisplay; }; @@ -8578,7 +8578,8 @@ TEST_F(MultiTouchInputMapperTest, Process_Pointer_ShowTouches) { // Default device will reconfigure above, need additional reconfiguration for another device. device2->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(), - InputReaderConfiguration::CHANGE_DISPLAY_INFO); + InputReaderConfiguration::CHANGE_DISPLAY_INFO | + InputReaderConfiguration::CHANGE_SHOW_TOUCHES); // Two fingers down at default display. int32_t x1 = 100, y1 = 125, x2 = 300, y2 = 500; @@ -8605,6 +8606,13 @@ TEST_F(MultiTouchInputMapperTest, Process_Pointer_ShowTouches) { iter = fakePointerController->getSpots().find(SECONDARY_DISPLAY_ID); ASSERT_TRUE(iter != fakePointerController->getSpots().end()); ASSERT_EQ(size_t(2), iter->second.size()); + + // Disable the show touches configuration and ensure the spots are cleared. + mFakePolicy->setShowTouches(false); + device2->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(), + InputReaderConfiguration::CHANGE_SHOW_TOUCHES); + + ASSERT_TRUE(fakePointerController->getSpots().empty()); } TEST_F(MultiTouchInputMapperTest, VideoFrames_ReceivedByListener) { |