Add a new method to notify system to detach the nav bar

For the attaching the nav bar to the app during quick switch, we
reparent the leash of the nav bar to the app the user swipes from and
restore it back when the quick switch gesture is finished.

There is a callback IRecentsAnimationController.finish() which seems to
be a good timing to restore the nav bar. However, it doesn't work well
in the live tile mode.

In the live tile mode, the overview won't call
IRecentsAnimationController.finish() until a new task is started and
this is why we need to add this API.

Bug: 139273001
Test: make
Change-Id: Iabea2fb222a2dacd57207b74d1778f93237268ea
diff --git a/core/java/android/view/IRecentsAnimationController.aidl b/core/java/android/view/IRecentsAnimationController.aidl
index f209d88..cac91a9 100644
--- a/core/java/android/view/IRecentsAnimationController.aidl
+++ b/core/java/android/view/IRecentsAnimationController.aidl
@@ -136,4 +136,13 @@
      * @return {@code true} when target removed successfully, {@code false} otherwise.
      */
     boolean removeTask(int taskId);
+
+    /**
+     * Detach navigation bar from app.
+     *
+     * The system reparents the leash of navigation bar to the app when the recents animation starts
+     * and Launcher should call this method to let system restore the navigation bar to its
+     * original position when the quick switch gesture is finished.
+     */
+    void detachNavigationBarFromApp();
 }
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RecentsAnimationControllerCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RecentsAnimationControllerCompat.java
index 611c4b7..fa2f8b9 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RecentsAnimationControllerCompat.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RecentsAnimationControllerCompat.java
@@ -137,4 +137,15 @@
             return false;
         }
     }
+
+    /**
+     * @see IRecentsAnimationController#detachNavigationBarFromApp
+     */
+    public void detachNavigationBarFromApp() {
+        try {
+            mAnimationController.detachNavigationBarFromApp();
+        } catch (RemoteException e) {
+            Log.e(TAG, "Failed to detach the navigation bar from app", e);
+        }
+    }
 }
\ No newline at end of file
diff --git a/services/core/java/com/android/server/wm/RecentsAnimationController.java b/services/core/java/com/android/server/wm/RecentsAnimationController.java
index 16c7226..d1b2e80 100644
--- a/services/core/java/com/android/server/wm/RecentsAnimationController.java
+++ b/services/core/java/com/android/server/wm/RecentsAnimationController.java
@@ -364,6 +364,9 @@
                 Binder.restoreCallingIdentity(token);
             }
         }
+
+        @Override
+        public void detachNavigationBarFromApp() {}
     };
 
     /**