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

Commit 42f0fa2d authored by Mariia Sandrikova's avatar Mariia Sandrikova Committed by Automerger Merge Worker
Browse files

Merge "[Letterbox] Remove multi-window restriction from aspect ratio logic."...

Merge "[Letterbox] Remove multi-window restriction from aspect ratio logic." into tm-qpr-dev am: 86a33bf1 am: 2a601ddf

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18404626



Change-Id: Iba561f94e2723edfac07d3d688b933c446e47461
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 2d305f3b 2a601ddf
Loading
Loading
Loading
Loading
+9 −14
Original line number Diff line number Diff line
@@ -8075,7 +8075,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                        ? letterboxAspectRatioOverride : computeAspectRatio(parentBounds);
        // Apply aspect ratio to resolved bounds
        mIsAspectRatioApplied = applyAspectRatio(resolvedBounds, containingBoundsWithInsets,
                containingBounds, desiredAspectRatio, true);
                containingBounds, desiredAspectRatio);

        if (mCompatDisplayInsets != null) {
            mCompatDisplayInsets.getBoundsByRotation(
@@ -8501,7 +8501,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    private boolean applyAspectRatio(Rect outBounds, Rect containingAppBounds,
            Rect containingBounds) {
        return applyAspectRatio(outBounds, containingAppBounds, containingBounds,
                0 /* desiredAspectRatio */, false /* fixedOrientationLetterboxed */);
                0 /* desiredAspectRatio */);
    }

    /**
@@ -8512,23 +8512,18 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     */
    // TODO(b/36505427): Consider moving this method and similar ones to ConfigurationContainer.
    private boolean applyAspectRatio(Rect outBounds, Rect containingAppBounds,
            Rect containingBounds, float desiredAspectRatio, boolean fixedOrientationLetterboxed) {
            Rect containingBounds, float desiredAspectRatio) {
        final float maxAspectRatio = info.getMaxAspectRatio();
        final Task rootTask = getRootTask();
        final float minAspectRatio = getMinAspectRatio();
        // Not using ActivityRecord#isResizeable() directly because app compatibility testing
        // showed that android:supportsPictureInPicture="true" alone is not sufficient signal for
        // not letterboxing an app.
        // TODO(214602463): Remove multi-window check since orientation and aspect ratio
        // restrictions should always be applied in multi-window.
        final TaskFragment organizedTf = getOrganizedTaskFragment();
        if (task == null || rootTask == null
                || (inMultiWindowMode() && isResizeable(/* checkPictureInPictureSupport */ false)
                && !fixedOrientationLetterboxed)
                || (maxAspectRatio < 1 && minAspectRatio < 1 && desiredAspectRatio < 1)
                || isInVrUiMode(getConfiguration())) {
            // We don't enforce aspect ratio if the activity task is in multiwindow unless it is in
            // size-compat mode or is letterboxed from fixed orientation. We also don't set it if we
            // are in VR mode.
                // Don't set aspect ratio if we are in VR mode.
                || isInVrUiMode(getConfiguration())
                // TODO(b/232898850): Always respect aspect ratio requests.
                // Don't set aspect ratio for activity in ActivityEmbedding split.
                || (organizedTf != null && !organizedTf.fillsParent())) {
            return false;
        }

+30 −0
Original line number Diff line number Diff line
@@ -1248,6 +1248,36 @@ public class SizeCompatTests extends WindowTestsBase {
        assertEquals(1000, activity.getBounds().width());
    }

    @Test
    @EnableCompatChanges({ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO,
            ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_LARGE})
    public void testOverrideMinAspectRatioLargeForResizableAppInSplitScreen() {
        setUpDisplaySizeWithApp(/* dw= */ 1000, /* dh= */ 2800);

        // Create a size compat activity on the same task.
        final ActivityRecord activity = new ActivityBuilder(mAtm)
                .setTask(mTask)
                .setScreenOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
                .setComponent(ComponentName.createRelative(mContext,
                        SizeCompatTests.class.getName()))
                .setUid(android.os.Process.myUid())
                .build();

        final TestSplitOrganizer organizer =
                new TestSplitOrganizer(mAtm, activity.getDisplayContent());

        // Move activity to split screen which takes half of the screen.
        mTask.reparent(organizer.mPrimary, POSITION_TOP, /* moveParents= */ false , "test");
        organizer.mPrimary.setBounds(0, 0, 1000, 1400);
        assertEquals(WINDOWING_MODE_MULTI_WINDOW, mTask.getWindowingMode());
        assertEquals(WINDOWING_MODE_MULTI_WINDOW, activity.getWindowingMode());

        // The per-package override forces the activity into a 16:9 aspect ratio
        assertEquals(1400, activity.getBounds().height());
        assertEquals(1400 / ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_LARGE_VALUE,
                activity.getBounds().width(), 0.5);
    }

    @Test
    public void testLaunchWithFixedRotationTransform() {
        final int dw = 1000;