summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/wm/LetterboxConfiguration.java3
-rw-r--r--services/core/java/com/android/server/wm/LetterboxUiController.java20
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java22
3 files changed, 39 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/wm/LetterboxConfiguration.java b/services/core/java/com/android/server/wm/LetterboxConfiguration.java
index 611cbc78865d..6936a2dcba19 100644
--- a/services/core/java/com/android/server/wm/LetterboxConfiguration.java
+++ b/services/core/java/com/android/server/wm/LetterboxConfiguration.java
@@ -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,
diff --git a/services/core/java/com/android/server/wm/LetterboxUiController.java b/services/core/java/com/android/server/wm/LetterboxUiController.java
index bf2f436b35eb..8075692e63af 100644
--- a/services/core/java/com/android/server/wm/LetterboxUiController.java
+++ b/services/core/java/com/android/server/wm/LetterboxUiController.java
@@ -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,11 +933,18 @@ 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
- || isCameraCompatSplitScreenAspectRatioAllowed()
- && isCameraCompatTreatmentActive();
+ 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();
}
private float getDefaultMinAspectRatioForUnresizableApps() {
@@ -996,7 +1004,7 @@ final class LetterboxUiController {
@LetterboxConfiguration.LetterboxHorizontalReachabilityPosition
int getLetterboxPositionForHorizontalReachability() {
- final boolean isInFullScreenBookMode = isDisplayFullScreenAndSeparatingHinge();
+ final boolean isInFullScreenBookMode = isFullScreenAndBookModeEnabled();
return mLetterboxConfiguration.getLetterboxPositionForHorizontalReachability(
isInFullScreenBookMode);
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
index 4a3f46a567d1..e279145ac3d5 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
@@ -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;
@@ -3771,6 +3772,27 @@ public class SizeCompatTests extends WindowTestsBase {
}
@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
setUpDisplaySizeWithApp(2800, 1400);