Merge "Use full bounds if fixed aspect ratio does not apply" into rvc-dev am: 0350a0c4ec

Change-Id: Icdf87a01ba53834ec175cf9c14007f8e692a3068
This commit is contained in:
TreeHugger Robot
2020-04-09 05:37:16 +00:00
committed by Automerger Merge Worker
3 changed files with 30 additions and 4 deletions

View File

@@ -6484,11 +6484,18 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
final Rect containingBounds = mTmpBounds; final Rect containingBounds = mTmpBounds;
mCompatDisplayInsets.getContainerBounds(containingAppBounds, containingBounds, rotation, mCompatDisplayInsets.getContainerBounds(containingAppBounds, containingBounds, rotation,
orientation, orientationRequested, canChangeOrientation); orientation, orientationRequested, canChangeOrientation);
resolvedBounds.set(containingAppBounds); resolvedBounds.set(containingBounds);
// The size of floating task is fixed (only swap), so the aspect ratio is already correct. // The size of floating task is fixed (only swap), so the aspect ratio is already correct.
if (!mCompatDisplayInsets.mIsFloating) { if (!mCompatDisplayInsets.mIsFloating) {
applyAspectRatio(resolvedBounds, containingAppBounds, containingBounds); applyAspectRatio(resolvedBounds, containingAppBounds, containingBounds);
} }
// If the bounds are restricted by fixed aspect ratio, the resolved bounds should be put in
// the container app bounds. Otherwise the entire container bounds are available.
final boolean fillContainer = resolvedBounds.equals(containingBounds);
if (!fillContainer) {
// The horizontal position should not cover insets.
resolvedBounds.left = containingAppBounds.left;
}
// Use resolvedBounds to compute other override configurations such as appBounds. The bounds // Use resolvedBounds to compute other override configurations such as appBounds. The bounds
// are calculated in compat container space. The actual position on screen will be applied // are calculated in compat container space. The actual position on screen will be applied
@@ -6557,7 +6564,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
final int offsetX = getHorizontalCenterOffset( final int offsetX = getHorizontalCenterOffset(
(int) viewportW, (int) (contentW * mSizeCompatScale)); (int) viewportW, (int) (contentW * mSizeCompatScale));
// Above coordinates are in "@" space, now place "*" and "#" to screen space. // Above coordinates are in "@" space, now place "*" and "#" to screen space.
final int screenPosX = parentAppBounds.left + offsetX; final int screenPosX = (fillContainer ? parentBounds.left : parentAppBounds.left) + offsetX;
final int screenPosY = parentBounds.top; final int screenPosY = parentBounds.top;
if (screenPosX != 0 || screenPosY != 0) { if (screenPosX != 0 || screenPosY != 0) {
if (mSizeCompatBounds != null) { if (mSizeCompatBounds != null) {
@@ -7654,8 +7661,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
// Ensure the app bounds won't overlap with insets. // Ensure the app bounds won't overlap with insets.
Task.intersectWithInsetsIfFits(outAppBounds, outBounds, mNonDecorInsets[rotation]); Task.intersectWithInsetsIfFits(outAppBounds, outBounds, mNonDecorInsets[rotation]);
} }
// The horizontal position is centered and it should not cover insets.
outBounds.left = outAppBounds.left;
} }
} }

View File

@@ -242,6 +242,26 @@ public class SizeCompatTests extends ActivityTestsBase {
assertFalse(mActivity.mDisplayContent.isImeAttachedToApp()); assertFalse(mActivity.mDisplayContent.isImeAttachedToApp());
} }
@Test
public void testAspectRatioMatchParentBoundsAndImeAttachable() {
setUpApp(new TestDisplayContent.Builder(mService, 1000, 2000)
.setSystemDecorations(true).build());
prepareUnresizable(2f /* maxAspect */, SCREEN_ORIENTATION_UNSPECIFIED);
assertFitted();
rotateDisplay(mActivity.mDisplayContent, ROTATION_90);
mActivity.mDisplayContent.mInputMethodTarget = addWindowToActivity(mActivity);
// Because the aspect ratio of display doesn't exceed the max aspect ratio of activity.
// The activity should still fill its parent container and IME can attach to the activity.
assertTrue(mActivity.matchParentBounds());
assertTrue(mActivity.mDisplayContent.isImeAttachedToApp());
final Rect letterboxInnerBounds = new Rect();
mActivity.getLetterboxInnerBounds(letterboxInnerBounds);
// The activity should not have letterbox.
assertTrue(letterboxInnerBounds.isEmpty());
}
@Test @Test
public void testMoveToDifferentOrientDisplay() { public void testMoveToDifferentOrientDisplay() {
setUpDisplaySizeWithApp(1000, 2500); setUpDisplaySizeWithApp(1000, 2500);

View File

@@ -139,6 +139,7 @@ class TestDisplayContent extends DisplayContent {
spyOn(displayPolicy); spyOn(displayPolicy);
if (mSystemDecorations) { if (mSystemDecorations) {
doReturn(true).when(newDisplay).supportsSystemDecorations(); doReturn(true).when(newDisplay).supportsSystemDecorations();
doReturn(true).when(displayPolicy).hasNavigationBar();
} else { } else {
doReturn(false).when(displayPolicy).hasNavigationBar(); doReturn(false).when(displayPolicy).hasNavigationBar();
doReturn(false).when(displayPolicy).hasStatusBar(); doReturn(false).when(displayPolicy).hasStatusBar();