From d64fe113f5f636fe55fefabf5255a56c2478c0ce Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Wed, 20 Feb 2019 13:18:24 -0800 Subject: [PATCH] Put pippable apps to pip mode upon swipe up to home gesture Fixes: 122609330 Test: manual Change-Id: I6cd0110b17fba9be6de1b3e6ba5750018d6f0514 (cherry picked from commit b091ed9098c32ac6fd7ffa211e1a3e9e2ec6b049) --- .../quickstep/RecentsAnimationWrapper.java | 22 ++++++++++++++----- .../WindowTransformSwipeHandler.java | 3 ++- .../util/SwipeAnimationTargetSet.java | 4 ++-- 3 files changed, 20 insertions(+), 9 deletions(-) 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 0924f38dcf..ced9afab78 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 @@ public class RecentsAnimationWrapper { } } + /** 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 @@ public class RecentsAnimationWrapper { 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 @@ public class RecentsAnimationWrapper { 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 a974135be3..5a1d3877a4 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 @@ public class WindowTransformSwipeHandler 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 b6824813f4..5a1a103204 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 @@ public class SwipeAnimationTargetSet extends RemoteAnimationTargetSet { 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);