From c6b845dee35adff5498fe742b0a845cdf4f20b2f Mon Sep 17 00:00:00 2001 From: Naomi Musgrave Date: Tue, 5 Apr 2022 10:37:45 +0000 Subject: [PATCH] Do not apply taskbar insets for overlay case. Taskbar is shown as an overlay when an app is in immersive mode. The user can swipe away the taskbar, or swipe up to show it. No insets need to be applied in this scenario; the app content can stretch to the bottom of the screen. Also, migrate from InsetsState#getSource to InsetsState#peekSource to avoid unnecessary creation of the source. Fix: 202836652 Test: manual Change-Id: If573b2fa3936b81f92a2c196d49149782cb65b0a --- .../android/server/wm/LetterboxUiController.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/wm/LetterboxUiController.java b/services/core/java/com/android/server/wm/LetterboxUiController.java index c162e8ecadfcd..bb15d76c3bac0 100644 --- a/services/core/java/com/android/server/wm/LetterboxUiController.java +++ b/services/core/java/com/android/server/wm/LetterboxUiController.java @@ -332,25 +332,29 @@ final class LetterboxUiController { if (windowSurface != null && windowSurface.isValid()) { Transaction transaction = mActivityRecord.getSyncTransaction(); + final InsetsState insetsState = mainWindow.getInsetsState(); + final InsetsSource taskbarInsetsSource = + insetsState.peekSource(InsetsState.ITYPE_EXTRA_NAVIGATION_BAR); + if (!isLetterboxedNotForDisplayCutout(mainWindow) - || !mLetterboxConfiguration.isLetterboxActivityCornersRounded()) { + || !mLetterboxConfiguration.isLetterboxActivityCornersRounded() + || taskbarInsetsSource == null) { transaction .setWindowCrop(windowSurface, null) .setCornerRadius(windowSurface, 0); return; } - final InsetsState insetsState = mainWindow.getInsetsState(); - final InsetsSource taskbarInsetsSource = - insetsState.getSource(InsetsState.ITYPE_EXTRA_NAVIGATION_BAR); - Rect cropBounds = null; // Rounded corners should be displayed above the taskbar. When taskbar is hidden, // an insets frame is equal to a navigation bar which shouldn't affect position of // rounded corners since apps are expected to handle navigation bar inset. // This condition checks whether the taskbar is visible. - if (taskbarInsetsSource.getFrame().height() >= mExpandedTaskBarHeight) { + // Do not crop the taskbar inset if the window is in immersive mode - the user can + // swipe to show/hide the taskbar as an overlay. + if (taskbarInsetsSource.getFrame().height() >= mExpandedTaskBarHeight + && taskbarInsetsSource.isVisible()) { cropBounds = new Rect(mActivityRecord.getBounds()); // Activity bounds are in screen coordinates while (0,0) for activity's surface // control is at the top left corner of an app window so offsetting bounds