Loading services/inputflinger/reader/mapper/TouchInputMapper.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -437,6 +437,10 @@ void TouchInputMapper::configureParameters() { mParameters.supportsUsi = false; getDeviceContext().getConfiguration().tryGetProperty("touch.supportsUsi", mParameters.supportsUsi); mParameters.enableForInactiveViewport = false; getDeviceContext().getConfiguration().tryGetProperty("touch.enableForInactiveViewport", mParameters.enableForInactiveViewport); } void TouchInputMapper::dumpParameters(std::string& dump) { Loading @@ -454,6 +458,8 @@ void TouchInputMapper::dumpParameters(std::string& dump) { dump += StringPrintf(INDENT4 "OrientationAware: %s\n", toString(mParameters.orientationAware)); dump += INDENT4 "Orientation: " + ftl::enum_string(mParameters.orientation) + "\n"; dump += StringPrintf(INDENT4 "SupportsUsi: %s\n", toString(mParameters.supportsUsi)); dump += StringPrintf(INDENT4 "EnableForInactiveViewport: %s\n", toString(mParameters.enableForInactiveViewport)); } void TouchInputMapper::configureRawPointerAxes() { Loading Loading @@ -856,7 +862,7 @@ void TouchInputMapper::configureInputDevice(nsecs_t when, bool* outResetNeeded) "becomes available.", getDeviceName().c_str()); mDeviceMode = DeviceMode::DISABLED; } else if (!newViewportOpt->isActive) { } else if (!mParameters.enableForInactiveViewport && !newViewportOpt->isActive) { ALOGI("Disabling %s (device %i) because the associated viewport is not active", getDeviceName().c_str(), getDeviceId()); mDeviceMode = DeviceMode::DISABLED; Loading services/inputflinger/reader/mapper/TouchInputMapper.h +3 −0 Original line number Diff line number Diff line Loading @@ -236,6 +236,9 @@ protected: // Whether the device supports the Universal Stylus Initiative (USI) protocol for styluses. bool supportsUsi; // Allows touches while the display is off. bool enableForInactiveViewport; } mParameters; // Immutable calibration parameters in parsed form. Loading services/inputflinger/tests/InputReader_test.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -9082,6 +9082,7 @@ TEST_F(MultiTouchInputMapperTest, Process_SendsReadTime) { */ TEST_F(MultiTouchInputMapperTest, WhenViewportIsNotActive_TouchesAreDropped) { addConfigurationProperty("touch.deviceType", "touchScreen"); // Don't set touch.enableForInactiveViewport to verify the default behavior. mFakePolicy->addDisplayViewport(DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_ORIENTATION_0, false /*isActive*/, UNIQUE_ID, NO_PORT, ViewportType::INTERNAL); Loading @@ -9096,8 +9097,31 @@ TEST_F(MultiTouchInputMapperTest, WhenViewportIsNotActive_TouchesAreDropped) { mFakeListener->assertNotifyMotionWasNotCalled(); } /** * When the viewport is not active (isActive=false) and touch.enableForInactiveViewport is true, * the touch mapper can process the events and the events can be delivered to the listener. */ TEST_F(MultiTouchInputMapperTest, WhenViewportIsNotActive_TouchesAreProcessed) { addConfigurationProperty("touch.deviceType", "touchScreen"); addConfigurationProperty("touch.enableForInactiveViewport", "1"); mFakePolicy->addDisplayViewport(DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_ORIENTATION_0, false /*isActive*/, UNIQUE_ID, NO_PORT, ViewportType::INTERNAL); configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO); prepareAxes(POSITION); MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>(); NotifyMotionArgs motionArgs; processPosition(mapper, 100, 100); processSync(mapper); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs)); EXPECT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action); } TEST_F(MultiTouchInputMapperTest, Process_DeactivateViewport_AbortTouches) { addConfigurationProperty("touch.deviceType", "touchScreen"); addConfigurationProperty("touch.enableForInactiveViewport", "0"); mFakePolicy->addDisplayViewport(DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_ORIENTATION_0, true /*isActive*/, UNIQUE_ID, NO_PORT, ViewportType::INTERNAL); Loading Loading
services/inputflinger/reader/mapper/TouchInputMapper.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -437,6 +437,10 @@ void TouchInputMapper::configureParameters() { mParameters.supportsUsi = false; getDeviceContext().getConfiguration().tryGetProperty("touch.supportsUsi", mParameters.supportsUsi); mParameters.enableForInactiveViewport = false; getDeviceContext().getConfiguration().tryGetProperty("touch.enableForInactiveViewport", mParameters.enableForInactiveViewport); } void TouchInputMapper::dumpParameters(std::string& dump) { Loading @@ -454,6 +458,8 @@ void TouchInputMapper::dumpParameters(std::string& dump) { dump += StringPrintf(INDENT4 "OrientationAware: %s\n", toString(mParameters.orientationAware)); dump += INDENT4 "Orientation: " + ftl::enum_string(mParameters.orientation) + "\n"; dump += StringPrintf(INDENT4 "SupportsUsi: %s\n", toString(mParameters.supportsUsi)); dump += StringPrintf(INDENT4 "EnableForInactiveViewport: %s\n", toString(mParameters.enableForInactiveViewport)); } void TouchInputMapper::configureRawPointerAxes() { Loading Loading @@ -856,7 +862,7 @@ void TouchInputMapper::configureInputDevice(nsecs_t when, bool* outResetNeeded) "becomes available.", getDeviceName().c_str()); mDeviceMode = DeviceMode::DISABLED; } else if (!newViewportOpt->isActive) { } else if (!mParameters.enableForInactiveViewport && !newViewportOpt->isActive) { ALOGI("Disabling %s (device %i) because the associated viewport is not active", getDeviceName().c_str(), getDeviceId()); mDeviceMode = DeviceMode::DISABLED; Loading
services/inputflinger/reader/mapper/TouchInputMapper.h +3 −0 Original line number Diff line number Diff line Loading @@ -236,6 +236,9 @@ protected: // Whether the device supports the Universal Stylus Initiative (USI) protocol for styluses. bool supportsUsi; // Allows touches while the display is off. bool enableForInactiveViewport; } mParameters; // Immutable calibration parameters in parsed form. Loading
services/inputflinger/tests/InputReader_test.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -9082,6 +9082,7 @@ TEST_F(MultiTouchInputMapperTest, Process_SendsReadTime) { */ TEST_F(MultiTouchInputMapperTest, WhenViewportIsNotActive_TouchesAreDropped) { addConfigurationProperty("touch.deviceType", "touchScreen"); // Don't set touch.enableForInactiveViewport to verify the default behavior. mFakePolicy->addDisplayViewport(DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_ORIENTATION_0, false /*isActive*/, UNIQUE_ID, NO_PORT, ViewportType::INTERNAL); Loading @@ -9096,8 +9097,31 @@ TEST_F(MultiTouchInputMapperTest, WhenViewportIsNotActive_TouchesAreDropped) { mFakeListener->assertNotifyMotionWasNotCalled(); } /** * When the viewport is not active (isActive=false) and touch.enableForInactiveViewport is true, * the touch mapper can process the events and the events can be delivered to the listener. */ TEST_F(MultiTouchInputMapperTest, WhenViewportIsNotActive_TouchesAreProcessed) { addConfigurationProperty("touch.deviceType", "touchScreen"); addConfigurationProperty("touch.enableForInactiveViewport", "1"); mFakePolicy->addDisplayViewport(DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_ORIENTATION_0, false /*isActive*/, UNIQUE_ID, NO_PORT, ViewportType::INTERNAL); configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO); prepareAxes(POSITION); MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>(); NotifyMotionArgs motionArgs; processPosition(mapper, 100, 100); processSync(mapper); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs)); EXPECT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action); } TEST_F(MultiTouchInputMapperTest, Process_DeactivateViewport_AbortTouches) { addConfigurationProperty("touch.deviceType", "touchScreen"); addConfigurationProperty("touch.enableForInactiveViewport", "0"); mFakePolicy->addDisplayViewport(DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_ORIENTATION_0, true /*isActive*/, UNIQUE_ID, NO_PORT, ViewportType::INTERNAL); Loading