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

Commit 8dfd2d47 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[dev_option]Use indentation 4 in DesktopModeFlags.kt" into main

parents 4c7fd777 7c7cfba4
Loading
Loading
Loading
Loading
+90 −86
Original line number Diff line number Diff line
@@ -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,
@@ -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() ||
@@ -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
            }
        }

@@ -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
@@ -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