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

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

Merge "Allow letterbox repositioning only when filling of parent dimensions"...

Merge "Allow letterbox repositioning only when filling of parent dimensions" into tm-qpr-dev am: 2b7f1675

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



Change-Id: I53924b029339158b5b5dee8b4d367f6845babac8
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents ba6f9d24 2b7f1675
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -724,6 +724,7 @@ final class LetterboxUiController {
     *   <li>Activity is portrait-only.
     *   <li>Fullscreen window in landscape device orientation.
     *   <li>Horizontal Reachability is enabled.
     *   <li>Activity fills parent vertically.
     * </ul>
     */
    private boolean isHorizontalReachabilityEnabled(Configuration parentConfiguration) {
@@ -731,10 +732,14 @@ final class LetterboxUiController {
                && parentConfiguration.windowConfiguration.getWindowingMode()
                        == WINDOWING_MODE_FULLSCREEN
                && (parentConfiguration.orientation == ORIENTATION_LANDSCAPE
                && mActivityRecord.getOrientationForReachability() == ORIENTATION_PORTRAIT);
                        && mActivityRecord.getOrientationForReachability() == ORIENTATION_PORTRAIT)
                // Check whether the activity fills the parent vertically.
                && parentConfiguration.windowConfiguration.getBounds().height()
                        == mActivityRecord.getBounds().height();
    }

    private boolean isHorizontalReachabilityEnabled() {
    @VisibleForTesting
    boolean isHorizontalReachabilityEnabled() {
        return isHorizontalReachabilityEnabled(mActivityRecord.getParent().getConfiguration());
    }

@@ -746,6 +751,7 @@ final class LetterboxUiController {
     *   <li>Activity is landscape-only.
     *   <li>Fullscreen window in portrait device orientation.
     *   <li>Vertical Reachability is enabled.
     *   <li>Activity fills parent horizontally.
     * </ul>
     */
    private boolean isVerticalReachabilityEnabled(Configuration parentConfiguration) {
@@ -753,10 +759,14 @@ final class LetterboxUiController {
                && parentConfiguration.windowConfiguration.getWindowingMode()
                        == WINDOWING_MODE_FULLSCREEN
                && (parentConfiguration.orientation == ORIENTATION_PORTRAIT
                && mActivityRecord.getOrientationForReachability() == ORIENTATION_LANDSCAPE);
                        && mActivityRecord.getOrientationForReachability() == ORIENTATION_LANDSCAPE)
                // Check whether the activity fills the parent horizontally.
                && parentConfiguration.windowConfiguration.getBounds().width()
                        == mActivityRecord.getBounds().width();
    }

    private boolean isVerticalReachabilityEnabled() {
    @VisibleForTesting
    boolean isVerticalReachabilityEnabled() {
        return isVerticalReachabilityEnabled(mActivityRecord.getParent().getConfiguration());
    }

+127 −0
Original line number Diff line number Diff line
@@ -2583,6 +2583,133 @@ public class SizeCompatTests extends WindowTestsBase {
        assertLetterboxSurfacesDrawnBetweenActivityAndParentBounds(organizer.mPrimary.getBounds());
    }

    @Test
    public void testIsHorizontalReachabilityEnabled_splitScreen_false() {
        mAtm.mDevEnableNonResizableMultiWindow = true;
        setUpDisplaySizeWithApp(2800, 1000);
        mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
        mWm.mLetterboxConfiguration.setIsHorizontalReachabilityEnabled(true);
        final TestSplitOrganizer organizer =
                new TestSplitOrganizer(mAtm, mActivity.getDisplayContent());

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

        // 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, 1400, 1000);
        assertEquals(WINDOWING_MODE_MULTI_WINDOW, mTask.getWindowingMode());
        assertEquals(WINDOWING_MODE_MULTI_WINDOW, mActivity.getWindowingMode());

        // Horizontal reachability is disabled because the app is in split screen.
        assertFalse(mActivity.mLetterboxUiController.isHorizontalReachabilityEnabled());
    }

    @Test
    public void testIsVerticalReachabilityEnabled_splitScreen_false() {
        mAtm.mDevEnableNonResizableMultiWindow = true;
        setUpDisplaySizeWithApp(1000, 2800);
        mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
        mWm.mLetterboxConfiguration.setIsVerticalReachabilityEnabled(true);
        final TestSplitOrganizer organizer =
                new TestSplitOrganizer(mAtm, mActivity.getDisplayContent());

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

        // 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, mActivity.getWindowingMode());

        // Vertical reachability is disabled because the app is in split screen.
        assertFalse(mActivity.mLetterboxUiController.isVerticalReachabilityEnabled());
    }

    @Test
    public void testIsVerticalReachabilityEnabled_doesNotMatchParentWidth_false() {
        setUpDisplaySizeWithApp(1000, 2800);
        mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
        mWm.mLetterboxConfiguration.setIsVerticalReachabilityEnabled(true);

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

        // Rotate to put activity in size compat mode.
        rotateDisplay(mActivity.mDisplayContent, ROTATION_90);

        // Activity now in size compat mode.
        assertTrue(mActivity.inSizeCompatMode());

        // Vertical reachability is disabled because the app does not match parent width
        assertNotEquals(mActivity.getBounds().width(), mActivity.mDisplayContent.getBounds()
                .width());
        assertFalse(mActivity.mLetterboxUiController.isVerticalReachabilityEnabled());
    }

    @Test
    public void testIsHorizontalReachabilityEnabled_doesNotMatchParentHeight_false() {
        setUpDisplaySizeWithApp(2800, 1000);
        mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
        mWm.mLetterboxConfiguration.setIsHorizontalReachabilityEnabled(true);

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

        // Rotate to put activity in size compat mode.
        rotateDisplay(mActivity.mDisplayContent, ROTATION_90);

        // Activity now in size compat mode.
        assertTrue(mActivity.inSizeCompatMode());

        // Horizontal reachability is disabled because the app does not match parent height
        assertNotEquals(mActivity.getBounds().height(), mActivity.mDisplayContent.getBounds()
                .height());
        assertFalse(mActivity.mLetterboxUiController.isHorizontalReachabilityEnabled());
    }

    @Test
    public void testIsHorizontalReachabilityEnabled_inSizeCompatMode_matchesParentHeight_true() {
        setUpDisplaySizeWithApp(1800, 2200);
        mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
        mWm.mLetterboxConfiguration.setIsHorizontalReachabilityEnabled(true);

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

        // Rotate to put activity in size compat mode.
        rotateDisplay(mActivity.mDisplayContent, ROTATION_90);

        // Activity now in size compat mode.
        assertTrue(mActivity.inSizeCompatMode());

        // Horizontal reachability is enabled because the app matches parent height
        assertEquals(mActivity.getBounds().height(), mActivity.mDisplayContent.getBounds()
                .height());
        assertTrue(mActivity.mLetterboxUiController.isHorizontalReachabilityEnabled());
    }

    @Test
    public void testIsVerticalReachabilityEnabled_inSizeCompatMode_matchesParentWidth_true() {
        setUpDisplaySizeWithApp(2200, 1800);
        mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
        mWm.mLetterboxConfiguration.setIsVerticalReachabilityEnabled(true);

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

        // Rotate to put activity in size compat mode.
        rotateDisplay(mActivity.mDisplayContent, ROTATION_90);

        // Activity now in size compat mode.
        assertTrue(mActivity.inSizeCompatMode());

        // Vertical reachability is enabled because the app matches parent width
        assertEquals(mActivity.getBounds().width(), mActivity.mDisplayContent.getBounds().width());
        assertTrue(mActivity.mLetterboxUiController.isVerticalReachabilityEnabled());
    }

    @Test
    public void testLetterboxDetailsForStatusBar_noLetterbox() {
        setUpDisplaySizeWithApp(2800, 1000);