From 93845662e72104484455bbca1dad74829dbd2dcd Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Wed, 1 Mar 2023 15:34:41 +0800 Subject: [PATCH] Update launch policy state when finishing transient launch This aligns with the legacy implementation of RecentsAnimation#finishAnimation: If it is returning to home, it will call stopAppSwitches and moveTaskToFront -> TDA#onChildPositionChanged -> RWC#invalidateTaskLayers. Legacy: move home to top at the end. Shell: move home to top at the at the beginning. So manual call rankTaskLayers for shell transition. Then the background launch restriction can detect the valid states for the launches after the swipe-to-home gesture is done. Bug: 270383113 Test: atest TransitionTests#testTransientLaunch Change-Id: I0987f2a0afa2bf599322d37acfe19d40060f7879 --- .../core/java/com/android/server/wm/Transition.java | 12 +++++++++--- .../android/server/wm/WindowProcessController.java | 3 +++ .../src/com/android/server/wm/TransitionTests.java | 3 +++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java index a68b3cb2a2ea5..12cfa26342449 100644 --- a/services/core/java/com/android/server/wm/Transition.java +++ b/services/core/java/com/android/server/wm/Transition.java @@ -813,7 +813,7 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener { } boolean hasParticipatedDisplay = false; - boolean reportTaskStackChanged = false; + boolean hasVisibleTransientLaunch = false; // Commit all going-invisible containers for (int i = 0; i < mParticipants.size(); ++i) { final WindowContainer participant = mParticipants.valueAt(i); @@ -856,7 +856,7 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener { && ar.isVisible()) { // Transient launch was committed, so report enteringAnimation ar.mEnteringAnimation = true; - reportTaskStackChanged = true; + hasVisibleTransientLaunch = true; // Since transient launches don't automatically take focus, make sure we // synchronize focus since we committed to the launch. @@ -900,8 +900,14 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener { } } - if (reportTaskStackChanged) { + if (hasVisibleTransientLaunch) { + // Notify the change about the transient-below task that becomes invisible. mController.mAtm.getTaskChangeNotificationController().notifyTaskStackChanged(); + // Prevent spurious background app switches. + mController.mAtm.stopAppSwitches(); + // The end of transient launch may not reorder task, so make sure to compute the latest + // task rank according to the current visibility. + mController.mAtm.mRootWindowContainer.rankTaskLayers(); } // dispatch legacy callback in a different loop. This is because multiple legacy handlers diff --git a/services/core/java/com/android/server/wm/WindowProcessController.java b/services/core/java/com/android/server/wm/WindowProcessController.java index e56b6792f491f..a33a237ccf5d2 100644 --- a/services/core/java/com/android/server/wm/WindowProcessController.java +++ b/services/core/java/com/android/server/wm/WindowProcessController.java @@ -1839,6 +1839,9 @@ public class WindowProcessController extends ConfigurationContainer