Hide the Taskbar when user leaves PiP mode

This is to prevent the Taskbar from flickering when the app settles in
full-screen mode.

Video: http://recall/-/aaaaaabFQoRHlzixHdtY/dIgvinb9yEB8MYfYDx0Ijy
Bug: 218450853
Test: see video
Change-Id: I9cfb0ca151dea6951561f78798bb16bafa48eba0
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
index 6bc2a93..d5c399b 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
@@ -75,4 +75,15 @@
     public void hideAllApps() {
         mControllers.taskbarAllAppsController.hide();
     }
+
+    /**
+     * User expands PiP to full-screen (or split-screen) mode, try to hide the Taskbar.
+     */
+    public void onExpandPip() {
+        if (mControllers != null) {
+            final TaskbarStashController stashController = mControllers.taskbarStashController;
+            stashController.updateStateForFlag(TaskbarStashController.FLAG_IN_APP, true);
+            stashController.applyState();
+        }
+    }
 }
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 3c10e21..da3b77b 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -5102,6 +5102,19 @@
                 mRecentsView.mPipCornerRadius = cornerRadius;
             }
         }
+
+        @Override
+        public void onExpandPip() {
+            MAIN_EXECUTOR.execute(() -> {
+                if (mRecentsView == null
+                        || mRecentsView.mSizeStrategy.getTaskbarController() == null) {
+                    return;
+                }
+                // Hide the task bar when leaving PiP to prevent it from flickering once
+                // the app settles in full-screen mode.
+                mRecentsView.mSizeStrategy.getTaskbarController().onExpandPip();
+            });
+        }
     }
 
     /** Get the color used for foreground scrimming the RecentsView for sharing. */