From 8bf24a58ae90f513e726aef01ba709aba6670a3d Mon Sep 17 00:00:00 2001 From: Iris Yang Date: Thu, 16 Sep 2021 02:30:25 +0000 Subject: [PATCH] Move/Launch task on the TaskView's display. Add ActivityOptions#setLaunchDisplayId to the display that the TaskView is currently on. So the task will be moved to the display as the user is interactiving with. This change is adding ag/15604010 back since b/197293995 is fixed. Bug: 183461428 Test: Manually tested using Exo. Open appliction(e.g.Calculator) on Exo virtual display, and tapping on the phone's recents to bring the application back to phone. The demo video https://drive.google.com/file/d/1JMncvsI-VPosK4ql2xeVA8csVAF7Rb16/view?usp=sharing&resourcekey=0-PYRw1k3KdtY0-KZNo6OqjQ Change-Id: I39b1825b69d55001f66ee01a982e3cd366da56bd --- quickstep/src/com/android/quickstep/views/TaskView.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index b3e0dcee1e..6a8d66ddac 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -693,6 +693,7 @@ public class TaskView extends FrameLayout implements Reusable { TestLogging.recordEvent( TestProtocol.SEQUENCE_MAIN, "startActivityFromRecentsAsync", mTask); ActivityOptionsWrapper opts = mActivity.getActivityLaunchOptions(this, null); + opts.options.setLaunchDisplayId(getRootViewDisplayId()); boolean isOldTaskSplit = LauncherSplitScreenListener.INSTANCE.getNoCreate() .getPersistentSplitIds().length > 0; if (ActivityManagerWrapper.getInstance() @@ -738,6 +739,7 @@ public class TaskView extends FrameLayout implements Reusable { // Indicate success once the system has indicated that the transition has started ActivityOptions opts = ActivityOptionsCompat.makeCustomAnimation( getContext(), 0, 0, () -> callback.accept(true), MAIN_EXECUTOR.getHandler()); + opts.setLaunchDisplayId(getRootViewDisplayId()); if (freezeTaskList) { ActivityOptionsCompat.setFreezeRecentTasksList(opts); } @@ -1537,6 +1539,11 @@ public class TaskView extends FrameLayout implements Reusable { mDigitalWellBeingToast.setBannerColorTint(tintColor, amount); } + + private int getRootViewDisplayId() { + return getRootView().getDisplay().getDisplayId(); + } + /** * We update and subsequently draw these in {@link #setFullscreenProgress(float)}. */