diff options
| author | 2021-06-08 20:00:16 +0100 | |
|---|---|---|
| committer | 2021-06-08 23:15:09 +0100 | |
| commit | fc0a04921db48b761a626c776c706b40f0f2fd46 (patch) | |
| tree | ee644b587092d36fe1226921b8c9178962c7e690 | |
| parent | 20da155df4d5a7a53153d84b4aa5239226596115 (diff) | |
Don't shown letterbox surfaces unless activity is visible.
Also, merging visibility and "surface ready" checks in LetterboxUiController#shouldShowLetterboxUi because other UI parts of letterbox like rounded corners and background also shouldn't be applied until those conditions are true.
Fix: 185955096
Test: atest WmTests:SizeCompatTests
Change-Id: I5822d651ff65c17fce4891b8728546bec235e54f
| -rw-r--r-- | services/core/java/com/android/server/wm/LetterboxUiController.java | 22 | ||||
| -rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java | 6 |
2 files changed, 19 insertions, 9 deletions
diff --git a/services/core/java/com/android/server/wm/LetterboxUiController.java b/services/core/java/com/android/server/wm/LetterboxUiController.java index e5a634f792aa..b6b8ad14e106 100644 --- a/services/core/java/com/android/server/wm/LetterboxUiController.java +++ b/services/core/java/com/android/server/wm/LetterboxUiController.java @@ -128,12 +128,9 @@ final class LetterboxUiController { if (w == null || winHint != null && w != winHint) { return; } - final boolean surfaceReady = w.isDrawn() // Regular case - || w.isDragResizeChanged(); // Waiting for relayoutWindow to call preserveSurface. - final boolean needsLetterbox = surfaceReady && shouldShowLetterboxUi(w); updateRoundedCorners(w); updateWallpaperForLetterbox(w); - if (needsLetterbox) { + if (shouldShowLetterboxUi(w)) { if (mLetterbox == null) { mLetterbox = new Letterbox(() -> mActivityRecord.makeChildSurface(null), mActivityRecord.mWmService.mTransactionFactory, @@ -161,19 +158,26 @@ final class LetterboxUiController { } } - /** - * @return {@code true} when the main window is letterboxed, this activity isn't transparent - * and doesn't show a wallpaper. - */ @VisibleForTesting boolean shouldShowLetterboxUi(WindowState mainWindow) { - return mainWindow.areAppWindowBoundsLetterboxed() && mActivityRecord.fillsParent() + return isSurfaceReadyAndVisible(mainWindow) && mainWindow.areAppWindowBoundsLetterboxed() + // Check that an activity isn't transparent. + && mActivityRecord.fillsParent() // Check for FLAG_SHOW_WALLPAPER explicitly instead of using // WindowContainer#showWallpaper because the later will return true when this // activity is using blurred wallpaper for letterbox backgroud. && (mainWindow.mAttrs.flags & FLAG_SHOW_WALLPAPER) == 0; } + @VisibleForTesting + boolean isSurfaceReadyAndVisible(WindowState mainWindow) { + boolean surfaceReady = mainWindow.isDrawn() // Regular case + // Waiting for relayoutWindow to call preserveSurface + || mainWindow.isDragResizeChanged(); + return surfaceReady && (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/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java index db7e43757f53..d2270b55b954 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java @@ -50,6 +50,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.same; @@ -357,6 +358,11 @@ public class SizeCompatTests extends WindowTestsBase { final WindowState window = createWindow(null, TYPE_BASE_APPLICATION, mActivity, "window"); assertEquals(window, mActivity.findMainWindow()); + + spyOn(mActivity.mLetterboxUiController); + doReturn(true).when(mActivity.mLetterboxUiController) + .isSurfaceReadyAndVisible(any()); + assertTrue(mActivity.mLetterboxUiController.shouldShowLetterboxUi( mActivity.findMainWindow())); |