From c043fa586dd4794ffbf0d8ba91324c444b3bd2e2 Mon Sep 17 00:00:00 2001 From: Louis Chang Date: Mon, 11 Apr 2022 17:29:01 +0800 Subject: [PATCH] Migrate task intent/info to new task only if source task is empty Migrate the task intent and info to the new task only if the source task is empty or is about to remove. Or the source task will be trimmed from Recents due to newly created task added. Bug: 205215708 Test: start tips from Settings Change-Id: I283b777b20f702b49fcf06fd7435bab87816d7d5 --- .../com/android/server/wm/ActivityStarter.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java index eb912d4c2747b..5b3d0ee6dcd30 100644 --- a/services/core/java/com/android/server/wm/ActivityStarter.java +++ b/services/core/java/com/android/server/wm/ActivityStarter.java @@ -2638,14 +2638,16 @@ class ActivityStarter { Slog.w(TAG, "startActivity called from finishing " + mSourceRecord + "; forcing " + "Intent.FLAG_ACTIVITY_NEW_TASK for: " + mIntent); mLaunchFlags |= FLAG_ACTIVITY_NEW_TASK; - mNewTaskInfo = mSourceRecord.info; - // It is not guaranteed that the source record will have a task associated with it. For, - // example, if this method is being called for processing a pending activity launch, it - // is possible that the activity has been removed from the task after the launch was - // enqueued. + // It is not guaranteed that the source record will have a task associated with it. + // For example, if this method is being called for processing a pending activity + // launch, it is possible that the activity has been removed from the task after the + // launch was enqueued. final Task sourceTask = mSourceRecord.getTask(); - mNewTaskIntent = sourceTask != null ? sourceTask.intent : null; + if (sourceTask == null || sourceTask.getTopNonFinishingActivity() == null) { + mNewTaskInfo = mSourceRecord.info; + mNewTaskIntent = sourceTask != null ? sourceTask.intent : null; + } } mSourceRecord = null; mSourceRootTask = null;