Fix abnormal flicking when swiping up to exit OHM

Defer the action of onStopGestureDetected() from ACTION_MOVE
to ACTION_UP in OneHandedInputConsumer.

Bug: 171307756

Test: manual
Change-Id: Ie4a3cb0ba4477c131191a7ed1cf4daec2d364285
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/OneHandedModeInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/OneHandedModeInputConsumer.java
index 22bd334..b10bdde 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/OneHandedModeInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/OneHandedModeInputConsumer.java
@@ -54,6 +54,7 @@
     private final PointF mLastPos = new PointF();
 
     private boolean mPassedSlop;
+    private boolean mIsStopGesture;
 
     public OneHandedModeInputConsumer(Context context, RecentsAnimationDeviceState deviceState,
             InputConsumer delegate, InputMonitorCompat inputMonitor) {
@@ -105,7 +106,7 @@
                     float distance = (float) Math.hypot(mLastPos.x - mDownPos.x,
                             mLastPos.y - mDownPos.y);
                     if (distance > mDragDistThreshold && mPassedSlop) {
-                        onStopGestureDetected();
+                        mIsStopGesture = true;
                     }
                 }
                 break;
@@ -113,15 +114,14 @@
             case ACTION_UP: {
                 if (mLastPos.y >= mDownPos.y && mPassedSlop) {
                     onStartGestureDetected();
+                } else if (mIsStopGesture) {
+                    onStopGestureDetected();
                 }
-
-                mPassedSlop = false;
-                mState = STATE_INACTIVE;
+                clearState();
                 break;
             }
             case ACTION_CANCEL:
-                mPassedSlop = false;
-                mState = STATE_INACTIVE;
+                clearState();
                 break;
         }
 
@@ -130,6 +130,12 @@
         }
     }
 
+    private void clearState() {
+        mPassedSlop = false;
+        mState = STATE_INACTIVE;
+        mIsStopGesture = false;
+    }
+
     private void onStartGestureDetected() {
         if (mDeviceState.isOneHandedModeEnabled()) {
             if (!mDeviceState.isOneHandedModeActive()) {