Merge "Introduce config to use display aspect ratio for letterbox" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e32cf9e75e
@@ -5356,6 +5356,9 @@
|
|||||||
<!-- Whether using split screen aspect ratio as a default aspect ratio for unresizable apps. -->
|
<!-- Whether using split screen aspect ratio as a default aspect ratio for unresizable apps. -->
|
||||||
<bool name="config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled">false</bool>
|
<bool name="config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled">false</bool>
|
||||||
|
|
||||||
|
<!-- Whether using display aspect ratio as a default aspect ratio for all letterboxed apps. -->
|
||||||
|
<bool name="config_letterboxIsDisplayAspectRatioForFixedOrientationLetterboxEnabled">false</bool>
|
||||||
|
|
||||||
<!-- Whether the specific behaviour for translucent activities letterboxing is enabled.
|
<!-- Whether the specific behaviour for translucent activities letterboxing is enabled.
|
||||||
TODO(b/255532890) Enable when ignoreOrientationRequest is set -->
|
TODO(b/255532890) Enable when ignoreOrientationRequest is set -->
|
||||||
<bool name="config_letterboxIsEnabledForTranslucentActivities">false</bool>
|
<bool name="config_letterboxIsEnabledForTranslucentActivities">false</bool>
|
||||||
|
|||||||
@@ -4463,6 +4463,7 @@
|
|||||||
<java-symbol type="bool" name="config_letterboxIsEducationEnabled" />
|
<java-symbol type="bool" name="config_letterboxIsEducationEnabled" />
|
||||||
<java-symbol type="dimen" name="config_letterboxDefaultMinAspectRatioForUnresizableApps" />
|
<java-symbol type="dimen" name="config_letterboxDefaultMinAspectRatioForUnresizableApps" />
|
||||||
<java-symbol type="bool" name="config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled" />
|
<java-symbol type="bool" name="config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled" />
|
||||||
|
<java-symbol type="bool" name="config_letterboxIsDisplayAspectRatioForFixedOrientationLetterboxEnabled" />
|
||||||
<java-symbol type="bool" name="config_isCompatFakeFocusEnabled" />
|
<java-symbol type="bool" name="config_isCompatFakeFocusEnabled" />
|
||||||
<java-symbol type="bool" name="config_isWindowManagerCameraCompatTreatmentEnabled" />
|
<java-symbol type="bool" name="config_isWindowManagerCameraCompatTreatmentEnabled" />
|
||||||
<java-symbol type="bool" name="config_isCameraCompatControlForStretchedIssuesEnabled" />
|
<java-symbol type="bool" name="config_isCameraCompatControlForStretchedIssuesEnabled" />
|
||||||
|
|||||||
@@ -197,6 +197,12 @@ final class LetterboxConfiguration {
|
|||||||
// Whether using split screen aspect ratio as a default aspect ratio for unresizable apps.
|
// Whether using split screen aspect ratio as a default aspect ratio for unresizable apps.
|
||||||
private boolean mIsSplitScreenAspectRatioForUnresizableAppsEnabled;
|
private boolean mIsSplitScreenAspectRatioForUnresizableAppsEnabled;
|
||||||
|
|
||||||
|
// Whether using display aspect ratio as a default aspect ratio for all letterboxed apps.
|
||||||
|
// mIsSplitScreenAspectRatioForUnresizableAppsEnabled and
|
||||||
|
// config_letterboxDefaultMinAspectRatioForUnresizableApps take priority over this for
|
||||||
|
// unresizable apps
|
||||||
|
private boolean mIsDisplayAspectRatioEnabledForFixedOrientationLetterbox;
|
||||||
|
|
||||||
// Whether letterboxing strategy is enabled for translucent activities. If {@value false}
|
// Whether letterboxing strategy is enabled for translucent activities. If {@value false}
|
||||||
// all the feature is disabled
|
// all the feature is disabled
|
||||||
private boolean mTranslucentLetterboxingEnabled;
|
private boolean mTranslucentLetterboxingEnabled;
|
||||||
@@ -288,6 +294,9 @@ final class LetterboxConfiguration {
|
|||||||
R.dimen.config_letterboxDefaultMinAspectRatioForUnresizableApps));
|
R.dimen.config_letterboxDefaultMinAspectRatioForUnresizableApps));
|
||||||
mIsSplitScreenAspectRatioForUnresizableAppsEnabled = mContext.getResources().getBoolean(
|
mIsSplitScreenAspectRatioForUnresizableAppsEnabled = mContext.getResources().getBoolean(
|
||||||
R.bool.config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled);
|
R.bool.config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled);
|
||||||
|
mIsDisplayAspectRatioEnabledForFixedOrientationLetterbox = mContext.getResources()
|
||||||
|
.getBoolean(R.bool
|
||||||
|
.config_letterboxIsDisplayAspectRatioForFixedOrientationLetterboxEnabled);
|
||||||
mTranslucentLetterboxingEnabled = mContext.getResources().getBoolean(
|
mTranslucentLetterboxingEnabled = mContext.getResources().getBoolean(
|
||||||
R.bool.config_letterboxIsEnabledForTranslucentActivities);
|
R.bool.config_letterboxIsEnabledForTranslucentActivities);
|
||||||
mIsCameraCompatTreatmentEnabled = mContext.getResources().getBoolean(
|
mIsCameraCompatTreatmentEnabled = mContext.getResources().getBoolean(
|
||||||
@@ -942,6 +951,13 @@ final class LetterboxConfiguration {
|
|||||||
return mIsSplitScreenAspectRatioForUnresizableAppsEnabled;
|
return mIsSplitScreenAspectRatioForUnresizableAppsEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether using display aspect ratio as a default aspect ratio for all letterboxed apps.
|
||||||
|
*/
|
||||||
|
boolean getIsDisplayAspectRatioEnabledForFixedOrientationLetterbox() {
|
||||||
|
return mIsDisplayAspectRatioEnabledForFixedOrientationLetterbox;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overrides whether using split screen aspect ratio as a default aspect ratio for unresizable
|
* Overrides whether using split screen aspect ratio as a default aspect ratio for unresizable
|
||||||
* apps.
|
* apps.
|
||||||
@@ -950,6 +966,14 @@ final class LetterboxConfiguration {
|
|||||||
mIsSplitScreenAspectRatioForUnresizableAppsEnabled = enabled;
|
mIsSplitScreenAspectRatioForUnresizableAppsEnabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overrides whether using display aspect ratio as a default aspect ratio for all letterboxed
|
||||||
|
* apps.
|
||||||
|
*/
|
||||||
|
void setIsDisplayAspectRatioEnabledForFixedOrientationLetterbox(boolean enabled) {
|
||||||
|
mIsDisplayAspectRatioEnabledForFixedOrientationLetterbox = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets whether using split screen aspect ratio as a default aspect ratio for unresizable
|
* Resets whether using split screen aspect ratio as a default aspect ratio for unresizable
|
||||||
* apps {@link R.bool.config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled}.
|
* apps {@link R.bool.config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled}.
|
||||||
@@ -959,6 +983,16 @@ final class LetterboxConfiguration {
|
|||||||
R.bool.config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled);
|
R.bool.config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets whether using display aspect ratio as a default aspect ratio for all letterboxed
|
||||||
|
* apps {@link R.bool.config_letterboxIsDisplayAspectRatioForFixedOrientationLetterboxEnabled}.
|
||||||
|
*/
|
||||||
|
void resetIsDisplayAspectRatioEnabledForFixedOrientationLetterbox() {
|
||||||
|
mIsDisplayAspectRatioEnabledForFixedOrientationLetterbox = mContext.getResources()
|
||||||
|
.getBoolean(R.bool
|
||||||
|
.config_letterboxIsDisplayAspectRatioForFixedOrientationLetterboxEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
boolean isTranslucentLetterboxingEnabled() {
|
boolean isTranslucentLetterboxingEnabled() {
|
||||||
return mTranslucentLetterboxingOverrideEnabled || (mTranslucentLetterboxingEnabled
|
return mTranslucentLetterboxingOverrideEnabled || (mTranslucentLetterboxingEnabled
|
||||||
&& isTranslucentLetterboxingAllowed());
|
&& isTranslucentLetterboxingAllowed());
|
||||||
|
|||||||
@@ -584,7 +584,7 @@ final class LetterboxUiController {
|
|||||||
? getSplitScreenAspectRatio()
|
? getSplitScreenAspectRatio()
|
||||||
: mActivityRecord.shouldCreateCompatDisplayInsets()
|
: mActivityRecord.shouldCreateCompatDisplayInsets()
|
||||||
? getDefaultMinAspectRatioForUnresizableApps()
|
? getDefaultMinAspectRatioForUnresizableApps()
|
||||||
: mLetterboxConfiguration.getFixedOrientationLetterboxAspectRatio();
|
: getDefaultMinAspectRatio();
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getDefaultMinAspectRatioForUnresizableApps() {
|
private float getDefaultMinAspectRatioForUnresizableApps() {
|
||||||
@@ -593,7 +593,7 @@ final class LetterboxUiController {
|
|||||||
return mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps()
|
return mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps()
|
||||||
> MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO
|
> MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO
|
||||||
? mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps()
|
? mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps()
|
||||||
: mLetterboxConfiguration.getFixedOrientationLetterboxAspectRatio();
|
: getDefaultMinAspectRatio();
|
||||||
}
|
}
|
||||||
|
|
||||||
return getSplitScreenAspectRatio();
|
return getSplitScreenAspectRatio();
|
||||||
@@ -621,6 +621,16 @@ final class LetterboxUiController {
|
|||||||
return computeAspectRatio(bounds);
|
return computeAspectRatio(bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private float getDefaultMinAspectRatio() {
|
||||||
|
final DisplayContent displayContent = mActivityRecord.getDisplayContent();
|
||||||
|
if (displayContent == null
|
||||||
|
|| !mLetterboxConfiguration
|
||||||
|
.getIsDisplayAspectRatioEnabledForFixedOrientationLetterbox()) {
|
||||||
|
return mLetterboxConfiguration.getFixedOrientationLetterboxAspectRatio();
|
||||||
|
}
|
||||||
|
return computeAspectRatio(new Rect(displayContent.getBounds()));
|
||||||
|
}
|
||||||
|
|
||||||
Resources getResources() {
|
Resources getResources() {
|
||||||
return mActivityRecord.mWmService.mContext.getResources();
|
return mActivityRecord.mWmService.mContext.getResources();
|
||||||
}
|
}
|
||||||
@@ -1014,6 +1024,9 @@ final class LetterboxUiController {
|
|||||||
+ mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps());
|
+ mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps());
|
||||||
pw.println(prefix + " isSplitScreenAspectRatioForUnresizableAppsEnabled="
|
pw.println(prefix + " isSplitScreenAspectRatioForUnresizableAppsEnabled="
|
||||||
+ mLetterboxConfiguration.getIsSplitScreenAspectRatioForUnresizableAppsEnabled());
|
+ mLetterboxConfiguration.getIsSplitScreenAspectRatioForUnresizableAppsEnabled());
|
||||||
|
pw.println(prefix + " isDisplayAspectRatioEnabledForFixedOrientationLetterbox="
|
||||||
|
+ mLetterboxConfiguration
|
||||||
|
.getIsDisplayAspectRatioEnabledForFixedOrientationLetterbox());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -955,6 +955,10 @@ public class WindowManagerShellCommand extends ShellCommand {
|
|||||||
runSetBooleanFlag(pw, mLetterboxConfiguration
|
runSetBooleanFlag(pw, mLetterboxConfiguration
|
||||||
::setIsSplitScreenAspectRatioForUnresizableAppsEnabled);
|
::setIsSplitScreenAspectRatioForUnresizableAppsEnabled);
|
||||||
break;
|
break;
|
||||||
|
case "--isDisplayAspectRatioEnabledForFixedOrientationLetterbox":
|
||||||
|
runSetBooleanFlag(pw, mLetterboxConfiguration
|
||||||
|
::setIsDisplayAspectRatioEnabledForFixedOrientationLetterbox);
|
||||||
|
break;
|
||||||
case "--isTranslucentLetterboxingEnabled":
|
case "--isTranslucentLetterboxingEnabled":
|
||||||
runSetBooleanFlag(pw, mLetterboxConfiguration
|
runSetBooleanFlag(pw, mLetterboxConfiguration
|
||||||
::setTranslucentLetterboxingOverrideEnabled);
|
::setTranslucentLetterboxingOverrideEnabled);
|
||||||
@@ -1030,6 +1034,10 @@ public class WindowManagerShellCommand extends ShellCommand {
|
|||||||
mLetterboxConfiguration
|
mLetterboxConfiguration
|
||||||
.resetIsSplitScreenAspectRatioForUnresizableAppsEnabled();
|
.resetIsSplitScreenAspectRatioForUnresizableAppsEnabled();
|
||||||
break;
|
break;
|
||||||
|
case "IsDisplayAspectRatioEnabledForFixedOrientationLetterbox":
|
||||||
|
mLetterboxConfiguration
|
||||||
|
.resetIsDisplayAspectRatioEnabledForFixedOrientationLetterbox();
|
||||||
|
break;
|
||||||
case "isTranslucentLetterboxingEnabled":
|
case "isTranslucentLetterboxingEnabled":
|
||||||
mLetterboxConfiguration.resetTranslucentLetterboxingEnabled();
|
mLetterboxConfiguration.resetTranslucentLetterboxingEnabled();
|
||||||
break;
|
break;
|
||||||
@@ -1140,6 +1148,7 @@ public class WindowManagerShellCommand extends ShellCommand {
|
|||||||
mLetterboxConfiguration.resetDefaultPositionForVerticalReachability();
|
mLetterboxConfiguration.resetDefaultPositionForVerticalReachability();
|
||||||
mLetterboxConfiguration.resetIsEducationEnabled();
|
mLetterboxConfiguration.resetIsEducationEnabled();
|
||||||
mLetterboxConfiguration.resetIsSplitScreenAspectRatioForUnresizableAppsEnabled();
|
mLetterboxConfiguration.resetIsSplitScreenAspectRatioForUnresizableAppsEnabled();
|
||||||
|
mLetterboxConfiguration.resetIsDisplayAspectRatioEnabledForFixedOrientationLetterbox();
|
||||||
mLetterboxConfiguration.resetTranslucentLetterboxingEnabled();
|
mLetterboxConfiguration.resetTranslucentLetterboxingEnabled();
|
||||||
mLetterboxConfiguration.resetCameraCompatRefreshEnabled();
|
mLetterboxConfiguration.resetCameraCompatRefreshEnabled();
|
||||||
mLetterboxConfiguration.resetCameraCompatRefreshCycleThroughStopEnabled();
|
mLetterboxConfiguration.resetCameraCompatRefreshCycleThroughStopEnabled();
|
||||||
@@ -1187,7 +1196,9 @@ public class WindowManagerShellCommand extends ShellCommand {
|
|||||||
pw.println("Is using split screen aspect ratio as aspect ratio for unresizable apps: "
|
pw.println("Is using split screen aspect ratio as aspect ratio for unresizable apps: "
|
||||||
+ mLetterboxConfiguration
|
+ mLetterboxConfiguration
|
||||||
.getIsSplitScreenAspectRatioForUnresizableAppsEnabled());
|
.getIsSplitScreenAspectRatioForUnresizableAppsEnabled());
|
||||||
|
pw.println("Is using display aspect ratio as aspect ratio for all letterboxed apps: "
|
||||||
|
+ mLetterboxConfiguration
|
||||||
|
.getIsDisplayAspectRatioEnabledForFixedOrientationLetterbox());
|
||||||
pw.println(" Is activity \"refresh\" in camera compatibility treatment enabled: "
|
pw.println(" Is activity \"refresh\" in camera compatibility treatment enabled: "
|
||||||
+ mLetterboxConfiguration.isCameraCompatRefreshEnabled());
|
+ mLetterboxConfiguration.isCameraCompatRefreshEnabled());
|
||||||
pw.println(" Refresh using \"stopped -> resumed\" cycle: "
|
pw.println(" Refresh using \"stopped -> resumed\" cycle: "
|
||||||
|
|||||||
@@ -1911,6 +1911,132 @@ public class SizeCompatTests extends WindowTestsBase {
|
|||||||
assertFitted();
|
assertFitted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDisplayAspectRatioForResizablePortraitApps() {
|
||||||
|
// Set up a display in portrait and ignoring orientation request.
|
||||||
|
int displayWidth = 1400;
|
||||||
|
int displayHeight = 1600;
|
||||||
|
setUpDisplaySizeWithApp(displayWidth, displayHeight);
|
||||||
|
mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
|
||||||
|
mWm.mLetterboxConfiguration.setFixedOrientationLetterboxAspectRatio(2f);
|
||||||
|
|
||||||
|
// Enable display aspect ratio to take precedence before
|
||||||
|
// fixedOrientationLetterboxAspectRatio
|
||||||
|
mWm.mLetterboxConfiguration
|
||||||
|
.setIsDisplayAspectRatioEnabledForFixedOrientationLetterbox(true);
|
||||||
|
|
||||||
|
// Set up resizable app in portrait
|
||||||
|
prepareLimitedBounds(mActivity, SCREEN_ORIENTATION_PORTRAIT, false /* isUnresizable */);
|
||||||
|
|
||||||
|
final TestSplitOrganizer organizer =
|
||||||
|
new TestSplitOrganizer(mAtm, mActivity.getDisplayContent());
|
||||||
|
// Move activity to split screen which takes half of the screen.
|
||||||
|
mTask.reparent(organizer.mPrimary, POSITION_TOP, /* moveParents= */ false , "test");
|
||||||
|
organizer.mPrimary.setBounds(0, 0, displayWidth, getExpectedSplitSize(displayHeight));
|
||||||
|
assertEquals(WINDOWING_MODE_MULTI_WINDOW, mTask.getWindowingMode());
|
||||||
|
assertEquals(WINDOWING_MODE_MULTI_WINDOW, mActivity.getWindowingMode());
|
||||||
|
|
||||||
|
// App should launch in fixed orientation letterbox.
|
||||||
|
assertTrue(mActivity.isLetterboxedForFixedOrientationAndAspectRatio());
|
||||||
|
// Checking that there is no size compat mode.
|
||||||
|
assertFitted();
|
||||||
|
// Check that the display aspect ratio is used by the app.
|
||||||
|
final float targetMinAspectRatio = 1f * displayHeight / displayWidth;
|
||||||
|
final float delta = 0.01f;
|
||||||
|
assertEquals(targetMinAspectRatio, ActivityRecord
|
||||||
|
.computeAspectRatio(mActivity.getBounds()), delta);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDisplayAspectRatioForResizableLandscapeApps() {
|
||||||
|
// Set up a display in landscape and ignoring orientation request.
|
||||||
|
int displayWidth = 1600;
|
||||||
|
int displayHeight = 1400;
|
||||||
|
setUpDisplaySizeWithApp(displayWidth, displayHeight);
|
||||||
|
mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
|
||||||
|
mWm.mLetterboxConfiguration.setFixedOrientationLetterboxAspectRatio(2f);
|
||||||
|
|
||||||
|
// Enable display aspect ratio to take precedence before
|
||||||
|
// fixedOrientationLetterboxAspectRatio
|
||||||
|
mWm.mLetterboxConfiguration
|
||||||
|
.setIsDisplayAspectRatioEnabledForFixedOrientationLetterbox(true);
|
||||||
|
|
||||||
|
// Set up resizable app in landscape
|
||||||
|
prepareLimitedBounds(mActivity, SCREEN_ORIENTATION_LANDSCAPE, false /* isUnresizable */);
|
||||||
|
|
||||||
|
final TestSplitOrganizer organizer =
|
||||||
|
new TestSplitOrganizer(mAtm, mActivity.getDisplayContent());
|
||||||
|
// Move activity to split screen which takes half of the screen.
|
||||||
|
mTask.reparent(organizer.mPrimary, POSITION_TOP, /* moveParents= */ false , "test");
|
||||||
|
organizer.mPrimary.setBounds(0, 0, getExpectedSplitSize(displayWidth), displayHeight);
|
||||||
|
assertEquals(WINDOWING_MODE_MULTI_WINDOW, mTask.getWindowingMode());
|
||||||
|
assertEquals(WINDOWING_MODE_MULTI_WINDOW, mActivity.getWindowingMode());
|
||||||
|
|
||||||
|
// App should launch in fixed orientation letterbox.
|
||||||
|
assertTrue(mActivity.isLetterboxedForFixedOrientationAndAspectRatio());
|
||||||
|
// Checking that there is no size compat mode.
|
||||||
|
assertFitted();
|
||||||
|
// Check that the display aspect ratio is used by the app.
|
||||||
|
final float targetMinAspectRatio = 1f * displayWidth / displayHeight;
|
||||||
|
final float delta = 0.01f;
|
||||||
|
assertEquals(targetMinAspectRatio, ActivityRecord
|
||||||
|
.computeAspectRatio(mActivity.getBounds()), delta);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDisplayAspectRatioForUnresizableLandscapeApps() {
|
||||||
|
// Set up a display in portrait and ignoring orientation request.
|
||||||
|
int displayWidth = 1400;
|
||||||
|
int displayHeight = 1600;
|
||||||
|
setUpDisplaySizeWithApp(displayWidth, displayHeight);
|
||||||
|
mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
|
||||||
|
|
||||||
|
mActivity.mWmService.mLetterboxConfiguration.setFixedOrientationLetterboxAspectRatio(1.1f);
|
||||||
|
// Enable display aspect ratio to take precedence before
|
||||||
|
// fixedOrientationLetterboxAspectRatio
|
||||||
|
mWm.mLetterboxConfiguration
|
||||||
|
.setIsDisplayAspectRatioEnabledForFixedOrientationLetterbox(true);
|
||||||
|
|
||||||
|
prepareUnresizable(mActivity, SCREEN_ORIENTATION_LANDSCAPE);
|
||||||
|
|
||||||
|
// App should launch in fixed orientation letterbox.
|
||||||
|
assertTrue(mActivity.isLetterboxedForFixedOrientationAndAspectRatio());
|
||||||
|
// Checking that there is no size compat mode.
|
||||||
|
assertFitted();
|
||||||
|
// Check that the display aspect ratio is used by the app.
|
||||||
|
final float targetMinAspectRatio = 1f * displayHeight / displayWidth;
|
||||||
|
final float delta = 0.01f;
|
||||||
|
assertEquals(targetMinAspectRatio, ActivityRecord
|
||||||
|
.computeAspectRatio(mActivity.getBounds()), delta);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDisplayAspectRatioForUnresizablePortraitApps() {
|
||||||
|
// Set up a display in landscape and ignoring orientation request.
|
||||||
|
int displayWidth = 1600;
|
||||||
|
int displayHeight = 1400;
|
||||||
|
setUpDisplaySizeWithApp(displayWidth, displayHeight);
|
||||||
|
mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
|
||||||
|
|
||||||
|
mActivity.mWmService.mLetterboxConfiguration.setFixedOrientationLetterboxAspectRatio(1.1f);
|
||||||
|
// Enable display aspect ratio to take precedence before
|
||||||
|
// fixedOrientationLetterboxAspectRatio
|
||||||
|
mWm.mLetterboxConfiguration
|
||||||
|
.setIsDisplayAspectRatioEnabledForFixedOrientationLetterbox(true);
|
||||||
|
|
||||||
|
prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT);
|
||||||
|
|
||||||
|
// App should launch in fixed orientation letterbox.
|
||||||
|
assertTrue(mActivity.isLetterboxedForFixedOrientationAndAspectRatio());
|
||||||
|
// Checking that there is no size compat mode.
|
||||||
|
assertFitted();
|
||||||
|
// Check that the display aspect ratio is used by the app.
|
||||||
|
final float targetMinAspectRatio = 1f * displayWidth / displayHeight;
|
||||||
|
final float delta = 0.01f;
|
||||||
|
assertEquals(targetMinAspectRatio, ActivityRecord
|
||||||
|
.computeAspectRatio(mActivity.getBounds()), delta);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void
|
public void
|
||||||
testDisplayIgnoreOrientationRequest_orientationLetterboxBecameSizeCompatAfterRotate() {
|
testDisplayIgnoreOrientationRequest_orientationLetterboxBecameSizeCompatAfterRotate() {
|
||||||
|
|||||||
@@ -253,6 +253,12 @@ class WindowTestsBase extends SystemServiceTestsBase {
|
|||||||
// device form factors.
|
// device form factors.
|
||||||
mAtm.mWindowManager.mLetterboxConfiguration
|
mAtm.mWindowManager.mLetterboxConfiguration
|
||||||
.setIsSplitScreenAspectRatioForUnresizableAppsEnabled(false);
|
.setIsSplitScreenAspectRatioForUnresizableAppsEnabled(false);
|
||||||
|
// Ensure aspect ratio for al apps isn't overridden on any device target.
|
||||||
|
// {@link com.android.internal.R.bool
|
||||||
|
// .config_letterboxIsDisplayAspectRatioForFixedOrientationLetterboxEnabled}, may be set on
|
||||||
|
// some device form factors.
|
||||||
|
mAtm.mWindowManager.mLetterboxConfiguration
|
||||||
|
.setIsDisplayAspectRatioEnabledForFixedOrientationLetterbox(false);
|
||||||
|
|
||||||
checkDeviceSpecificOverridesNotApplied();
|
checkDeviceSpecificOverridesNotApplied();
|
||||||
}
|
}
|
||||||
@@ -267,6 +273,8 @@ class WindowTestsBase extends SystemServiceTestsBase {
|
|||||||
mAtm.mWindowManager.mLetterboxConfiguration.resetIsVerticalReachabilityEnabled();
|
mAtm.mWindowManager.mLetterboxConfiguration.resetIsVerticalReachabilityEnabled();
|
||||||
mAtm.mWindowManager.mLetterboxConfiguration
|
mAtm.mWindowManager.mLetterboxConfiguration
|
||||||
.resetIsSplitScreenAspectRatioForUnresizableAppsEnabled();
|
.resetIsSplitScreenAspectRatioForUnresizableAppsEnabled();
|
||||||
|
mAtm.mWindowManager.mLetterboxConfiguration
|
||||||
|
.resetIsDisplayAspectRatioEnabledForFixedOrientationLetterbox();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user