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

Commit 7080e1a5 authored by Jackal Guo's avatar Jackal Guo
Browse files

Avoid duplicated touch events

TouchExplorer doesn't check for double tap (and hold) so there may
be duplicated TYPE_TOUCH_INTERACTION_START/END events.

Bug: 66730372
Test: manual
Test: CtsAccessibilityServiceTestCases
Test: CtsAccessibilityTestCases
Change-Id: Iece13d3a401f13d8a7dcda2147b2865eee5e5f33
parent 3caa5404
Loading
Loading
Loading
Loading
+14 −8
Original line number Diff line number Diff line
@@ -375,6 +375,7 @@ class TouchExplorer extends BaseEventStreamTransformation
            return false;
        }

        mAms.onTouchInteractionEnd();
        // Remove pending event deliveries.
        mSendHoverEnterAndMoveDelayed.cancel();
        mSendHoverExitDelayed.cancel();
@@ -382,9 +383,9 @@ class TouchExplorer extends BaseEventStreamTransformation
        if (mSendTouchExplorationEndDelayed.isPending()) {
            mSendTouchExplorationEndDelayed.forceSendAndRemove();
        }
        if (mSendTouchInteractionEndDelayed.isPending()) {
            mSendTouchInteractionEndDelayed.forceSendAndRemove();
        }

        // Announce the end of a new touch interaction.
        sendAccessibilityEvent(AccessibilityEvent.TYPE_TOUCH_INTERACTION_END);

        // Try to use the standard accessibility API to click
        if (mAms.performActionOnAccessibilityFocusedItem(
@@ -487,20 +488,25 @@ class TouchExplorer extends BaseEventStreamTransformation
            case MotionEvent.ACTION_DOWN: {
                mAms.onTouchInteractionStart();

                sendAccessibilityEvent(AccessibilityEvent.TYPE_TOUCH_INTERACTION_START);

                // If we still have not notified the user for the last
                // touch, we figure out what to do. If were waiting
                // we resent the delayed callback and wait again.
                mSendHoverEnterAndMoveDelayed.cancel();
                mSendHoverExitDelayed.cancel();

                if (mSendTouchExplorationEndDelayed.isPending()) {
                    mSendTouchExplorationEndDelayed.forceSendAndRemove();
                // If a touch exploration gesture is in progress send events for its end.
                if(mTouchExplorationInProgress) {
                    sendHoverExitAndTouchExplorationGestureEndIfNeeded(policyFlags);
                }

                if (mSendTouchInteractionEndDelayed.isPending()) {
                // Avoid duplicated TYPE_TOUCH_INTERACTION_START event when 2nd tap of double tap.
                if (!mGestureDetector.firstTapDetected()) {
                    mSendTouchExplorationEndDelayed.forceSendAndRemove();
                    mSendTouchInteractionEndDelayed.forceSendAndRemove();
                    sendAccessibilityEvent(AccessibilityEvent.TYPE_TOUCH_INTERACTION_START);
                } else {
                    // Let gesture to handle to avoid duplicated TYPE_TOUCH_INTERACTION_END event.
                    mSendTouchInteractionEndDelayed.cancel();
                }

                if (!mGestureDetector.firstTapDetected() && !mTouchExplorationInProgress) {