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

Commit ca7d53d8 authored by Mariia Sandrikova's avatar Mariia Sandrikova Committed by Automerger Merge Worker
Browse files

Merge "Only check letterbox position in book mode" into tm-qpr-dev am: edc5058b am: ef53043c

parents 9eeb5332 ef53043c
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;
@@ -924,9 +925,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();
    }
@@ -988,7 +996,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;
@@ -3804,6 +3805,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