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

Commit fd24f5ca authored by Ameer Armaly's avatar Ameer Armaly Committed by Automerger Merge Worker
Browse files

[DO NOT MERGE] Transition to clear state after gesture cancelation. am: a9027a7f

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13036714

Change-Id: Idfc6d16c3048fdf1f49cbb3dc34ddef5cb6195b3
parents a26bcb66 a9027a7f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -104,9 +104,9 @@ class GestureManifold implements GestureMatcher.StateChangeListener {
    // Shared state information.
    private TouchState mState;

    GestureManifold(Context context, Listener listener, TouchState state) {
    GestureManifold(Context context, Listener listener, TouchState state, Handler handler) {
        mContext = context;
        mHandler = new Handler(context.getMainLooper());
        mHandler = handler;
        mListener = listener;
        mState = state;
        mMultiFingerGesturesEnabled = false;
+11 −3
Original line number Diff line number Diff line
@@ -175,7 +175,7 @@ public class TouchExplorer extends BaseEventStreamTransformation
                AccessibilityEvent.TYPE_TOUCH_INTERACTION_END,
                mDetermineUserIntentTimeout);
        if (detector == null) {
            mGestureDetector = new GestureManifold(context, this, mState);
            mGestureDetector = new GestureManifold(context, this, mState, mHandler);
        } else {
            mGestureDetector = detector;
        }
@@ -353,7 +353,6 @@ public class TouchExplorer extends BaseEventStreamTransformation
    public boolean onGestureStarted() {
        // We have to perform gesture detection, so
        // clear the current state and try to detect.
        mState.startGestureDetecting();
        mSendHoverEnterAndMoveDelayed.cancel();
        mSendHoverExitDelayed.cancel();
        mExitGestureDetectionModeDelayed.post();
@@ -1107,7 +1106,7 @@ public class TouchExplorer extends BaseEventStreamTransformation
    }

    private boolean shouldPerformGestureDetection(MotionEvent event) {
        if (mState.isDelegating()) {
        if (mState.isDelegating() || mState.isDragging()) {
            return false;
        }
        if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
@@ -1200,6 +1199,15 @@ public class TouchExplorer extends BaseEventStreamTransformation
        }

        public void run() {
            if (mReceivedPointerTracker.getReceivedPointerDownCount() > 1) {
                // Multi-finger touch exploration doesn't make sense.
                Slog.e(
                        LOG_TAG,
                        "Attempted touch exploration with "
                                + mReceivedPointerTracker.getReceivedPointerDownCount()
                                + " pointers down.");
                return;
            }
            // Send an accessibility event to announce the touch exploration start.
            mDispatcher.sendAccessibilityEvent(
                    AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START);
+3 −1
Original line number Diff line number Diff line
@@ -208,7 +208,9 @@ public class TouchState {
                startGestureDetecting();
                break;
            case AccessibilityEvent.TYPE_GESTURE_DETECTION_END:
                startTouchInteracting();
                // Clear to make sure that we don't accidentally execute passthrough, and that we
                // are ready for the next interaction.
                clear();
                break;
            default:
                break;
+3 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.accessibilityservice.AccessibilityService;
import android.content.Context;
import android.graphics.Point;
import android.graphics.PointF;
import android.os.Handler;
import android.view.MotionEvent;

import androidx.test.InstrumentationRegistry;
@@ -56,7 +57,8 @@ public class GestureManifoldTest {
        // Construct a testable GestureManifold.
        mResultListener = mock(GestureManifold.Listener.class);
        mState = new TouchState();
        mManifold = new GestureManifold(context, mResultListener, mState);
        Handler handler = new Handler(context.getMainLooper());
        mManifold = new GestureManifold(context, mResultListener, mState, handler);
        // Play the role of touch explorer in updating the shared state.
        when(mResultListener.onGestureStarted()).thenReturn(onGestureStarted());