From 094a6119014b0abdc8e56d97b9081f1370ec6aa7 Mon Sep 17 00:00:00 2001 From: Milton Wu Date: Wed, 27 Apr 2022 19:32:56 +0800 Subject: [PATCH] Rounded corner not align to right on land 1. On landscape mode, the right rounded corner shall be aligned to the right side, not left side 2. Add correct null check in onDisplayChanged() inside ScreenDecorations 3. ScreenDecorHwcLayer::updateRoundedCornerExistenceAndSize() shall compare top size Bug: 230592960 Test: atest ScreenDecorHwcLayerTest ScreenDecorationsTest Test: Rotate app to landscape mode and check rounded corner drawn on correct pos Change-Id: Ifb62e0a74f8e3c93c2ea897fa67c4a9393096f7e --- .../com/android/systemui/ScreenDecorHwcLayer.kt | 2 +- .../com/android/systemui/ScreenDecorations.java | 15 +++++++++------ .../decor/RoundedCornerDecorProviderImpl.kt | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorHwcLayer.kt b/packages/SystemUI/src/com/android/systemui/ScreenDecorHwcLayer.kt index 3641e1d52144a..0df2730a48ebb 100644 --- a/packages/SystemUI/src/com/android/systemui/ScreenDecorHwcLayer.kt +++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorHwcLayer.kt @@ -380,7 +380,7 @@ class ScreenDecorHwcLayer(context: Context, displayDecorationSupport: DisplayDec ) { if (hasTopRoundedCorner == hasTop && hasBottomRoundedCorner == hasBottom && - roundedCornerBottomSize == bottomSize && + roundedCornerTopSize == topSize && roundedCornerBottomSize == bottomSize) { return } diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java index 38f9ac1b4cdc4..1838b4b11aa4b 100644 --- a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java +++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java @@ -346,7 +346,8 @@ public class ScreenDecorations extends CoreStartable implements Tunable , Dumpab @Override public void onDisplayChanged(int displayId) { final int newRotation = mContext.getDisplay().getRotation(); - if (mOverlays != null && mRotation != newRotation) { + if ((mOverlays != null || mScreenDecorHwcWindow != null) + && mRotation != newRotation) { // We cannot immediately update the orientation. Otherwise // WindowManager is still deferring layout until it has finished dispatching // the config changes, which may cause divergence between what we draw @@ -360,11 +361,13 @@ public class ScreenDecorations extends CoreStartable implements Tunable , Dumpab + mRotation); } - for (int i = 0; i < BOUNDS_POSITION_LENGTH; i++) { - if (mOverlays[i] != null) { - final ViewGroup overlayView = mOverlays[i].getRootView(); - overlayView.getViewTreeObserver().addOnPreDrawListener( - new RestartingPreDrawListener(overlayView, i, newRotation)); + if (mOverlays != null) { + for (int i = 0; i < BOUNDS_POSITION_LENGTH; i++) { + if (mOverlays[i] != null) { + final ViewGroup overlayView = mOverlays[i].getRootView(); + overlayView.getViewTreeObserver().addOnPreDrawListener( + new RestartingPreDrawListener(overlayView, i, newRotation)); + } } } diff --git a/packages/SystemUI/src/com/android/systemui/decor/RoundedCornerDecorProviderImpl.kt b/packages/SystemUI/src/com/android/systemui/decor/RoundedCornerDecorProviderImpl.kt index 9dbeb77ebc005..e316722b64ea6 100644 --- a/packages/SystemUI/src/com/android/systemui/decor/RoundedCornerDecorProviderImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/decor/RoundedCornerDecorProviderImpl.kt @@ -105,7 +105,7 @@ private fun Int.toLayoutGravity(@Surface.Rotation rotation: Int): Int = when (ro DisplayCutout.BOUNDS_POSITION_LEFT -> Gravity.BOTTOM DisplayCutout.BOUNDS_POSITION_TOP -> Gravity.LEFT DisplayCutout.BOUNDS_POSITION_RIGHT -> Gravity.TOP - else /* DisplayCutout.BOUNDS_POSITION_BOTTOM */ -> Gravity.LEFT + else /* DisplayCutout.BOUNDS_POSITION_BOTTOM */ -> Gravity.RIGHT } Surface.ROTATION_270 -> when (this) { DisplayCutout.BOUNDS_POSITION_LEFT -> Gravity.TOP