Merge "Ignore regions specified by the nav bar overlay" into sc-dev
diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarOverlayController.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarOverlayController.java
index 40f908b..9f2fb50 100644
--- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarOverlayController.java
+++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarOverlayController.java
@@ -17,6 +17,7 @@
 package com.android.systemui.navigationbar;
 
 import android.content.Context;
+import android.graphics.Rect;
 import android.view.View;
 
 import com.android.systemui.dagger.SysUISingleton;
@@ -47,7 +48,8 @@
     /**
      * Initialize the controller with visibility change callback.
      */
-    public void init(Consumer<Boolean> visibilityChangeCallback) {}
+    public void init(Consumer<Boolean> visibilityChangeCallback,
+            Consumer<Rect> excludeBackRegionCallback) {}
 
     /**
      * Set whether the view can be shown.
diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java
index fcbd596..7af4853 100644
--- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java
@@ -323,10 +323,6 @@
 
         mOverviewProxyService = Dependency.get(OverviewProxyService.class);
         mRecentsOnboarding = new RecentsOnboarding(context, mOverviewProxyService);
-        mNavBarOverlayController = Dependency.get(NavigationBarOverlayController.class);
-        if (mNavBarOverlayController.isNavigationBarOverlayEnabled()) {
-            mNavBarOverlayController.init(mNavbarOverlayVisibilityChangeCallback);
-        }
 
         mConfiguration = new Configuration();
         mTmpLastConfiguration = new Configuration();
@@ -371,6 +367,12 @@
                         return isGesturalModeOnDefaultDisplay(getContext(), mNavBarMode);
                     }
                 });
+
+        mNavBarOverlayController = Dependency.get(NavigationBarOverlayController.class);
+        if (mNavBarOverlayController.isNavigationBarOverlayEnabled()) {
+            mNavBarOverlayController.init(mNavbarOverlayVisibilityChangeCallback,
+                    mEdgeBackGestureHandler::updateNavigationBarOverlayExcludeRegion);
+        }
     }
 
     public void setAutoHideController(AutoHideController autoHideController) {
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 fc615de..be513f3 100644
--- a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java
@@ -187,6 +187,7 @@
     private final Executor mMainExecutor;
 
     private final Rect mPipExcludedBounds = new Rect();
+    private final Rect mNavBarOverlayExcludedBounds = new Rect();
     private final Region mExcludeRegion = new Region();
     private final Region mUnrestrictedExcludeRegion = new Region();
 
@@ -366,6 +367,10 @@
         mTouchSlop = mViewConfiguration.getScaledTouchSlop() * backGestureSlop;
     }
 
+    public void updateNavigationBarOverlayExcludeRegion(Rect exclude) {
+        mNavBarOverlayExcludedBounds.set(exclude);
+    }
+
     private void onNavigationSettingsChanged() {
         boolean wasBackAllowed = isHandlingGestures();
         updateCurrentUserResources();
@@ -629,8 +634,9 @@
             return false;
         }
 
-        // If the point is inside the PiP excluded bounds, then drop it.
-        if (mPipExcludedBounds.contains(x, y)) {
+        // If the point is inside the PiP or Nav bar overlay excluded bounds, then ignore the back
+        // gesture
+        if (mPipExcludedBounds.contains(x, y) || mNavBarOverlayExcludedBounds.contains(x, y)) {
             return false;
         }
 
@@ -893,6 +899,7 @@
         pw.println("  mExcludeRegion=" + mExcludeRegion);
         pw.println("  mUnrestrictedExcludeRegion=" + mUnrestrictedExcludeRegion);
         pw.println("  mPipExcludedBounds=" + mPipExcludedBounds);
+        pw.println("  mNavBarOverlayExcludedBounds=" + mNavBarOverlayExcludedBounds);
         pw.println("  mEdgeWidthLeft=" + mEdgeWidthLeft);
         pw.println("  mEdgeWidthRight=" + mEdgeWidthRight);
         pw.println("  mLeftInset=" + mLeftInset);