summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Shawn Lin <shawnlin@google.com> 2022-09-30 15:39:32 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2022-09-30 15:39:32 +0000
commit4bcadbe5b56869704d0e8393a81f5afa78831c21 (patch)
tree62a932d216fcd7a4976d381733c6f232c7cd390c
parentc80c5d099eeb2bb4e7272cfbc76e08a75704a72f (diff)
parent0451488d747bd7a5c8d5e30f080ab546cabb0845 (diff)
Merge "Revert "Fix flicker when swiching resolution change"" into tm-qpr-dev am: fa1f278976 am: 0451488d74
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20080411 Change-Id: I0cd40540342007eaa03feb1051ae046ddb62d901 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--packages/SystemUI/src/com/android/systemui/ScreenDecorations.java34
-rw-r--r--packages/SystemUI/src/com/android/systemui/decor/RoundedCornerResDelegate.kt17
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java56
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/decor/RoundedCornerResDelegateTest.kt12
4 files changed, 104 insertions, 15 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
index 67b683ec643a..2e13903814a5 100644
--- a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
+++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
@@ -455,6 +455,7 @@ public class ScreenDecorations extends CoreStartable implements Tunable , Dumpab
}
}
+ boolean needToUpdateProviderViews = false;
final String newUniqueId = mDisplayInfo.uniqueId;
if (!Objects.equals(newUniqueId, mDisplayUniqueId)) {
mDisplayUniqueId = newUniqueId;
@@ -472,6 +473,37 @@ public class ScreenDecorations extends CoreStartable implements Tunable , Dumpab
setupDecorations();
return;
}
+
+ if (mScreenDecorHwcLayer != null) {
+ updateHwLayerRoundedCornerDrawable();
+ updateHwLayerRoundedCornerExistAndSize();
+ }
+ needToUpdateProviderViews = true;
+ }
+
+ final float newRatio = getPhysicalPixelDisplaySizeRatio();
+ if (mRoundedCornerResDelegate.getPhysicalPixelDisplaySizeRatio() != newRatio) {
+ mRoundedCornerResDelegate.setPhysicalPixelDisplaySizeRatio(newRatio);
+ if (mScreenDecorHwcLayer != null) {
+ updateHwLayerRoundedCornerExistAndSize();
+ }
+ needToUpdateProviderViews = true;
+ }
+
+ if (needToUpdateProviderViews) {
+ updateOverlayProviderViews(null);
+ } else {
+ updateOverlayProviderViews(new Integer[] {
+ mFaceScanningViewId,
+ R.id.display_cutout,
+ R.id.display_cutout_left,
+ R.id.display_cutout_right,
+ R.id.display_cutout_bottom,
+ });
+ }
+
+ if (mScreenDecorHwcLayer != null) {
+ mScreenDecorHwcLayer.onDisplayChanged(newUniqueId);
}
}
};
@@ -1037,8 +1069,6 @@ public class ScreenDecorations extends CoreStartable implements Tunable , Dumpab
&& (newRotation != mRotation || displayModeChanged(mDisplayMode, newMod))) {
mRotation = newRotation;
mDisplayMode = newMod;
- mRoundedCornerResDelegate.setPhysicalPixelDisplaySizeRatio(
- getPhysicalPixelDisplaySizeRatio());
if (mScreenDecorHwcLayer != null) {
mScreenDecorHwcLayer.pendingConfigChange = false;
mScreenDecorHwcLayer.updateRotation(mRotation);
diff --git a/packages/SystemUI/src/com/android/systemui/decor/RoundedCornerResDelegate.kt b/packages/SystemUI/src/com/android/systemui/decor/RoundedCornerResDelegate.kt
index 8b4aeefb6ed4..a25286438387 100644
--- a/packages/SystemUI/src/com/android/systemui/decor/RoundedCornerResDelegate.kt
+++ b/packages/SystemUI/src/com/android/systemui/decor/RoundedCornerResDelegate.kt
@@ -78,18 +78,23 @@ class RoundedCornerResDelegate(
reloadMeasures()
}
+ private fun reloadAll(newReloadToken: Int) {
+ if (reloadToken == newReloadToken) {
+ return
+ }
+ reloadToken = newReloadToken
+ reloadRes()
+ reloadMeasures()
+ }
+
fun updateDisplayUniqueId(newDisplayUniqueId: String?, newReloadToken: Int?) {
if (displayUniqueId != newDisplayUniqueId) {
displayUniqueId = newDisplayUniqueId
newReloadToken ?.let { reloadToken = it }
reloadRes()
reloadMeasures()
- } else if (newReloadToken != null) {
- if (reloadToken == newReloadToken) {
- return
- }
- reloadToken = newReloadToken
- reloadMeasures()
+ } else {
+ newReloadToken?.let { reloadAll(it) }
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java b/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java
index 5a26d05d7b37..df10dfe9f160 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java
@@ -1005,13 +1005,18 @@ public class ScreenDecorationsTest extends SysuiTestCase {
assertEquals(new Size(3, 3), resDelegate.getTopRoundedSize());
assertEquals(new Size(4, 4), resDelegate.getBottomRoundedSize());
- doReturn(2f).when(mScreenDecorations).getPhysicalPixelDisplaySizeRatio();
+ setupResources(20 /* radius */, 0 /* radiusTop */, 0 /* radiusBottom */,
+ getTestsDrawable(com.android.systemui.tests.R.drawable.rounded4px)
+ /* roundedTopDrawable */,
+ getTestsDrawable(com.android.systemui.tests.R.drawable.rounded5px)
+ /* roundedBottomDrawable */,
+ 0 /* roundedPadding */, true /* privacyDot */, false /* faceScanning*/);
mDisplayInfo.rotation = Surface.ROTATION_270;
mScreenDecorations.onConfigurationChanged(null);
- assertEquals(new Size(6, 6), resDelegate.getTopRoundedSize());
- assertEquals(new Size(8, 8), resDelegate.getBottomRoundedSize());
+ assertEquals(new Size(4, 4), resDelegate.getTopRoundedSize());
+ assertEquals(new Size(5, 5), resDelegate.getBottomRoundedSize());
}
@Test
@@ -1288,6 +1293,51 @@ public class ScreenDecorationsTest extends SysuiTestCase {
}
@Test
+ public void testOnDisplayChanged_hwcLayer() {
+ setupResources(0 /* radius */, 0 /* radiusTop */, 0 /* radiusBottom */,
+ null /* roundedTopDrawable */, null /* roundedBottomDrawable */,
+ 0 /* roundedPadding */, false /* privacyDot */, false /* faceScanning */);
+ final DisplayDecorationSupport decorationSupport = new DisplayDecorationSupport();
+ decorationSupport.format = PixelFormat.R_8;
+ doReturn(decorationSupport).when(mDisplay).getDisplayDecorationSupport();
+
+ // top cutout
+ mMockCutoutList.add(new CutoutDecorProviderImpl(BOUNDS_POSITION_TOP));
+
+ mScreenDecorations.start();
+
+ final ScreenDecorHwcLayer hwcLayer = mScreenDecorations.mScreenDecorHwcLayer;
+ spyOn(hwcLayer);
+ doReturn(mDisplay).when(hwcLayer).getDisplay();
+
+ mScreenDecorations.mDisplayListener.onDisplayChanged(1);
+
+ verify(hwcLayer, times(1)).onDisplayChanged(any());
+ }
+
+ @Test
+ public void testOnDisplayChanged_nonHwcLayer() {
+ setupResources(0 /* radius */, 0 /* radiusTop */, 0 /* radiusBottom */,
+ null /* roundedTopDrawable */, null /* roundedBottomDrawable */,
+ 0 /* roundedPadding */, false /* privacyDot */, false /* faceScanning */);
+
+ // top cutout
+ mMockCutoutList.add(new CutoutDecorProviderImpl(BOUNDS_POSITION_TOP));
+
+ mScreenDecorations.start();
+
+ final ScreenDecorations.DisplayCutoutView cutoutView = (ScreenDecorations.DisplayCutoutView)
+ mScreenDecorations.getOverlayView(R.id.display_cutout);
+ assertNotNull(cutoutView);
+ spyOn(cutoutView);
+ doReturn(mDisplay).when(cutoutView).getDisplay();
+
+ mScreenDecorations.mDisplayListener.onDisplayChanged(1);
+
+ verify(cutoutView, times(1)).onDisplayChanged(any());
+ }
+
+ @Test
public void testHasSameProvidersWithNullOverlays() {
setupResources(0 /* radius */, 0 /* radiusTop */, 0 /* radiusBottom */,
null /* roundedTopDrawable */, null /* roundedBottomDrawable */,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/decor/RoundedCornerResDelegateTest.kt b/packages/SystemUI/tests/src/com/android/systemui/decor/RoundedCornerResDelegateTest.kt
index 93a1868b72f5..f93336134900 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/decor/RoundedCornerResDelegateTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/decor/RoundedCornerResDelegateTest.kt
@@ -24,11 +24,12 @@ import androidx.annotation.DrawableRes
import androidx.test.filters.SmallTest
import com.android.internal.R as InternalR
import com.android.systemui.R as SystemUIR
-import com.android.systemui.SysuiTestCase
import com.android.systemui.tests.R
+import com.android.systemui.SysuiTestCase
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
+
import org.junit.runner.RunWith
import org.mockito.Mock
import org.mockito.MockitoAnnotations
@@ -101,11 +102,14 @@ class RoundedCornerResDelegateTest : SysuiTestCase() {
assertEquals(Size(3, 3), roundedCornerResDelegate.topRoundedSize)
assertEquals(Size(4, 4), roundedCornerResDelegate.bottomRoundedSize)
- roundedCornerResDelegate.physicalPixelDisplaySizeRatio = 2f
+ setupResources(radius = 100,
+ roundedTopDrawable = getTestsDrawable(R.drawable.rounded4px),
+ roundedBottomDrawable = getTestsDrawable(R.drawable.rounded5px))
+
roundedCornerResDelegate.updateDisplayUniqueId(null, 1)
- assertEquals(Size(6, 6), roundedCornerResDelegate.topRoundedSize)
- assertEquals(Size(8, 8), roundedCornerResDelegate.bottomRoundedSize)
+ assertEquals(Size(4, 4), roundedCornerResDelegate.topRoundedSize)
+ assertEquals(Size(5, 5), roundedCornerResDelegate.bottomRoundedSize)
}
@Test