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

Commit d37f882b authored by Graciela Putri's avatar Graciela Putri Committed by Android (Google) Code Review
Browse files

Merge "Ignore aspect ratio if override to fullscreen" into 24D1-dev

parents bb2e391c 8b125e37
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -8519,7 +8519,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            }
        // If activity in fullscreen mode is letterboxed because of fixed orientation then bounds
        // are already calculated in resolveFixedOrientationConfiguration.
        } else if (!isLetterboxedForFixedOrientationAndAspectRatio()) {
        // Don't apply aspect ratio if app is overridden to fullscreen by device user/manufacturer.
        } else if (!isLetterboxedForFixedOrientationAndAspectRatio()
                && !mLetterboxUiController.hasFullscreenOverride()) {
            resolveAspectRatioRestriction(newParentConfiguration);
        }

+4 −0
Original line number Diff line number Diff line
@@ -1216,6 +1216,10 @@ final class LetterboxUiController {
                    || mUserAspectRatio == USER_MIN_ASPECT_RATIO_FULLSCREEN);
    }

    boolean hasFullscreenOverride() {
        return isSystemOverrideToFullscreenEnabled() || shouldApplyUserFullscreenOverride();
    }

    float getUserMinAspectRatio() {
        switch (mUserAspectRatio) {
            case USER_MIN_ASPECT_RATIO_DISPLAY_SIZE:
+86 −0
Original line number Diff line number Diff line
@@ -2325,6 +2325,92 @@ public class SizeCompatTests extends WindowTestsBase {
        assertFitted();
    }

    @Test
    public void testUserOverrideFullscreenForLandscapeDisplay() {
        final int displayWidth = 1600;
        final int displayHeight = 1400;
        setUpDisplaySizeWithApp(displayWidth, displayHeight);
        mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
        spyOn(mActivity.mWmService.mLetterboxConfiguration);
        doReturn(true).when(mActivity.mWmService.mLetterboxConfiguration)
                .isUserAppAspectRatioFullscreenEnabled();

        // Set user aspect ratio override
        spyOn(mActivity.mLetterboxUiController);
        doReturn(USER_MIN_ASPECT_RATIO_FULLSCREEN).when(mActivity.mLetterboxUiController)
                .getUserMinAspectRatioOverrideCode();

        prepareMinAspectRatio(mActivity, 16 / 9f, SCREEN_ORIENTATION_PORTRAIT);

        final Rect bounds = mActivity.getBounds();

        // bounds should be fullscreen
        assertEquals(displayHeight, bounds.height());
        assertEquals(displayWidth, bounds.width());
    }

    @Test
    public void testUserOverrideFullscreenForPortraitDisplay() {
        final int displayWidth = 1400;
        final int displayHeight = 1600;
        setUpDisplaySizeWithApp(displayWidth, displayHeight);
        mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
        spyOn(mActivity.mWmService.mLetterboxConfiguration);
        doReturn(true).when(mActivity.mWmService.mLetterboxConfiguration)
                .isUserAppAspectRatioFullscreenEnabled();

        // Set user aspect ratio override
        spyOn(mActivity.mLetterboxUiController);
        doReturn(USER_MIN_ASPECT_RATIO_FULLSCREEN).when(mActivity.mLetterboxUiController)
                .getUserMinAspectRatioOverrideCode();

        prepareMinAspectRatio(mActivity, 16 / 9f, SCREEN_ORIENTATION_LANDSCAPE);

        final Rect bounds = mActivity.getBounds();

        // bounds should be fullscreen
        assertEquals(displayHeight, bounds.height());
        assertEquals(displayWidth, bounds.width());
    }

    @Test
    public void testSystemFullscreenOverrideForLandscapeDisplay() {
        final int displayWidth = 1600;
        final int displayHeight = 1400;
        setUpDisplaySizeWithApp(displayWidth, displayHeight);
        mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
        spyOn(mActivity.mLetterboxUiController);
        doReturn(true).when(mActivity.mLetterboxUiController)
                .isSystemOverrideToFullscreenEnabled();

        prepareMinAspectRatio(mActivity, 16 / 9f, SCREEN_ORIENTATION_PORTRAIT);

        final Rect bounds = mActivity.getBounds();

        // bounds should be fullscreen
        assertEquals(displayHeight, bounds.height());
        assertEquals(displayWidth, bounds.width());
    }

    @Test
    public void testSystemFullscreenOverrideForPortraitDisplay() {
        final int displayWidth = 1400;
        final int displayHeight = 1600;
        setUpDisplaySizeWithApp(displayWidth, displayHeight);
        mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
        spyOn(mActivity.mLetterboxUiController);
        doReturn(true).when(mActivity.mLetterboxUiController)
                .isSystemOverrideToFullscreenEnabled();

        prepareMinAspectRatio(mActivity, 16 / 9f, SCREEN_ORIENTATION_LANDSCAPE);

        final Rect bounds = mActivity.getBounds();

        // bounds should be fullscreen
        assertEquals(displayHeight, bounds.height());
        assertEquals(displayWidth, bounds.width());
    }

    @Test
    public void testUserOverrideSplitScreenAspectRatioForLandscapeDisplay() {
        final int displayWidth = 1600;