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

Commit 4f59199a authored by wilsonshih's avatar wilsonshih Committed by Wei Sheng Shih
Browse files

Attemp to fix letterbox flicker before app window draw.

While starting app & before app window draw, letterbox can only check
whether to show letterbox by starting window, but starting window can
transfer to another activity during start app process.
To ensure letterbox state stable during animation, only check the
visibility state of activity, so it won't affected by window.

Bug: 328598627
Test: atest SizeCompatTests LetterboxUiControllerTest
Test: launch app throught trampoline activity, verify the letterbox of
closing activity stay visible during transition animation.

Change-Id: I6c18c9b507f0c732d58c739bee068f835fad4391
Merged-In: I6c18c9b507f0c732d58c739bee068f835fad4391
parent 6b003be2
Loading
Loading
Loading
Loading
+2 −7
Original line number Original line Diff line number Diff line
@@ -1305,7 +1305,8 @@ final class LetterboxUiController {
        }
        }


        final boolean shouldShowLetterboxUi =
        final boolean shouldShowLetterboxUi =
                (mActivityRecord.isInLetterboxAnimation() || isSurfaceVisible(mainWindow))
                (mActivityRecord.isInLetterboxAnimation() || mActivityRecord.isVisible()
                        || mActivityRecord.isVisibleRequested())
                && mainWindow.areAppWindowBoundsLetterboxed()
                && mainWindow.areAppWindowBoundsLetterboxed()
                // Check for FLAG_SHOW_WALLPAPER explicitly instead of using
                // Check for FLAG_SHOW_WALLPAPER explicitly instead of using
                // WindowContainer#showWallpaper because the later will return true when this
                // WindowContainer#showWallpaper because the later will return true when this
@@ -1317,12 +1318,6 @@ final class LetterboxUiController {
        return shouldShowLetterboxUi;
        return shouldShowLetterboxUi;
    }
    }


    @VisibleForTesting
    boolean isSurfaceVisible(WindowState mainWindow) {
        return mainWindow.isOnScreen() && (mActivityRecord.isVisible()
                || mActivityRecord.isVisibleRequested());
    }

    private Color getLetterboxBackgroundColor() {
    private Color getLetterboxBackgroundColor() {
        final WindowState w = mActivityRecord.findMainWindow();
        final WindowState w = mActivityRecord.findMainWindow();
        if (w == null || w.isLetterboxedForDisplayCutout()) {
        if (w == null || w.isLetterboxedForDisplayCutout()) {
+2 −1
Original line number Original line Diff line number Diff line
@@ -606,7 +606,8 @@ public class LetterboxUiControllerTest extends WindowTestsBase {
        doReturn(false).when(mActivity).isInLetterboxAnimation();
        doReturn(false).when(mActivity).isInLetterboxAnimation();
        assertEquals(expectedRadius, mController.getRoundedCornersRadius(mainWindow));
        assertEquals(expectedRadius, mController.getRoundedCornersRadius(mainWindow));


        doReturn(false).when(mainWindow).isOnScreen();
        doReturn(false).when(mActivity).isVisibleRequested();
        doReturn(false).when(mActivity).isVisible();
        assertEquals(0, mController.getRoundedCornersRadius(mainWindow));
        assertEquals(0, mController.getRoundedCornersRadius(mainWindow));


        doReturn(true).when(mActivity).isInLetterboxAnimation();
        doReturn(true).when(mActivity).isInLetterboxAnimation();
+1 −2
Original line number Original line Diff line number Diff line
@@ -909,8 +909,7 @@ public class SizeCompatTests extends WindowTestsBase {
        assertEquals(window, mActivity.findMainWindow());
        assertEquals(window, mActivity.findMainWindow());


        spyOn(mActivity.mLetterboxUiController);
        spyOn(mActivity.mLetterboxUiController);
        doReturn(true).when(mActivity.mLetterboxUiController)
        doReturn(true).when(mActivity).isVisibleRequested();
                .isSurfaceVisible(any());


        assertTrue(mActivity.mLetterboxUiController.shouldShowLetterboxUi(
        assertTrue(mActivity.mLetterboxUiController.shouldShowLetterboxUi(
                mActivity.findMainWindow()));
                mActivity.findMainWindow()));