diff options
| author | 2018-04-03 00:24:11 +0000 | |
|---|---|---|
| committer | 2018-04-03 00:24:11 +0000 | |
| commit | e88e5584849c5d95d2f1ec4abfbcdf1d8f691a23 (patch) | |
| tree | 15e91640f203d56ee93703ad50359244531173f2 | |
| parent | d2dc31b5b847c77048657e5ef10058ade64fc9f8 (diff) | |
| parent | 540f74786135b5c99170a518ef246ecfd0588739 (diff) | |
Merge "Do not set activity's task before clearing in some scenarios." into pi-dev
am: 540f747861
Change-Id: Ida4807ded086a070e2e905f03d298ffd4c6ab98b
| -rw-r--r-- | services/core/java/com/android/server/am/ActivityStarter.java | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java index a30a944b44f1..1b7e1edeffe9 100644 --- a/services/core/java/com/android/server/am/ActivityStarter.java +++ b/services/core/java/com/android/server/am/ActivityStarter.java @@ -46,6 +46,7 @@ import static android.content.Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED; import static android.content.Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS; import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP; import static android.content.pm.ActivityInfo.DOCUMENT_LAUNCH_ALWAYS; +import static android.content.pm.ActivityInfo.LAUNCH_MULTIPLE; import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_INSTANCE; import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_TASK; import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_TOP; @@ -1205,9 +1206,20 @@ class ActivityStarter { return START_RETURN_LOCK_TASK_MODE_VIOLATION; } - if (mStartActivity.getTask() == null) { + // True if we are clearing top and resetting of a standard (default) launch mode + // ({@code LAUNCH_MULTIPLE}) activity. The existing activity will be finished. + final boolean clearTopAndResetStandardLaunchMode = + (mLaunchFlags & (FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_RESET_TASK_IF_NEEDED)) + == (FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_RESET_TASK_IF_NEEDED) + && mLaunchMode == LAUNCH_MULTIPLE; + + // If mStartActivity does not have a task associated with it, associate it with the + // reused activity's task. Do not do so if we're clearing top and resetting for a + // standard launchMode activity. + if (mStartActivity.getTask() == null && !clearTopAndResetStandardLaunchMode) { mStartActivity.setTask(reusedActivity.getTask()); } + if (reusedActivity.getTask().intent == null) { // This task was started because of movement of the activity based on affinity... // Now that we are actually launching it, we can assign the base intent. @@ -1266,17 +1278,21 @@ class ActivityStarter { resumeTargetStackIfNeeded(); return START_RETURN_INTENT_TO_CALLER; } - setTaskFromIntentActivity(reusedActivity); - if (!mAddingToTask && mReuseTask == null) { - // We didn't do anything... but it was needed (a.k.a., client don't use that - // intent!) And for paranoia, make sure we have correctly resumed the top activity. - resumeTargetStackIfNeeded(); - if (outActivity != null && outActivity.length > 0) { - outActivity[0] = reusedActivity; - } + if (reusedActivity != null) { + setTaskFromIntentActivity(reusedActivity); + + if (!mAddingToTask && mReuseTask == null) { + // We didn't do anything... but it was needed (a.k.a., client don't use that + // intent!) And for paranoia, make sure we have correctly resumed the top activity. - return mMovedToFront ? START_TASK_TO_FRONT : START_DELIVERED_TO_TOP; + resumeTargetStackIfNeeded(); + if (outActivity != null && outActivity.length > 0) { + outActivity[0] = reusedActivity; + } + + return mMovedToFront ? START_TASK_TO_FRONT : START_DELIVERED_TO_TOP; + } } } |