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

Commit a7e27ab0 authored by Graciela Wissen Putri's avatar Graciela Wissen Putri
Browse files

Only check letterbox position in book mode

Don't resize app only when device is in half-folded book mode state and
app is centered - this will fix and allow app to resize to split screen
size in tabletop mode again.

Fix: 274983420
Test: atest WmTests:SizeCompatTests
Change-Id: Iad48912a06174354be1ed450c04b967ae379daaf
parent e3ae617c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -53,6 +53,9 @@ final class LetterboxConfiguration {
     */
    static final float MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO = 1.0f;

    /** Letterboxed app window position multiplier indicating center position. */
    static final float LETTERBOX_POSITION_MULTIPLIER_CENTER = 0.5f;

    /** Enum for Letterbox background type. */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef({LETTERBOX_BACKGROUND_SOLID_COLOR, LETTERBOX_BACKGROUND_APP_COLOR_BACKGROUND,
+14 −6
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_BACKGROUND_
import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_HORIZONTAL_REACHABILITY_POSITION_CENTER;
import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_HORIZONTAL_REACHABILITY_POSITION_LEFT;
import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_HORIZONTAL_REACHABILITY_POSITION_RIGHT;
import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_POSITION_MULTIPLIER_CENTER;
import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_VERTICAL_REACHABILITY_POSITION_BOTTOM;
import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_VERTICAL_REACHABILITY_POSITION_CENTER;
import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_VERTICAL_REACHABILITY_POSITION_TOP;
@@ -932,9 +933,16 @@ final class LetterboxUiController {
    }

    private boolean shouldUseSplitScreenAspectRatio(@NonNull Configuration parentConfiguration) {
        return isDisplayFullScreenAndSeparatingHinge()
                // Don't resize to split screen size when half folded and centered
                && getHorizontalPositionMultiplier(parentConfiguration) != 0.5f
        final boolean isBookMode = isDisplayFullScreenAndInPosture(
                DeviceStateController.DeviceState.HALF_FOLDED,
                /* isTabletop */ false);
        final boolean isNotCenteredHorizontally = getHorizontalPositionMultiplier(
                parentConfiguration) != LETTERBOX_POSITION_MULTIPLIER_CENTER;
        final boolean isTabletopMode = isDisplayFullScreenAndInPosture(
                DeviceStateController.DeviceState.HALF_FOLDED,
                /* isTabletop */ true);
        // Don't resize to split screen size when in book mode if letterbox position is centered
        return ((isBookMode && isNotCenteredHorizontally) || isTabletopMode)
                    || isCameraCompatSplitScreenAspectRatioAllowed()
                        && isCameraCompatTreatmentActive();
    }
@@ -996,7 +1004,7 @@ final class LetterboxUiController {

    @LetterboxConfiguration.LetterboxHorizontalReachabilityPosition
    int getLetterboxPositionForHorizontalReachability() {
        final boolean isInFullScreenBookMode = isDisplayFullScreenAndSeparatingHinge();
        final boolean isInFullScreenBookMode = isFullScreenAndBookModeEnabled();
        return mLetterboxConfiguration.getLetterboxPositionForHorizontalReachability(
                isInFullScreenBookMode);
    }
+22 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ import static com.android.server.wm.ActivityRecord.State.RESTARTING_PROCESS;
import static com.android.server.wm.ActivityRecord.State.RESUMED;
import static com.android.server.wm.ActivityRecord.State.STOPPED;
import static com.android.server.wm.DisplayContent.IME_TARGET_LAYERING;
import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_POSITION_MULTIPLIER_CENTER;
import static com.android.server.wm.WindowContainer.POSITION_TOP;

import static com.google.common.truth.Truth.assertThat;
@@ -3770,6 +3771,27 @@ public class SizeCompatTests extends WindowTestsBase {
        assertEquals(letterboxNoFold, mActivity.getBounds());
    }

    @Test
    public void testGetFixedOrientationLetterboxAspectRatio_tabletop_centered() {
        // Set up a display in portrait with a fixed-orientation LANDSCAPE app
        setUpDisplaySizeWithApp(1400, 2800);
        mWm.mLetterboxConfiguration.setLetterboxHorizontalPositionMultiplier(
                LETTERBOX_POSITION_MULTIPLIER_CENTER);
        mActivity.mWmService.mLetterboxConfiguration.setLetterboxVerticalPositionMultiplier(
                1.0f /*letterboxVerticalPositionMultiplier*/);
        prepareUnresizable(mActivity, SCREEN_ORIENTATION_LANDSCAPE);

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

        Configuration parentConfig = mActivity.getParent().getConfiguration();

        float actual = mActivity.mLetterboxUiController
                .getFixedOrientationLetterboxAspectRatio(parentConfig);
        float expected = mActivity.mLetterboxUiController.getSplitScreenAspectRatio();

        assertEquals(expected, actual, 0.01);
    }

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