Merge "ScreenDecorations: Update corner radius when configuration changes" into pi-dev
am: 2c9fd5fbbb
Change-Id: I158edc773a287df8b3824f6e80b696e593c0d1d2
diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
index 71cf9b5..9ced14d 100644
--- a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
+++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
@@ -89,9 +89,9 @@
private DisplayManager mDisplayManager;
private DisplayManager.DisplayListener mDisplayListener;
- private int mRoundedDefault;
- private int mRoundedDefaultTop;
- private int mRoundedDefaultBottom;
+ @VisibleForTesting protected int mRoundedDefault;
+ @VisibleForTesting protected int mRoundedDefaultTop;
+ @VisibleForTesting protected int mRoundedDefaultBottom;
private View mOverlay;
private View mBottomOverlay;
private float mDensity;
@@ -119,12 +119,7 @@
private void startOnScreenDecorationsThread() {
mRotation = RotationUtils.getExactRotation(mContext);
mWindowManager = mContext.getSystemService(WindowManager.class);
- mRoundedDefault = mContext.getResources().getDimensionPixelSize(
- R.dimen.rounded_corner_radius);
- mRoundedDefaultTop = mContext.getResources().getDimensionPixelSize(
- R.dimen.rounded_corner_radius_top);
- mRoundedDefaultBottom = mContext.getResources().getDimensionPixelSize(
- R.dimen.rounded_corner_radius_bottom);
+ updateRoundedCornerRadii();
if (hasRoundedCorners() || shouldDrawCutout()) {
setupDecorations();
}
@@ -249,6 +244,7 @@
int oldRotation = mRotation;
mPendingRotationChange = false;
updateOrientation();
+ updateRoundedCornerRadii();
if (DEBUG) Log.i(TAG, "onConfigChanged from rot " + oldRotation + " to " + mRotation);
if (shouldDrawCutout() && mOverlay == null) {
setupDecorations();
@@ -281,6 +277,26 @@
}
}
+ private void updateRoundedCornerRadii() {
+ final int newRoundedDefault = mContext.getResources().getDimensionPixelSize(
+ R.dimen.rounded_corner_radius);
+ final int newRoundedDefaultTop = mContext.getResources().getDimensionPixelSize(
+ R.dimen.rounded_corner_radius_top);
+ final int newRoundedDefaultBottom = mContext.getResources().getDimensionPixelSize(
+ R.dimen.rounded_corner_radius_bottom);
+
+ final boolean roundedCornersChanged = mRoundedDefault != newRoundedDefault
+ || mRoundedDefaultBottom != newRoundedDefaultBottom
+ || mRoundedDefaultTop != newRoundedDefaultTop;
+
+ if (roundedCornersChanged) {
+ mRoundedDefault = newRoundedDefault;
+ mRoundedDefaultTop = newRoundedDefaultTop;
+ mRoundedDefaultBottom = newRoundedDefaultBottom;
+ onTuningChanged(SIZE, null);
+ }
+ }
+
private void updateViews() {
View topLeft = mOverlay.findViewById(R.id.left);
View topRight = mOverlay.findViewById(R.id.right);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java b/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java
index 644c0b3..cc96917 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java
@@ -21,6 +21,7 @@
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
@@ -226,4 +227,17 @@
verify(padding).destroy();
}
+ @Test
+ public void testUpdateRoundedCorners() {
+ mContext.getOrCreateTestableResources().addOverride(
+ com.android.internal.R.bool.config_fillMainBuiltInDisplayCutout, false);
+ mContext.getOrCreateTestableResources().addOverride(dimen.rounded_corner_radius, 20);
+
+ mScreenDecorations.start();
+ assertEquals(mScreenDecorations.mRoundedDefault, 20);
+
+ mContext.getOrCreateTestableResources().addOverride(dimen.rounded_corner_radius, 5);
+ mScreenDecorations.onConfigurationChanged(null);
+ assertEquals(mScreenDecorations.mRoundedDefault, 5);
+ }
}