From 8c97862312261c4e06c1131e1e8413d9f120f290 Mon Sep 17 00:00:00 2001 From: Jeff Chang Date: Wed, 24 Mar 2021 14:13:32 +0800 Subject: [PATCH] Revert f714906c for startActivityForResult f714906c, Avoid creating new instances when started for results with singleInstance/singleTask. The CL breaks the start for results function. Bug: 180774751 Test: atest IntentTests Change-Id: Ib4086734f8d731a35b05afecab0a6042573600e8 --- .../core/java/com/android/server/wm/ActivityStarter.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java index 59d40cf36e9d2..912078c415304 100644 --- a/services/core/java/com/android/server/wm/ActivityStarter.java +++ b/services/core/java/com/android/server/wm/ActivityStarter.java @@ -1815,7 +1815,8 @@ class ActivityStarter { } private Task computeTargetTask() { - if (mInTask == null && !mAddingToTask && (mLaunchFlags & FLAG_ACTIVITY_NEW_TASK) != 0) { + if (mStartActivity.resultTo == null && mInTask == null && !mAddingToTask + && (mLaunchFlags & FLAG_ACTIVITY_NEW_TASK) != 0) { // A new task should be created instead of using existing one. return null; } else if (mSourceRecord != null) { @@ -2515,9 +2516,7 @@ class ActivityStarter { // If bring to front is requested, and no result is requested and we have not been given // an explicit task to launch in to, and we can find a task that was started with this // same component, then instead of launching bring that one to the front. - putIntoExistingTask &= !isLaunchModeOneOf(LAUNCH_SINGLE_INSTANCE, LAUNCH_SINGLE_TASK) - ? (mInTask == null && mStartActivity.resultTo == null) - : (mInTask == null); + putIntoExistingTask &= mInTask == null && mStartActivity.resultTo == null; ActivityRecord intentActivity = null; if (putIntoExistingTask) { if (LAUNCH_SINGLE_INSTANCE == mLaunchMode) {