From a93b8addce9384374291f774698dadae6d9b013d Mon Sep 17 00:00:00 2001 From: Kazuki Takise Date: Thu, 16 Mar 2023 22:34:33 +0900 Subject: [PATCH] Run transition when app dies in freeform In a freeform environment, currently a shell transition times out when an app is killed via adb force-stop. In this timeout case, setReady() isn't called where it's supposed to because handleAppDied doesn't directly trigger any z-order or focus update in freeform mode. This CL adjusts the if condition in question so that this kind of lingering transition will be executed even without any focus change. This CL also fixes the timeout issue when dismissing placeholder activity and a PIP task is there. Bug: 244123821 Bug: 268239637 fixes: 274536834 Test: adb shell am force-stop com.android.settings Test: manual - Open settings + pip and fold the foldables Merged-In: I07bdadd81f6992445b11e21dc08a68c231e8d5b8 Change-Id: I07bdadd81f6992445b11e21dc08a68c231e8d5b8 --- .../java/com/android/server/wm/RootWindowContainer.java | 9 ++++----- .../com/android/server/wm/RootWindowContainerTests.java | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java index 129a48f6f193b..a4e08dfb1e3bd 100644 --- a/services/core/java/com/android/server/wm/RootWindowContainer.java +++ b/services/core/java/com/android/server/wm/RootWindowContainer.java @@ -2282,11 +2282,10 @@ class RootWindowContainer extends WindowContainer resumedOnDisplay[0] |= curResult; return; } - if (rootTask.getDisplayArea().isTopRootTask(rootTask) - && topRunningActivity.isState(RESUMED)) { - // Kick off any lingering app transitions from the MoveTaskToFront - // operation, but only consider the top task and root-task on that - // display. + if (topRunningActivity.isState(RESUMED) + && topRunningActivity == rootTask.getDisplayArea().topRunningActivity()) { + // Kick off any lingering app transitions form the MoveTaskToFront operation, + // but only consider the top activity on that display. rootTask.executeAppTransition(targetOptions); } else { resumedOnDisplay[0] |= topRunningActivity.makeActiveIfNeeded(target); diff --git a/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java b/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java index b89643cba1161..42dafe226abd3 100644 --- a/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java @@ -761,7 +761,7 @@ public class RootWindowContainerTests extends WindowTestsBase { // Assume the task is at the topmost position assertFalse(rootTask.isTopRootTaskInDisplayArea()); - doReturn(rootTask).when(mRootWindowContainer).getTopDisplayFocusedRootTask(); + doReturn(taskDisplayArea.getHomeActivity()).when(taskDisplayArea).topRunningActivity(); // Use the task as target to resume. mRootWindowContainer.resumeFocusedTasksTopActivities();