From 79fd9aea20931abc3295c0838ea1e1fa68d105d5 Mon Sep 17 00:00:00 2001 From: Ming-Shin Lu Date: Tue, 14 Jun 2022 11:23:40 +0800 Subject: Fix the startingWindow may clipped during AR#transferStartingWindow Consider a transferStartingWindow use case that a trampoline activity with unspecified orientation to start another activity with fixed landcape orientation, As AR#setInsetsFrozen(true) will be invoked when the trampoline activity is leaving, and then calling AR#transferStartingWindow if the trampoline activity is finishing. If we don't clear the frozen insets state when transferring the starting window to the new target activity, it may end up seeing a flicker that the starting window being clipped because computeWindowFrames took the wrong frozen insets state and leads to the starting window frame size wrong. Ensure to call clearFrozenInsetsState for the starting window when transfering to the new activity for fixing this flicker case. Bug: 235440740 Test: atest ActivityRecordTests#\ testTryTransferStartingWindowFromHiddenAboveToken Change-Id: I78d59308c6353e841ca8ba2f60428063094c5d25 --- services/core/java/com/android/server/wm/ActivityRecord.java | 12 +++++++++--- .../src/com/android/server/wm/ActivityRecordTests.java | 6 ++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 859b4df3baa6..d70d29138c94 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -4299,9 +4299,15 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A mTransitionController.collect(tStartingWindow); tStartingWindow.reparent(this, POSITION_TOP); - // Propagate other interesting state between the tokens. If the old token is displayed, - // we should immediately force the new one to be displayed. If it is animating, we need - // to move that animation to the new one. + // Clear the frozen insets state when transferring the existing starting window to + // the next target activity. In case the frozen state from a trampoline activity + // affecting the starting window frame computation to see the window being + // clipped if the rotation change during the transition animation. + tStartingWindow.clearFrozenInsetsState(); + + // Propagate other interesting state between the tokens. If the old token is + // displayed, we should immediately force the new one to be displayed. If it is + // animating, we need to move that animation to the new one. if (fromActivity.allDrawn) { allDrawn = true; } diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java index 8c4a4c9ea284..03d87749072d 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java @@ -2811,12 +2811,18 @@ public class ActivityRecordTests extends WindowTestsBase { true, false, false, false); waitUntilHandlersIdle(); + final WindowState startingWindow = activityTop.mStartingWindow; + assertNotNull(startingWindow); + // Make the top one invisible, and try transferring the starting window from the top to the // bottom one. activityTop.setVisibility(false, false); activityBottom.transferStartingWindowFromHiddenAboveTokenIfNeeded(); waitUntilHandlersIdle(); + // Expect getFrozenInsetsState will be null when transferring the starting window. + assertNull(startingWindow.getFrozenInsetsState()); + // Assert that the bottom window now has the starting window. assertNoStartingWindow(activityTop); assertHasStartingWindow(activityBottom); -- cgit v1.2.3-59-g8ed1b