Put pippable apps to pip mode upon swipe up to home gesture

Fixes: 122609330
Test: manual
Change-Id: I6cd0110b17fba9be6de1b3e6ba5750018d6f0514
(cherry picked from commit b091ed9098c32ac6fd7ffa211e1a3e9e2ec6b049)
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsAnimationWrapper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsAnimationWrapper.java
index 0924f38..ced9afa 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsAnimationWrapper.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsAnimationWrapper.java
@@ -85,15 +85,24 @@
         }
     }
 
+    /** See {@link #finish(boolean, Runnable, boolean)} */
+    @UiThread
+    public void finish(boolean toRecents, Runnable onFinishComplete) {
+        finish(toRecents, onFinishComplete, false /* sendUserLeaveHint */);
+    }
+
     /**
      * @param onFinishComplete A callback that runs on the main thread after the animation
      *                         controller has finished on the background thread.
+     * @param sendUserLeaveHint Determines whether userLeaveHint flag will be set on the pausing
+     *                          activity. If userLeaveHint is true, the activity will enter into
+     *                          picture-in-picture mode upon being paused.
      */
     @UiThread
-    public void finish(boolean toRecents, Runnable onFinishComplete) {
+    public void finish(boolean toRecents, Runnable onFinishComplete, boolean sendUserLeaveHint) {
         Preconditions.assertUIThread();
         if (!toRecents) {
-            finishAndClear(false, onFinishComplete);
+            finishAndClear(false, onFinishComplete, sendUserLeaveHint);
         } else {
             if (mTouchInProgress) {
                 mFinishPending = true;
@@ -102,16 +111,17 @@
                     onFinishComplete.run();
                 }
             } else {
-                finishAndClear(true, onFinishComplete);
+                finishAndClear(true, onFinishComplete, sendUserLeaveHint);
             }
         }
     }
 
-    private void finishAndClear(boolean toRecents, Runnable onFinishComplete) {
+    private void finishAndClear(boolean toRecents, Runnable onFinishComplete,
+            boolean sendUserLeaveHint) {
         SwipeAnimationTargetSet controller = targetSet;
         targetSet = null;
         if (controller != null) {
-            controller.finishController(toRecents, onFinishComplete);
+            controller.finishController(toRecents, onFinishComplete, sendUserLeaveHint);
         }
     }
 
@@ -163,7 +173,7 @@
             mTouchInProgress = false;
             if (mFinishPending) {
                 mFinishPending = false;
-                finishAndClear(true /* toRecents */, null);
+                finishAndClear(true /* toRecents */, null, false /* sendUserLeaveHint */);
             }
         }
         if (mInputConsumer != null) {
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java
index a974135..5a1d387 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java
@@ -1130,7 +1130,8 @@
     private void finishCurrentTransitionToHome() {
         synchronized (mRecentsAnimationWrapper) {
             mRecentsAnimationWrapper.finish(true /* toRecents */,
-                    () -> setStateOnUiThread(STATE_CURRENT_TASK_FINISHED));
+                    () -> setStateOnUiThread(STATE_CURRENT_TASK_FINISHED),
+                    true /* sendUserLeaveHint */);
         }
         TOUCH_INTERACTION_LOG.addLog("finishRecentsAnimation", true);
         doLogGesture(HOME);
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/SwipeAnimationTargetSet.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/SwipeAnimationTargetSet.java
index b682481..5a1a103 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/SwipeAnimationTargetSet.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/SwipeAnimationTargetSet.java
@@ -53,11 +53,11 @@
         this.mOnFinishListener = onFinishListener;
     }
 
-    public void finishController(boolean toRecents, Runnable callback) {
+    public void finishController(boolean toRecents, Runnable callback, boolean sendUserLeaveHint) {
         mOnFinishListener.accept(this);
         BACKGROUND_EXECUTOR.execute(() -> {
             controller.setInputConsumerEnabled(false);
-            controller.finish(toRecents);
+            controller.finish(toRecents, sendUserLeaveHint);
 
             if (callback != null) {
                 MAIN_THREAD_EXECUTOR.execute(callback);