From deaad42323ea79a677c810f4ddbb22d1abf38768 Mon Sep 17 00:00:00 2001 From: Jerry Chang Date: Thu, 19 May 2022 10:35:22 +0000 Subject: [PATCH] Support to launch the matching task into a closer adjacent target task When launching trampoline activities into split screen while having the final activity in another side, it'll move the matching task, the task containing the final activity, to another side of the split and result to split dismissed due to one side of the split is empty. To prevent split screen got dismissed during trampoline launch, adjust to apply a closer adjacent launch target to the matching task. Bug: 224901460 Test: atest ActivityStarterTests Test: put a trampoline launched activity into split, drag and drop the same app icon into another side of the split, verified it won't dismiss split screen. Change-Id: I17d401a6648214fbc21c5fb1799267b34abdb355 --- .../android/server/wm/ActivityStarter.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java index 0d447e34502e7..e702c33b9bd67 100644 --- a/services/core/java/com/android/server/wm/ActivityStarter.java +++ b/services/core/java/com/android/server/wm/ActivityStarter.java @@ -2753,17 +2753,15 @@ class ActivityStarter { mTargetRootTask = getOrCreateRootTask(mStartActivity, mLaunchFlags, intentTask, mOptions); } - } else { - // If a launch target indicated, and the matching task is already in the adjacent task - // of the launch target. Adjust to use the adjacent task as its launch target. So the - // existing task will be launched into the closer one and won't be reparent redundantly. - // TODO(b/231541706): Migrate the logic to wm-shell after having proper APIs to help - // resolve target task without actually starting the activity. - final Task adjacentTargetTask = mTargetRootTask.getAdjacentTaskFragment() != null - ? mTargetRootTask.getAdjacentTaskFragment().asTask() : null; - if (adjacentTargetTask != null && intentActivity.isDescendantOf(adjacentTargetTask)) { - mTargetRootTask = adjacentTargetTask; - } + } + + // If the matching task is already in the adjacent task of the launch target. Adjust to use + // the adjacent task as its launch target. So the existing task will be launched into the + // closer one and won't be reparent redundantly. + final Task adjacentTargetTask = mTargetRootTask.getAdjacentTaskFragment() != null + ? mTargetRootTask.getAdjacentTaskFragment().asTask() : null; + if (adjacentTargetTask != null && intentActivity.isDescendantOf(adjacentTargetTask)) { + mTargetRootTask = adjacentTargetTask; } // If the target task is not in the front, then we need to bring it to the front...