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

Commit bdb4d97d authored by shawnlin's avatar shawnlin
Browse files

Fix rounded corners not showing when only top and bottom radius are set.

The changed condition compared the all default, top and bottom to default
one which is wrong.

This cl also fix that the color inversion observor might not re-register
when screendecoration changes in below order:
has screenDecor-> no screenDecor -> has screenDecor.

Bug: 171018853
Test: atest ScreenDecorationsTest.
Change-Id: I52ccc9f4246cdcd0bedf24925dd1e3a24d22fe58
parent c1271a4f
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -317,10 +317,9 @@ public class ScreenDecorations extends SystemUI implements Tunable {
                        updateColorInversion(value);
                    }
                };

            }
            mColorInversionSetting.setListening(true);
            mColorInversionSetting.onChange(false);
            }

            IntentFilter filter = new IntentFilter();
            filter.addAction(Intent.ACTION_USER_SWITCHED);
@@ -640,8 +639,8 @@ public class ScreenDecorations extends SystemUI implements Tunable {
                com.android.internal.R.dimen.rounded_corner_radius_bottom);

        final boolean changed = mRoundedDefault.x != newRoundedDefault
                        || mRoundedDefaultTop.x != newRoundedDefault
                        || mRoundedDefaultBottom.x != newRoundedDefault;
                        || mRoundedDefaultTop.x != newRoundedDefaultTop
                        || mRoundedDefaultBottom.x != newRoundedDefaultBottom;

        if (changed) {
            // If config_roundedCornerMultipleRadius set as true, ScreenDecorations respect the
+38 −0
Original line number Diff line number Diff line
@@ -621,6 +621,44 @@ public class ScreenDecorationsTest extends SysuiTestCase {
        assertEquals(mScreenDecorations.mRoundedDefault, new Point(5, 5));
    }

    @Test
    public void testOnlyRoundedCornerRadiusTop() {
        mContext.getOrCreateTestableResources().addOverride(
                com.android.internal.R.bool.config_fillMainBuiltInDisplayCutout, false);
        mContext.getOrCreateTestableResources().addOverride(
                com.android.internal.R.dimen.rounded_corner_radius, 0);
        mContext.getOrCreateTestableResources().addOverride(
                com.android.internal.R.dimen.rounded_corner_radius_top, 10);
        mContext.getOrCreateTestableResources().addOverride(
                com.android.internal.R.dimen.rounded_corner_radius_bottom, 0);
        mContext.getOrCreateTestableResources()
                .addOverride(R.bool.config_roundedCornerMultipleRadius, false);

        mScreenDecorations.start();
        assertEquals(new Point(0, 0), mScreenDecorations.mRoundedDefault);
        assertEquals(new Point(10, 10), mScreenDecorations.mRoundedDefaultTop);
        assertEquals(new Point(0, 0), mScreenDecorations.mRoundedDefaultBottom);
    }

    @Test
    public void testOnlyRoundedCornerRadiusBottom() {
        mContext.getOrCreateTestableResources().addOverride(
                com.android.internal.R.bool.config_fillMainBuiltInDisplayCutout, false);
        mContext.getOrCreateTestableResources().addOverride(
                com.android.internal.R.dimen.rounded_corner_radius, 0);
        mContext.getOrCreateTestableResources().addOverride(
                com.android.internal.R.dimen.rounded_corner_radius_top, 0);
        mContext.getOrCreateTestableResources().addOverride(
                com.android.internal.R.dimen.rounded_corner_radius_bottom, 20);
        mContext.getOrCreateTestableResources()
                .addOverride(R.bool.config_roundedCornerMultipleRadius, false);

        mScreenDecorations.start();
        assertEquals(new Point(0, 0), mScreenDecorations.mRoundedDefault);
        assertEquals(new Point(0, 0), mScreenDecorations.mRoundedDefaultTop);
        assertEquals(new Point(20, 20), mScreenDecorations.mRoundedDefaultBottom);
    }


    @Test
    public void testBoundingRectsToRegion() throws Exception {