diff options
| author | 2024-04-17 10:31:31 +0000 | |
|---|---|---|
| committer | 2024-04-18 07:56:52 +0000 | |
| commit | b54fcdfc413d8917a880323e49f3398ec1f877cb (patch) | |
| tree | c59ccb25cc3061c638e080e41e31dad4665cec23 | |
| parent | ed46d368dbf24a2d69454f80aacae7678e15559d (diff) | |
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
3 files changed, 5 insertions, 10 deletions
diff --git a/services/core/java/com/android/server/wm/LetterboxUiController.java b/services/core/java/com/android/server/wm/LetterboxUiController.java index f220c9d06e14..cb5ad910c651 100644 --- a/services/core/java/com/android/server/wm/LetterboxUiController.java +++ b/services/core/java/com/android/server/wm/LetterboxUiController.java @@ -1308,7 +1308,8 @@ final class LetterboxUiController { } final boolean shouldShowLetterboxUi = - (mActivityRecord.isInLetterboxAnimation() || isSurfaceVisible(mainWindow)) + (mActivityRecord.isInLetterboxAnimation() || mActivityRecord.isVisible() + || mActivityRecord.isVisibleRequested()) && mainWindow.areAppWindowBoundsLetterboxed() // Check for FLAG_SHOW_WALLPAPER explicitly instead of using // WindowContainer#showWallpaper because the later will return true when this @@ -1320,12 +1321,6 @@ final class LetterboxUiController { return shouldShowLetterboxUi; } - @VisibleForTesting - boolean isSurfaceVisible(WindowState mainWindow) { - return mainWindow.isOnScreen() && (mActivityRecord.isVisible() - || mActivityRecord.isVisibleRequested()); - } - private Color getLetterboxBackgroundColor() { final WindowState w = mActivityRecord.findMainWindow(); if (w == null || w.isLetterboxedForDisplayCutout()) { diff --git a/services/tests/wmtests/src/com/android/server/wm/LetterboxUiControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/LetterboxUiControllerTest.java index 5aabea38bf5b..b41db3170ef6 100644 --- a/services/tests/wmtests/src/com/android/server/wm/LetterboxUiControllerTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/LetterboxUiControllerTest.java @@ -643,7 +643,8 @@ public class LetterboxUiControllerTest extends WindowTestsBase { doReturn(false).when(mActivity).isInLetterboxAnimation(); 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)); doReturn(true).when(mActivity).isInLetterboxAnimation(); diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java index 2e80bc721c7f..ff5309c1c0bb 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java @@ -916,8 +916,7 @@ public class SizeCompatTests extends WindowTestsBase { assertEquals(window, mActivity.findMainWindow()); spyOn(mActivity.mLetterboxUiController); - doReturn(true).when(mActivity.mLetterboxUiController) - .isSurfaceVisible(any()); + doReturn(true).when(mActivity).isVisibleRequested(); assertTrue(mActivity.mLetterboxUiController.shouldShowLetterboxUi( mActivity.findMainWindow())); |