Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 79fd9aea authored by Ming-Shin Lu's avatar Ming-Shin Lu
Browse files

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
parent 19885f1c
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -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;
                }
+6 −0
Original line number Diff line number Diff line
@@ -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);