diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 51d4bd220bc1f..b290bec8c4e0f 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -1588,6 +1588,11 @@ class Task extends TaskFragment { removeChild(r, reason); }); } 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(); forAllActivities((r) -> { if (r.finishing || (excludingTaskOverlay && r.isTaskOverlay())) { return; @@ -1601,7 +1606,7 @@ class Task extends TaskFragment { } else { r.destroyIfPossible(reason); } - }); + }, traverseTopToBottom); } }