diff --git a/packages/SystemUI/res/layout/super_status_bar.xml b/packages/SystemUI/res/layout/super_status_bar.xml index 9d56e08bc555d..d68bd5d442eda 100644 --- a/packages/SystemUI/res/layout/super_status_bar.xml +++ b/packages/SystemUI/res/layout/super_status_bar.xml @@ -55,7 +55,8 @@ android:id="@+id/status_bar_container" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="@drawable/system_bar_background" /> + android:background="@drawable/system_bar_background" + sysui:ignoreRightInset="true" /> cornerCutoutMargins = cornerCutoutMargins(mDisplayCutout, - getDisplay()); + getDisplay(), mRotationOrientation, mStatusBarHeight); updateCutoutLocation(cornerCutoutMargins); updateSafeInsets(cornerCutoutMargins); } @@ -332,15 +336,13 @@ public class PhoneStatusBarView extends PanelBar { // or letterboxing from the right or left sides. FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams(); - if (mDisplayCutout == null || mDisplayCutout.isEmpty() - || mLastOrientation != ORIENTATION_PORTRAIT || cornerCutoutMargins == null) { + if (mDisplayCutout == null || mDisplayCutout.isEmpty() || cornerCutoutMargins == null) { lp.leftMargin = 0; lp.rightMargin = 0; return; } - - lp.leftMargin = Math.max(lp.leftMargin, cornerCutoutMargins.first); - lp.rightMargin = Math.max(lp.rightMargin, cornerCutoutMargins.second); + lp.leftMargin = cornerCutoutMargins.first; + lp.rightMargin = cornerCutoutMargins.second; // If we're already inset enough (e.g. on the status bar side), we can have 0 margin WindowInsets insets = getRootWindowInsets(); @@ -354,8 +356,19 @@ public class PhoneStatusBarView extends PanelBar { } } + /** + * Returns a Pair of integers where + * - Pair.first is the left margin inset + * - Pair.second is the right margin inset + * This method always assumes the cutout is on the top when the device is in portrait mode. + */ public static Pair cornerCutoutMargins(DisplayCutout cutout, Display display) { + return cornerCutoutMargins(cutout, display, RotationUtils.ROTATION_NONE, -1); + } + + private static Pair cornerCutoutMargins(DisplayCutout cutout, + Display display, int rotationOrientation, int statusBarHeight) { if (cutout == null) { return null; } @@ -363,14 +376,33 @@ public class PhoneStatusBarView extends PanelBar { display.getRealSize(size); Rect bounds = new Rect(); - boundsFromDirection(cutout, Gravity.TOP, bounds); + switch (rotationOrientation) { + case RotationUtils.ROTATION_LANDSCAPE: + boundsFromDirection(cutout, Gravity.LEFT, bounds); + break; + case RotationUtils.ROTATION_SEASCAPE: + boundsFromDirection(cutout, Gravity.RIGHT, bounds); + break; + case RotationUtils.ROTATION_NONE: + boundsFromDirection(cutout, Gravity.TOP, bounds); + break; + case RotationUtils.ROTATION_UPSIDE_DOWN: + // we assume the cutout is always on top in portrait mode + return null; + } + + if (statusBarHeight >= 0 && bounds.top > statusBarHeight) { + return null; + } if (bounds.left <= 0) { return new Pair<>(bounds.right, 0); } + if (bounds.right >= size.x) { return new Pair<>(0, size.x - bounds.left); } + return null; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java index 0ab2af864383e..459e0da0b067e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java @@ -180,7 +180,8 @@ public class StatusBarWindowView extends FrameLayout { int targetLeft = Math.max(insets.left, leftCutout); int targetRight = Math.max(insets.right, rightCutout); - // Super-special right inset handling, because scrims and backdrop need to ignore it. + // Super-special right inset handling, because scrims, backdrop and status bar + // container need to ignore it. if (targetRight != mRightInset || targetLeft != mLeftInset) { mRightInset = targetRight; mLeftInset = targetLeft;