Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2b192c53 authored by Shawn Lin's avatar Shawn Lin Committed by Android (Google) Code Review
Browse files

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

parents 617b65e4 e1d2b2b7
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -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);
                }
+52 −0
Original line number Diff line number Diff line
@@ -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(