Reset WindowMagnification when the density is changed

To prevent MirrorSurfaceView not cleared, when the
denisty is changed, we should call
deleteWindowMagnification and enableWindowMagnification
to reset WindowMagnification instead of just removing
the mirrorview.

Bug: 169149030
Test: atest WindowMagnificationControllerTest
Change-Id: Ie1da5f3556cf23482c562b479f483783e09ded1f
This commit is contained in:
mincheli
2020-10-13 15:34:27 +08:00
parent 168d7918b8
commit b5f6720f9c
2 changed files with 6 additions and 3 deletions

View File

@@ -249,8 +249,8 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
if ((configDiff & ActivityInfo.CONFIG_DENSITY) != 0) {
updateDimensions();
if (isWindowVisible()) {
mWm.removeView(mMirrorView);
createMirrorWindow();
deleteWindowMagnification();
enableWindowMagnification(Float.NaN, Float.NaN, Float.NaN);
}
} else if ((configDiff & ActivityInfo.CONFIG_ORIENTATION) != 0) {
onRotate();

View File

@@ -224,11 +224,12 @@ public class WindowMagnificationControllerTest extends SysuiTestCase {
@Test
public void onDensityChanged_enabled_updateDimensionsAndLayout() {
public void onDensityChanged_enabled_updateDimensionsAndResetWindowMagnification() {
mInstrumentation.runOnMainSync(() -> {
mWindowMagnificationController.enableWindowMagnification(Float.NaN, Float.NaN,
Float.NaN);
Mockito.reset(mWindowManager);
Mockito.reset(mMirrorWindowControl);
});
mInstrumentation.runOnMainSync(() -> {
@@ -237,7 +238,9 @@ public class WindowMagnificationControllerTest extends SysuiTestCase {
verify(mResources, atLeastOnce()).getDimensionPixelSize(anyInt());
verify(mWindowManager).removeView(any());
verify(mMirrorWindowControl).destroyControl();
verify(mWindowManager).addView(any(), any());
verify(mMirrorWindowControl).showControl();
}
@Test