Loading services/core/java/com/android/server/wm/LetterboxConfiguration.java +3 −0 Original line number Diff line number Diff line Loading @@ -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, Loading services/core/java/com/android/server/wm/LetterboxUiController.java +14 −6 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); } Loading Loading @@ -996,7 +1004,7 @@ final class LetterboxUiController { @LetterboxConfiguration.LetterboxHorizontalReachabilityPosition int getLetterboxPositionForHorizontalReachability() { final boolean isInFullScreenBookMode = isDisplayFullScreenAndSeparatingHinge(); final boolean isInFullScreenBookMode = isFullScreenAndBookModeEnabled(); return mLetterboxConfiguration.getLetterboxPositionForHorizontalReachability( isInFullScreenBookMode); } Loading services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +22 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading Loading
services/core/java/com/android/server/wm/LetterboxConfiguration.java +3 −0 Original line number Diff line number Diff line Loading @@ -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, Loading
services/core/java/com/android/server/wm/LetterboxUiController.java +14 −6 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); } Loading Loading @@ -996,7 +1004,7 @@ final class LetterboxUiController { @LetterboxConfiguration.LetterboxHorizontalReachabilityPosition int getLetterboxPositionForHorizontalReachability() { final boolean isInFullScreenBookMode = isDisplayFullScreenAndSeparatingHinge(); final boolean isInFullScreenBookMode = isFullScreenAndBookModeEnabled(); return mLetterboxConfiguration.getLetterboxPositionForHorizontalReachability( isInFullScreenBookMode); } Loading
services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +22 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading