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

Commit fd6aa8a1 authored by Zachary Kuznia's avatar Zachary Kuznia
Browse files

Fix double tap issue in TouchExplorer

In certain conditions, the first tap in a double tap could be detected
as Touch Exploration.  This ensures that cannot occur.

Change-Id: I20941be54413534d9dc74e5a3152c27dd0c998fe
parent 5781e61c
Loading
Loading
Loading
Loading
+9 −10
Original line number Diff line number Diff line
@@ -62,14 +62,6 @@ class AccessibilityGestureDetector extends GestureDetector.SimpleOnGestureListen
         */
        void onDoubleTapAndHold(MotionEvent event, int policyFlags);

        /**
         * Called when the user touches the screen on the second tap of a double
         * tap.
         *
         * @return true if the event is consumed, else false
         */
        boolean onDoubleTapStarted();

        /**
         * Called when the user lifts their finger on the second tap of a double
         * tap.
@@ -246,13 +238,20 @@ class AccessibilityGestureDetector extends GestureDetector.SimpleOnGestureListen
                        mBaseY = y;
                        mBaseTime = time;

                        // Since the pointer has moved, this is not a double
                        // tap.
                        mFirstTapDetected = false;
                        mDoubleTapDetected = false;

                        // If this hasn't been confirmed as a gesture yet, send
                        // the event.
                        if (!mGestureStarted) {
                            mGestureStarted = true;
                            return mListener.onGestureStarted();
                        }
                    } else {
                    } else if (!mFirstTapDetected) {
                        // The finger may not move if they are double tapping.
                        // In that case, we shouldn't cancel the gesture.
                        final long timeDelta = time - mBaseTime;
                        final long threshold = mGestureStarted ?
                            CANCEL_ON_PAUSE_THRESHOLD_STARTED_MS :
@@ -371,7 +370,7 @@ class AccessibilityGestureDetector extends GestureDetector.SimpleOnGestureListen
        // The processing of the double tap is deferred until the finger is
        // lifted, so that we can detect a long press on the second tap.
        mDoubleTapDetected = true;
        return mListener.onDoubleTapStarted();
        return false;
    }

    private void maybeSendLongPress(MotionEvent event, int policyFlags) {
+0 −5
Original line number Diff line number Diff line
@@ -389,11 +389,6 @@ class TouchExplorer implements EventStreamTransformation, AccessibilityGestureDe
        sendDownForAllNotInjectedPointers(event, policyFlags);
    }

    @Override
    public boolean onDoubleTapStarted() {
        return true;
    }

    @Override
    public boolean onDoubleTap(MotionEvent event, int policyFlags) {
        // Ignore the event if we aren't touch exploring.