Merge "Fixed cutout not being updated for non hwc layer" into tm-dev

This commit is contained in:
Shawn Lin
2022-03-28 02:17:43 +00:00
committed by Android (Google) Code Review
2 changed files with 64 additions and 1 deletions

View File

@@ -139,8 +139,9 @@ public class ScreenDecorations extends CoreStartable implements Tunable , Dumpab
protected RoundedCornerResDelegate mRoundedCornerResDelegate;
@VisibleForTesting
protected OverlayWindow[] mOverlays = null;
@VisibleForTesting
@Nullable
private DisplayCutoutView[] mCutoutViews;
DisplayCutoutView[] mCutoutViews;
@VisibleForTesting
ViewGroup mScreenDecorHwcWindow;
@VisibleForTesting
@@ -361,6 +362,16 @@ public class ScreenDecorations extends CoreStartable implements Tunable , Dumpab
}
updateRoundedCornerDrawable();
}
if (mCutoutViews != null) {
final int size = mCutoutViews.length;
for (int i = 0; i < size; i++) {
final DisplayCutoutView cutoutView = mCutoutViews[i];
if (cutoutView == null) {
continue;
}
cutoutView.onDisplayChanged(displayId);
}
}
if (mScreenDecorHwcLayer != null) {
mScreenDecorHwcLayer.onDisplayChanged(displayId);
}

View File

@@ -125,6 +125,8 @@ public class ScreenDecorationsTest extends SysuiTestCase {
private CornerDecorProvider mPrivacyDotBottomLeftDecorProvider;
@Mock
private CornerDecorProvider mPrivacyDotBottomRightDecorProvider;
@Mock
private Display.Mode mDisplayMode;
@Before
public void setup() {
@@ -1135,6 +1137,56 @@ public class ScreenDecorationsTest extends SysuiTestCase {
}
@Test
public void testOnDisplayChanged_hwcLayer() {
setupResources(0 /* radius */, 0 /* radiusTop */, 0 /* radiusBottom */,
0 /* roundedPadding */, false /* multipleRadius */,
true /* fillCutout */, false /* privacyDot */);
final DisplayDecorationSupport decorationSupport = new DisplayDecorationSupport();
decorationSupport.format = PixelFormat.R_8;
doReturn(decorationSupport).when(mDisplay).getDisplayDecorationSupport();
// top cutout
final Rect[] bounds = {null, new Rect(9, 0, 10, 1), null, null};
doReturn(getDisplayCutoutForRotation(Insets.of(0, 1, 0, 0), bounds))
.when(mScreenDecorations).getCutout();
mScreenDecorations.start();
final ScreenDecorHwcLayer hwcLayer = mScreenDecorations.mScreenDecorHwcLayer;
spyOn(hwcLayer);
doReturn(mDisplay).when(hwcLayer).getDisplay();
doReturn(mDisplayMode).when(mDisplay).getMode();
mScreenDecorations.mDisplayListener.onDisplayChanged(1);
verify(hwcLayer, times(1)).onDisplayChanged(1);
}
@Test
public void testOnDisplayChanged_nonHwcLayer() {
setupResources(0 /* radius */, 0 /* radiusTop */, 0 /* radiusBottom */,
0 /* roundedPadding */, false /* multipleRadius */,
true /* fillCutout */, false /* privacyDot */);
// top cutout
final Rect[] bounds = {null, new Rect(9, 0, 10, 1), null, null};
doReturn(getDisplayCutoutForRotation(Insets.of(0, 1, 0, 0), bounds))
.when(mScreenDecorations).getCutout();
mScreenDecorations.start();
final ScreenDecorations.DisplayCutoutView cutoutView =
mScreenDecorations.mCutoutViews[BOUNDS_POSITION_TOP];
spyOn(cutoutView);
doReturn(mDisplay).when(cutoutView).getDisplay();
doReturn(mDisplayMode).when(mDisplay).getMode();
mScreenDecorations.mDisplayListener.onDisplayChanged(1);
verify(cutoutView, times(1)).onDisplayChanged(1);
}
private void setupResources(int radius, int radiusTop, int radiusBottom, int roundedPadding,
boolean multipleRadius, boolean fillCutout, boolean privacyDot) {
mContext.getOrCreateTestableResources().addOverride(