Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aaafdc1a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

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

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

Change-Id: Iee535294c57a6fcc588aeba216ba14fb132e3e64
parents 061abd1f 3650c991
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -6484,11 +6484,18 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        final Rect containingBounds = mTmpBounds;
        mCompatDisplayInsets.getContainerBounds(containingAppBounds, containingBounds, rotation,
                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.
        if (!mCompatDisplayInsets.mIsFloating) {
            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
        // 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(
                (int) viewportW, (int) (contentW * mSizeCompatScale));
        // 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;
        if (screenPosX != 0 || screenPosY != 0) {
            if (mSizeCompatBounds != null) {
@@ -7654,8 +7661,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                // Ensure the app bounds won't overlap with insets.
                Task.intersectWithInsetsIfFits(outAppBounds, outBounds, mNonDecorInsets[rotation]);
            }
            // The horizontal position is centered and it should not cover insets.
            outBounds.left = outAppBounds.left;
        }
    }

+20 −0
Original line number Diff line number Diff line
@@ -242,6 +242,26 @@ public class SizeCompatTests extends ActivityTestsBase {
        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
    public void testMoveToDifferentOrientDisplay() {
        setUpDisplaySizeWithApp(1000, 2500);
+1 −0
Original line number Diff line number Diff line
@@ -139,6 +139,7 @@ class TestDisplayContent extends DisplayContent {
            spyOn(displayPolicy);
            if (mSystemDecorations) {
                doReturn(true).when(newDisplay).supportsSystemDecorations();
                doReturn(true).when(displayPolicy).hasNavigationBar();
            } else {
                doReturn(false).when(displayPolicy).hasNavigationBar();
                doReturn(false).when(displayPolicy).hasStatusBar();