Merge "Reland - Fix flicker when swiching resolution change" into tm-qpr-dev
This commit is contained in:
@@ -86,30 +86,38 @@ open class DisplayCutoutBaseView : View, RegionInterceptableView {
|
|||||||
onUpdate()
|
onUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onDisplayChanged(newDisplayUniqueId: String?) {
|
fun updateConfiguration(newDisplayUniqueId: String?) {
|
||||||
|
val info = DisplayInfo()
|
||||||
|
context.display?.getDisplayInfo(info)
|
||||||
val oldMode: Display.Mode? = displayMode
|
val oldMode: Display.Mode? = displayMode
|
||||||
val display: Display? = context.display
|
displayMode = info.mode
|
||||||
displayMode = display?.mode
|
|
||||||
|
|
||||||
if (displayUniqueId != display?.uniqueId) {
|
updateDisplayUniqueId(info.uniqueId)
|
||||||
displayUniqueId = display?.uniqueId
|
|
||||||
shouldDrawCutout = DisplayCutout.getFillBuiltInDisplayCutout(
|
|
||||||
context.resources, displayUniqueId
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip if display mode or cutout hasn't changed.
|
// Skip if display mode or cutout hasn't changed.
|
||||||
if (!displayModeChanged(oldMode, displayMode) &&
|
if (!displayModeChanged(oldMode, displayMode) &&
|
||||||
display?.cutout == displayInfo.displayCutout) {
|
displayInfo.displayCutout == info.displayCutout &&
|
||||||
|
displayRotation == info.rotation) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (newDisplayUniqueId == display?.uniqueId) {
|
if (newDisplayUniqueId == info.uniqueId) {
|
||||||
|
displayRotation = info.rotation
|
||||||
updateCutout()
|
updateCutout()
|
||||||
updateProtectionBoundingPath()
|
updateProtectionBoundingPath()
|
||||||
onUpdate()
|
onUpdate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun updateDisplayUniqueId(newDisplayUniqueId: String?) {
|
||||||
|
if (displayUniqueId != newDisplayUniqueId) {
|
||||||
|
displayUniqueId = newDisplayUniqueId
|
||||||
|
shouldDrawCutout = DisplayCutout.getFillBuiltInDisplayCutout(
|
||||||
|
context.resources, displayUniqueId
|
||||||
|
)
|
||||||
|
invalidate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open fun updateRotation(rotation: Int) {
|
open fun updateRotation(rotation: Int) {
|
||||||
displayRotation = rotation
|
displayRotation = rotation
|
||||||
updateCutout()
|
updateCutout()
|
||||||
|
|||||||
@@ -456,7 +456,6 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean needToUpdateProviderViews = false;
|
|
||||||
final String newUniqueId = mDisplayInfo.uniqueId;
|
final String newUniqueId = mDisplayInfo.uniqueId;
|
||||||
if (!Objects.equals(newUniqueId, mDisplayUniqueId)) {
|
if (!Objects.equals(newUniqueId, mDisplayUniqueId)) {
|
||||||
mDisplayUniqueId = newUniqueId;
|
mDisplayUniqueId = newUniqueId;
|
||||||
@@ -474,37 +473,6 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
|
|||||||
setupDecorations();
|
setupDecorations();
|
||||||
return;
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1070,9 +1038,11 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
|
|||||||
&& (newRotation != mRotation || displayModeChanged(mDisplayMode, newMod))) {
|
&& (newRotation != mRotation || displayModeChanged(mDisplayMode, newMod))) {
|
||||||
mRotation = newRotation;
|
mRotation = newRotation;
|
||||||
mDisplayMode = newMod;
|
mDisplayMode = newMod;
|
||||||
|
mRoundedCornerResDelegate.setPhysicalPixelDisplaySizeRatio(
|
||||||
|
getPhysicalPixelDisplaySizeRatio());
|
||||||
if (mScreenDecorHwcLayer != null) {
|
if (mScreenDecorHwcLayer != null) {
|
||||||
mScreenDecorHwcLayer.pendingConfigChange = false;
|
mScreenDecorHwcLayer.pendingConfigChange = false;
|
||||||
mScreenDecorHwcLayer.updateRotation(mRotation);
|
mScreenDecorHwcLayer.updateConfiguration(mDisplayUniqueId);
|
||||||
updateHwLayerRoundedCornerExistAndSize();
|
updateHwLayerRoundedCornerExistAndSize();
|
||||||
updateHwLayerRoundedCornerDrawable();
|
updateHwLayerRoundedCornerDrawable();
|
||||||
}
|
}
|
||||||
@@ -1111,7 +1081,8 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
|
|||||||
context.getResources(), context.getDisplay().getUniqueId());
|
context.getResources(), context.getDisplay().getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateOverlayProviderViews(@Nullable Integer[] filterIds) {
|
@VisibleForTesting
|
||||||
|
void updateOverlayProviderViews(@Nullable Integer[] filterIds) {
|
||||||
if (mOverlays == null) {
|
if (mOverlays == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class CutoutDecorProviderImpl(
|
|||||||
(view as? DisplayCutoutView)?.let { cutoutView ->
|
(view as? DisplayCutoutView)?.let { cutoutView ->
|
||||||
cutoutView.setColor(tintColor)
|
cutoutView.setColor(tintColor)
|
||||||
cutoutView.updateRotation(rotation)
|
cutoutView.updateRotation(rotation)
|
||||||
cutoutView.onDisplayChanged(displayUniqueId)
|
cutoutView.updateConfiguration(displayUniqueId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ class FaceScanningOverlayProviderImpl(
|
|||||||
view.layoutParams = it
|
view.layoutParams = it
|
||||||
(view as? FaceScanningOverlay)?.let { overlay ->
|
(view as? FaceScanningOverlay)?.let { overlay ->
|
||||||
overlay.setColor(tintColor)
|
overlay.setColor(tintColor)
|
||||||
overlay.onDisplayChanged(displayUniqueId)
|
overlay.updateConfiguration(displayUniqueId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,23 +78,18 @@ class RoundedCornerResDelegate(
|
|||||||
reloadMeasures()
|
reloadMeasures()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun reloadAll(newReloadToken: Int) {
|
|
||||||
if (reloadToken == newReloadToken) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reloadToken = newReloadToken
|
|
||||||
reloadRes()
|
|
||||||
reloadMeasures()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun updateDisplayUniqueId(newDisplayUniqueId: String?, newReloadToken: Int?) {
|
fun updateDisplayUniqueId(newDisplayUniqueId: String?, newReloadToken: Int?) {
|
||||||
if (displayUniqueId != newDisplayUniqueId) {
|
if (displayUniqueId != newDisplayUniqueId) {
|
||||||
displayUniqueId = newDisplayUniqueId
|
displayUniqueId = newDisplayUniqueId
|
||||||
newReloadToken ?.let { reloadToken = it }
|
newReloadToken ?.let { reloadToken = it }
|
||||||
reloadRes()
|
reloadRes()
|
||||||
reloadMeasures()
|
reloadMeasures()
|
||||||
} else {
|
} else if (newReloadToken != null) {
|
||||||
newReloadToken?.let { reloadAll(it) }
|
if (reloadToken == newReloadToken) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
reloadToken = newReloadToken
|
||||||
|
reloadMeasures()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import static org.mockito.ArgumentMatchers.any;
|
|||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.ArgumentMatchers.isA;
|
import static org.mockito.ArgumentMatchers.isA;
|
||||||
import static org.mockito.Mockito.doAnswer;
|
import static org.mockito.Mockito.doAnswer;
|
||||||
|
import static org.mockito.Mockito.doNothing;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
@@ -255,6 +256,7 @@ public class ScreenDecorationsTest extends SysuiTestCase {
|
|||||||
});
|
});
|
||||||
mScreenDecorations.mDisplayInfo = mDisplayInfo;
|
mScreenDecorations.mDisplayInfo = mDisplayInfo;
|
||||||
doReturn(1f).when(mScreenDecorations).getPhysicalPixelDisplaySizeRatio();
|
doReturn(1f).when(mScreenDecorations).getPhysicalPixelDisplaySizeRatio();
|
||||||
|
doNothing().when(mScreenDecorations).updateOverlayProviderViews(any());
|
||||||
reset(mTunerService);
|
reset(mTunerService);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -1005,18 +1007,13 @@ public class ScreenDecorationsTest extends SysuiTestCase {
|
|||||||
assertEquals(new Size(3, 3), resDelegate.getTopRoundedSize());
|
assertEquals(new Size(3, 3), resDelegate.getTopRoundedSize());
|
||||||
assertEquals(new Size(4, 4), resDelegate.getBottomRoundedSize());
|
assertEquals(new Size(4, 4), resDelegate.getBottomRoundedSize());
|
||||||
|
|
||||||
setupResources(20 /* radius */, 0 /* radiusTop */, 0 /* radiusBottom */,
|
doReturn(2f).when(mScreenDecorations).getPhysicalPixelDisplaySizeRatio();
|
||||||
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;
|
mDisplayInfo.rotation = Surface.ROTATION_270;
|
||||||
|
|
||||||
mScreenDecorations.onConfigurationChanged(null);
|
mScreenDecorations.onConfigurationChanged(null);
|
||||||
|
|
||||||
assertEquals(new Size(4, 4), resDelegate.getTopRoundedSize());
|
assertEquals(new Size(6, 6), resDelegate.getTopRoundedSize());
|
||||||
assertEquals(new Size(5, 5), resDelegate.getBottomRoundedSize());
|
assertEquals(new Size(8, 8), resDelegate.getBottomRoundedSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1292,51 +1289,6 @@ public class ScreenDecorationsTest extends SysuiTestCase {
|
|||||||
verifyFaceScanningViewExists(true);
|
verifyFaceScanningViewExists(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@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
|
@Test
|
||||||
public void testHasSameProvidersWithNullOverlays() {
|
public void testHasSameProvidersWithNullOverlays() {
|
||||||
setupResources(0 /* radius */, 0 /* radiusTop */, 0 /* radiusBottom */,
|
setupResources(0 /* radius */, 0 /* radiusTop */, 0 /* radiusBottom */,
|
||||||
|
|||||||
@@ -24,12 +24,11 @@ import androidx.annotation.DrawableRes
|
|||||||
import androidx.test.filters.SmallTest
|
import androidx.test.filters.SmallTest
|
||||||
import com.android.internal.R as InternalR
|
import com.android.internal.R as InternalR
|
||||||
import com.android.systemui.R as SystemUIR
|
import com.android.systemui.R as SystemUIR
|
||||||
import com.android.systemui.tests.R
|
|
||||||
import com.android.systemui.SysuiTestCase
|
import com.android.systemui.SysuiTestCase
|
||||||
|
import com.android.systemui.tests.R
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.mockito.MockitoAnnotations
|
import org.mockito.MockitoAnnotations
|
||||||
@@ -102,14 +101,11 @@ class RoundedCornerResDelegateTest : SysuiTestCase() {
|
|||||||
assertEquals(Size(3, 3), roundedCornerResDelegate.topRoundedSize)
|
assertEquals(Size(3, 3), roundedCornerResDelegate.topRoundedSize)
|
||||||
assertEquals(Size(4, 4), roundedCornerResDelegate.bottomRoundedSize)
|
assertEquals(Size(4, 4), roundedCornerResDelegate.bottomRoundedSize)
|
||||||
|
|
||||||
setupResources(radius = 100,
|
roundedCornerResDelegate.physicalPixelDisplaySizeRatio = 2f
|
||||||
roundedTopDrawable = getTestsDrawable(R.drawable.rounded4px),
|
|
||||||
roundedBottomDrawable = getTestsDrawable(R.drawable.rounded5px))
|
|
||||||
|
|
||||||
roundedCornerResDelegate.updateDisplayUniqueId(null, 1)
|
roundedCornerResDelegate.updateDisplayUniqueId(null, 1)
|
||||||
|
|
||||||
assertEquals(Size(4, 4), roundedCornerResDelegate.topRoundedSize)
|
assertEquals(Size(6, 6), roundedCornerResDelegate.topRoundedSize)
|
||||||
assertEquals(Size(5, 5), roundedCornerResDelegate.bottomRoundedSize)
|
assertEquals(Size(8, 8), roundedCornerResDelegate.bottomRoundedSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user