From 55f74d675c394b22aa50479bb22018bab6218c85 Mon Sep 17 00:00:00 2001 From: Iris Yang Date: Tue, 21 Dec 2021 08:56:19 +0000 Subject: [PATCH] Set launch display id to an action performed on BaseQuickStepLauncher Without this change, tapping all apps of work profile wouldn't bring the work profile app back to phone. Add ActivityOptions#setLaunchDisplayId to the display that the given view is currently on. So the activity will be launched to the display as the user is interacting with. This change also modified BaseDraggingActivity which is the parent class of BaseQuickstepLauncher. And the RecentsActivity is extending BaseDraggingActivity. Bug: 204164763 Test: Manually tested using Exo. Open work appliction(e.g.Calendar) on Exo virtual display, and tapping on the phone's Calendar on work profile to bring the application back to phone. Demo video: https://drive.google.com/file/d/18LWMyDz5kYj8IwAwu5EOsBk3PsjEx1zf/view?usp=sharing&resourcekey=0-7eGtqiWZDciSCfFce29MtA Change-Id: I31d822f6df7222939413f13da850230f46ba8001 --- .../src/com/android/launcher3/BaseQuickstepLauncher.java | 4 ++++ quickstep/src/com/android/quickstep/RecentsActivity.java | 4 ++++ src/com/android/launcher3/BaseDraggingActivity.java | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java index 65b346a590..d9829c6611 100644 --- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java @@ -39,6 +39,7 @@ import android.hardware.SensorManager; import android.hardware.devicestate.DeviceStateManager; import android.os.Bundle; import android.os.CancellationSignal; +import android.view.Display; import android.view.View; import android.view.WindowInsets; import android.window.SplashScreen; @@ -509,6 +510,9 @@ public abstract class BaseQuickstepLauncher extends Launcher activityOptions.options, mLastTouchUpTime); } activityOptions.options.setSplashScreenStyle(SplashScreen.SPLASH_SCREEN_STYLE_ICON); + activityOptions.options.setLaunchDisplayId( + (v != null && v.getDisplay() != null) ? v.getDisplay().getDisplayId() + : Display.DEFAULT_DISPLAY); addLaunchCookie(item, activityOptions.options); return activityOptions; } diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java index 306e864372..beeb723ddb 100644 --- a/quickstep/src/com/android/quickstep/RecentsActivity.java +++ b/quickstep/src/com/android/quickstep/RecentsActivity.java @@ -38,6 +38,7 @@ import android.content.res.Configuration; import android.os.Bundle; import android.os.Handler; import android.os.Looper; +import android.view.Display; import android.view.SurfaceControl.Transaction; import android.view.View; import android.window.SplashScreen; @@ -256,6 +257,9 @@ public final class RecentsActivity extends StatefulActivity { ActivityOptionsCompat.makeRemoteAnimation(adapterCompat), onEndCallback); activityOptions.options.setSplashScreenStyle(SplashScreen.SPLASH_SCREEN_STYLE_ICON); + activityOptions.options.setLaunchDisplayId( + (v != null && v.getDisplay() != null) ? v.getDisplay().getDisplayId() + : Display.DEFAULT_DISPLAY); return activityOptions; } diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java index dd56ca3a23..80c2d9e48b 100644 --- a/src/com/android/launcher3/BaseDraggingActivity.java +++ b/src/com/android/launcher3/BaseDraggingActivity.java @@ -182,6 +182,10 @@ public abstract class BaseDraggingActivity extends BaseActivity } ActivityOptions options = ActivityOptions.makeClipRevealAnimation(v, left, top, width, height); + + options.setLaunchDisplayId( + (v != null && v.getDisplay() != null) ? v.getDisplay().getDisplayId() + : Display.DEFAULT_DISPLAY); RunnableList callback = new RunnableList(); addOnResumeCallback(callback::executeAllAndDestroy); return new ActivityOptionsWrapper(options, callback);