From d7c00cb8b4b69b47e0d392086711d255e19caf04 Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Wed, 17 May 2023 15:45:35 -0700 Subject: [PATCH] Disallow two finger gesture nav behaviors when the cursor is in the zones - This change addresses swipe up and quick switch from the nav bar area using two fingers - Separate changes will be implemented in SysUI to disable two finger swipe down from the status bar area and two finger swipe edge swipe for back Bug: 283112069 Test: manual Change-Id: I67c7ba31e759d5693d89112fd8f37f3d2a9eaa41 --- .../com/android/quickstep/RotationTouchHelper.java | 11 +++++++---- .../android/quickstep/TouchInteractionService.java | 3 +-- .../inputconsumers/AccessibilityInputConsumer.java | 3 +-- .../inputconsumers/DeviceLockedInputConsumer.java | 3 +-- .../inputconsumers/OtherActivityInputConsumer.java | 3 +-- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/quickstep/src/com/android/quickstep/RotationTouchHelper.java b/quickstep/src/com/android/quickstep/RotationTouchHelper.java index 8626c40ae0..2d47097671 100644 --- a/quickstep/src/com/android/quickstep/RotationTouchHelper.java +++ b/quickstep/src/com/android/quickstep/RotationTouchHelper.java @@ -19,6 +19,7 @@ import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Surface.ROTATION_0; import static com.android.launcher3.MotionEventsUtils.isTrackpadMultiFingerSwipe; +import static com.android.launcher3.MotionEventsUtils.isTrackpadScroll; import static com.android.launcher3.util.DisplayController.CHANGE_ACTIVE_SCREEN; import static com.android.launcher3.util.DisplayController.CHANGE_ALL; import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE; @@ -232,16 +233,18 @@ public class RotationTouchHelper implements DisplayInfoChangeListener { /** * @return whether the coordinates of the {@param event} is in the swipe up gesture region. */ - public boolean isInSwipeUpTouchRegion(MotionEvent event, BaseActivityInterface activity) { - return isInSwipeUpTouchRegion(event, 0, activity); + public boolean isInSwipeUpTouchRegion(MotionEvent event) { + return isInSwipeUpTouchRegion(event, 0); } /** * @return whether the coordinates of the {@param event} with the given {@param pointerIndex} * is in the swipe up gesture region. */ - public boolean isInSwipeUpTouchRegion(MotionEvent event, int pointerIndex, - BaseActivityInterface activity) { + public boolean isInSwipeUpTouchRegion(MotionEvent event, int pointerIndex) { + if (isTrackpadScroll(event)) { + return false; + } if (isTrackpadMultiFingerSwipe(event)) { return true; } diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index 1fbfbe63bb..edaee8c74a 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -661,8 +661,7 @@ public class TouchInteractionService extends Service mRotationTouchHelper.setOrientationTransformIfNeeded(event); if ((!mDeviceState.isOneHandedModeActive() - && mRotationTouchHelper.isInSwipeUpTouchRegion(event, - mOverviewComponentObserver.getActivityInterface())) + && mRotationTouchHelper.isInSwipeUpTouchRegion(event)) || isHoverActionWithoutConsumer) { // Clone the previous gesture state since onConsumerAboutToBeSwitched might trigger // onConsumerInactive and wipe the previous gesture state diff --git a/quickstep/src/com/android/quickstep/inputconsumers/AccessibilityInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/AccessibilityInputConsumer.java index 6a36d9fd64..2abc7babe7 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/AccessibilityInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/AccessibilityInputConsumer.java @@ -103,8 +103,7 @@ public class AccessibilityInputConsumer extends DelegateInputConsumer { if (mState == STATE_INACTIVE) { int pointerIndex = ev.getActionIndex(); if (mDeviceState.getRotationTouchHelper().isInSwipeUpTouchRegion(ev, - pointerIndex, mGestureState.getActivityInterface()) - && mDelegate.allowInterceptByParent()) { + pointerIndex) && mDelegate.allowInterceptByParent()) { setActive(ev); mActivePointerId = ev.getPointerId(pointerIndex); diff --git a/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java index 59a9582c1f..a5536483df 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java @@ -153,8 +153,7 @@ public class DeviceLockedInputConsumer implements InputConsumer, if (!mThresholdCrossed) { // Cancel interaction in case of multi-touch interaction int ptrIdx = ev.getActionIndex(); - if (!mDeviceState.getRotationTouchHelper().isInSwipeUpTouchRegion(ev, ptrIdx, - mGestureState.getActivityInterface())) { + if (!mDeviceState.getRotationTouchHelper().isInSwipeUpTouchRegion(ev, ptrIdx)) { int action = ev.getAction(); ev.setAction(ACTION_CANCEL); finishTouchTracking(ev); diff --git a/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java index f9cd4ee1cd..7d0937fc8c 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java @@ -248,8 +248,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC if (!mPassedPilferInputSlop) { // Cancel interaction in case of multi-touch interaction int ptrIdx = ev.getActionIndex(); - if (!mRotationTouchHelper.isInSwipeUpTouchRegion(ev, ptrIdx, - mActivityInterface)) { + if (!mRotationTouchHelper.isInSwipeUpTouchRegion(ev, ptrIdx)) { forceCancelGesture(ev); } }