diff options
| author | 2023-11-27 20:19:35 +0000 | |
|---|---|---|
| committer | 2023-11-28 18:28:09 +0000 | |
| commit | f18f5bf7f42b9224e1ef7b824b5a0fd85f66d7bc (patch) | |
| tree | c514078eb606f16a8a97fa2baf202eff19b1a573 | |
| parent | c8ce1cc55448951879e570ebf4c66727c54c10a8 (diff) | |
Fix Desktop Windowing focus if clicked in Taskbar
* Added `hasOrderChanges` to `Transition` to make a shallow check if
there was a reorder change.
* Updated `ActivityStarter.handleStartResult` to not abort
`START_DELIVERED_TO_TOP` result when has reorder changes.
Bug: 308995974
Test: manual, atest TransitionTests
Flag: none
Change-Id: Ia295ead19109126a6406ab9de4427f4270341ca6
4 files changed, 31 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java index 009b8e048840..8d3f175773ab 100644 --- a/services/core/java/com/android/server/wm/ActivityStarter.java +++ b/services/core/java/com/android/server/wm/ActivityStarter.java @@ -1567,6 +1567,7 @@ class ActivityStarter { // An activity has changed order/visibility or the task is occluded by a transient // activity, so this isn't just deliver-to-top && mMovedToTopActivity == null + && !transitionController.hasOrderChanges() && !transitionController.isTransientHide(startedActivityRootTask)) { // We just delivered to top, so there isn't an actual transition here. if (!forceTransientTransition) { diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java index caa57bb032ca..56db495c2fbe 100644 --- a/services/core/java/com/android/server/wm/Transition.java +++ b/services/core/java/com/android/server/wm/Transition.java @@ -1756,6 +1756,27 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener { } /** + * Checks if the transition contains order changes. + * + * This is a shallow check that doesn't account for collection in parallel, unlike + * {@code collectOrderChanges} + */ + boolean hasOrderChanges() { + ArrayList<Task> onTopTasks = new ArrayList<>(); + // Iterate over target displays to get up to date on top tasks. + // Cannot use `mOnTopTasksAtReady` as it's not populated before the `applyReady` is called. + for (DisplayContent dc : mTargetDisplays) { + addOnTopTasks(dc, onTopTasks); + } + for (Task task : onTopTasks) { + if (!mOnTopTasksStart.contains(task)) { + return true; + } + } + return false; + } + + /** * Collect tasks which moved-to-top as part of this transition. This also updates the * controller's latest-reported when relevant. * diff --git a/services/core/java/com/android/server/wm/TransitionController.java b/services/core/java/com/android/server/wm/TransitionController.java index a736874f178d..a6a9f13edf28 100644 --- a/services/core/java/com/android/server/wm/TransitionController.java +++ b/services/core/java/com/android/server/wm/TransitionController.java @@ -792,6 +792,12 @@ class TransitionController { mCollectingTransition.recordTaskOrder(wc); } + /** @see Transition#hasOrderChanges */ + boolean hasOrderChanges() { + if (mCollectingTransition == null) return false; + return mCollectingTransition.hasOrderChanges(); + } + /** * Collects the window containers which need to be synced with the changing display area into * the current collecting transition. diff --git a/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java b/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java index dade3b91e0eb..71447e72de8c 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java @@ -2015,6 +2015,9 @@ public class TransitionTests extends WindowTestsBase { transition.collect(leafTaskA); rootTaskA.moveToFront("test", leafTaskA); + // Test has order changes, a shallow check of order changes + assertTrue(transition.hasOrderChanges()); + // All the tasks were already visible, so there shouldn't be any changes ArrayList<Transition.ChangeInfo> targets = Transition.calculateTargets( participants, changes); |