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

Commit b34754c7 authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge "Merge "Disable split screen aspect ratio for portrait apps in tabletop"...

Merge "Merge "Disable split screen aspect ratio for portrait apps in tabletop" into 24D1-dev am: 9154fe5c" into main
parents b9fb256a 96143235
Loading
Loading
Loading
Loading
+14 −23
Original line number Original line Diff line number Diff line
@@ -905,13 +905,11 @@ final class LetterboxUiController {
    // Note that we check the task rather than the parent as with ActivityEmbedding the parent might
    // Note that we check the task rather than the parent as with ActivityEmbedding the parent might
    // be a TaskFragment, and its windowing mode is always MULTI_WINDOW, even if the task is
    // be a TaskFragment, and its windowing mode is always MULTI_WINDOW, even if the task is
    // actually fullscreen.
    // actually fullscreen.
    private boolean isDisplayFullScreenAndInPosture(DeviceStateController.DeviceState state,
    private boolean isDisplayFullScreenAndInPosture(boolean isTabletop) {
            boolean isTabletop) {
        Task task = mActivityRecord.getTask();
        Task task = mActivityRecord.getTask();
        return mActivityRecord.mDisplayContent != null
        return mActivityRecord.mDisplayContent != null && task != null
                && mActivityRecord.mDisplayContent.getDisplayRotation().isDeviceInPosture(state,
                && mActivityRecord.mDisplayContent.getDisplayRotation().isDeviceInPosture(
                    isTabletop)
                        DeviceStateController.DeviceState.HALF_FOLDED, isTabletop)
                && task != null
                && task.getWindowingMode() == WINDOWING_MODE_FULLSCREEN;
                && task.getWindowingMode() == WINDOWING_MODE_FULLSCREEN;
    }
    }


@@ -939,16 +937,14 @@ final class LetterboxUiController {
    }
    }


    private boolean isFullScreenAndBookModeEnabled() {
    private boolean isFullScreenAndBookModeEnabled() {
        return isDisplayFullScreenAndInPosture(
        return isDisplayFullScreenAndInPosture(/* isTabletop */ false)
                DeviceStateController.DeviceState.HALF_FOLDED, false /* isTabletop */)
                && mLetterboxConfiguration.getIsAutomaticReachabilityInBookModeEnabled();
                && mLetterboxConfiguration.getIsAutomaticReachabilityInBookModeEnabled();
    }
    }


    float getVerticalPositionMultiplier(Configuration parentConfiguration) {
    float getVerticalPositionMultiplier(Configuration parentConfiguration) {
        // Don't check resolved configuration because it may not be updated yet during
        // Don't check resolved configuration because it may not be updated yet during
        // configuration change.
        // configuration change.
        boolean tabletopMode = isDisplayFullScreenAndInPosture(
        boolean tabletopMode = isDisplayFullScreenAndInPosture(/* isTabletop */ true);
                DeviceStateController.DeviceState.HALF_FOLDED, true /* isTabletop */);
        return isVerticalReachabilityEnabled(parentConfiguration)
        return isVerticalReachabilityEnabled(parentConfiguration)
                // Using the last global dynamic position to avoid "jumps" when moving
                // Using the last global dynamic position to avoid "jumps" when moving
                // between apps or activities.
                // between apps or activities.
@@ -981,16 +977,15 @@ final class LetterboxUiController {
    }
    }


    private boolean shouldUseSplitScreenAspectRatio(@NonNull Configuration parentConfiguration) {
    private boolean shouldUseSplitScreenAspectRatio(@NonNull Configuration parentConfiguration) {
        final boolean isBookMode = isDisplayFullScreenAndInPosture(
        final boolean isBookMode = isDisplayFullScreenAndInPosture(/* isTabletop */ false);
                DeviceStateController.DeviceState.HALF_FOLDED,
                /* isTabletop */ false);
        final boolean isNotCenteredHorizontally = getHorizontalPositionMultiplier(
        final boolean isNotCenteredHorizontally = getHorizontalPositionMultiplier(
                parentConfiguration) != LETTERBOX_POSITION_MULTIPLIER_CENTER;
                parentConfiguration) != LETTERBOX_POSITION_MULTIPLIER_CENTER;
        final boolean isTabletopMode = isDisplayFullScreenAndInPosture(
        final boolean isTabletopMode = isDisplayFullScreenAndInPosture(/* isTabletop */ true);
                DeviceStateController.DeviceState.HALF_FOLDED,
        final boolean isLandscape = isFixedOrientationLandscape(
                /* isTabletop */ true);
                mActivityRecord.getOverrideOrientation());

        // Don't resize to split screen size when in book mode if letterbox position is centered
        // Don't resize to split screen size when in book mode if letterbox position is centered
        return ((isBookMode && isNotCenteredHorizontally) || isTabletopMode)
        return (isBookMode && isNotCenteredHorizontally || isTabletopMode && isLandscape)
                    || isCameraCompatSplitScreenAspectRatioAllowed()
                    || isCameraCompatSplitScreenAspectRatioAllowed()
                        && isCameraCompatTreatmentActive();
                        && isCameraCompatTreatmentActive();
    }
    }
@@ -1647,17 +1642,13 @@ final class LetterboxUiController {
        if (isHorizontalReachabilityEnabled()) {
        if (isHorizontalReachabilityEnabled()) {
            int letterboxPositionForHorizontalReachability = getLetterboxConfiguration()
            int letterboxPositionForHorizontalReachability = getLetterboxConfiguration()
                    .getLetterboxPositionForHorizontalReachability(
                    .getLetterboxPositionForHorizontalReachability(
                            isDisplayFullScreenAndInPosture(
                            isDisplayFullScreenAndInPosture(/* isTabletop */ false));
                                    DeviceStateController.DeviceState.HALF_FOLDED,
                                    false /* isTabletop */));
            positionToLog = letterboxHorizontalReachabilityPositionToLetterboxPosition(
            positionToLog = letterboxHorizontalReachabilityPositionToLetterboxPosition(
                    letterboxPositionForHorizontalReachability);
                    letterboxPositionForHorizontalReachability);
        } else if (isVerticalReachabilityEnabled()) {
        } else if (isVerticalReachabilityEnabled()) {
            int letterboxPositionForVerticalReachability = getLetterboxConfiguration()
            int letterboxPositionForVerticalReachability = getLetterboxConfiguration()
                    .getLetterboxPositionForVerticalReachability(
                    .getLetterboxPositionForVerticalReachability(
                            isDisplayFullScreenAndInPosture(
                            isDisplayFullScreenAndInPosture(/* isTabletop */ true));
                                    DeviceStateController.DeviceState.HALF_FOLDED,
                                    true /* isTabletop */));
            positionToLog = letterboxVerticalReachabilityPositionToLetterboxPosition(
            positionToLog = letterboxVerticalReachabilityPositionToLetterboxPosition(
                    letterboxPositionForVerticalReachability);
                    letterboxPositionForVerticalReachability);
        }
        }
+15 −0
Original line number Original line Diff line number Diff line
@@ -4483,6 +4483,21 @@ public class SizeCompatTests extends WindowTestsBase {
        assertEquals(expected, actual, DELTA_ASPECT_RATIO_TOLERANCE);
        assertEquals(expected, actual, DELTA_ASPECT_RATIO_TOLERANCE);
    }
    }


    @Test
    public void testPortraitAppInTabletop_notSplitScreen() {
        final int dw = 2400;
        setUpDisplaySizeWithApp(dw, 2000);
        prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT);

        final int initialWidth = mActivity.getBounds().width();

        setFoldablePosture(true /* isHalfFolded */, true /* isTabletop */);

        final int finalWidth = mActivity.getBounds().width();
        assertEquals(initialWidth, finalWidth);
        assertNotEquals(finalWidth, getExpectedSplitSize(dw));
    }

    @Test
    @Test
    public void testUpdateResolvedBoundsHorizontalPosition_bookModeEnabled() {
    public void testUpdateResolvedBoundsHorizontalPosition_bookModeEnabled() {
        // Set up a display in landscape with a fixed-orientation PORTRAIT app
        // Set up a display in landscape with a fixed-orientation PORTRAIT app