From 0098aee998ee15b15badd16a3059dc3bec7ad2b8 Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Mon, 3 Jun 2019 16:47:02 +0200 Subject: [PATCH] ScreenDecor: Fix cutout overlay regression Fixes an issue with the cutout software overlay (for anti-aliasing and emulation) that only became apparent once the assist hints were added to the overlay; the cutout view did not set the appropriate gravity, which caused it to be aligned wrongly in certain orientations, or with bottom cutouts, now that the window got bigger due to the assist hints. Fixes: 134052901 Test: Enable double cutout, verify that the emulated cutout is not cut off at the bottom Change-Id: Ied19c117a9ee560310ce783633f001a6003de869 --- .../android/systemui/ScreenDecorations.java | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java index 4aaf85adfce64..08ce07bf41b27 100644 --- a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java +++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java @@ -848,6 +848,7 @@ public class ScreenDecorations extends SystemUI implements Tunable, if (shouldDrawCutout(getContext()) && hasCutout()) { mBounds.addAll(mInfo.displayCutout.getBoundingRects()); localBounds(mBoundingRect); + updateGravity(); updateBoundingPath(); invalidate(); newVisible = VISIBLE; @@ -898,6 +899,18 @@ public class ScreenDecorations extends SystemUI implements Tunable, } } + private void updateGravity() { + LayoutParams lp = getLayoutParams(); + if (lp instanceof FrameLayout.LayoutParams) { + FrameLayout.LayoutParams flp = (FrameLayout.LayoutParams) lp; + int newGravity = getGravity(mInfo.displayCutout); + if (flp.gravity != newGravity) { + flp.gravity = newGravity; + setLayoutParams(flp); + } + } + } + private boolean hasCutout() { final DisplayCutout displayCutout = mInfo.displayCutout; if (displayCutout == null) { @@ -944,21 +957,25 @@ public class ScreenDecorations extends SystemUI implements Tunable, } private void localBounds(Rect out) { - final DisplayCutout displayCutout = mInfo.displayCutout; + DisplayCutout displayCutout = mInfo.displayCutout; + boundsFromDirection(displayCutout, getGravity(displayCutout), out); + } + private int getGravity(DisplayCutout displayCutout) { if (mStart) { if (displayCutout.getSafeInsetLeft() > 0) { - boundsFromDirection(displayCutout, Gravity.LEFT, out); + return Gravity.LEFT; } else if (displayCutout.getSafeInsetTop() > 0) { - boundsFromDirection(displayCutout, Gravity.TOP, out); + return Gravity.TOP; } } else { if (displayCutout.getSafeInsetRight() > 0) { - boundsFromDirection(displayCutout, Gravity.RIGHT, out); + return Gravity.RIGHT; } else if (displayCutout.getSafeInsetBottom() > 0) { - boundsFromDirection(displayCutout, Gravity.BOTTOM, out); + return Gravity.BOTTOM; } } + return Gravity.NO_GRAVITY; } @Override