Clearing the touch state on ACTON_UP/ACTIUON_CANCEL

The touch listener may not get ACTION_DOWN if it came through an intercept,
in which case it will continue to use the previous state. Clearing the state
ensures that the next touch is not affected.

Bug: 76152745
Change-Id: I18cfbac67aa373e935822003e746af9def6d9122
diff --git a/src/com/android/launcher3/touch/WorkspaceTouchListener.java b/src/com/android/launcher3/touch/WorkspaceTouchListener.java
index df11686..2f9cf3a 100644
--- a/src/com/android/launcher3/touch/WorkspaceTouchListener.java
+++ b/src/com/android/launcher3/touch/WorkspaceTouchListener.java
@@ -102,23 +102,30 @@
             // Inform the workspace to cancel touch handling
             ev.setAction(ACTION_CANCEL);
             mWorkspace.onTouchEvent(ev);
+
             ev.setAction(action);
             mLongPressState = STATE_COMPLETED;
         }
 
+        final boolean result;
         if (mLongPressState == STATE_COMPLETED) {
             // We have handled the touch, so workspace does not need to know anything anymore.
-            return true;
+            result = true;
         } else if (mLongPressState == STATE_REQUESTED) {
             mWorkspace.onTouchEvent(ev);
-            if (action == ACTION_UP || action == ACTION_CANCEL || mWorkspace.isHandlingTouch()) {
+            if (mWorkspace.isHandlingTouch()) {
                 cancelLongPress();
             }
-            return true;
+
+            result = true;
         } else {
             // We don't want to handle touch, let workspace handle it as usual.
-            return false;
+            result = false;
         }
+        if (action == ACTION_UP || action == ACTION_CANCEL) {
+            cancelLongPress();
+        }
+        return result;
     }
 
     private void cancelLongPress() {