Loading core/res/res/values/config.xml +6 −0 Original line number Original line Diff line number Diff line Loading @@ -5176,6 +5176,12 @@ <!-- Whether displaying letterbox education is enabled for letterboxed fullscreen apps. --> <!-- Whether displaying letterbox education is enabled for letterboxed fullscreen apps. --> <bool name="config_letterboxIsEducationEnabled">false</bool> <bool name="config_letterboxIsEducationEnabled">false</bool> <!-- Default min aspect ratio for unresizable apps which is used when an app doesn't specify android:minAspectRatio in accordance with CDD 7.1.1.2 requirement: https://source.android.com/compatibility/12/android-12-cdd#7112_screen_aspect_ratio. An exception will be thrown if the given aspect ratio < 4:3. --> <item name="config_letterboxDefaultMinAspectRatioForUnresizableApps" format="float" type="dimen">1.5</item> <!-- Whether a camera compat controller is enabled to allow the user to apply or revert <!-- Whether a camera compat controller is enabled to allow the user to apply or revert treatment for stretched issues in camera viewfinder. --> treatment for stretched issues in camera viewfinder. --> <bool name="config_isCameraCompatControlForStretchedIssuesEnabled">false</bool> <bool name="config_isCameraCompatControlForStretchedIssuesEnabled">false</bool> Loading core/res/res/values/symbols.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -4395,6 +4395,7 @@ <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="bool" name="config_letterboxIsEducationEnabled" /> <java-symbol type="bool" name="config_letterboxIsEducationEnabled" /> <java-symbol type="dimen" name="config_letterboxDefaultMinAspectRatioForUnresizableApps" /> <java-symbol type="bool" name="config_isCameraCompatControlForStretchedIssuesEnabled" /> <java-symbol type="bool" name="config_isCameraCompatControlForStretchedIssuesEnabled" /> <java-symbol type="bool" name="config_hideDisplayCutoutWithDisplayArea" /> <java-symbol type="bool" name="config_hideDisplayCutoutWithDisplayArea" /> Loading services/core/java/com/android/server/wm/ActivityRecord.java +16 −2 Original line number Original line Diff line number Diff line Loading @@ -7860,7 +7860,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // Vertical position // Vertical position int offsetY = 0; int offsetY = 0; if (parentBounds.height() != screenResolvedBounds.height()) { if (parentBounds.height() != screenResolvedBounds.height()) { if (screenResolvedBounds.height() >= parentAppBounds.height()) { if (screenResolvedBounds.height() >= parentAppBounds.height()) { // If resolved bounds overlap with insets, center within app bounds. // If resolved bounds overlap with insets, center within app bounds. offsetY = getCenterOffset( offsetY = getCenterOffset( Loading Loading @@ -7908,6 +7907,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return mLetterboxBoundsForFixedOrientationAndAspectRatio != null; return mLetterboxBoundsForFixedOrientationAndAspectRatio != null; } } boolean isAspectRatioApplied() { return mIsAspectRatioApplied; } /** /** * Whether this activity is eligible for letterbox eduction. * Whether this activity is eligible for letterbox eduction. * * Loading Loading @@ -8632,7 +8635,18 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A * Returns the min aspect ratio of this activity. * Returns the min aspect ratio of this activity. */ */ private float getMinAspectRatio() { private float getMinAspectRatio() { return info.getMinAspectRatio(getRequestedOrientation()); float infoAspectRatio = info.getMinAspectRatio(getRequestedOrientation()); // Complying with the CDD 7.1.1.2 requirement for unresizble apps: // https://source.android.com/compatibility/12/android-12-cdd#7112_screen_aspect_ratio return infoAspectRatio < 1f && info.resizeMode == RESIZE_MODE_UNRESIZEABLE // TODO(233582832): Consider removing fixed-orientation condition. // Some apps switching from tablet to phone layout at the certain size // threshold. This may lead to flickering on tablets in landscape orientation // if an app sets orientation to portrait dynamically because of aspect ratio // restriction applied here. && getRequestedConfigurationOrientation() != ORIENTATION_UNDEFINED ? mWmService.mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps() : infoAspectRatio; } } /** /** Loading services/core/java/com/android/server/wm/LetterboxConfiguration.java +49 −0 Original line number Original line Diff line number Diff line Loading @@ -37,6 +37,11 @@ final class LetterboxConfiguration { */ */ static final float MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO = 1.0f; static final float MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO = 1.0f; // Min allowed aspect ratio for unresizable apps which is used when an app doesn't specify // android:minAspectRatio in accordance with the CDD 7.1.1.2 requirement: // https://source.android.com/compatibility/12/android-12-cdd#7112_screen_aspect_ratio static final float MIN_UNRESIZABLE_ASPECT_RATIO = 4 / 3f; /** Enum for Letterbox background type. */ /** Enum for Letterbox background type. */ @Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE) @IntDef({LETTERBOX_BACKGROUND_SOLID_COLOR, LETTERBOX_BACKGROUND_APP_COLOR_BACKGROUND, @IntDef({LETTERBOX_BACKGROUND_SOLID_COLOR, LETTERBOX_BACKGROUND_APP_COLOR_BACKGROUND, Loading Loading @@ -104,6 +109,11 @@ final class LetterboxConfiguration { // MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO will be ignored. // MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO will be ignored. private float mFixedOrientationLetterboxAspectRatio; private float mFixedOrientationLetterboxAspectRatio; // Default min aspect ratio for unresizable apps which is used when an app doesn't specify // android:minAspectRatio in accordance with the CDD 7.1.1.2 requirement: // https://source.android.com/compatibility/12/android-12-cdd#7112_screen_aspect_ratio private float mDefaultMinAspectRatioForUnresizableApps; // Corners radius for activities presented in the letterbox mode, values < 0 will be ignored. // Corners radius for activities presented in the letterbox mode, values < 0 will be ignored. private int mLetterboxActivityCornersRadius; private int mLetterboxActivityCornersRadius; Loading Loading @@ -204,6 +214,8 @@ final class LetterboxConfiguration { mLetterboxPositionForVerticalReachability = mDefaultPositionForVerticalReachability; mLetterboxPositionForVerticalReachability = mDefaultPositionForVerticalReachability; mIsEducationEnabled = mContext.getResources().getBoolean( mIsEducationEnabled = mContext.getResources().getBoolean( R.bool.config_letterboxIsEducationEnabled); R.bool.config_letterboxIsEducationEnabled); setDefaultMinAspectRatioForUnresizableApps(mContext.getResources().getFloat( R.dimen.config_letterboxDefaultMinAspectRatioForUnresizableApps)); } } /** /** Loading Loading @@ -232,6 +244,43 @@ final class LetterboxConfiguration { return mFixedOrientationLetterboxAspectRatio; return mFixedOrientationLetterboxAspectRatio; } } /** * Resets the min aspect ratio for unresizable apps which is used when an app doesn't specify * {@code android:minAspectRatio} to {@link * R.dimen.config_letterboxDefaultMinAspectRatioForUnresizableApps}. * * @throws AssertionError if {@link * R.dimen.config_letterboxDefaultMinAspectRatioForUnresizableApps} is < {@link * #MIN_UNRESIZABLE_ASPECT_RATIO}. */ void resetDefaultMinAspectRatioForUnresizableApps() { setDefaultMinAspectRatioForUnresizableApps(mContext.getResources().getFloat( R.dimen.config_letterboxDefaultMinAspectRatioForUnresizableApps)); } /** * Gets the min aspect ratio for unresizable apps which is used when an app doesn't specify * {@code android:minAspectRatio}. */ float getDefaultMinAspectRatioForUnresizableApps() { return mDefaultMinAspectRatioForUnresizableApps; } /** * Overrides the min aspect ratio for unresizable apps which is used when an app doesn't * specify {@code android:minAspectRatio}. * * @throws AssertionError if given value is < {@link #MIN_UNRESIZABLE_ASPECT_RATIO}. */ void setDefaultMinAspectRatioForUnresizableApps(float aspectRatio) { if (aspectRatio < MIN_UNRESIZABLE_ASPECT_RATIO) { throw new AssertionError( "Unexpected min aspect ratio for unresizable apps, it should be <= " + MIN_UNRESIZABLE_ASPECT_RATIO + " but was " + aspectRatio); } mDefaultMinAspectRatioForUnresizableApps = aspectRatio; } /** /** * Overrides corners raidus for activities presented in the letterbox mode. If given value < 0, * Overrides corners raidus for activities presented in the letterbox mode. If given value < 0, * both it and a value of {@link * both it and a value of {@link Loading services/core/java/com/android/server/wm/LetterboxUiController.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -540,6 +540,8 @@ final class LetterboxUiController { pw.println(prefix + " fixedOrientationLetterboxAspectRatio=" pw.println(prefix + " fixedOrientationLetterboxAspectRatio=" + getFixedOrientationLetterboxAspectRatio( + getFixedOrientationLetterboxAspectRatio( mActivityRecord.getParent().getConfiguration())); mActivityRecord.getParent().getConfiguration())); pw.println(prefix + " defaultMinAspectRatioForUnresizableApps=" + mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps()); } } /** /** Loading @@ -556,6 +558,9 @@ final class LetterboxUiController { if (mainWin.isLetterboxedForDisplayCutout()) { if (mainWin.isLetterboxedForDisplayCutout()) { return "DISPLAY_CUTOUT"; return "DISPLAY_CUTOUT"; } } if (mActivityRecord.isAspectRatioApplied()) { return "ASPECT_RATIO"; } return "UNKNOWN_REASON"; return "UNKNOWN_REASON"; } } Loading Loading
core/res/res/values/config.xml +6 −0 Original line number Original line Diff line number Diff line Loading @@ -5176,6 +5176,12 @@ <!-- Whether displaying letterbox education is enabled for letterboxed fullscreen apps. --> <!-- Whether displaying letterbox education is enabled for letterboxed fullscreen apps. --> <bool name="config_letterboxIsEducationEnabled">false</bool> <bool name="config_letterboxIsEducationEnabled">false</bool> <!-- Default min aspect ratio for unresizable apps which is used when an app doesn't specify android:minAspectRatio in accordance with CDD 7.1.1.2 requirement: https://source.android.com/compatibility/12/android-12-cdd#7112_screen_aspect_ratio. An exception will be thrown if the given aspect ratio < 4:3. --> <item name="config_letterboxDefaultMinAspectRatioForUnresizableApps" format="float" type="dimen">1.5</item> <!-- Whether a camera compat controller is enabled to allow the user to apply or revert <!-- Whether a camera compat controller is enabled to allow the user to apply or revert treatment for stretched issues in camera viewfinder. --> treatment for stretched issues in camera viewfinder. --> <bool name="config_isCameraCompatControlForStretchedIssuesEnabled">false</bool> <bool name="config_isCameraCompatControlForStretchedIssuesEnabled">false</bool> Loading
core/res/res/values/symbols.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -4395,6 +4395,7 @@ <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="bool" name="config_letterboxIsEducationEnabled" /> <java-symbol type="bool" name="config_letterboxIsEducationEnabled" /> <java-symbol type="dimen" name="config_letterboxDefaultMinAspectRatioForUnresizableApps" /> <java-symbol type="bool" name="config_isCameraCompatControlForStretchedIssuesEnabled" /> <java-symbol type="bool" name="config_isCameraCompatControlForStretchedIssuesEnabled" /> <java-symbol type="bool" name="config_hideDisplayCutoutWithDisplayArea" /> <java-symbol type="bool" name="config_hideDisplayCutoutWithDisplayArea" /> Loading
services/core/java/com/android/server/wm/ActivityRecord.java +16 −2 Original line number Original line Diff line number Diff line Loading @@ -7860,7 +7860,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // Vertical position // Vertical position int offsetY = 0; int offsetY = 0; if (parentBounds.height() != screenResolvedBounds.height()) { if (parentBounds.height() != screenResolvedBounds.height()) { if (screenResolvedBounds.height() >= parentAppBounds.height()) { if (screenResolvedBounds.height() >= parentAppBounds.height()) { // If resolved bounds overlap with insets, center within app bounds. // If resolved bounds overlap with insets, center within app bounds. offsetY = getCenterOffset( offsetY = getCenterOffset( Loading Loading @@ -7908,6 +7907,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return mLetterboxBoundsForFixedOrientationAndAspectRatio != null; return mLetterboxBoundsForFixedOrientationAndAspectRatio != null; } } boolean isAspectRatioApplied() { return mIsAspectRatioApplied; } /** /** * Whether this activity is eligible for letterbox eduction. * Whether this activity is eligible for letterbox eduction. * * Loading Loading @@ -8632,7 +8635,18 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A * Returns the min aspect ratio of this activity. * Returns the min aspect ratio of this activity. */ */ private float getMinAspectRatio() { private float getMinAspectRatio() { return info.getMinAspectRatio(getRequestedOrientation()); float infoAspectRatio = info.getMinAspectRatio(getRequestedOrientation()); // Complying with the CDD 7.1.1.2 requirement for unresizble apps: // https://source.android.com/compatibility/12/android-12-cdd#7112_screen_aspect_ratio return infoAspectRatio < 1f && info.resizeMode == RESIZE_MODE_UNRESIZEABLE // TODO(233582832): Consider removing fixed-orientation condition. // Some apps switching from tablet to phone layout at the certain size // threshold. This may lead to flickering on tablets in landscape orientation // if an app sets orientation to portrait dynamically because of aspect ratio // restriction applied here. && getRequestedConfigurationOrientation() != ORIENTATION_UNDEFINED ? mWmService.mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps() : infoAspectRatio; } } /** /** Loading
services/core/java/com/android/server/wm/LetterboxConfiguration.java +49 −0 Original line number Original line Diff line number Diff line Loading @@ -37,6 +37,11 @@ final class LetterboxConfiguration { */ */ static final float MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO = 1.0f; static final float MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO = 1.0f; // Min allowed aspect ratio for unresizable apps which is used when an app doesn't specify // android:minAspectRatio in accordance with the CDD 7.1.1.2 requirement: // https://source.android.com/compatibility/12/android-12-cdd#7112_screen_aspect_ratio static final float MIN_UNRESIZABLE_ASPECT_RATIO = 4 / 3f; /** Enum for Letterbox background type. */ /** Enum for Letterbox background type. */ @Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE) @IntDef({LETTERBOX_BACKGROUND_SOLID_COLOR, LETTERBOX_BACKGROUND_APP_COLOR_BACKGROUND, @IntDef({LETTERBOX_BACKGROUND_SOLID_COLOR, LETTERBOX_BACKGROUND_APP_COLOR_BACKGROUND, Loading Loading @@ -104,6 +109,11 @@ final class LetterboxConfiguration { // MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO will be ignored. // MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO will be ignored. private float mFixedOrientationLetterboxAspectRatio; private float mFixedOrientationLetterboxAspectRatio; // Default min aspect ratio for unresizable apps which is used when an app doesn't specify // android:minAspectRatio in accordance with the CDD 7.1.1.2 requirement: // https://source.android.com/compatibility/12/android-12-cdd#7112_screen_aspect_ratio private float mDefaultMinAspectRatioForUnresizableApps; // Corners radius for activities presented in the letterbox mode, values < 0 will be ignored. // Corners radius for activities presented in the letterbox mode, values < 0 will be ignored. private int mLetterboxActivityCornersRadius; private int mLetterboxActivityCornersRadius; Loading Loading @@ -204,6 +214,8 @@ final class LetterboxConfiguration { mLetterboxPositionForVerticalReachability = mDefaultPositionForVerticalReachability; mLetterboxPositionForVerticalReachability = mDefaultPositionForVerticalReachability; mIsEducationEnabled = mContext.getResources().getBoolean( mIsEducationEnabled = mContext.getResources().getBoolean( R.bool.config_letterboxIsEducationEnabled); R.bool.config_letterboxIsEducationEnabled); setDefaultMinAspectRatioForUnresizableApps(mContext.getResources().getFloat( R.dimen.config_letterboxDefaultMinAspectRatioForUnresizableApps)); } } /** /** Loading Loading @@ -232,6 +244,43 @@ final class LetterboxConfiguration { return mFixedOrientationLetterboxAspectRatio; return mFixedOrientationLetterboxAspectRatio; } } /** * Resets the min aspect ratio for unresizable apps which is used when an app doesn't specify * {@code android:minAspectRatio} to {@link * R.dimen.config_letterboxDefaultMinAspectRatioForUnresizableApps}. * * @throws AssertionError if {@link * R.dimen.config_letterboxDefaultMinAspectRatioForUnresizableApps} is < {@link * #MIN_UNRESIZABLE_ASPECT_RATIO}. */ void resetDefaultMinAspectRatioForUnresizableApps() { setDefaultMinAspectRatioForUnresizableApps(mContext.getResources().getFloat( R.dimen.config_letterboxDefaultMinAspectRatioForUnresizableApps)); } /** * Gets the min aspect ratio for unresizable apps which is used when an app doesn't specify * {@code android:minAspectRatio}. */ float getDefaultMinAspectRatioForUnresizableApps() { return mDefaultMinAspectRatioForUnresizableApps; } /** * Overrides the min aspect ratio for unresizable apps which is used when an app doesn't * specify {@code android:minAspectRatio}. * * @throws AssertionError if given value is < {@link #MIN_UNRESIZABLE_ASPECT_RATIO}. */ void setDefaultMinAspectRatioForUnresizableApps(float aspectRatio) { if (aspectRatio < MIN_UNRESIZABLE_ASPECT_RATIO) { throw new AssertionError( "Unexpected min aspect ratio for unresizable apps, it should be <= " + MIN_UNRESIZABLE_ASPECT_RATIO + " but was " + aspectRatio); } mDefaultMinAspectRatioForUnresizableApps = aspectRatio; } /** /** * Overrides corners raidus for activities presented in the letterbox mode. If given value < 0, * Overrides corners raidus for activities presented in the letterbox mode. If given value < 0, * both it and a value of {@link * both it and a value of {@link Loading
services/core/java/com/android/server/wm/LetterboxUiController.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -540,6 +540,8 @@ final class LetterboxUiController { pw.println(prefix + " fixedOrientationLetterboxAspectRatio=" pw.println(prefix + " fixedOrientationLetterboxAspectRatio=" + getFixedOrientationLetterboxAspectRatio( + getFixedOrientationLetterboxAspectRatio( mActivityRecord.getParent().getConfiguration())); mActivityRecord.getParent().getConfiguration())); pw.println(prefix + " defaultMinAspectRatioForUnresizableApps=" + mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps()); } } /** /** Loading @@ -556,6 +558,9 @@ final class LetterboxUiController { if (mainWin.isLetterboxedForDisplayCutout()) { if (mainWin.isLetterboxedForDisplayCutout()) { return "DISPLAY_CUTOUT"; return "DISPLAY_CUTOUT"; } } if (mActivityRecord.isAspectRatioApplied()) { return "ASPECT_RATIO"; } return "UNKNOWN_REASON"; return "UNKNOWN_REASON"; } } Loading