Merge "Add isAutomaticReachabilityInBookModeEnabled config" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
fe1eb22663
@@ -5333,6 +5333,10 @@
|
||||
<!-- Whether vertical reachability repositioning is allowed for letterboxed fullscreen apps. -->
|
||||
<bool name="config_letterboxIsVerticalReachabilityEnabled">false</bool>
|
||||
|
||||
<!-- Whether book mode automatic horizontal reachability positioning is allowed for letterboxed
|
||||
fullscreen apps -->
|
||||
<bool name="config_letterboxIsAutomaticReachabilityInBookModeEnabled">false</bool>
|
||||
|
||||
<!-- Default horizontal position of the letterboxed app window when reachability is
|
||||
enabled and an app is fullscreen in landscape device orientation. When reachability is
|
||||
enabled, the position can change between left, center and right. This config defines the
|
||||
|
||||
@@ -4475,6 +4475,7 @@
|
||||
<java-symbol type="dimen" name="config_letterboxTabletopModePositionMultiplier" />
|
||||
<java-symbol type="bool" name="config_letterboxIsHorizontalReachabilityEnabled" />
|
||||
<java-symbol type="bool" name="config_letterboxIsVerticalReachabilityEnabled" />
|
||||
<java-symbol type="bool" name="config_letterboxIsAutomaticReachabilityInBookModeEnabled" />
|
||||
<java-symbol type="integer" name="config_letterboxDefaultPositionForHorizontalReachability" />
|
||||
<java-symbol type="integer" name="config_letterboxDefaultPositionForVerticalReachability" />
|
||||
<java-symbol type="integer" name="config_letterboxDefaultPositionForBookModeReachability" />
|
||||
|
||||
@@ -8585,7 +8585,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
resolvedBounds.set(containingBounds);
|
||||
|
||||
final float letterboxAspectRatioOverride =
|
||||
mLetterboxUiController.getFixedOrientationLetterboxAspectRatio();
|
||||
mLetterboxUiController.getFixedOrientationLetterboxAspectRatio(newParentConfig);
|
||||
final float desiredAspectRatio =
|
||||
letterboxAspectRatioOverride > MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO
|
||||
? letterboxAspectRatioOverride : computeAspectRatio(parentBounds);
|
||||
|
||||
@@ -184,6 +184,10 @@ final class LetterboxConfiguration {
|
||||
// portrait device orientation.
|
||||
private boolean mIsVerticalReachabilityEnabled;
|
||||
|
||||
// Whether book mode automatic horizontal reachability positioning is allowed for letterboxed
|
||||
// fullscreen apps in landscape device orientation.
|
||||
private boolean mIsAutomaticReachabilityInBookModeEnabled;
|
||||
|
||||
// Whether education is allowed for letterboxed fullscreen apps.
|
||||
private boolean mIsEducationEnabled;
|
||||
|
||||
@@ -277,6 +281,8 @@ final class LetterboxConfiguration {
|
||||
R.bool.config_letterboxIsHorizontalReachabilityEnabled);
|
||||
mIsVerticalReachabilityEnabled = mContext.getResources().getBoolean(
|
||||
R.bool.config_letterboxIsVerticalReachabilityEnabled);
|
||||
mIsAutomaticReachabilityInBookModeEnabled = mContext.getResources().getBoolean(
|
||||
R.bool.config_letterboxIsAutomaticReachabilityInBookModeEnabled);
|
||||
mDefaultPositionForHorizontalReachability =
|
||||
readLetterboxHorizontalReachabilityPositionFromConfig(mContext, false);
|
||||
mDefaultPositionForVerticalReachability =
|
||||
@@ -681,6 +687,14 @@ final class LetterboxConfiguration {
|
||||
return mIsVerticalReachabilityEnabled;
|
||||
}
|
||||
|
||||
/*
|
||||
* Whether automatic horizontal reachability repositioning in book mode is allowed for
|
||||
* letterboxed fullscreen apps in landscape device orientation.
|
||||
*/
|
||||
boolean getIsAutomaticReachabilityInBookModeEnabled() {
|
||||
return mIsAutomaticReachabilityInBookModeEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides whether horizontal reachability repositioning is allowed for letterboxed fullscreen
|
||||
* apps in landscape device orientation.
|
||||
@@ -697,6 +711,14 @@ final class LetterboxConfiguration {
|
||||
mIsVerticalReachabilityEnabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides whether automatic horizontal reachability repositioning in book mode is allowed for
|
||||
* letterboxed fullscreen apps in landscape device orientation.
|
||||
*/
|
||||
void setIsAutomaticReachabilityInBookModeEnabled(boolean enabled) {
|
||||
mIsAutomaticReachabilityInBookModeEnabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets whether horizontal reachability repositioning is allowed for letterboxed fullscreen
|
||||
* apps in landscape device orientation to
|
||||
@@ -717,6 +739,16 @@ final class LetterboxConfiguration {
|
||||
R.bool.config_letterboxIsVerticalReachabilityEnabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets whether automatic horizontal reachability repositioning in book mode is
|
||||
* allowed for letterboxed fullscreen apps in landscape device orientation to
|
||||
* {@link R.bool.config_letterboxIsAutomaticReachabilityInBookModeEnabled}.
|
||||
*/
|
||||
void resetEnabledAutomaticReachabilityInBookMode() {
|
||||
mIsAutomaticReachabilityInBookModeEnabled = mContext.getResources().getBoolean(
|
||||
R.bool.config_letterboxIsAutomaticReachabilityInBookModeEnabled);
|
||||
}
|
||||
|
||||
/*
|
||||
* Gets default horizontal position of the letterboxed app window when horizontal reachability
|
||||
* is enabled.
|
||||
|
||||
@@ -801,13 +801,18 @@ final class LetterboxUiController {
|
||||
float getHorizontalPositionMultiplier(Configuration parentConfiguration) {
|
||||
// Don't check resolved configuration because it may not be updated yet during
|
||||
// configuration change.
|
||||
boolean bookMode = isDisplayFullScreenAndInPosture(
|
||||
DeviceStateController.DeviceState.HALF_FOLDED, false /* isTabletop */);
|
||||
boolean bookModeEnabled = isFullScreenAndBookModeEnabled();
|
||||
return isHorizontalReachabilityEnabled(parentConfiguration)
|
||||
// Using the last global dynamic position to avoid "jumps" when moving
|
||||
// between apps or activities.
|
||||
? mLetterboxConfiguration.getHorizontalMultiplierForReachability(bookMode)
|
||||
: mLetterboxConfiguration.getLetterboxHorizontalPositionMultiplier(bookMode);
|
||||
? mLetterboxConfiguration.getHorizontalMultiplierForReachability(bookModeEnabled)
|
||||
: mLetterboxConfiguration.getLetterboxHorizontalPositionMultiplier(bookModeEnabled);
|
||||
}
|
||||
|
||||
private boolean isFullScreenAndBookModeEnabled() {
|
||||
return isDisplayFullScreenAndInPosture(
|
||||
DeviceStateController.DeviceState.HALF_FOLDED, false /* isTabletop */)
|
||||
&& mLetterboxConfiguration.getIsAutomaticReachabilityInBookModeEnabled();
|
||||
}
|
||||
|
||||
float getVerticalPositionMultiplier(Configuration parentConfiguration) {
|
||||
@@ -822,12 +827,14 @@ final class LetterboxUiController {
|
||||
: mLetterboxConfiguration.getLetterboxVerticalPositionMultiplier(tabletopMode);
|
||||
}
|
||||
|
||||
float getFixedOrientationLetterboxAspectRatio() {
|
||||
float getFixedOrientationLetterboxAspectRatio(@NonNull Configuration parentConfiguration) {
|
||||
// Don't resize to split screen size when half folded if letterbox position is centered
|
||||
return isDisplayFullScreenAndSeparatingHinge()
|
||||
? getSplitScreenAspectRatio()
|
||||
: mActivityRecord.shouldCreateCompatDisplayInsets()
|
||||
? getDefaultMinAspectRatioForUnresizableApps()
|
||||
: getDefaultMinAspectRatio();
|
||||
&& getHorizontalPositionMultiplier(parentConfiguration) != 0.5f
|
||||
? getSplitScreenAspectRatio()
|
||||
: mActivityRecord.shouldCreateCompatDisplayInsets()
|
||||
? getDefaultMinAspectRatioForUnresizableApps()
|
||||
: getDefaultMinAspectRatio();
|
||||
}
|
||||
|
||||
private float getDefaultMinAspectRatioForUnresizableApps() {
|
||||
@@ -889,7 +896,8 @@ final class LetterboxUiController {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isInFullScreenBookMode = isDisplayFullScreenAndSeparatingHinge();
|
||||
boolean isInFullScreenBookMode = isDisplayFullScreenAndSeparatingHinge()
|
||||
&& mLetterboxConfiguration.getIsAutomaticReachabilityInBookModeEnabled();
|
||||
int letterboxPositionForHorizontalReachability = mLetterboxConfiguration
|
||||
.getLetterboxPositionForHorizontalReachability(isInFullScreenBookMode);
|
||||
if (mLetterbox.getInnerFrame().left > x) {
|
||||
|
||||
@@ -942,6 +942,10 @@ public class WindowManagerShellCommand extends ShellCommand {
|
||||
runSetBooleanFlag(pw, mLetterboxConfiguration
|
||||
::setIsVerticalReachabilityEnabled);
|
||||
break;
|
||||
case "--isAutomaticReachabilityInBookModeEnabled":
|
||||
runSetBooleanFlag(pw, mLetterboxConfiguration
|
||||
::setIsAutomaticReachabilityInBookModeEnabled);
|
||||
break;
|
||||
case "--defaultPositionForHorizontalReachability":
|
||||
runSetLetterboxDefaultPositionForHorizontalReachability(pw);
|
||||
break;
|
||||
@@ -1144,6 +1148,7 @@ public class WindowManagerShellCommand extends ShellCommand {
|
||||
mLetterboxConfiguration.resetLetterboxHorizontalPositionMultiplier();
|
||||
mLetterboxConfiguration.resetIsHorizontalReachabilityEnabled();
|
||||
mLetterboxConfiguration.resetIsVerticalReachabilityEnabled();
|
||||
mLetterboxConfiguration.resetEnabledAutomaticReachabilityInBookMode();
|
||||
mLetterboxConfiguration.resetDefaultPositionForHorizontalReachability();
|
||||
mLetterboxConfiguration.resetDefaultPositionForVerticalReachability();
|
||||
mLetterboxConfiguration.resetIsEducationEnabled();
|
||||
@@ -1179,6 +1184,8 @@ public class WindowManagerShellCommand extends ShellCommand {
|
||||
+ mLetterboxConfiguration.getIsHorizontalReachabilityEnabled());
|
||||
pw.println("Is vertical reachability enabled: "
|
||||
+ mLetterboxConfiguration.getIsVerticalReachabilityEnabled());
|
||||
pw.println("Is automatic reachability in book mode enabled: "
|
||||
+ mLetterboxConfiguration.getIsAutomaticReachabilityInBookModeEnabled());
|
||||
pw.println("Default position for horizontal reachability: "
|
||||
+ LetterboxConfiguration.letterboxHorizontalReachabilityPositionToString(
|
||||
mLetterboxConfiguration.getDefaultPositionForHorizontalReachability()));
|
||||
|
||||
@@ -3664,7 +3664,6 @@ public class SizeCompatTests extends WindowTestsBase {
|
||||
|
||||
@Test
|
||||
public void testUpdateResolvedBoundsVerticalPosition_tabletop() {
|
||||
|
||||
// Set up a display in portrait with a fixed-orientation LANDSCAPE app
|
||||
setUpDisplaySizeWithApp(1400, 2800);
|
||||
mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
|
||||
@@ -3686,16 +3685,15 @@ public class SizeCompatTests extends WindowTestsBase {
|
||||
setFoldablePosture(false /* isHalfFolded */, false /* isTabletop */);
|
||||
|
||||
assertEquals(letterboxNoFold, mActivity.getBounds());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateResolvedBoundsHorizontalPosition_book() {
|
||||
|
||||
public void testUpdateResolvedBoundsHorizontalPosition_bookModeEnabled() {
|
||||
// Set up a display in landscape with a fixed-orientation PORTRAIT app
|
||||
setUpDisplaySizeWithApp(2800, 1400);
|
||||
mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
|
||||
mActivity.mWmService.mLetterboxConfiguration.setLetterboxHorizontalPositionMultiplier(
|
||||
mWm.mLetterboxConfiguration.setIsAutomaticReachabilityInBookModeEnabled(true);
|
||||
mWm.mLetterboxConfiguration.setLetterboxHorizontalPositionMultiplier(
|
||||
1.0f /*letterboxVerticalPositionMultiplier*/);
|
||||
prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT);
|
||||
|
||||
@@ -3713,7 +3711,28 @@ public class SizeCompatTests extends WindowTestsBase {
|
||||
setFoldablePosture(false /* isHalfFolded */, false /* isTabletop */);
|
||||
|
||||
assertEquals(letterboxNoFold, mActivity.getBounds());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateResolvedBoundsHorizontalPosition_bookModeDisabled_centered() {
|
||||
// Set up a display in landscape with a fixed-orientation PORTRAIT app
|
||||
setUpDisplaySizeWithApp(2800, 1400);
|
||||
mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
|
||||
mWm.mLetterboxConfiguration.setLetterboxHorizontalPositionMultiplier(0.5f);
|
||||
prepareUnresizable(mActivity, 1.75f, SCREEN_ORIENTATION_PORTRAIT);
|
||||
|
||||
Rect letterboxNoFold = new Rect(1000, 0, 1800, 1400);
|
||||
assertEquals(letterboxNoFold, mActivity.getBounds());
|
||||
|
||||
// Make the activity full-screen
|
||||
mTask.setWindowingMode(WINDOWING_MODE_FULLSCREEN);
|
||||
|
||||
// Stay centered and bounds don't change
|
||||
setFoldablePosture(true /* isHalfFolded */, false /* isTabletop */);
|
||||
assertEquals(letterboxNoFold, mActivity.getBounds());
|
||||
|
||||
setFoldablePosture(false /* isHalfFolded */, false /* isTabletop */);
|
||||
assertEquals(letterboxNoFold, mActivity.getBounds());
|
||||
}
|
||||
|
||||
private void setFoldablePosture(ActivityRecord activity, boolean isHalfFolded,
|
||||
|
||||
Reference in New Issue
Block a user