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

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

Merge "Disable split screen aspect ratio for portrait apps in tabletop" into 24D1-dev

parents 8834639a 837352b2
Loading
Loading
Loading
Loading
+14 −23
Original line number Diff line number Diff line
@@ -885,13 +885,11 @@ final class LetterboxUiController {
    // 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
    // actually fullscreen.
    private boolean isDisplayFullScreenAndInPosture(DeviceStateController.DeviceState state,
            boolean isTabletop) {
    private boolean isDisplayFullScreenAndInPosture(boolean isTabletop) {
        Task task = mActivityRecord.getTask();
        return mActivityRecord.mDisplayContent != null
                && mActivityRecord.mDisplayContent.getDisplayRotation().isDeviceInPosture(state,
                    isTabletop)
                && task != null
        return mActivityRecord.mDisplayContent != null && task != null
                && mActivityRecord.mDisplayContent.getDisplayRotation().isDeviceInPosture(
                        DeviceStateController.DeviceState.HALF_FOLDED, isTabletop)
                && task.getWindowingMode() == WINDOWING_MODE_FULLSCREEN;
    }

@@ -919,16 +917,14 @@ final class LetterboxUiController {
    }

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

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

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

        // 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()
                        && isCameraCompatTreatmentActive();
    }
@@ -1632,17 +1627,13 @@ final class LetterboxUiController {
        if (isHorizontalReachabilityEnabled()) {
            int letterboxPositionForHorizontalReachability = getLetterboxConfiguration()
                    .getLetterboxPositionForHorizontalReachability(
                            isDisplayFullScreenAndInPosture(
                                    DeviceStateController.DeviceState.HALF_FOLDED,
                                    false /* isTabletop */));
                            isDisplayFullScreenAndInPosture(/* isTabletop */ false));
            positionToLog = letterboxHorizontalReachabilityPositionToLetterboxPosition(
                    letterboxPositionForHorizontalReachability);
        } else if (isVerticalReachabilityEnabled()) {
            int letterboxPositionForVerticalReachability = getLetterboxConfiguration()
                    .getLetterboxPositionForVerticalReachability(
                            isDisplayFullScreenAndInPosture(
                                    DeviceStateController.DeviceState.HALF_FOLDED,
                                    true /* isTabletop */));
                            isDisplayFullScreenAndInPosture(/* isTabletop */ true));
            positionToLog = letterboxVerticalReachabilityPositionToLetterboxPosition(
                    letterboxPositionForVerticalReachability);
        }
+15 −0
Original line number Diff line number Diff line
@@ -4424,6 +4424,21 @@ public class SizeCompatTests extends WindowTestsBase {
        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
    public void testUpdateResolvedBoundsHorizontalPosition_bookModeEnabled() {
        // Set up a display in landscape with a fixed-orientation PORTRAIT app