From 74e50739dd595c9c3d676322d1a356a7b65e965f Mon Sep 17 00:00:00 2001 From: Bryce Lee Date: Wed, 29 Sep 2021 12:08:22 -0700 Subject: [PATCH] Correct launch task behind when dream is present. Logic was introduced to launch any activity behind the current task when a dream was present. This is problematic when a dream is stopping as the top task will not be the dream and the new activity will be launched behind the task previously behind the dream. This changelist addresses this corner case by checking the stopped state of the DreamActivity before deciding to place the new activity behind. Test: CtsWindowManagerDeviceTestCases Bug: 200752015 Change-Id: I050eac31e1a40c885b24565f5a4c3bb1a053c2a5 --- .../com/android/server/wm/ActivityStarter.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java index b966ed1af8b65..00eb0d3256df6 100644 --- a/services/core/java/com/android/server/wm/ActivityStarter.java +++ b/services/core/java/com/android/server/wm/ActivityStarter.java @@ -88,6 +88,7 @@ import android.app.IApplicationThread; import android.app.PendingIntent; import android.app.ProfilerInfo; import android.app.WaitResult; +import android.app.WindowConfiguration; import android.app.compat.CompatChanges; import android.compat.annotation.ChangeId; import android.compat.annotation.EnabledSince; @@ -1745,6 +1746,16 @@ class ActivityStarter { mIntent.setFlags(mLaunchFlags); + boolean dreamStopping = false; + + for (ActivityRecord stoppingActivity : mSupervisor.mStoppingActivities) { + if (stoppingActivity.getActivityType() + == WindowConfiguration.ACTIVITY_TYPE_DREAM) { + dreamStopping = true; + break; + } + } + // Get top task at beginning because the order may be changed when reusing existing task. final Task prevTopTask = mPreferredTaskDisplayArea.getFocusedRootTask(); final Task reusedTask = getReusableTask(); @@ -1805,7 +1816,8 @@ class ActivityStarter { if (!mAvoidMoveToFront && mDoResume) { mTargetRootTask.getRootTask().moveToFront("reuseOrNewTask", targetTask); - if (!mTargetRootTask.isTopRootTaskInDisplayArea() && mService.mInternal.isDreaming()) { + if (!mTargetRootTask.isTopRootTaskInDisplayArea() && mService.mInternal.isDreaming() + && !dreamStopping) { // Launching underneath dream activity (fullscreen, always-on-top). Run the launch- // -behind transition so the Activity gets created and starts in visible state. mLaunchTaskBehind = true;