Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 89ea6a91 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add a config to allow touches while the display is off."

parents ce1cd88c 50c19b1a
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -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) {
@@ -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() {
@@ -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;
+3 −0
Original line number Diff line number Diff line
@@ -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.
+24 −0
Original line number Diff line number Diff line
@@ -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);
@@ -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);