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