From 158ddb1254a2842947fcc66c22be0b6f5a833d23 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Tue, 16 Feb 2021 23:59:30 -0800 Subject: [PATCH] Update task top activity after applying launch flags - When recycling a task complyActivityFlags() may clear the task and finish the task top activity, in this case we should act on the subsequent task top activity Bug: 179905395 Test: atest NexusLauncherTests:TaplTestsNexus#testOverviewActions on a CF instance Change-Id: Ic5db82b82ffe13641519c3cea032c6e46ef1423c --- .../com/android/server/wm/ActivityStarter.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java index 79f8229c61623..29f074ac47abd 100644 --- a/services/core/java/com/android/server/wm/ActivityStarter.java +++ b/services/core/java/com/android/server/wm/ActivityStarter.java @@ -1989,6 +1989,13 @@ class ActivityStarter { return START_SUCCESS; } + // The reusedActivity could be finishing, for example of starting an activity with + // FLAG_ACTIVITY_CLEAR_TOP flag. In that case, use the top running activity in the + // task instead. + targetTaskTop = targetTaskTop.finishing + ? targetTask.getTopNonFinishingActivity() + : targetTaskTop; + // At this point we are certain we want the task moved to the front. If we need to dismiss // any other always-on-top root tasks, now is the time to do it. if (targetTaskTop.canTurnScreenOn() && mService.mInternal.isDreaming()) { @@ -2006,11 +2013,8 @@ class ActivityStarter { // 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. resumeTargetRootTaskIfNeeded(); - // The reusedActivity could be finishing, for example of starting an activity with - // FLAG_ACTIVITY_CLEAR_TOP flag. In that case, return the top running activity in the - // task instead. - mLastStartActivityRecord = - targetTaskTop.finishing ? targetTask.getTopNonFinishingActivity() : targetTaskTop; + + mLastStartActivityRecord = targetTaskTop; return mMovedToFront ? START_TASK_TO_FRONT : START_DELIVERED_TO_TOP; }