From 47f63c00104390559e6303178500b9143babebed Mon Sep 17 00:00:00 2001 From: Louis Chang Date: Wed, 23 Nov 2022 05:03:54 +0000 Subject: [PATCH] Finishes activities in the reverse order This is the follow-up changes after commit b131a1e that the activities in the Task should be removed in the reverse order in order to prevent unnecessary activity lifecycle events sending to the next top activities in the Task. This should be done regardless shell-transition is enabled. Bug: 249658397 Test: wm presubmit Change-Id: Id89996fa9ccde5164645ea5fefe77f7b63d5372a --- services/core/java/com/android/server/wm/Task.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 756e449b8c4ee..ac81dbb8c663e 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -1587,9 +1587,9 @@ class Task extends TaskFragment { } else { // Finish or destroy apps from the bottom to ensure that all the other activity have // been finished and the top task in another task gets resumed when a top activity is - // removed. Otherwise, shell transitions wouldn't run because there would be no event - // that sets the transition ready. - final boolean traverseTopToBottom = !mTransitionController.isShellTransitionsEnabled(); + // removed. Otherwise, the next top activity could be started while the top activity + // is removed, which is not necessary since the next top activity is on the same Task + // and should also be removed. forAllActivities((r) -> { if (r.finishing || (excludingTaskOverlay && r.isTaskOverlay())) { return; @@ -1603,7 +1603,7 @@ class Task extends TaskFragment { } else { r.destroyIfPossible(reason); } - }, traverseTopToBottom); + }, false /* traverseTopToBottom */); } }