From 0716736daae50b58b35c7ffdb6b9c2d00fea6009 Mon Sep 17 00:00:00 2001 From: Massimo Carli Date: Fri, 16 Jun 2023 17:55:44 +0000 Subject: [PATCH] [1/n] Add build and runtime flags to guard user aspect ratio settings Introduces config_appCompatUserAppAspectRatioSettingsIsEnabled as a build time flag and "enable_app_compat_user_aspect_ratio_settings" as runtime flag to guard user aspect ratio settings. Fix: 287448178 Test: atest WmTests:LetterboxConfigurationTest Change-Id: Ic742a325891c7bf07ddb95a633b2db38dfa5f241 --- core/res/res/values/config.xml | 3 +++ core/res/res/values/symbols.xml | 9 ++++++--- .../server/wm/LetterboxConfiguration.java | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index e643240932f1e..f27535c65fe49 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -5702,6 +5702,9 @@ TODO(b/255532890) Enable when ignoreOrientationRequest is set --> false + + false + diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 11f50dfdf84b8..2e5da33537526 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -4430,9 +4430,6 @@ - - - @@ -4528,6 +4525,12 @@ + + + + + + diff --git a/services/core/java/com/android/server/wm/LetterboxConfiguration.java b/services/core/java/com/android/server/wm/LetterboxConfiguration.java index 09cd6a5aa688d..fd4d0405e2985 100644 --- a/services/core/java/com/android/server/wm/LetterboxConfiguration.java +++ b/services/core/java/com/android/server/wm/LetterboxConfiguration.java @@ -78,6 +78,13 @@ final class LetterboxConfiguration { private static final boolean DEFAULT_VALUE_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY = true; + // Whether per-app user aspect ratio override settings is enabled + private static final String KEY_ENABLE_USER_ASPECT_RATIO_SETTINGS = + "enable_app_compat_user_aspect_ratio_settings"; + + // TODO(b/288142656): Enable user aspect ratio settings by default. + private static final boolean DEFAULT_VALUE_ENABLE_USER_ASPECT_RATIO_SETTINGS = false; + /** * Override of aspect ratio for fixed orientation letterboxing that is set via ADB with * set-fixed-orientation-letterbox-aspect-ratio or via {@link @@ -345,6 +352,10 @@ final class LetterboxConfiguration { DEFAULT_VALUE_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY, mContext.getResources().getBoolean( R.bool.config_letterboxIsEnabledForTranslucentActivities)) + .addDeviceConfigEntry(KEY_ENABLE_USER_ASPECT_RATIO_SETTINGS, + DEFAULT_VALUE_ENABLE_USER_ASPECT_RATIO_SETTINGS, + mContext.getResources().getBoolean( + R.bool.config_appCompatUserAppAspectRatioSettingsIsEnabled)) .build(); } @@ -1207,4 +1218,11 @@ final class LetterboxConfiguration { boolean isDisplayRotationImmersiveAppCompatPolicyEnabled() { return mDeviceConfig.getFlagValue(KEY_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY); } + + /** + * Whether per-app user aspect ratio override settings is enabled + */ + boolean isUserAppAspectRatioSettingsEnabled() { + return mDeviceConfig.getFlagValue(KEY_ENABLE_USER_ASPECT_RATIO_SETTINGS); + } }