Loading libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeFlags.kt +90 −86 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ import com.android.window.flags.Flags * * The class computes whether a Desktop Windowing flag should be enabled by using the aconfig flag * value and the developer option override state (if applicable). **/ */ enum class DesktopModeFlags( // Function called to obtain aconfig flag value. private val flagFunction: () -> Boolean, Loading @@ -49,7 +49,8 @@ enum class DesktopModeFlags( EDGE_DRAG_RESIZE(Flags::enableWindowingEdgeDragResize, true); /** * Determines state of flag based on the actual flag and desktop mode developer option overrides. * Determines state of flag based on the actual flag and desktop mode developer option * overrides. */ fun isEnabled(context: Context): Boolean = if (!Flags.showDesktopWindowingDevOption() || Loading @@ -57,14 +58,16 @@ enum class DesktopModeFlags( context.contentResolver == null) { flagFunction() } else { val shouldToggleBeEnabledByDefault = DesktopModeStatus.shouldDevOptionBeEnabledByDefault() val shouldToggleBeEnabledByDefault = DesktopModeStatus.shouldDevOptionBeEnabledByDefault() when (getToggleOverride(context)) { ToggleOverride.OVERRIDE_UNSET -> flagFunction() // When toggle override matches its default state, don't override flags. This helps users // reset their feature overrides. // When toggle override matches its default state, don't override flags. This helps // users reset their feature overrides. ToggleOverride.OVERRIDE_OFF -> if (shouldToggleBeEnabledByDefault) false else flagFunction() ToggleOverride.OVERRIDE_ON -> if (shouldToggleBeEnabledByDefault) flagFunction() else true ToggleOverride.OVERRIDE_ON -> if (shouldToggleBeEnabledByDefault) flagFunction() else true } } Loading @@ -73,8 +76,8 @@ enum class DesktopModeFlags( cachedToggleOverride ?: run { val override = getToggleOverrideFromSystem(context) // Cache toggle override the first time we encounter context. Override does not change // with context, as context is just used to fetch Settings.Global // Cache toggle override the first time we encounter context. Override does not // change with context, as context is just used to fetch Settings.Global cachedToggleOverride = override Log.d(TAG, "Toggle override initialized to: $override") override Loading Loading @@ -110,8 +113,9 @@ enum class DesktopModeFlags( private const val TAG = "DesktopModeFlags" /** * Local cache for toggle override, which is initialized once on its first access. It needs to * be refreshed only on reboots as overridden state is expected to take effect on reboots. * Local cache for toggle override, which is initialized once on its first access. It needs * to be refreshed only on reboots as overridden state is expected to take effect on * reboots. */ private var cachedToggleOverride: ToggleOverride? = null Loading Loading
libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeFlags.kt +90 −86 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ import com.android.window.flags.Flags * * The class computes whether a Desktop Windowing flag should be enabled by using the aconfig flag * value and the developer option override state (if applicable). **/ */ enum class DesktopModeFlags( // Function called to obtain aconfig flag value. private val flagFunction: () -> Boolean, Loading @@ -49,7 +49,8 @@ enum class DesktopModeFlags( EDGE_DRAG_RESIZE(Flags::enableWindowingEdgeDragResize, true); /** * Determines state of flag based on the actual flag and desktop mode developer option overrides. * Determines state of flag based on the actual flag and desktop mode developer option * overrides. */ fun isEnabled(context: Context): Boolean = if (!Flags.showDesktopWindowingDevOption() || Loading @@ -57,14 +58,16 @@ enum class DesktopModeFlags( context.contentResolver == null) { flagFunction() } else { val shouldToggleBeEnabledByDefault = DesktopModeStatus.shouldDevOptionBeEnabledByDefault() val shouldToggleBeEnabledByDefault = DesktopModeStatus.shouldDevOptionBeEnabledByDefault() when (getToggleOverride(context)) { ToggleOverride.OVERRIDE_UNSET -> flagFunction() // When toggle override matches its default state, don't override flags. This helps users // reset their feature overrides. // When toggle override matches its default state, don't override flags. This helps // users reset their feature overrides. ToggleOverride.OVERRIDE_OFF -> if (shouldToggleBeEnabledByDefault) false else flagFunction() ToggleOverride.OVERRIDE_ON -> if (shouldToggleBeEnabledByDefault) flagFunction() else true ToggleOverride.OVERRIDE_ON -> if (shouldToggleBeEnabledByDefault) flagFunction() else true } } Loading @@ -73,8 +76,8 @@ enum class DesktopModeFlags( cachedToggleOverride ?: run { val override = getToggleOverrideFromSystem(context) // Cache toggle override the first time we encounter context. Override does not change // with context, as context is just used to fetch Settings.Global // Cache toggle override the first time we encounter context. Override does not // change with context, as context is just used to fetch Settings.Global cachedToggleOverride = override Log.d(TAG, "Toggle override initialized to: $override") override Loading Loading @@ -110,8 +113,9 @@ enum class DesktopModeFlags( private const val TAG = "DesktopModeFlags" /** * Local cache for toggle override, which is initialized once on its first access. It needs to * be refreshed only on reboots as overridden state is expected to take effect on reboots. * Local cache for toggle override, which is initialized once on its first access. It needs * to be refreshed only on reboots as overridden state is expected to take effect on * reboots. */ private var cachedToggleOverride: ToggleOverride? = null Loading