summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tracy Zhou <tracyzhou@google.com> 2023-02-23 00:27:27 -0800
committer Tracy Zhou <tracyzhou@google.com> 2023-03-01 23:44:56 +0000
commite8008e814aba547f9aa51a274a2fe4943c71860e (patch)
tree4f6f536c3b3f398c84cd8063be65575ad80b64c2
parente7020d59bd8d37de52f846e557477be97aebfa57 (diff)
Disable back gesture on the home and -1 screen
The way to disable back on home / -1 screen is by specifying the entire screen as part of systemGestureExclusion when launcher is in that state. For trackpad gestures, we bypass that check generally when the cursor is in an excluded region (since 3-finger swipe doesn't interact with that region instead of touch). However, in a case like this (when the whole screen is excluded from system gesture), we should respect it. Fixes: 270585141 Test: 3-finger horizontal swipe from home / -1, make sure that back behavior is not triggered Change-Id: I329fc0f3efbb268e2fa1a9e9e33902cd523d4253
-rw-r--r--packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java18
1 files changed, 17 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java
index 342e0b006c18..f28c275158b9 100644
--- a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java
@@ -28,6 +28,7 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.graphics.Insets;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.PointF;
@@ -54,6 +55,7 @@ import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.ViewConfiguration;
+import android.view.WindowInsets;
import android.view.WindowManager;
import android.window.BackEvent;
@@ -776,6 +778,19 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
return true;
}
+ private boolean isValidTrackpadBackGesture(boolean isTrackpadEvent) {
+ if (!isTrackpadEvent) {
+ return false;
+ }
+ // for trackpad gestures, unless the whole screen is excluded region, 3-finger swipe
+ // gestures are allowed even if the cursor is in the excluded region.
+ WindowInsets windowInsets = mWindowManager.getCurrentWindowMetrics().getWindowInsets();
+ Insets insets = windowInsets.getInsets(WindowInsets.Type.systemBars());
+ final Rect excludeBounds = mExcludeRegion.getBounds();
+ return !excludeBounds.contains(insets.left, insets.top, mDisplaySize.x - insets.right,
+ mDisplaySize.y - insets.bottom);
+ }
+
private boolean isWithinTouchRegion(int x, int y) {
// If the point is inside the PiP or Nav bar overlay excluded bounds, then ignore the back
// gesture
@@ -896,7 +911,8 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
&& (isTrackpadEvent || isWithinInsets)
&& !mGestureBlockingActivityRunning
&& !QuickStepContract.isBackGestureDisabled(mSysUiFlags)
- && (isTrackpadEvent || isWithinTouchRegion((int) ev.getX(), (int) ev.getY()));
+ && (isValidTrackpadBackGesture(isTrackpadEvent) || isWithinTouchRegion(
+ (int) ev.getX(), (int) ev.getY()));
if (mAllowGesture) {
mEdgeBackPlugin.setIsLeftPanel(mIsOnLeftEdge);
mEdgeBackPlugin.onMotionEvent(ev);