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

Commit 9e8d7845 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6232927 from 353d26c8 to qt-qpr3-release

Change-Id: If030d251e5a080060e4cdd77691a6b1807faf81e
parents 2a0464fd 353d26c8
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -488,4 +488,7 @@
    <!-- Preferred refresh rate at keyguard, if supported by the display -->
    <integer name="config_keyguardRefreshRate">-1</integer>

    <!-- Respect the drawable/rounded.xml that allow to customize as multiple radius corner path -->
    <bool name="config_roundedCornerMultipleRadius">false</bool>

</resources>
+22 −6
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import android.graphics.Path;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.drawable.VectorDrawable;
import android.hardware.display.DisplayManager;
import android.os.Handler;
import android.os.HandlerThread;
@@ -105,6 +106,7 @@ public class ScreenDecorations extends SystemUI implements Tunable,
    private static final boolean DEBUG_SCREENSHOT_ROUNDED_CORNERS =
            SystemProperties.getBoolean("debug.screenshot_rounded_corners", false);
    private static final boolean VERBOSE = false;
    private static final boolean DEBUG_COLOR = DEBUG_SCREENSHOT_ROUNDED_CORNERS;

    private DisplayManager mDisplayManager;
    private DisplayManager.DisplayListener mDisplayListener;
@@ -129,6 +131,7 @@ public class ScreenDecorations extends SystemUI implements Tunable,
    private boolean mAssistHintBlocked = false;
    private boolean mIsReceivingNavBarColor = false;
    private boolean mInGesturalMode;
    private boolean mIsRoundedCornerMultipleRadius;

    /**
     * Converts a set of {@link Rect}s into a {@link Region}
@@ -323,6 +326,8 @@ public class ScreenDecorations extends SystemUI implements Tunable,
    private void startOnScreenDecorationsThread() {
        mRotation = RotationUtils.getExactRotation(mContext);
        mWindowManager = mContext.getSystemService(WindowManager.class);
        mIsRoundedCornerMultipleRadius = mContext.getResources().getBoolean(
                R.bool.config_roundedCornerMultipleRadius);
        updateRoundedCornerRadii();
        if (hasRoundedCorners() || shouldDrawCutout() || shouldHostHandles()) {
            setupDecorations();
@@ -457,6 +462,9 @@ public class ScreenDecorations extends SystemUI implements Tunable,

    private void updateColorInversion(int colorsInvertedValue) {
        int tint = colorsInvertedValue != 0 ? Color.WHITE : Color.BLACK;
        if (DEBUG_COLOR) {
            tint = Color.RED;
        }
        ColorStateList tintList = ColorStateList.valueOf(tint);
        ((ImageView) mOverlay.findViewById(R.id.left)).setImageTintList(tintList);
        ((ImageView) mOverlay.findViewById(R.id.right)).setImageTintList(tintList);
@@ -528,18 +536,25 @@ public class ScreenDecorations extends SystemUI implements Tunable,
                com.android.internal.R.dimen.rounded_corner_radius_top);
        final int newRoundedDefaultBottom = mContext.getResources().getDimensionPixelSize(
                com.android.internal.R.dimen.rounded_corner_radius_bottom);

        final boolean roundedCornersChanged = mRoundedDefault != newRoundedDefault
                || mRoundedDefaultBottom != newRoundedDefaultBottom
                || mRoundedDefaultTop != newRoundedDefaultTop;

        if (roundedCornersChanged) {
            // If config_roundedCornerMultipleRadius set as true, ScreenDecorations respect the
            // max(width, height) size of drawable/rounded.xml instead of rounded_corner_radius
            if (mIsRoundedCornerMultipleRadius) {
                final VectorDrawable d = (VectorDrawable) mContext.getDrawable(R.drawable.rounded);
                mRoundedDefault = Math.max(d.getIntrinsicWidth(), d.getIntrinsicHeight());
                mRoundedDefaultTop = mRoundedDefaultBottom = mRoundedDefault;
            } else {
                mRoundedDefault = newRoundedDefault;
                mRoundedDefaultTop = newRoundedDefaultTop;
                mRoundedDefaultBottom = newRoundedDefaultBottom;
            onTuningChanged(SIZE, null);
            }
        }
        onTuningChanged(SIZE, null);
    }

    private void updateViews() {
        View topLeft = mOverlay.findViewById(R.id.left);
@@ -637,7 +652,8 @@ public class ScreenDecorations extends SystemUI implements Tunable,
    }

    private boolean hasRoundedCorners() {
        return mRoundedDefault > 0 || mRoundedDefaultBottom > 0 || mRoundedDefaultTop > 0;
        return mRoundedDefault > 0 || mRoundedDefaultBottom > 0 || mRoundedDefaultTop > 0
                || mIsRoundedCornerMultipleRadius;
    }

    private boolean shouldDrawCutout() {
+65 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import static com.android.systemui.ScreenDecorations.rectsToRegion;
import static com.android.systemui.tuner.TunablePadding.FLAG_END;
import static com.android.systemui.tuner.TunablePadding.FLAG_START;

import static com.google.common.truth.Truth.assertThat;

import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
@@ -38,6 +40,7 @@ import static org.mockito.Mockito.when;
import android.app.Fragment;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.graphics.drawable.VectorDrawable;
import android.os.Handler;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
@@ -148,6 +151,8 @@ public class ScreenDecorationsTest extends SysuiTestCase {
                com.android.internal.R.dimen.rounded_corner_radius_bottom, 0);
        mContext.getOrCreateTestableResources()
                .addOverride(dimen.rounded_corner_content_padding, 0);
        mContext.getOrCreateTestableResources()
                .addOverride(R.bool.config_roundedCornerMultipleRadius, false);

        mScreenDecorations.start();
        // No views added.
@@ -166,6 +171,55 @@ public class ScreenDecorationsTest extends SysuiTestCase {
                com.android.internal.R.dimen.rounded_corner_radius, 20);
        mContext.getOrCreateTestableResources()
                .addOverride(dimen.rounded_corner_content_padding, 20);
        mContext.getOrCreateTestableResources()
                .addOverride(R.bool.config_roundedCornerMultipleRadius, false);

        mScreenDecorations.start();
        // Add 2 windows for rounded corners (top and bottom).
        verify(mWindowManager, times(2)).addView(any(), any());

        // Add 2 tag listeners for each of the fragments that are needed.
        verify(mFragmentHostManager, times(2)).addTagListener(any(), any());
        // One tunable.
        verify(mTunerService, times(1)).addTunable(any(), any());
        // One TunablePadding.
        verify(mTunablePaddingService, times(1)).add(any(), anyString(), anyInt(), anyInt());
    }

    @Test
    public void testRoundingRadius() {
        final int testRadius = 1;
        mContext.getOrCreateTestableResources().addOverride(
                com.android.internal.R.bool.config_fillMainBuiltInDisplayCutout, false);
        mContext.getOrCreateTestableResources().addOverride(
                com.android.internal.R.dimen.rounded_corner_radius, testRadius);
        mContext.getOrCreateTestableResources().addOverride(
                com.android.internal.R.dimen.rounded_corner_radius_top, testRadius);
        mContext.getOrCreateTestableResources().addOverride(
                com.android.internal.R.dimen.rounded_corner_radius_bottom, testRadius);
        mContext.getOrCreateTestableResources()
                .addOverride(R.bool.config_roundedCornerMultipleRadius, false);

        mScreenDecorations.start();
        // Size of corner view should same as rounded_corner_radius{_top|_bottom}
        assertThat(mScreenDecorations.mRoundedDefault).isEqualTo(testRadius);
        assertThat(mScreenDecorations.mRoundedDefaultTop).isEqualTo(testRadius);
        assertThat(mScreenDecorations.mRoundedDefaultBottom).isEqualTo(testRadius);
    }

    @Test
    public void testRoundingMultipleRadius() {
        final VectorDrawable d = (VectorDrawable) mContext.getDrawable(R.drawable.rounded);
        final int multipleRadiusSize = Math.max(d.getIntrinsicWidth(), d.getIntrinsicHeight());

        mContext.getOrCreateTestableResources().addOverride(
                com.android.internal.R.bool.config_fillMainBuiltInDisplayCutout, false);
        mContext.getOrCreateTestableResources().addOverride(
                com.android.internal.R.dimen.rounded_corner_radius, 9999);
        mContext.getOrCreateTestableResources()
                .addOverride(dimen.rounded_corner_content_padding, 9999);
        mContext.getOrCreateTestableResources()
                .addOverride(R.bool.config_roundedCornerMultipleRadius, true);

        mScreenDecorations.start();
        // Add 2 windows for rounded corners (top and bottom).
@@ -177,6 +231,10 @@ public class ScreenDecorationsTest extends SysuiTestCase {
        verify(mTunerService, times(1)).addTunable(any(), any());
        // One TunablePadding.
        verify(mTunablePaddingService, times(1)).add(any(), anyString(), anyInt(), anyInt());
        // Size of corner view should exactly match max(width, height) of R.drawable.rounded
        assertThat(mScreenDecorations.mRoundedDefault).isEqualTo(multipleRadiusSize);
        assertThat(mScreenDecorations.mRoundedDefaultTop).isEqualTo(multipleRadiusSize);
        assertThat(mScreenDecorations.mRoundedDefaultBottom).isEqualTo(multipleRadiusSize);
    }

    @Test
@@ -224,6 +282,9 @@ public class ScreenDecorationsTest extends SysuiTestCase {
                com.android.internal.R.dimen.rounded_corner_radius_bottom, 0);
        mContext.getOrCreateTestableResources()
                .addOverride(dimen.rounded_corner_content_padding, 0);
        mContext.getOrCreateTestableResources()
                .addOverride(R.bool.config_roundedCornerMultipleRadius, false);

        when(mNavigationModeController.addListener(any())).thenReturn(
                WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL);

@@ -245,6 +306,8 @@ public class ScreenDecorationsTest extends SysuiTestCase {
                com.android.internal.R.dimen.rounded_corner_radius_bottom, 0);
        mContext.getOrCreateTestableResources()
                .addOverride(dimen.rounded_corner_content_padding, 0);
        mContext.getOrCreateTestableResources()
                .addOverride(R.bool.config_roundedCornerMultipleRadius, false);
        when(mNavigationModeController.addListener(any())).thenReturn(
                WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON);

@@ -296,6 +359,8 @@ public class ScreenDecorationsTest extends SysuiTestCase {
                com.android.internal.R.bool.config_fillMainBuiltInDisplayCutout, false);
        mContext.getOrCreateTestableResources().addOverride(
                com.android.internal.R.dimen.rounded_corner_radius, 20);
        mContext.getOrCreateTestableResources()
                .addOverride(R.bool.config_roundedCornerMultipleRadius, false);

        mScreenDecorations.start();
        assertEquals(mScreenDecorations.mRoundedDefault, 20);