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
This commit is contained in:
Bryce Lee
2021-09-29 12:08:22 -07:00
parent 13b1cbf553
commit 74e50739dd

View File

@@ -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;