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

Commit 9cb16861 authored by Vali Calinescu's avatar Vali Calinescu Committed by Automerger Merge Worker
Browse files

Merge "Use appBounds when computing split screen aspect ratio" into tm-qpr-dev...

Merge "Use appBounds when computing split screen aspect ratio" into tm-qpr-dev am: 02b2a06f am: 4865b4a9 am: 8d969cfe am: 0ff4b46b

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



Change-Id: Id09574d4b646e46d2b9469192430aff455c03796
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 83f8edfe 0ff4b46b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -841,7 +841,7 @@ final class LetterboxUiController {
        int dividerInsets =
                getResources().getDimensionPixelSize(R.dimen.docked_stack_divider_insets);
        int dividerSize = dividerWindowWidth - dividerInsets * 2;
        final Rect bounds = new Rect(displayContent.getBounds());
        final Rect bounds = new Rect(displayContent.getWindowConfiguration().getAppBounds());
        if (bounds.width() >= bounds.height()) {
            bounds.inset(/* dx */ dividerSize / 2, /* dy */ 0);
            bounds.right = bounds.centerX();
@@ -1498,7 +1498,7 @@ final class LetterboxUiController {
    }

    private void inheritConfiguration(ActivityRecord firstOpaque) {
        // To avoid wrong behaviour, we're not forcing a specific aspet ratio to activities
        // To avoid wrong behaviour, we're not forcing a specific aspect ratio to activities
        // which are not already providing one (e.g. permission dialogs) and presumably also
        // not resizable.
        if (mActivityRecord.getMinAspectRatio() != UNDEFINED_ASPECT_RATIO) {
+86 −5
Original line number Diff line number Diff line
@@ -108,7 +108,6 @@ import libcore.junit.util.compat.CoreCompatChangeRule.DisableCompatChanges;
import libcore.junit.util.compat.CoreCompatChangeRule.EnableCompatChanges;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -2027,7 +2026,7 @@ public class SizeCompatTests extends WindowTestsBase {
        float expectedAspectRatio = 1f * displayWidth / getExpectedSplitSize(displayHeight);
        final Rect afterBounds = activity.getBounds();
        final float afterAspectRatio = (float) (afterBounds.height()) / afterBounds.width();
        Assert.assertEquals(expectedAspectRatio, afterAspectRatio, 0.001f);
        assertEquals(expectedAspectRatio, afterAspectRatio, 0.001f);
    }

    @Test
@@ -2052,7 +2051,7 @@ public class SizeCompatTests extends WindowTestsBase {
        float expectedAspectRatio = 1f * displayHeight / getExpectedSplitSize(displayWidth);
        final Rect afterBounds = activity.getBounds();
        final float afterAspectRatio = (float) (afterBounds.height()) / afterBounds.width();
        Assert.assertEquals(expectedAspectRatio, afterAspectRatio, 0.001f);
        assertEquals(expectedAspectRatio, afterAspectRatio, 0.001f);
    }

    @Test
@@ -2078,7 +2077,7 @@ public class SizeCompatTests extends WindowTestsBase {
        float expectedAspectRatio = 1f * displayWidth / getExpectedSplitSize(displayHeight);
        final Rect afterBounds = activity.getBounds();
        final float afterAspectRatio = (float) (afterBounds.width()) / afterBounds.height();
        Assert.assertEquals(expectedAspectRatio, afterAspectRatio, 0.001f);
        assertEquals(expectedAspectRatio, afterAspectRatio, 0.001f);
    }

    @Test
@@ -2104,7 +2103,89 @@ public class SizeCompatTests extends WindowTestsBase {
        float expectedAspectRatio = 1f * displayHeight / getExpectedSplitSize(displayWidth);
        final Rect afterBounds = activity.getBounds();
        final float afterAspectRatio = (float) (afterBounds.width()) / afterBounds.height();
        Assert.assertEquals(expectedAspectRatio, afterAspectRatio, 0.001f);
        assertEquals(expectedAspectRatio, afterAspectRatio, 0.001f);
    }

    @Test
    @EnableCompatChanges({ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO,
            ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_TO_ALIGN_WITH_SPLIT_SCREEN})
    public void testOverrideSplitScreenAspectRatio_splitScreenActivityInPortrait_notLetterboxed() {
        mAtm.mDevEnableNonResizableMultiWindow = true;
        final int screenWidth = 1800;
        final int screenHeight = 1000;
        setUpDisplaySizeWithApp(screenWidth, screenHeight);
        final ActivityRecord activity = new ActivityBuilder(mAtm)
                .setTask(mTask)
                .setComponent(ComponentName.createRelative(mContext,
                        SizeCompatTests.class.getName()))
                .setUid(android.os.Process.myUid())
                .build();

        activity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
        // Simulate real display with top insets.
        final int topInset = 30;
        activity.mDisplayContent.getWindowConfiguration()
                .setAppBounds(0, topInset, screenWidth, screenHeight);

        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, getExpectedSplitSize(screenWidth), screenHeight);
        assertEquals(WINDOWING_MODE_MULTI_WINDOW, mTask.getWindowingMode());
        assertEquals(WINDOWING_MODE_MULTI_WINDOW, activity.getWindowingMode());

        // Unresizable portrait-only activity.
        prepareUnresizable(activity, 3f, SCREEN_ORIENTATION_PORTRAIT);

        // Activity should have the aspect ratio of a split screen activity and occupy exactly one
        // half of the screen, so there is no letterbox
        float expectedAspectRatio = 1f * screenHeight / getExpectedSplitSize(screenWidth);
        final Rect afterBounds = activity.getBounds();
        final float afterAspectRatio = (float) (afterBounds.height()) / afterBounds.width();
        assertEquals(expectedAspectRatio, afterAspectRatio, 0.001f);
        assertFalse(activity.areBoundsLetterboxed());
    }

    @Test
    @EnableCompatChanges({ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO,
            ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_TO_ALIGN_WITH_SPLIT_SCREEN})
    public void testOverrideSplitScreenAspectRatio_splitScreenActivityInLandscape_notLetterboxed() {
        mAtm.mDevEnableNonResizableMultiWindow = true;
        final int screenWidth = 1000;
        final int screenHeight = 1800;
        setUpDisplaySizeWithApp(screenWidth, screenHeight);
        final ActivityRecord activity = new ActivityBuilder(mAtm)
                .setTask(mTask)
                .setComponent(ComponentName.createRelative(mContext,
                        SizeCompatTests.class.getName()))
                .setUid(android.os.Process.myUid())
                .build();

        activity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
        // Simulate real display with top insets.
        final int leftInset = 30;
        activity.mDisplayContent.getWindowConfiguration()
                .setAppBounds(leftInset, 0, screenWidth, screenHeight);

        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, screenWidth, getExpectedSplitSize(screenHeight));
        assertEquals(WINDOWING_MODE_MULTI_WINDOW, mTask.getWindowingMode());
        assertEquals(WINDOWING_MODE_MULTI_WINDOW, activity.getWindowingMode());

        // Unresizable landscape-only activity.
        prepareUnresizable(activity, 3f, SCREEN_ORIENTATION_LANDSCAPE);

        // Activity should have the aspect ratio of a split screen activity and occupy exactly one
        // half of the screen, so there is no letterbox
        float expectedAspectRatio = 1f * screenWidth / getExpectedSplitSize(screenHeight);
        final Rect afterBounds = activity.getBounds();
        final float afterAspectRatio = (float) (afterBounds.width()) / afterBounds.height();
        assertEquals(expectedAspectRatio, afterAspectRatio, 0.001f);
        assertFalse(activity.areBoundsLetterboxed());
    }

    @Test