Merge "Don't shown letterbox surfaces unless activity is visible." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b3a96f3cc1
@@ -128,12 +128,9 @@ final class LetterboxUiController {
|
|||||||
if (w == null || winHint != null && w != winHint) {
|
if (w == null || winHint != null && w != winHint) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final boolean surfaceReady = w.isDrawn() // Regular case
|
|
||||||
|| w.isDragResizeChanged(); // Waiting for relayoutWindow to call preserveSurface.
|
|
||||||
final boolean needsLetterbox = surfaceReady && shouldShowLetterboxUi(w);
|
|
||||||
updateRoundedCorners(w);
|
updateRoundedCorners(w);
|
||||||
updateWallpaperForLetterbox(w);
|
updateWallpaperForLetterbox(w);
|
||||||
if (needsLetterbox) {
|
if (shouldShowLetterboxUi(w)) {
|
||||||
if (mLetterbox == null) {
|
if (mLetterbox == null) {
|
||||||
mLetterbox = new Letterbox(() -> mActivityRecord.makeChildSurface(null),
|
mLetterbox = new Letterbox(() -> mActivityRecord.makeChildSurface(null),
|
||||||
mActivityRecord.mWmService.mTransactionFactory,
|
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
|
@VisibleForTesting
|
||||||
boolean shouldShowLetterboxUi(WindowState mainWindow) {
|
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
|
// 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
|
||||||
// activity is using blurred wallpaper for letterbox backgroud.
|
// activity is using blurred wallpaper for letterbox backgroud.
|
||||||
&& (mainWindow.mAttrs.flags & FLAG_SHOW_WALLPAPER) == 0;
|
&& (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() {
|
private Color getLetterboxBackgroundColor() {
|
||||||
final WindowState w = mActivityRecord.findMainWindow();
|
final WindowState w = mActivityRecord.findMainWindow();
|
||||||
if (w == null || w.isLetterboxedForDisplayCutout()) {
|
if (w == null || w.isLetterboxedForDisplayCutout()) {
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ import static org.junit.Assert.assertEquals;
|
|||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.ArgumentMatchers.same;
|
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");
|
final WindowState window = createWindow(null, TYPE_BASE_APPLICATION, mActivity, "window");
|
||||||
|
|
||||||
assertEquals(window, mActivity.findMainWindow());
|
assertEquals(window, mActivity.findMainWindow());
|
||||||
|
|
||||||
|
spyOn(mActivity.mLetterboxUiController);
|
||||||
|
doReturn(true).when(mActivity.mLetterboxUiController)
|
||||||
|
.isSurfaceReadyAndVisible(any());
|
||||||
|
|
||||||
assertTrue(mActivity.mLetterboxUiController.shouldShowLetterboxUi(
|
assertTrue(mActivity.mLetterboxUiController.shouldShowLetterboxUi(
|
||||||
mActivity.findMainWindow()));
|
mActivity.findMainWindow()));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user