Loading services/inputflinger/reader/mapper/TouchInputMapper.cpp +12 −1 Original line number Diff line number Diff line Loading @@ -972,7 +972,18 @@ void TouchInputMapper::configureInputDevice(nsecs_t when, bool* outResetNeeded) (rawXResolution > 0 && rawYResolution > 0) ? (rawXResolution + rawYResolution) / 2 : 0; const DisplayViewport& newViewport = newViewportOpt.value_or(kUninitializedViewport); const bool viewportChanged = mViewport != newViewport; bool viewportChanged; if (mParameters.enableForInactiveViewport) { // When touch is enabled for an inactive viewport, ignore the // viewport active status when checking whether the viewport has // changed. DisplayViewport tempViewport = mViewport; tempViewport.isActive = newViewport.isActive; viewportChanged = tempViewport != newViewport; } else { viewportChanged = mViewport != newViewport; } bool skipViewportUpdate = false; if (viewportChanged) { const bool viewportOrientationChanged = mViewport.orientation != newViewport.orientation; Loading services/inputflinger/tests/InputReader_test.cpp +59 −0 Original line number Diff line number Diff line Loading @@ -9352,6 +9352,11 @@ TEST_F(MultiTouchInputMapperTest, WhenViewportIsNotActive_TouchesAreProcessed) { EXPECT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action); } /** * When the viewport is deactivated (isActive transitions from true to false), * and touch.enableForInactiveViewport is false, touches prior to the transition * should be cancelled. */ TEST_F(MultiTouchInputMapperTest, Process_DeactivateViewport_AbortTouches) { addConfigurationProperty("touch.deviceType", "touchScreen"); addConfigurationProperty("touch.enableForInactiveViewport", "0"); Loading Loading @@ -9403,6 +9408,60 @@ TEST_F(MultiTouchInputMapperTest, Process_DeactivateViewport_AbortTouches) { EXPECT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action); } /** * When the viewport is deactivated (isActive transitions from true to false), * and touch.enableForInactiveViewport is true, touches prior to the transition * should not be cancelled. */ TEST_F(MultiTouchInputMapperTest, Process_DeactivateViewport_TouchesNotAborted) { addConfigurationProperty("touch.deviceType", "touchScreen"); addConfigurationProperty("touch.enableForInactiveViewport", "1"); mFakePolicy->addDisplayViewport(DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT, ui::ROTATION_0, /*isActive=*/true, UNIQUE_ID, NO_PORT, ViewportType::INTERNAL); std::optional<DisplayViewport> optionalDisplayViewport = mFakePolicy->getDisplayViewportByUniqueId(UNIQUE_ID); ASSERT_TRUE(optionalDisplayViewport.has_value()); DisplayViewport displayViewport = *optionalDisplayViewport; configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO); prepareAxes(POSITION); MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>(); // Finger down int32_t x = 100, y = 100; processPosition(mapper, x, y); processSync(mapper); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled( WithMotionAction(AMOTION_EVENT_ACTION_DOWN))); // Deactivate display viewport displayViewport.isActive = false; ASSERT_TRUE(mFakePolicy->updateViewport(displayViewport)); configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO); // The ongoing touch should not be canceled ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasNotCalled()); // Finger move is not ignored x += 10, y += 10; processPosition(mapper, x, y); processSync(mapper); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled( WithMotionAction(AMOTION_EVENT_ACTION_MOVE))); // Reactivate display viewport displayViewport.isActive = true; ASSERT_TRUE(mFakePolicy->updateViewport(displayViewport)); configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO); // Finger move continues and does not start new gesture x += 10, y += 10; processPosition(mapper, x, y); processSync(mapper); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled( WithMotionAction(AMOTION_EVENT_ACTION_MOVE))); } TEST_F(MultiTouchInputMapperTest, Process_Pointer_ShowTouches) { // Setup the first touch screen device. prepareAxes(POSITION | ID | SLOT); Loading Loading
services/inputflinger/reader/mapper/TouchInputMapper.cpp +12 −1 Original line number Diff line number Diff line Loading @@ -972,7 +972,18 @@ void TouchInputMapper::configureInputDevice(nsecs_t when, bool* outResetNeeded) (rawXResolution > 0 && rawYResolution > 0) ? (rawXResolution + rawYResolution) / 2 : 0; const DisplayViewport& newViewport = newViewportOpt.value_or(kUninitializedViewport); const bool viewportChanged = mViewport != newViewport; bool viewportChanged; if (mParameters.enableForInactiveViewport) { // When touch is enabled for an inactive viewport, ignore the // viewport active status when checking whether the viewport has // changed. DisplayViewport tempViewport = mViewport; tempViewport.isActive = newViewport.isActive; viewportChanged = tempViewport != newViewport; } else { viewportChanged = mViewport != newViewport; } bool skipViewportUpdate = false; if (viewportChanged) { const bool viewportOrientationChanged = mViewport.orientation != newViewport.orientation; Loading
services/inputflinger/tests/InputReader_test.cpp +59 −0 Original line number Diff line number Diff line Loading @@ -9352,6 +9352,11 @@ TEST_F(MultiTouchInputMapperTest, WhenViewportIsNotActive_TouchesAreProcessed) { EXPECT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action); } /** * When the viewport is deactivated (isActive transitions from true to false), * and touch.enableForInactiveViewport is false, touches prior to the transition * should be cancelled. */ TEST_F(MultiTouchInputMapperTest, Process_DeactivateViewport_AbortTouches) { addConfigurationProperty("touch.deviceType", "touchScreen"); addConfigurationProperty("touch.enableForInactiveViewport", "0"); Loading Loading @@ -9403,6 +9408,60 @@ TEST_F(MultiTouchInputMapperTest, Process_DeactivateViewport_AbortTouches) { EXPECT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action); } /** * When the viewport is deactivated (isActive transitions from true to false), * and touch.enableForInactiveViewport is true, touches prior to the transition * should not be cancelled. */ TEST_F(MultiTouchInputMapperTest, Process_DeactivateViewport_TouchesNotAborted) { addConfigurationProperty("touch.deviceType", "touchScreen"); addConfigurationProperty("touch.enableForInactiveViewport", "1"); mFakePolicy->addDisplayViewport(DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT, ui::ROTATION_0, /*isActive=*/true, UNIQUE_ID, NO_PORT, ViewportType::INTERNAL); std::optional<DisplayViewport> optionalDisplayViewport = mFakePolicy->getDisplayViewportByUniqueId(UNIQUE_ID); ASSERT_TRUE(optionalDisplayViewport.has_value()); DisplayViewport displayViewport = *optionalDisplayViewport; configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO); prepareAxes(POSITION); MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>(); // Finger down int32_t x = 100, y = 100; processPosition(mapper, x, y); processSync(mapper); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled( WithMotionAction(AMOTION_EVENT_ACTION_DOWN))); // Deactivate display viewport displayViewport.isActive = false; ASSERT_TRUE(mFakePolicy->updateViewport(displayViewport)); configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO); // The ongoing touch should not be canceled ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasNotCalled()); // Finger move is not ignored x += 10, y += 10; processPosition(mapper, x, y); processSync(mapper); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled( WithMotionAction(AMOTION_EVENT_ACTION_MOVE))); // Reactivate display viewport displayViewport.isActive = true; ASSERT_TRUE(mFakePolicy->updateViewport(displayViewport)); configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO); // Finger move continues and does not start new gesture x += 10, y += 10; processPosition(mapper, x, y); processSync(mapper); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled( WithMotionAction(AMOTION_EVENT_ACTION_MOVE))); } TEST_F(MultiTouchInputMapperTest, Process_Pointer_ShowTouches) { // Setup the first touch screen device. prepareAxes(POSITION | ID | SLOT); Loading