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

Commit 975c5e65 authored by Daniel Norman's avatar Daniel Norman
Browse files

Revert "Sends ACTION_CANCEL before the very first touch exploration HOVER event."

This reverts commit 900c31fd.

Reason for revert: Re-landing with a more precise approach.

Change-Id: If6068b9a4e3e4518a6603b28cb14fa30ddbc1fa5
parent 2f89d9d4
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -313,16 +313,6 @@ flag {
    }
}

flag {
    name: "reset_input_dispatcher_before_first_touch_exploration"
    namespace: "accessibility"
    description: "Resets InputDispatcher state by sending ACTION_CANCEL before the first TouchExploration hover events"
    bug: "364408887"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "scan_packages_without_lock"
    namespace: "accessibility"
@@ -336,7 +326,6 @@ flag {
    description: "Sends accessibility events in TouchExplorer#onAccessibilityEvent based on internal state to keep it consistent. This reduces test flakiness."
    bug: "295575684"
}

flag {
    name: "send_hover_events_based_on_event_stream"
    namespace: "accessibility"
+0 −18
Original line number Diff line number Diff line
@@ -1611,19 +1611,6 @@ public class TouchExplorer extends BaseEventStreamTransformation
                dispatchGesture(gestureEvent);
            }
            if (!mEvents.isEmpty() && !mRawEvents.isEmpty()) {
                if (Flags.resetInputDispatcherBeforeFirstTouchExploration()
                        && !mState.hasResetInputDispatcherState()) {
                    // Cancel any possible ongoing touch gesture from before touch exploration
                    // started. This clears out the InputDispatcher event stream state so that it
                    // is ready to accept new injected HOVER events.
                    mDispatcher.sendMotionEvent(
                            mEvents.get(0),
                            ACTION_CANCEL,
                            mRawEvents.get(0),
                            mPointerIdBits,
                            mPolicyFlags);
                    setHasResetInputDispatcherState(true);
                }
                // Deliver a down event.
                mDispatcher.sendMotionEvent(
                        mEvents.get(0),
@@ -1784,9 +1771,4 @@ public class TouchExplorer extends BaseEventStreamTransformation
                + ", mDraggingPointerId: " + mDraggingPointerId
                + " }";
    }

    @VisibleForTesting
    void setHasResetInputDispatcherState(boolean value) {
        mState.setHasResetInputDispatcherState(value);
    }
}
+0 −9
Original line number Diff line number Diff line
@@ -89,7 +89,6 @@ public class TouchState {
    private MotionEvent mLastInjectedHoverEvent;
    // The last injected hover event used for performing clicks.
    private MotionEvent mLastInjectedHoverEventForClick;
    private boolean mHasResetInputDispatcherState;
    // The time of the last injected down.
    private long mLastInjectedDownEventTime;
    // Keep track of which pointers sent to the system are down.
@@ -376,14 +375,6 @@ public class TouchState {
        return mLastInjectedDownEventTime;
    }

    boolean hasResetInputDispatcherState() {
        return mHasResetInputDispatcherState;
    }

    void setHasResetInputDispatcherState(boolean value) {
        mHasResetInputDispatcherState = value;
    }

    public int getLastTouchedWindowId() {
        return mLastTouchedWindowId;
    }
+5 −30
Original line number Diff line number Diff line
@@ -166,43 +166,18 @@ public class TouchExplorerTest {
        mHandler = new TestHandler();
        mTouchExplorer = new TouchExplorer(mContext, mMockAms, null, mHandler);
        mTouchExplorer.setNext(mCaptor);
        // Start TouchExplorer in the state where it has already reset InputDispatcher so that
        // all tests do not start with an irrelevant ACTION_CANCEL.
        mTouchExplorer.setHasResetInputDispatcherState(true);
    }

    @Test
    public void testOneFingerMove_shouldInjectHoverEvents() {
        triggerTouchExplorationWithOneFingerDownMoveUp();
        assertCapturedEvents(ACTION_HOVER_ENTER, ACTION_HOVER_MOVE, ACTION_HOVER_EXIT);
        assertState(STATE_TOUCH_EXPLORING);
    }

    @Test
    @EnableFlags(Flags.FLAG_RESET_INPUT_DISPATCHER_BEFORE_FIRST_TOUCH_EXPLORATION)
    public void testStartTouchExploration_shouldResetInputDispatcherStateWithActionCancel() {
        // Start TouchExplorer in the state where it has *not yet* reset InputDispatcher.
        mTouchExplorer.setHasResetInputDispatcherState(false);
        // Trigger touch exploration twice, with a handler fast-forward in between so TouchExplorer
        // treats these as two separate interactions.
        triggerTouchExplorationWithOneFingerDownMoveUp();
        mHandler.fastForward(2 * USER_INTENT_TIMEOUT);
        triggerTouchExplorationWithOneFingerDownMoveUp();

        assertCapturedEvents(
                ACTION_CANCEL, // Only one ACTION_CANCEL before the first touch exploration
                ACTION_HOVER_ENTER, ACTION_HOVER_MOVE, ACTION_HOVER_EXIT,
                ACTION_HOVER_ENTER, ACTION_HOVER_MOVE, ACTION_HOVER_EXIT);
        assertState(STATE_TOUCH_EXPLORING);
    }

    private void triggerTouchExplorationWithOneFingerDownMoveUp() {
        send(downEvent());
        // Fast forward so that TouchExplorer's timeouts transition us to the touch exploring state.
        goFromStateClearTo(STATE_TOUCH_EXPLORING_1FINGER);
        // Wait for transiting to touch exploring state.
        mHandler.fastForward(2 * USER_INTENT_TIMEOUT);
        moveEachPointers(mLastEvent, p(10, 10));
        send(mLastEvent);
        send(upEvent());
        goToStateClearFrom(STATE_TOUCH_EXPLORING_1FINGER);
        assertCapturedEvents(ACTION_HOVER_ENTER, ACTION_HOVER_MOVE, ACTION_HOVER_EXIT);
        assertState(STATE_TOUCH_EXPLORING);
    }

    /**