Merge "Set pillar box bounds in fixed orientation display" into rvc-dev
This commit is contained in:
@@ -7724,24 +7724,25 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
|||||||
outAppBounds.set(outBounds);
|
outAppBounds.set(outBounds);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
outBounds.set(0, 0, mWidth, mHeight);
|
if (orientationRequested) {
|
||||||
getFrameByOrientation(outAppBounds, orientation);
|
getFrameByOrientation(outBounds, orientation);
|
||||||
if (orientationRequested && !canChangeOrientation
|
if ((outBounds.width() > outBounds.height()) != (mWidth > mHeight)) {
|
||||||
&& (outAppBounds.width() > outAppBounds.height()) != (mWidth > mHeight)) {
|
// The orientation is mismatched but the display cannot rotate. The bounds
|
||||||
// The orientation is mismatched but the display cannot rotate. The bounds will
|
// will fit to the short side of display.
|
||||||
// fit to the short side of display.
|
if (orientation == ORIENTATION_LANDSCAPE) {
|
||||||
if (orientation == ORIENTATION_LANDSCAPE) {
|
outBounds.bottom = (int) ((float) mWidth * mWidth / mHeight);
|
||||||
outAppBounds.bottom = (int) ((float) mWidth * mWidth / mHeight);
|
outBounds.right = mWidth;
|
||||||
outAppBounds.right = mWidth;
|
} else {
|
||||||
} else {
|
outBounds.bottom = mHeight;
|
||||||
outAppBounds.bottom = mHeight;
|
outBounds.right = (int) ((float) mHeight * mHeight / mWidth);
|
||||||
outAppBounds.right = (int) ((float) mHeight * mHeight / mWidth);
|
}
|
||||||
|
outBounds.offset(
|
||||||
|
getHorizontalCenterOffset(mWidth, outBounds.width()), 0 /* dy */);
|
||||||
}
|
}
|
||||||
outAppBounds.offset(getHorizontalCenterOffset(outBounds.width(),
|
|
||||||
outAppBounds.width()), 0 /* dy */);
|
|
||||||
} else {
|
} else {
|
||||||
outAppBounds.set(outBounds);
|
outBounds.set(0, 0, mWidth, mHeight);
|
||||||
}
|
}
|
||||||
|
outAppBounds.set(outBounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rotation != ROTATION_UNDEFINED) {
|
if (rotation != ROTATION_UNDEFINED) {
|
||||||
|
|||||||
@@ -289,14 +289,29 @@ public class SizeCompatTests extends ActivityTestsBase {
|
|||||||
|
|
||||||
// Move the non-resizable activity to the new display.
|
// Move the non-resizable activity to the new display.
|
||||||
mStack.reparent(newDisplay.getDefaultTaskDisplayArea(), true /* onTop */);
|
mStack.reparent(newDisplay.getDefaultTaskDisplayArea(), true /* onTop */);
|
||||||
// The configuration bounds should keep the same.
|
// The configuration bounds [820, 0 - 1820, 2500] should keep the same.
|
||||||
assertEquals(origWidth, configBounds.width());
|
assertEquals(origWidth, configBounds.width());
|
||||||
assertEquals(origHeight, configBounds.height());
|
assertEquals(origHeight, configBounds.height());
|
||||||
assertScaled();
|
assertScaled();
|
||||||
|
|
||||||
|
final Rect newDisplayBounds = newDisplay.getWindowConfiguration().getBounds();
|
||||||
// The scaled bounds should exclude notch area (1000 - 100 == 360 * 2500 / 1000 = 900).
|
// The scaled bounds should exclude notch area (1000 - 100 == 360 * 2500 / 1000 = 900).
|
||||||
assertEquals(newDisplay.getBounds().height() - notchHeight,
|
assertEquals(newDisplayBounds.height() - notchHeight,
|
||||||
(int) ((float) mActivity.getBounds().width() * origHeight / origWidth));
|
(int) ((float) mActivity.getBounds().width() * origHeight / origWidth));
|
||||||
|
|
||||||
|
// Recompute the natural configuration in the new display.
|
||||||
|
mActivity.clearSizeCompatMode();
|
||||||
|
mActivity.ensureActivityConfiguration(0 /* globalChanges */, false /* preserveWindow */);
|
||||||
|
// Because the display cannot rotate, the portrait activity will fit the short side of
|
||||||
|
// display with keeping portrait bounds [200, 0 - 700, 1000] in center.
|
||||||
|
assertEquals(newDisplayBounds.height(), configBounds.height());
|
||||||
|
assertEquals(configBounds.height() * newDisplayBounds.height() / newDisplayBounds.width(),
|
||||||
|
configBounds.width());
|
||||||
|
assertFitted();
|
||||||
|
// The appBounds should be [200, 100 - 700, 1000].
|
||||||
|
final Rect appBounds = mActivity.getWindowConfiguration().getAppBounds();
|
||||||
|
assertEquals(configBounds.width(), appBounds.width());
|
||||||
|
assertEquals(configBounds.height() - notchHeight, appBounds.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user