Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aa527d1b authored by Graciela Wissen Putri's avatar Graciela Wissen Putri
Browse files

[1/n] Add build and runtime flags for fullscreen option

Introduces config_appCompatUserAppAspectRatioFullscreenIsEnabled as a
build time flag and "enable_app_compat_user_aspect_ratio_fullscreen" as
a runtime flag to guard fullscreen option in user aspect ratio settings.
Can only be enabled if user app aspect ratio settings flag is enabled.

adb shell wm set-letterbox-style --isUserAppAspectRatioFullscreenEnabled
[true|1|false|0]

Bug: 291900454
Test: atest WmTests:LetterboxConfigurationTest
Change-Id: Id7e8aa6a82e79d3e5a8f8ab6855b4d574c01551c
parent de0c58bc
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -5718,6 +5718,9 @@
    <!-- Whether per-app user aspect ratio override settings is enabled -->
    <bool name="config_appCompatUserAppAspectRatioSettingsIsEnabled">false</bool>

    <!-- Whether per-app fullscreen override option is allowed in user aspect ratio settings -->
    <bool name="config_appCompatUserAppAspectRatioFullscreenIsEnabled">false</bool>

    <!-- Whether sending compat fake focus for split screen resumed activities is enabled.
         Needed because some game engines wait to get focus before drawing the content of
         the app which isn't guaranteed by default in multi-window modes. -->
+1 −0
Original line number Diff line number Diff line
@@ -4536,6 +4536,7 @@

  <!-- Whether per-app user aspect ratio override settings is enabled -->
  <java-symbol type="bool" name="config_appCompatUserAppAspectRatioSettingsIsEnabled" />
  <java-symbol type="bool" name="config_appCompatUserAppAspectRatioFullscreenIsEnabled" />

  <java-symbol type="bool" name="config_isCompatFakeFocusEnabled" />
  <java-symbol type="bool" name="config_isWindowManagerCameraCompatTreatmentEnabled" />
+29 −0
Original line number Diff line number Diff line
@@ -85,6 +85,11 @@ final class LetterboxConfiguration {
    // TODO(b/288142656): Enable user aspect ratio settings by default.
    private static final boolean DEFAULT_VALUE_ENABLE_USER_ASPECT_RATIO_SETTINGS = false;

    // Whether per-app fullscreen user aspect ratio override option is enabled
    private static final String KEY_ENABLE_USER_ASPECT_RATIO_FULLSCREEN =
            "enable_app_compat_user_aspect_ratio_fullscreen";
    private static final boolean DEFAULT_VALUE_ENABLE_USER_ASPECT_RATIO_FULLSCREEN = true;

    // Whether the letterbox wallpaper style is enabled by default
    private static final String KEY_ENABLE_LETTERBOX_BACKGROUND_WALLPAPER =
            "enable_letterbox_background_wallpaper";
@@ -266,6 +271,9 @@ final class LetterboxConfiguration {
    // Allows to enable user aspect ratio settings ignoring flags.
    private boolean mUserAppAspectRatioSettingsOverrideEnabled;

    // Allows to enable fullscreen option in user aspect ratio settings ignoring flags.
    private boolean mUserAppAspectRatioFullscreenOverrideEnabled;

    // The override for letterbox background type in case it's different from
    // LETTERBOX_BACKGROUND_OVERRIDE_UNSET
    @LetterboxBackgroundType
@@ -379,6 +387,10 @@ final class LetterboxConfiguration {
                                R.bool.config_appCompatUserAppAspectRatioSettingsIsEnabled))
                .addDeviceConfigEntry(KEY_ENABLE_LETTERBOX_BACKGROUND_WALLPAPER,
                        DEFAULT_VALUE_ENABLE_LETTERBOX_BACKGROUND_WALLPAPER, /* enabled */ true)
                .addDeviceConfigEntry(KEY_ENABLE_USER_ASPECT_RATIO_FULLSCREEN,
                        DEFAULT_VALUE_ENABLE_USER_ASPECT_RATIO_FULLSCREEN,
                        mContext.getResources().getBoolean(
                                R.bool.config_appCompatUserAppAspectRatioFullscreenIsEnabled))
                .build();
    }

@@ -1275,4 +1287,21 @@ final class LetterboxConfiguration {
    void resetUserAppAspectRatioSettingsEnabled() {
        setUserAppAspectRatioSettingsOverrideEnabled(false);
    }

    /**
     * Whether fullscreen option in per-app user aspect ratio settings is enabled
     */
    boolean isUserAppAspectRatioFullscreenEnabled() {
        return isUserAppAspectRatioSettingsEnabled()
                && (mUserAppAspectRatioFullscreenOverrideEnabled
                    || mDeviceConfig.getFlagValue(KEY_ENABLE_USER_ASPECT_RATIO_FULLSCREEN));
    }

    void setUserAppAspectRatioFullscreenOverrideEnabled(boolean enabled) {
        mUserAppAspectRatioFullscreenOverrideEnabled = enabled;
    }

    void resetUserAppAspectRatioFullscreenEnabled() {
        setUserAppAspectRatioFullscreenOverrideEnabled(false);
    }
}
+12 −0
Original line number Diff line number Diff line
@@ -1013,6 +1013,10 @@ public class WindowManagerShellCommand extends ShellCommand {
                    runSetBooleanFlag(pw, mLetterboxConfiguration
                            ::setUserAppAspectRatioSettingsOverrideEnabled);
                    break;
                case "--isUserAppAspectRatioFullscreenEnabled":
                    runSetBooleanFlag(pw, mLetterboxConfiguration
                            ::setUserAppAspectRatioFullscreenOverrideEnabled);
                    break;
                case "--isCameraCompatRefreshEnabled":
                    runSetBooleanFlag(pw, mLetterboxConfiguration::setCameraCompatRefreshEnabled);
                    break;
@@ -1093,6 +1097,9 @@ public class WindowManagerShellCommand extends ShellCommand {
                    case "isUserAppAspectRatioSettingsEnabled":
                        mLetterboxConfiguration.resetUserAppAspectRatioSettingsEnabled();
                        break;
                    case "isUserAppAspectRatioFullscreenEnabled":
                        mLetterboxConfiguration.resetUserAppAspectRatioFullscreenEnabled();
                        break;
                    case "isCameraCompatRefreshEnabled":
                        mLetterboxConfiguration.resetCameraCompatRefreshEnabled();
                        break;
@@ -1204,6 +1211,7 @@ public class WindowManagerShellCommand extends ShellCommand {
            mLetterboxConfiguration.resetIsDisplayAspectRatioEnabledForFixedOrientationLetterbox();
            mLetterboxConfiguration.resetTranslucentLetterboxingEnabled();
            mLetterboxConfiguration.resetUserAppAspectRatioSettingsEnabled();
            mLetterboxConfiguration.resetUserAppAspectRatioFullscreenEnabled();
            mLetterboxConfiguration.resetCameraCompatRefreshEnabled();
            mLetterboxConfiguration.resetCameraCompatRefreshCycleThroughStopEnabled();
        }
@@ -1272,6 +1280,8 @@ public class WindowManagerShellCommand extends ShellCommand {
                    + mLetterboxConfiguration.isTranslucentLetterboxingEnabled());
            pw.println("Is the user aspect ratio settings enabled: "
                    + mLetterboxConfiguration.isUserAppAspectRatioSettingsEnabled());
            pw.println("Is the fullscreen option in user aspect ratio settings enabled: "
                    + mLetterboxConfiguration.isUserAppAspectRatioFullscreenEnabled());
        }
        return 0;
    }
@@ -1471,6 +1481,8 @@ public class WindowManagerShellCommand extends ShellCommand {
        pw.println("        Whether letterboxing for translucent activities is enabled.");
        pw.println("      --isUserAppAspectRatioSettingsEnabled [true|1|false|0]");
        pw.println("        Whether user aspect ratio settings are enabled.");
        pw.println("      --isUserAppAspectRatioFullscreenEnabled [true|1|false|0]");
        pw.println("        Whether user aspect ratio fullscreen option is enabled.");
        pw.println("      --isCameraCompatRefreshEnabled [true|1|false|0]");
        pw.println("        Whether camera compatibility refresh is enabled.");
        pw.println("      --isCameraCompatRefreshCycleThroughStopEnabled [true|1|false|0]");