Loading core/java/android/window/DesktopModeFlags.java +19 −17 Original line number Diff line number Diff line Loading @@ -148,28 +148,22 @@ public enum DesktopModeFlags { return isFlagTrue(mFlagFunction, mShouldOverrideByDevOption); } public static boolean isDesktopModeForcedEnabled() { return getToggleOverride() == ToggleOverride.OVERRIDE_ON; } private static boolean isFlagTrue(BooleanSupplier flagFunction, boolean shouldOverrideByDevOption) { if (!shouldOverrideByDevOption) return flagFunction.getAsBoolean(); if (Flags.showDesktopExperienceDevOption()) { return switch (getToggleOverride(null)) { return switch (getToggleOverride()) { case OVERRIDE_UNSET, OVERRIDE_OFF -> flagFunction.getAsBoolean(); case OVERRIDE_ON -> true; }; } if (Flags.showDesktopWindowingDevOption()) { Application application = ActivityThread.currentApplication(); if (application == null) { Log.w(TAG, "Could not get the current application."); return flagFunction.getAsBoolean(); } ContentResolver contentResolver = application.getContentResolver(); if (contentResolver == null) { Log.w(TAG, "Could not get the content resolver for the application."); return flagFunction.getAsBoolean(); } boolean shouldToggleBeEnabledByDefault = Flags.enableDesktopWindowingMode(); return switch (getToggleOverride(contentResolver)) { return switch (getToggleOverride()) { case OVERRIDE_UNSET -> flagFunction.getAsBoolean(); // When toggle override matches its default state, don't override flags. This // helps users reset their feature overrides. Loading @@ -180,14 +174,13 @@ public enum DesktopModeFlags { return flagFunction.getAsBoolean(); } private static ToggleOverride getToggleOverride(@Nullable ContentResolver contentResolver) { private static ToggleOverride getToggleOverride() { // If cached, return it if (sCachedToggleOverride != null) { return sCachedToggleOverride; } // Otherwise, fetch and cache it ToggleOverride override = getToggleOverrideFromSystem(contentResolver); ToggleOverride override = getToggleOverrideFromSystem(); sCachedToggleOverride = override; Log.d(TAG, "Toggle override initialized to: " + override); return override; Loading @@ -196,8 +189,7 @@ public enum DesktopModeFlags { /** * Returns {@link ToggleOverride} from Settings.Global set by toggle. */ private static ToggleOverride getToggleOverrideFromSystem( @Nullable ContentResolver contentResolver) { private static ToggleOverride getToggleOverrideFromSystem() { int settingValue; if (Flags.showDesktopExperienceDevOption()) { settingValue = SystemProperties.getInt( Loading @@ -205,6 +197,16 @@ public enum DesktopModeFlags { ToggleOverride.OVERRIDE_UNSET.getSetting() ); } else { final Application application = ActivityThread.currentApplication(); if (application == null) { Log.w(TAG, "Could not get the current application."); return ToggleOverride.OVERRIDE_UNSET; } final ContentResolver contentResolver = application.getContentResolver(); if (contentResolver == null) { Log.w(TAG, "Could not get the content resolver for the application."); return ToggleOverride.OVERRIDE_UNSET; } settingValue = Settings.Global.getInt( contentResolver, Settings.Global.DEVELOPMENT_OVERRIDE_DESKTOP_MODE_FEATURES, Loading core/java/android/window/flags/lse_desktop_experience.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -600,3 +600,13 @@ flag { description: "Enables split screen on non default displays" bug: "384999213" } flag { name: "enable_desktop_mode_through_dev_option" namespace: "lse_desktop_experience" description: "Enables support for desktop mode through developer options for devices eligible for desktop mode." bug: "382238347" metadata { purpose: PURPOSE_BUGFIX } } core/res/res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -7245,6 +7245,9 @@ <!-- Whether desktop mode is supported on the current device --> <bool name="config_isDesktopModeSupported">false</bool> <!-- Whether the developer option for desktop mode is supported on the current device --> <bool name="config_isDesktopModeDevOptionSupported">false</bool> <!-- Maximum number of active tasks on a given Desktop Windowing session. Set to 0 for unlimited. --> <integer name="config_maxDesktopWindowingActiveTasks">0</integer> Loading core/res/res/values/symbols.xml +3 −0 Original line number Diff line number Diff line Loading @@ -5709,6 +5709,9 @@ <!-- Whether desktop mode is supported on the current device --> <java-symbol type="bool" name="config_isDesktopModeSupported" /> <!-- Whether the developer option for desktop mode is supported on the current device --> <java-symbol type="bool" name="config_isDesktopModeDevOptionSupported" /> <!-- Maximum number of active tasks on a given Desktop Windowing session. Set to 0 for unlimited. --> <java-symbol type="integer" name="config_maxDesktopWindowingActiveTasks"/> Loading libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeStatus.java +36 −6 Original line number Diff line number Diff line Loading @@ -211,11 +211,19 @@ public class DesktopModeStatus { return context.getResources().getBoolean(R.bool.config_isDesktopModeSupported); } /** * Return {@code true} if the current device supports the developer option for desktop mode. */ private static boolean isDesktopModeDevOptionSupported(@NonNull Context context) { return context.getResources().getBoolean(R.bool.config_isDesktopModeDevOptionSupported); } /** * Return {@code true} if desktop mode dev option should be shown on current device */ public static boolean canShowDesktopModeDevOption(@NonNull Context context) { return isDeviceEligibleForDesktopMode(context) && Flags.showDesktopWindowingDevOption(); return isDeviceEligibleForDesktopModeDevOption(context) && Flags.showDesktopWindowingDevOption(); } /** Loading @@ -226,17 +234,25 @@ public class DesktopModeStatus { } /** Returns if desktop mode dev option should be enabled if there is no user override. */ public static boolean shouldDevOptionBeEnabledByDefault() { return Flags.enableDesktopWindowingMode(); public static boolean shouldDevOptionBeEnabledByDefault(Context context) { return isDeviceEligibleForDesktopMode(context) && Flags.enableDesktopWindowingMode(); } /** * Return {@code true} if desktop mode is enabled and can be entered on the current device. */ public static boolean canEnterDesktopMode(@NonNull Context context) { if (!isDeviceEligibleForDesktopMode(context)) return false; return (isDeviceEligibleForDesktopMode(context) && DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_MODE.isTrue()) || isDesktopModeEnabledByDevOption(context); } return DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_MODE.isTrue(); /** * Check if Desktop mode should be enabled because the dev option is shown and enabled. */ private static boolean isDesktopModeEnabledByDevOption(@NonNull Context context) { return DesktopModeFlags.isDesktopModeForcedEnabled() && canShowDesktopModeDevOption(context); } /** Loading Loading @@ -298,7 +314,21 @@ public class DesktopModeStatus { * Return {@code true} if desktop mode is unrestricted and is supported in the device. */ public static boolean isDeviceEligibleForDesktopMode(@NonNull Context context) { return !enforceDeviceRestrictions() || isDesktopModeSupported(context); return !enforceDeviceRestrictions() || isDesktopModeSupported(context) || ( Flags.enableDesktopModeThroughDevOption() && isDesktopModeDevOptionSupported( context)); } /** * Return {@code true} if the developer option for desktop mode is unrestricted and is supported * in the device. * * Note that, if {@link #isDeviceEligibleForDesktopMode(Context)} is true, then * {@link #isDeviceEligibleForDesktopModeDevOption(Context)} is also true. */ private static boolean isDeviceEligibleForDesktopModeDevOption(@NonNull Context context) { return !enforceDeviceRestrictions() || isDesktopModeSupported(context) || isDesktopModeDevOptionSupported(context); } /** Loading Loading
core/java/android/window/DesktopModeFlags.java +19 −17 Original line number Diff line number Diff line Loading @@ -148,28 +148,22 @@ public enum DesktopModeFlags { return isFlagTrue(mFlagFunction, mShouldOverrideByDevOption); } public static boolean isDesktopModeForcedEnabled() { return getToggleOverride() == ToggleOverride.OVERRIDE_ON; } private static boolean isFlagTrue(BooleanSupplier flagFunction, boolean shouldOverrideByDevOption) { if (!shouldOverrideByDevOption) return flagFunction.getAsBoolean(); if (Flags.showDesktopExperienceDevOption()) { return switch (getToggleOverride(null)) { return switch (getToggleOverride()) { case OVERRIDE_UNSET, OVERRIDE_OFF -> flagFunction.getAsBoolean(); case OVERRIDE_ON -> true; }; } if (Flags.showDesktopWindowingDevOption()) { Application application = ActivityThread.currentApplication(); if (application == null) { Log.w(TAG, "Could not get the current application."); return flagFunction.getAsBoolean(); } ContentResolver contentResolver = application.getContentResolver(); if (contentResolver == null) { Log.w(TAG, "Could not get the content resolver for the application."); return flagFunction.getAsBoolean(); } boolean shouldToggleBeEnabledByDefault = Flags.enableDesktopWindowingMode(); return switch (getToggleOverride(contentResolver)) { return switch (getToggleOverride()) { case OVERRIDE_UNSET -> flagFunction.getAsBoolean(); // When toggle override matches its default state, don't override flags. This // helps users reset their feature overrides. Loading @@ -180,14 +174,13 @@ public enum DesktopModeFlags { return flagFunction.getAsBoolean(); } private static ToggleOverride getToggleOverride(@Nullable ContentResolver contentResolver) { private static ToggleOverride getToggleOverride() { // If cached, return it if (sCachedToggleOverride != null) { return sCachedToggleOverride; } // Otherwise, fetch and cache it ToggleOverride override = getToggleOverrideFromSystem(contentResolver); ToggleOverride override = getToggleOverrideFromSystem(); sCachedToggleOverride = override; Log.d(TAG, "Toggle override initialized to: " + override); return override; Loading @@ -196,8 +189,7 @@ public enum DesktopModeFlags { /** * Returns {@link ToggleOverride} from Settings.Global set by toggle. */ private static ToggleOverride getToggleOverrideFromSystem( @Nullable ContentResolver contentResolver) { private static ToggleOverride getToggleOverrideFromSystem() { int settingValue; if (Flags.showDesktopExperienceDevOption()) { settingValue = SystemProperties.getInt( Loading @@ -205,6 +197,16 @@ public enum DesktopModeFlags { ToggleOverride.OVERRIDE_UNSET.getSetting() ); } else { final Application application = ActivityThread.currentApplication(); if (application == null) { Log.w(TAG, "Could not get the current application."); return ToggleOverride.OVERRIDE_UNSET; } final ContentResolver contentResolver = application.getContentResolver(); if (contentResolver == null) { Log.w(TAG, "Could not get the content resolver for the application."); return ToggleOverride.OVERRIDE_UNSET; } settingValue = Settings.Global.getInt( contentResolver, Settings.Global.DEVELOPMENT_OVERRIDE_DESKTOP_MODE_FEATURES, Loading
core/java/android/window/flags/lse_desktop_experience.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -600,3 +600,13 @@ flag { description: "Enables split screen on non default displays" bug: "384999213" } flag { name: "enable_desktop_mode_through_dev_option" namespace: "lse_desktop_experience" description: "Enables support for desktop mode through developer options for devices eligible for desktop mode." bug: "382238347" metadata { purpose: PURPOSE_BUGFIX } }
core/res/res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -7245,6 +7245,9 @@ <!-- Whether desktop mode is supported on the current device --> <bool name="config_isDesktopModeSupported">false</bool> <!-- Whether the developer option for desktop mode is supported on the current device --> <bool name="config_isDesktopModeDevOptionSupported">false</bool> <!-- Maximum number of active tasks on a given Desktop Windowing session. Set to 0 for unlimited. --> <integer name="config_maxDesktopWindowingActiveTasks">0</integer> Loading
core/res/res/values/symbols.xml +3 −0 Original line number Diff line number Diff line Loading @@ -5709,6 +5709,9 @@ <!-- Whether desktop mode is supported on the current device --> <java-symbol type="bool" name="config_isDesktopModeSupported" /> <!-- Whether the developer option for desktop mode is supported on the current device --> <java-symbol type="bool" name="config_isDesktopModeDevOptionSupported" /> <!-- Maximum number of active tasks on a given Desktop Windowing session. Set to 0 for unlimited. --> <java-symbol type="integer" name="config_maxDesktopWindowingActiveTasks"/> Loading
libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeStatus.java +36 −6 Original line number Diff line number Diff line Loading @@ -211,11 +211,19 @@ public class DesktopModeStatus { return context.getResources().getBoolean(R.bool.config_isDesktopModeSupported); } /** * Return {@code true} if the current device supports the developer option for desktop mode. */ private static boolean isDesktopModeDevOptionSupported(@NonNull Context context) { return context.getResources().getBoolean(R.bool.config_isDesktopModeDevOptionSupported); } /** * Return {@code true} if desktop mode dev option should be shown on current device */ public static boolean canShowDesktopModeDevOption(@NonNull Context context) { return isDeviceEligibleForDesktopMode(context) && Flags.showDesktopWindowingDevOption(); return isDeviceEligibleForDesktopModeDevOption(context) && Flags.showDesktopWindowingDevOption(); } /** Loading @@ -226,17 +234,25 @@ public class DesktopModeStatus { } /** Returns if desktop mode dev option should be enabled if there is no user override. */ public static boolean shouldDevOptionBeEnabledByDefault() { return Flags.enableDesktopWindowingMode(); public static boolean shouldDevOptionBeEnabledByDefault(Context context) { return isDeviceEligibleForDesktopMode(context) && Flags.enableDesktopWindowingMode(); } /** * Return {@code true} if desktop mode is enabled and can be entered on the current device. */ public static boolean canEnterDesktopMode(@NonNull Context context) { if (!isDeviceEligibleForDesktopMode(context)) return false; return (isDeviceEligibleForDesktopMode(context) && DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_MODE.isTrue()) || isDesktopModeEnabledByDevOption(context); } return DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_MODE.isTrue(); /** * Check if Desktop mode should be enabled because the dev option is shown and enabled. */ private static boolean isDesktopModeEnabledByDevOption(@NonNull Context context) { return DesktopModeFlags.isDesktopModeForcedEnabled() && canShowDesktopModeDevOption(context); } /** Loading Loading @@ -298,7 +314,21 @@ public class DesktopModeStatus { * Return {@code true} if desktop mode is unrestricted and is supported in the device. */ public static boolean isDeviceEligibleForDesktopMode(@NonNull Context context) { return !enforceDeviceRestrictions() || isDesktopModeSupported(context); return !enforceDeviceRestrictions() || isDesktopModeSupported(context) || ( Flags.enableDesktopModeThroughDevOption() && isDesktopModeDevOptionSupported( context)); } /** * Return {@code true} if the developer option for desktop mode is unrestricted and is supported * in the device. * * Note that, if {@link #isDeviceEligibleForDesktopMode(Context)} is true, then * {@link #isDeviceEligibleForDesktopModeDevOption(Context)} is also true. */ private static boolean isDeviceEligibleForDesktopModeDevOption(@NonNull Context context) { return !enforceDeviceRestrictions() || isDesktopModeSupported(context) || isDesktopModeDevOptionSupported(context); } /** Loading