Merge "Fix incorrect boundary/appearance after folding the device" into sc-v2-dev
This commit is contained in:
@@ -28,6 +28,7 @@ import android.annotation.Nullable;
|
|||||||
import android.annotation.UiContext;
|
import android.annotation.UiContext;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Insets;
|
import android.graphics.Insets;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
@@ -35,6 +36,7 @@ import android.graphics.PixelFormat;
|
|||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.graphics.Region;
|
import android.graphics.Region;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
@@ -76,6 +78,8 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
|
|||||||
MirrorWindowControl.MirrorWindowDelegate, MagnificationGestureDetector.OnGestureListener {
|
MirrorWindowControl.MirrorWindowDelegate, MagnificationGestureDetector.OnGestureListener {
|
||||||
|
|
||||||
private static final String TAG = "WindowMagnificationController";
|
private static final String TAG = "WindowMagnificationController";
|
||||||
|
@SuppressWarnings("isloggabletaglength")
|
||||||
|
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG) || Build.IS_DEBUGGABLE;
|
||||||
// Delay to avoid updating state description too frequently.
|
// Delay to avoid updating state description too frequently.
|
||||||
private static final int UPDATE_STATE_DESCRIPTION_DELAY_MS = 100;
|
private static final int UPDATE_STATE_DESCRIPTION_DELAY_MS = 100;
|
||||||
// It should be consistent with the value defined in WindowMagnificationGestureHandler.
|
// It should be consistent with the value defined in WindowMagnificationGestureHandler.
|
||||||
@@ -158,14 +162,15 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
|
|||||||
mRotation = display.getRotation();
|
mRotation = display.getRotation();
|
||||||
|
|
||||||
mWm = context.getSystemService(WindowManager.class);
|
mWm = context.getSystemService(WindowManager.class);
|
||||||
mWindowBounds = mWm.getCurrentWindowMetrics().getBounds();
|
mWindowBounds = new Rect(mWm.getCurrentWindowMetrics().getBounds());
|
||||||
|
|
||||||
mResources = mContext.getResources();
|
mResources = mContext.getResources();
|
||||||
mScale = mResources.getInteger(R.integer.magnification_default_scale);
|
mScale = mResources.getInteger(R.integer.magnification_default_scale);
|
||||||
mBounceEffectDuration = mResources.getInteger(
|
mBounceEffectDuration = mResources.getInteger(
|
||||||
com.android.internal.R.integer.config_shortAnimTime);
|
com.android.internal.R.integer.config_shortAnimTime);
|
||||||
updateDimensions();
|
updateDimensions();
|
||||||
setInitialStartBounds();
|
setMagnificationFrameWith(mWindowBounds, mWindowBounds.width() / 2,
|
||||||
|
mWindowBounds.height() / 2);
|
||||||
computeBounceAnimationScale();
|
computeBounceAnimationScale();
|
||||||
|
|
||||||
mMirrorWindowControl = mirrorWindowControl;
|
mMirrorWindowControl = mirrorWindowControl;
|
||||||
@@ -286,18 +291,59 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
|
|||||||
* @param configDiff a bit mask of the differences between the configurations
|
* @param configDiff a bit mask of the differences between the configurations
|
||||||
*/
|
*/
|
||||||
void onConfigurationChanged(int configDiff) {
|
void onConfigurationChanged(int configDiff) {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "onConfigurationChanged = " + Configuration.configurationDiffToString(
|
||||||
|
configDiff));
|
||||||
|
}
|
||||||
|
if ((configDiff & ActivityInfo.CONFIG_ORIENTATION) != 0) {
|
||||||
|
onRotate();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((configDiff & ActivityInfo.CONFIG_LOCALE) != 0) {
|
||||||
|
updateAccessibilityWindowTitleIfNeeded();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean reCreateWindow = false;
|
||||||
if ((configDiff & ActivityInfo.CONFIG_DENSITY) != 0) {
|
if ((configDiff & ActivityInfo.CONFIG_DENSITY) != 0) {
|
||||||
updateDimensions();
|
updateDimensions();
|
||||||
computeBounceAnimationScale();
|
computeBounceAnimationScale();
|
||||||
if (isWindowVisible()) {
|
reCreateWindow = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((configDiff & ActivityInfo.CONFIG_SCREEN_SIZE) != 0) {
|
||||||
|
reCreateWindow |= handleScreenSizeChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recreate the window again to correct the window appearance due to density or
|
||||||
|
// window size changed not caused by rotation.
|
||||||
|
if (isWindowVisible() && reCreateWindow) {
|
||||||
deleteWindowMagnification();
|
deleteWindowMagnification();
|
||||||
enableWindowMagnification(Float.NaN, Float.NaN, Float.NaN);
|
enableWindowMagnification(Float.NaN, Float.NaN, Float.NaN);
|
||||||
}
|
}
|
||||||
} else if ((configDiff & ActivityInfo.CONFIG_ORIENTATION) != 0) {
|
|
||||||
onRotate();
|
|
||||||
} else if ((configDiff & ActivityInfo.CONFIG_LOCALE) != 0) {
|
|
||||||
updateAccessibilityWindowTitleIfNeeded();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the magnification frame if the window bounds is changed.
|
||||||
|
* Note that the orientation also changes the wind bounds, so it should be handled first.
|
||||||
|
*
|
||||||
|
* @return {@code true} if the magnification frame is changed with the new window bounds.
|
||||||
|
*/
|
||||||
|
private boolean handleScreenSizeChanged() {
|
||||||
|
final Rect oldWindowBounds = new Rect(mWindowBounds);
|
||||||
|
final Rect currentWindowBounds = mWm.getCurrentWindowMetrics().getBounds();
|
||||||
|
|
||||||
|
if (currentWindowBounds.equals(oldWindowBounds)) {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "updateMagnificationFrame -- window bounds is not changed");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
mWindowBounds.set(currentWindowBounds);
|
||||||
|
final float newCenterX = (getCenterX()) * mWindowBounds.width() / oldWindowBounds.width();
|
||||||
|
final float newCenterY = (getCenterY()) * mWindowBounds.height() / oldWindowBounds.height();
|
||||||
|
setMagnificationFrameWith(mWindowBounds, (int) newCenterX, (int) newCenterY);
|
||||||
|
calculateMagnificationFrameBoundary();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSystemUIStateIfNeeded() {
|
private void updateSystemUIStateIfNeeded() {
|
||||||
@@ -311,30 +357,42 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
|
|||||||
mWm.updateViewLayout(mMirrorView, params);
|
mWm.updateViewLayout(mMirrorView, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handles MirrorWindow position when the device rotation changed. */
|
/**
|
||||||
|
* Keep MirrorWindow position on the screen unchanged when device rotates 90° clockwise or
|
||||||
|
* anti-clockwise.
|
||||||
|
*/
|
||||||
private void onRotate() {
|
private void onRotate() {
|
||||||
final Display display = mContext.getDisplay();
|
final Display display = mContext.getDisplay();
|
||||||
final int oldRotation = mRotation;
|
final int oldRotation = mRotation;
|
||||||
mWindowBounds = mWm.getCurrentWindowMetrics().getBounds();
|
|
||||||
|
|
||||||
setMagnificationFrameBoundary();
|
|
||||||
mRotation = display.getRotation();
|
mRotation = display.getRotation();
|
||||||
|
final int rotationDegree = getDegreeFromRotation(mRotation, oldRotation);
|
||||||
|
if (rotationDegree == 0 || rotationDegree == 180) {
|
||||||
|
Log.w(TAG, "onRotate -- rotate with the device. skip it");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Rect currentWindowBounds = new Rect(mWm.getCurrentWindowMetrics().getBounds());
|
||||||
|
if (currentWindowBounds.width() != mWindowBounds.height()
|
||||||
|
|| currentWindowBounds.height() != mWindowBounds.width()) {
|
||||||
|
Log.w(TAG, "onRotate -- unexpected window height/width");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mWindowBounds.set(currentWindowBounds);
|
||||||
|
|
||||||
|
calculateMagnificationFrameBoundary();
|
||||||
|
|
||||||
if (!isWindowVisible()) {
|
if (!isWindowVisible()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Keep MirrorWindow position on the screen unchanged when device rotates 90°
|
// Keep MirrorWindow position on the screen unchanged when device rotates 90°
|
||||||
// clockwise or anti-clockwise.
|
// clockwise or anti-clockwise.
|
||||||
final int rotationDegree = getDegreeFromRotation(mRotation, oldRotation);
|
|
||||||
final Matrix matrix = new Matrix();
|
final Matrix matrix = new Matrix();
|
||||||
matrix.setRotate(rotationDegree);
|
matrix.setRotate(rotationDegree);
|
||||||
if (rotationDegree == 90) {
|
if (rotationDegree == 90) {
|
||||||
matrix.postTranslate(mWindowBounds.width(), 0);
|
matrix.postTranslate(mWindowBounds.width(), 0);
|
||||||
} else if (rotationDegree == 270) {
|
} else if (rotationDegree == 270) {
|
||||||
matrix.postTranslate(0, mWindowBounds.height());
|
matrix.postTranslate(0, mWindowBounds.height());
|
||||||
} else {
|
|
||||||
Log.w(TAG, "Invalid rotation change. " + rotationDegree);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
// The rect of MirrorView is going to be transformed.
|
// The rect of MirrorView is going to be transformed.
|
||||||
LayoutParams params =
|
LayoutParams params =
|
||||||
@@ -440,12 +498,12 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setInitialStartBounds() {
|
private void setMagnificationFrameWith(Rect windowBounds, int centerX, int centerY) {
|
||||||
// Sets the initial frame area for the mirror and places it in the center of the display.
|
// Sets the initial frame area for the mirror and places it in the center of the display.
|
||||||
final int initSize = Math.min(mWindowBounds.width(), mWindowBounds.height()) / 2
|
final int initSize = Math.min(windowBounds.width(), windowBounds.height()) / 2
|
||||||
+ 2 * mMirrorSurfaceMargin;
|
+ 2 * mMirrorSurfaceMargin;
|
||||||
final int initX = mWindowBounds.width() / 2 - initSize / 2;
|
final int initX = centerX - initSize / 2;
|
||||||
final int initY = mWindowBounds.height() / 2 - initSize / 2;
|
final int initY = centerY - initSize / 2;
|
||||||
mMagnificationFrame.set(initX, initY, initX + initSize, initY + initSize);
|
mMagnificationFrame.set(initX, initY, initX + initSize, initY + initSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -553,7 +611,7 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
|
|||||||
mSourceBounds.set(left, top, right, bottom);
|
mSourceBounds.set(left, top, right, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setMagnificationFrameBoundary() {
|
private void calculateMagnificationFrameBoundary() {
|
||||||
// Calculates width and height for magnification frame could exceed out the screen.
|
// Calculates width and height for magnification frame could exceed out the screen.
|
||||||
// TODO : re-calculating again when scale is changed.
|
// TODO : re-calculating again when scale is changed.
|
||||||
// The half width of magnification frame.
|
// The half width of magnification frame.
|
||||||
@@ -644,7 +702,7 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
|
|||||||
: centerY - mMagnificationFrame.exactCenterY();
|
: centerY - mMagnificationFrame.exactCenterY();
|
||||||
mScale = Float.isNaN(scale) ? mScale : scale;
|
mScale = Float.isNaN(scale) ? mScale : scale;
|
||||||
|
|
||||||
setMagnificationFrameBoundary();
|
calculateMagnificationFrameBoundary();
|
||||||
updateMagnificationFramePosition((int) offsetX, (int) offsetY);
|
updateMagnificationFramePosition((int) offsetX, (int) offsetY);
|
||||||
if (!isWindowVisible()) {
|
if (!isWindowVisible()) {
|
||||||
createMirrorWindow();
|
createMirrorWindow();
|
||||||
@@ -764,6 +822,8 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
|
|||||||
pw.println(" mOverlapWithGestureInsets:" + mOverlapWithGestureInsets);
|
pw.println(" mOverlapWithGestureInsets:" + mOverlapWithGestureInsets);
|
||||||
pw.println(" mScale:" + mScale);
|
pw.println(" mScale:" + mScale);
|
||||||
pw.println(" mMirrorViewBounds:" + (isWindowVisible() ? mMirrorViewBounds : "empty"));
|
pw.println(" mMirrorViewBounds:" + (isWindowVisible() ? mMirrorViewBounds : "empty"));
|
||||||
|
pw.println(" mSourceBounds:"
|
||||||
|
+ (isWindowVisible() ? mSourceBounds : "empty"));
|
||||||
pw.println(" mSystemGestureTop:" + mSystemGestureTop);
|
pw.println(" mSystemGestureTop:" + mSystemGestureTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,9 +16,6 @@
|
|||||||
|
|
||||||
package com.android.systemui.accessibility;
|
package com.android.systemui.accessibility;
|
||||||
|
|
||||||
import static android.view.WindowInsets.Type.systemGestures;
|
|
||||||
|
|
||||||
import android.graphics.Insets;
|
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.Region;
|
import android.graphics.Region;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
@@ -79,14 +76,11 @@ public class TestableWindowManager implements WindowManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WindowMetrics getCurrentWindowMetrics() {
|
public WindowMetrics getCurrentWindowMetrics() {
|
||||||
final Insets systemGesturesInsets = Insets.of(0, 0, 0, 10);
|
final WindowMetrics realMetrics = mWindowManager.getCurrentWindowMetrics();
|
||||||
final WindowInsets insets = new WindowInsets.Builder()
|
|
||||||
.setInsets(systemGestures(), systemGesturesInsets)
|
|
||||||
.build();
|
|
||||||
final WindowMetrics windowMetrics = new WindowMetrics(
|
final WindowMetrics windowMetrics = new WindowMetrics(
|
||||||
mWindowBounds == null ? mWindowManager.getCurrentWindowMetrics().getBounds()
|
mWindowBounds == null ? realMetrics.getBounds()
|
||||||
: mWindowBounds,
|
: mWindowBounds,
|
||||||
mWindowInsets == null ? insets : mWindowInsets);
|
mWindowInsets == null ? realMetrics.getWindowInsets() : mWindowInsets);
|
||||||
return windowMetrics;
|
return windowMetrics;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,10 +100,20 @@ public class TestableWindowManager implements WindowManager {
|
|||||||
return (WindowManager.LayoutParams) mView.getLayoutParams();
|
return (WindowManager.LayoutParams) mView.getLayoutParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the given window bounds to current window metrics.
|
||||||
|
*
|
||||||
|
* @param bounds the window bounds
|
||||||
|
*/
|
||||||
public void setWindowBounds(Rect bounds) {
|
public void setWindowBounds(Rect bounds) {
|
||||||
mWindowBounds = bounds;
|
mWindowBounds = bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the given window insets to the current window metics.
|
||||||
|
*
|
||||||
|
* @param insets the window insets.
|
||||||
|
*/
|
||||||
public void setWindowInsets(WindowInsets insets) {
|
public void setWindowInsets(WindowInsets insets) {
|
||||||
mWindowInsets = insets;
|
mWindowInsets = insets;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package com.android.systemui.accessibility;
|
package com.android.systemui.accessibility;
|
||||||
|
|
||||||
import static android.view.Choreographer.FrameCallback;
|
import static android.view.Choreographer.FrameCallback;
|
||||||
|
import static android.view.WindowInsets.Type.systemGestures;
|
||||||
import static android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
|
import static android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
|
||||||
|
|
||||||
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_MAGNIFICATION_OVERLAP;
|
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_MAGNIFICATION_OVERLAP;
|
||||||
@@ -45,6 +46,8 @@ import android.app.Instrumentation;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.graphics.Insets;
|
||||||
|
import android.graphics.PointF;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
@@ -55,6 +58,7 @@ import android.view.Display;
|
|||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
import android.view.SurfaceControl;
|
import android.view.SurfaceControl;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.WindowInsets;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.accessibility.AccessibilityNodeInfo;
|
import android.view.accessibility.AccessibilityNodeInfo;
|
||||||
|
|
||||||
@@ -239,11 +243,13 @@ public class WindowMagnificationControllerTest extends SysuiTestCase {
|
|||||||
mInstrumentation.runOnMainSync(() -> {
|
mInstrumentation.runOnMainSync(() -> {
|
||||||
mWindowMagnificationController.onConfigurationChanged(ActivityInfo.CONFIG_DENSITY);
|
mWindowMagnificationController.onConfigurationChanged(ActivityInfo.CONFIG_DENSITY);
|
||||||
mWindowMagnificationController.onConfigurationChanged(ActivityInfo.CONFIG_ORIENTATION);
|
mWindowMagnificationController.onConfigurationChanged(ActivityInfo.CONFIG_ORIENTATION);
|
||||||
|
mWindowMagnificationController.onConfigurationChanged(ActivityInfo.CONFIG_LOCALE);
|
||||||
|
mWindowMagnificationController.onConfigurationChanged(ActivityInfo.CONFIG_SCREEN_SIZE);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onOrientationChanged_enabled_updateDisplayRotationAndLayout() {
|
public void onOrientationChanged_enabled_updateDisplayRotationAndCenterStayAtSamePosition() {
|
||||||
final Display display = Mockito.spy(mContext.getDisplay());
|
final Display display = Mockito.spy(mContext.getDisplay());
|
||||||
when(display.getRotation()).thenReturn(Surface.ROTATION_90);
|
when(display.getRotation()).thenReturn(Surface.ROTATION_90);
|
||||||
when(mContext.getDisplay()).thenReturn(display);
|
when(mContext.getDisplay()).thenReturn(display);
|
||||||
@@ -251,13 +257,22 @@ public class WindowMagnificationControllerTest extends SysuiTestCase {
|
|||||||
mWindowMagnificationController.enableWindowMagnification(Float.NaN, Float.NaN,
|
mWindowMagnificationController.enableWindowMagnification(Float.NaN, Float.NaN,
|
||||||
Float.NaN);
|
Float.NaN);
|
||||||
});
|
});
|
||||||
|
final PointF expectedCenter = new PointF(mWindowMagnificationController.getCenterY(),
|
||||||
|
mWindowMagnificationController.getCenterX());
|
||||||
|
final Rect windowBounds = new Rect(mWindowManager.getCurrentWindowMetrics().getBounds());
|
||||||
|
// Rotate the window 90 degrees.
|
||||||
|
windowBounds.set(windowBounds.top, windowBounds.left, windowBounds.bottom,
|
||||||
|
windowBounds.right);
|
||||||
|
mWindowManager.setWindowBounds(windowBounds);
|
||||||
|
|
||||||
mInstrumentation.runOnMainSync(() -> {
|
mInstrumentation.runOnMainSync(() -> {
|
||||||
mWindowMagnificationController.onConfigurationChanged(ActivityInfo.CONFIG_ORIENTATION);
|
mWindowMagnificationController.onConfigurationChanged(ActivityInfo.CONFIG_ORIENTATION);
|
||||||
});
|
});
|
||||||
|
|
||||||
assertEquals(Surface.ROTATION_90, mWindowMagnificationController.mRotation);
|
assertEquals(Surface.ROTATION_90, mWindowMagnificationController.mRotation);
|
||||||
// The first invocation is called when the surface is created.
|
final PointF actualCenter = new PointF(mWindowMagnificationController.getCenterX(),
|
||||||
|
mWindowMagnificationController.getCenterY());
|
||||||
|
assertEquals(expectedCenter, actualCenter);
|
||||||
verify(mWindowManager, times(2)).updateViewLayout(any(), any());
|
verify(mWindowManager, times(2)).updateViewLayout(any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,6 +289,33 @@ public class WindowMagnificationControllerTest extends SysuiTestCase {
|
|||||||
assertEquals(Surface.ROTATION_90, mWindowMagnificationController.mRotation);
|
assertEquals(Surface.ROTATION_90, mWindowMagnificationController.mRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onScreenSizeChanged_enabledAtTheCenterOfScreen_keepSameWindowSizeRatio() {
|
||||||
|
// The default position is at the center of the screen.
|
||||||
|
final float expectedRatio = 0.5f;
|
||||||
|
final Rect testWindowBounds = new Rect(
|
||||||
|
mWindowManager.getCurrentWindowMetrics().getBounds());
|
||||||
|
testWindowBounds.set(testWindowBounds.left, testWindowBounds.top,
|
||||||
|
testWindowBounds.right + 100, testWindowBounds.bottom + 100);
|
||||||
|
mInstrumentation.runOnMainSync(() -> {
|
||||||
|
mWindowMagnificationController.enableWindowMagnification(Float.NaN, Float.NaN,
|
||||||
|
Float.NaN);
|
||||||
|
});
|
||||||
|
mWindowManager.setWindowBounds(testWindowBounds);
|
||||||
|
|
||||||
|
mInstrumentation.runOnMainSync(() -> {
|
||||||
|
mWindowMagnificationController.onConfigurationChanged(ActivityInfo.CONFIG_SCREEN_SIZE);
|
||||||
|
});
|
||||||
|
|
||||||
|
// The ratio of center to window size should be the same.
|
||||||
|
assertEquals(expectedRatio,
|
||||||
|
mWindowMagnificationController.getCenterX() / testWindowBounds.width(),
|
||||||
|
0);
|
||||||
|
assertEquals(expectedRatio,
|
||||||
|
mWindowMagnificationController.getCenterY() / testWindowBounds.height(),
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onDensityChanged_enabled_updateDimensionsAndResetWindowMagnification() {
|
public void onDensityChanged_enabled_updateDimensionsAndResetWindowMagnification() {
|
||||||
mInstrumentation.runOnMainSync(() -> {
|
mInstrumentation.runOnMainSync(() -> {
|
||||||
@@ -419,9 +461,12 @@ public class WindowMagnificationControllerTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void moveWindowMagnificationToTheBottom_enabled_overlapFlagIsTrue() {
|
public void moveWindowMagnificationToTheBottom_enabledWithGestureInset_overlapFlagIsTrue() {
|
||||||
final WindowManager wm = mContext.getSystemService(WindowManager.class);
|
final Rect bounds = mWindowManager.getCurrentWindowMetrics().getBounds();
|
||||||
final Rect bounds = wm.getCurrentWindowMetrics().getBounds();
|
final WindowInsets testInsets = new WindowInsets.Builder()
|
||||||
|
.setInsets(systemGestures(), Insets.of(0, 0, 0, 10))
|
||||||
|
.build();
|
||||||
|
mWindowManager.setWindowInsets(testInsets);
|
||||||
mInstrumentation.runOnMainSync(() -> {
|
mInstrumentation.runOnMainSync(() -> {
|
||||||
mWindowMagnificationController.enableWindowMagnification(Float.NaN, Float.NaN,
|
mWindowMagnificationController.enableWindowMagnification(Float.NaN, Float.NaN,
|
||||||
Float.NaN);
|
Float.NaN);
|
||||||
|
|||||||
Reference in New Issue
Block a user