Loading core/res/res/values/config.xml +5 −5 Original line number Diff line number Diff line Loading @@ -5180,11 +5180,11 @@ <!-- Whether displaying letterbox education is enabled for letterboxed fullscreen apps. --> <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> <!-- Default min aspect ratio for unresizable apps which are eligible for size compat mode. Values <= 1.0 will be ignored. Activity min/max aspect ratio restrictions will still be espected so this override can control the maximum screen area that can be occupied by the app in the letterbox mode. --> <item name="config_letterboxDefaultMinAspectRatioForUnresizableApps" format="float" type="dimen">0.0</item> <!-- Whether using split screen aspect ratio as a default aspect ratio for unresizable apps. --> <bool name="config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled">false</bool> Loading services/core/java/com/android/server/wm/ActivityRecord.java +2 −13 Original line number Diff line number Diff line Loading @@ -8182,7 +8182,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A resolvedBounds.set(containingBounds); final float letterboxAspectRatioOverride = mWmService.mLetterboxConfiguration.getFixedOrientationLetterboxAspectRatio(); mLetterboxUiController.getFixedOrientationLetterboxAspectRatio(); final float desiredAspectRatio = letterboxAspectRatioOverride > MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO ? letterboxAspectRatioOverride : computeAspectRatio(parentBounds); Loading Loading @@ -8735,18 +8735,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A * Returns the min aspect ratio of this activity. */ private float getMinAspectRatio() { 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 ? mLetterboxUiController.getDefaultMinAspectRatioForUnresizableApps() : infoAspectRatio; return info.getMinAspectRatio(getRequestedOrientation()); } /** Loading services/core/java/com/android/server/wm/LetterboxConfiguration.java +4 −26 Original line number Diff line number Diff line Loading @@ -37,11 +37,6 @@ final class LetterboxConfiguration { */ 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. */ @Retention(RetentionPolicy.SOURCE) @IntDef({LETTERBOX_BACKGROUND_SOLID_COLOR, LETTERBOX_BACKGROUND_APP_COLOR_BACKGROUND, Loading Loading @@ -109,9 +104,7 @@ final class LetterboxConfiguration { // MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO will be ignored. 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 // Default min aspect ratio for unresizable apps that are eligible for the size compat mode. private float mDefaultMinAspectRatioForUnresizableApps; // Corners radius for activities presented in the letterbox mode, values < 0 will be ignored. Loading Loading @@ -250,13 +243,7 @@ final class LetterboxConfiguration { } /** * 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}. * Resets the min aspect ratio for unresizable apps that are eligible for size compat mode. */ void resetDefaultMinAspectRatioForUnresizableApps() { setDefaultMinAspectRatioForUnresizableApps(mContext.getResources().getFloat( Loading @@ -264,25 +251,16 @@ final class LetterboxConfiguration { } /** * Gets the min aspect ratio for unresizable apps which is used when an app doesn't specify * {@code android:minAspectRatio}. * Gets the min aspect ratio for unresizable apps that are eligible for size compat mode. */ 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}. * Overrides the min aspect ratio for unresizable apps that are eligible for size compat mode. */ 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; } Loading services/core/java/com/android/server/wm/LetterboxUiController.java +14 −4 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_BACKGROUND_ import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_BACKGROUND_APP_COLOR_BACKGROUND_FLOATING; import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_BACKGROUND_SOLID_COLOR; import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_BACKGROUND_WALLPAPER; import static com.android.server.wm.LetterboxConfiguration.MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO; import static com.android.server.wm.LetterboxConfiguration.letterboxBackgroundTypeToString; import android.annotation.Nullable; Loading Loading @@ -211,10 +212,19 @@ final class LetterboxUiController { : mLetterboxConfiguration.getLetterboxVerticalPositionMultiplier(); } float getDefaultMinAspectRatioForUnresizableApps() { float getFixedOrientationLetterboxAspectRatio() { return mActivityRecord.shouldCreateCompatDisplayInsets() ? getDefaultMinAspectRatioForUnresizableApps() : mLetterboxConfiguration.getFixedOrientationLetterboxAspectRatio(); } private float getDefaultMinAspectRatioForUnresizableApps() { if (!mLetterboxConfiguration.getIsSplitScreenAspectRatioForUnresizableAppsEnabled() || mActivityRecord.getDisplayContent() == null) { return mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps(); return mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps() > MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO ? mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps() : mLetterboxConfiguration.getFixedOrientationLetterboxAspectRatio(); } int dividerWindowWidth = Loading @@ -226,10 +236,10 @@ final class LetterboxUiController { // Getting the same aspect ratio that apps get in split screen. Rect bounds = new Rect(mActivityRecord.getDisplayContent().getBounds()); if (bounds.width() >= bounds.height()) { bounds.inset(/* dx */ dividerSize, /* dy */ 0); bounds.inset(/* dx */ dividerSize / 2, /* dy */ 0); bounds.right = bounds.centerX(); } else { bounds.inset(/* dx */ 0, /* dy */ dividerSize); bounds.inset(/* dx */ 0, /* dy */ dividerSize / 2); bounds.bottom = bounds.centerY(); } return computeAspectRatio(bounds); Loading services/core/java/com/android/server/wm/WindowManagerShellCommand.java +4 −3 Original line number Diff line number Diff line Loading @@ -1370,9 +1370,10 @@ public class WindowManagerShellCommand extends ShellCommand { pw.println(" be ignored and framework implementation will determine aspect ratio."); pw.println(" --minAspectRatioForUnresizable aspectRatio"); pw.println(" Default min aspect ratio for unresizable apps which is used when an"); pw.println(" app doesn't specify android:minAspectRatio. An exception will be"); pw.println(" thrown if aspectRatio < " + LetterboxConfiguration.MIN_UNRESIZABLE_ASPECT_RATIO); pw.println(" app is eligible for the size compat mode. If aspectRatio <= " + LetterboxConfiguration.MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO); pw.println(" both it and R.dimen.config_fixedOrientationLetterboxAspectRatio will"); pw.println(" be ignored and framework implementation will determine aspect ratio."); pw.println(" --cornerRadius radius"); pw.println(" Corners radius for activities in the letterbox mode. If radius < 0,"); pw.println(" both it and R.integer.config_letterboxActivityCornersRadius will be"); Loading Loading
core/res/res/values/config.xml +5 −5 Original line number Diff line number Diff line Loading @@ -5180,11 +5180,11 @@ <!-- Whether displaying letterbox education is enabled for letterboxed fullscreen apps. --> <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> <!-- Default min aspect ratio for unresizable apps which are eligible for size compat mode. Values <= 1.0 will be ignored. Activity min/max aspect ratio restrictions will still be espected so this override can control the maximum screen area that can be occupied by the app in the letterbox mode. --> <item name="config_letterboxDefaultMinAspectRatioForUnresizableApps" format="float" type="dimen">0.0</item> <!-- Whether using split screen aspect ratio as a default aspect ratio for unresizable apps. --> <bool name="config_letterboxIsSplitScreenAspectRatioForUnresizableAppsEnabled">false</bool> Loading
services/core/java/com/android/server/wm/ActivityRecord.java +2 −13 Original line number Diff line number Diff line Loading @@ -8182,7 +8182,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A resolvedBounds.set(containingBounds); final float letterboxAspectRatioOverride = mWmService.mLetterboxConfiguration.getFixedOrientationLetterboxAspectRatio(); mLetterboxUiController.getFixedOrientationLetterboxAspectRatio(); final float desiredAspectRatio = letterboxAspectRatioOverride > MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO ? letterboxAspectRatioOverride : computeAspectRatio(parentBounds); Loading Loading @@ -8735,18 +8735,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A * Returns the min aspect ratio of this activity. */ private float getMinAspectRatio() { 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 ? mLetterboxUiController.getDefaultMinAspectRatioForUnresizableApps() : infoAspectRatio; return info.getMinAspectRatio(getRequestedOrientation()); } /** Loading
services/core/java/com/android/server/wm/LetterboxConfiguration.java +4 −26 Original line number Diff line number Diff line Loading @@ -37,11 +37,6 @@ final class LetterboxConfiguration { */ 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. */ @Retention(RetentionPolicy.SOURCE) @IntDef({LETTERBOX_BACKGROUND_SOLID_COLOR, LETTERBOX_BACKGROUND_APP_COLOR_BACKGROUND, Loading Loading @@ -109,9 +104,7 @@ final class LetterboxConfiguration { // MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO will be ignored. 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 // Default min aspect ratio for unresizable apps that are eligible for the size compat mode. private float mDefaultMinAspectRatioForUnresizableApps; // Corners radius for activities presented in the letterbox mode, values < 0 will be ignored. Loading Loading @@ -250,13 +243,7 @@ final class LetterboxConfiguration { } /** * 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}. * Resets the min aspect ratio for unresizable apps that are eligible for size compat mode. */ void resetDefaultMinAspectRatioForUnresizableApps() { setDefaultMinAspectRatioForUnresizableApps(mContext.getResources().getFloat( Loading @@ -264,25 +251,16 @@ final class LetterboxConfiguration { } /** * Gets the min aspect ratio for unresizable apps which is used when an app doesn't specify * {@code android:minAspectRatio}. * Gets the min aspect ratio for unresizable apps that are eligible for size compat mode. */ 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}. * Overrides the min aspect ratio for unresizable apps that are eligible for size compat mode. */ 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; } Loading
services/core/java/com/android/server/wm/LetterboxUiController.java +14 −4 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_BACKGROUND_ import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_BACKGROUND_APP_COLOR_BACKGROUND_FLOATING; import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_BACKGROUND_SOLID_COLOR; import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_BACKGROUND_WALLPAPER; import static com.android.server.wm.LetterboxConfiguration.MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO; import static com.android.server.wm.LetterboxConfiguration.letterboxBackgroundTypeToString; import android.annotation.Nullable; Loading Loading @@ -211,10 +212,19 @@ final class LetterboxUiController { : mLetterboxConfiguration.getLetterboxVerticalPositionMultiplier(); } float getDefaultMinAspectRatioForUnresizableApps() { float getFixedOrientationLetterboxAspectRatio() { return mActivityRecord.shouldCreateCompatDisplayInsets() ? getDefaultMinAspectRatioForUnresizableApps() : mLetterboxConfiguration.getFixedOrientationLetterboxAspectRatio(); } private float getDefaultMinAspectRatioForUnresizableApps() { if (!mLetterboxConfiguration.getIsSplitScreenAspectRatioForUnresizableAppsEnabled() || mActivityRecord.getDisplayContent() == null) { return mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps(); return mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps() > MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO ? mLetterboxConfiguration.getDefaultMinAspectRatioForUnresizableApps() : mLetterboxConfiguration.getFixedOrientationLetterboxAspectRatio(); } int dividerWindowWidth = Loading @@ -226,10 +236,10 @@ final class LetterboxUiController { // Getting the same aspect ratio that apps get in split screen. Rect bounds = new Rect(mActivityRecord.getDisplayContent().getBounds()); if (bounds.width() >= bounds.height()) { bounds.inset(/* dx */ dividerSize, /* dy */ 0); bounds.inset(/* dx */ dividerSize / 2, /* dy */ 0); bounds.right = bounds.centerX(); } else { bounds.inset(/* dx */ 0, /* dy */ dividerSize); bounds.inset(/* dx */ 0, /* dy */ dividerSize / 2); bounds.bottom = bounds.centerY(); } return computeAspectRatio(bounds); Loading
services/core/java/com/android/server/wm/WindowManagerShellCommand.java +4 −3 Original line number Diff line number Diff line Loading @@ -1370,9 +1370,10 @@ public class WindowManagerShellCommand extends ShellCommand { pw.println(" be ignored and framework implementation will determine aspect ratio."); pw.println(" --minAspectRatioForUnresizable aspectRatio"); pw.println(" Default min aspect ratio for unresizable apps which is used when an"); pw.println(" app doesn't specify android:minAspectRatio. An exception will be"); pw.println(" thrown if aspectRatio < " + LetterboxConfiguration.MIN_UNRESIZABLE_ASPECT_RATIO); pw.println(" app is eligible for the size compat mode. If aspectRatio <= " + LetterboxConfiguration.MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO); pw.println(" both it and R.dimen.config_fixedOrientationLetterboxAspectRatio will"); pw.println(" be ignored and framework implementation will determine aspect ratio."); pw.println(" --cornerRadius radius"); pw.println(" Corners radius for activities in the letterbox mode. If radius < 0,"); pw.println(" both it and R.integer.config_letterboxActivityCornersRadius will be"); Loading