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

Commit 38a276c1 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Do not slip touch into window with same input channel" into udc-dev am: 8aedbf30

parents 8175b4f9 8aedbf30
Loading
Loading
Loading
Loading
+6 −7
Original line number Original line Diff line number Diff line
@@ -2402,6 +2402,7 @@ std::vector<InputTarget> InputDispatcher::findTouchedWindowTargetsLocked(
            const bool isStylus = isPointerFromStylus(entry, /*pointerIndex=*/0);
            const bool isStylus = isPointerFromStylus(entry, /*pointerIndex=*/0);
            sp<WindowInfoHandle> oldTouchedWindowHandle =
            sp<WindowInfoHandle> oldTouchedWindowHandle =
                    tempTouchState.getFirstForegroundWindowHandle();
                    tempTouchState.getFirstForegroundWindowHandle();
            LOG_ALWAYS_FATAL_IF(oldTouchedWindowHandle == nullptr);
            auto [newTouchedWindowHandle, _] = findTouchedWindowAtLocked(displayId, x, y, isStylus);
            auto [newTouchedWindowHandle, _] = findTouchedWindowAtLocked(displayId, x, y, isStylus);


            // Verify targeted injection.
            // Verify targeted injection.
@@ -2417,13 +2418,11 @@ std::vector<InputTarget> InputDispatcher::findTouchedWindowTargetsLocked(
                newTouchedWindowHandle = nullptr;
                newTouchedWindowHandle = nullptr;
            }
            }


            if (oldTouchedWindowHandle != newTouchedWindowHandle &&
            if (!haveSameToken(oldTouchedWindowHandle, newTouchedWindowHandle)) {
                oldTouchedWindowHandle != nullptr && newTouchedWindowHandle != nullptr) {
                if (DEBUG_FOCUS) {
                ALOGD("Touch is slipping out of window %s into window %s in display %" PRId32,
                ALOGD("Touch is slipping out of window %s into window %s in display %" PRId32,
                      oldTouchedWindowHandle->getName().c_str(),
                      oldTouchedWindowHandle->getName().c_str(),
                      newTouchedWindowHandle->getName().c_str(), displayId);
                      newTouchedWindowHandle->getName().c_str(), displayId);
                }

                // Make a slippery exit from the old window.
                // Make a slippery exit from the old window.
                std::bitset<MAX_POINTER_ID + 1> pointerIds;
                std::bitset<MAX_POINTER_ID + 1> pointerIds;
                const int32_t pointerId = entry.pointerProperties[0].id;
                const int32_t pointerId = entry.pointerProperties[0].id;
+22 −0
Original line number Original line Diff line number Diff line
@@ -6140,6 +6140,28 @@ TEST_F(InputDispatcherMultiWindowSameTokenTests, MultipleWindowsFirstTouchWithSc
    touchAndAssertPositions(AMOTION_EVENT_ACTION_MOVE, touchedPoints, expectedPoints);
    touchAndAssertPositions(AMOTION_EVENT_ACTION_MOVE, touchedPoints, expectedPoints);
}
}


/**
 * When one of the windows is slippery, the touch should not slip into the other window with the
 * same input channel.
 */
TEST_F(InputDispatcherMultiWindowSameTokenTests, TouchDoesNotSlipEvenIfSlippery) {
    mWindow1->setSlippery(true);
    mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {mWindow1, mWindow2}}});

    // Touch down in window 1
    mDispatcher->notifyMotion(generateMotionArgs(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
                                                 ADISPLAY_ID_DEFAULT, {{50, 50}}));
    consumeMotionEvent(mWindow1, ACTION_DOWN, {{50, 50}});

    // Move touch to be above window 2. Even though window 1 is slippery, touch should not slip.
    // That means the gesture should continue normally, without any ACTION_CANCEL or ACTION_DOWN
    // getting generated.
    mDispatcher->notifyMotion(generateMotionArgs(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
                                                 ADISPLAY_ID_DEFAULT, {{150, 150}}));

    consumeMotionEvent(mWindow1, ACTION_MOVE, {{150, 150}});
}

class InputDispatcherSingleWindowAnr : public InputDispatcherTest {
class InputDispatcherSingleWindowAnr : public InputDispatcherTest {
    virtual void SetUp() override {
    virtual void SetUp() override {
        InputDispatcherTest::SetUp();
        InputDispatcherTest::SetUp();