Merge "Only check letterbox position in book mode" into tm-qpr-dev

This commit is contained in:
Mariia Sandrikova
2023-03-25 02:25:37 +00:00
committed by Android (Google) Code Review
3 changed files with 39 additions and 6 deletions

View File

@@ -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,

View File

@@ -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);
}

View File

@@ -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