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

Commit 996ce09e authored by Mina Granic's avatar Mina Granic
Browse files

Do not apply fullscreen override for camera activities.

Fixed-orientation activities are rarely tested in other orientations, and it often results in sideways or stretched previews. As the camera compat treatment targets fixed-orientation activities, overriding the orientation disables the treatment.

Fixes: 340818342
Test: atest WmTests:LetterboxUiControllerTest
Change-Id: I23cc542158e8fe53b1b210409dfb96c45ff7462f
parent 10c1a6d6
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -1131,6 +1131,17 @@ final class LetterboxUiController {
    }

    boolean shouldApplyUserFullscreenOverride() {
        // Do not override orientation to fullscreen for camera activities.
        // Fixed-orientation activities are rarely tested in other orientations, and it often
        // results in sideways or stretched previews. As the camera compat treatment targets
        // fixed-orientation activities, overriding the orientation disables the treatment.
        final DisplayContent displayContent = mActivityRecord.mDisplayContent;
        if (displayContent != null && displayContent.mDisplayRotationCompatPolicy != null
                && displayContent.mDisplayRotationCompatPolicy
                .isCameraActive(mActivityRecord, /* mustBeFullscreen= */ true)) {
            return false;
        }

        if (isUserFullscreenOverrideEnabled()) {
            mUserAspectRatio = getUserMinAspectRatioOverrideCode();

+18 −0
Original line number Diff line number Diff line
@@ -866,6 +866,24 @@ public class LetterboxUiControllerTest extends WindowTestsBase {
        assertEquals(SCREEN_ORIENTATION_USER, mController.overrideOrientationIfNeeded(
                /* candidate */ SCREEN_ORIENTATION_UNSPECIFIED));
    }
    @Test
    public void testOverrideOrientationIfNeeded_fullscreenOverride_cameraActivity_unchanged() {
        doReturn(true).when(mLetterboxConfiguration).isCameraCompatTreatmentEnabled();
        doReturn(true).when(mLetterboxConfiguration)
                .isCameraCompatTreatmentEnabledAtBuildTime();

        // Recreate DisplayContent with DisplayRotationCompatPolicy
        mActivity = setUpActivityWithComponent();
        mController = new LetterboxUiController(mWm, mActivity);
        spyOn(mDisplayContent.mDisplayRotationCompatPolicy);

        doReturn(false).when(mDisplayContent.mDisplayRotationCompatPolicy)
                .isCameraActive(mActivity, /* mustBeFullscreen= */ true);

        assertEquals(SCREEN_ORIENTATION_PORTRAIT, mController.overrideOrientationIfNeeded(
                /* candidate */ SCREEN_ORIENTATION_PORTRAIT));
    }

    @Test
    public void testOverrideOrientationIfNeeded_respectOrientationRequestOverUserFullScreen() {
        spyOn(mController);