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

Commit 776c7e63 authored by Tony Wickham's avatar Tony Wickham
Browse files

Fix ToggleableGlobalSettingsFlag on user builds

TogglableFlags are not initalized if !IS_DEBUG_DEVICE. Thus,
trying to read from the ContentProvider produces a NPE.

Also make ENABLE_TASK_STABILIZER global again now that this
fix is in place.

Bug: 123429711
Change-Id: I252e9b3ef4e802e769865f13b14487a36b8e1f82
parent e0c5f5d0
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -17,13 +17,16 @@
package com.android.launcher3.config;

import static androidx.core.util.Preconditions.checkNotNull;

import android.content.ContentResolver;
import android.content.Context;
import android.content.SharedPreferences;
import android.provider.Settings;

import androidx.annotation.GuardedBy;
import androidx.annotation.Keep;
import androidx.annotation.VisibleForTesting;

import com.android.launcher3.Utilities;

import java.util.ArrayList;
@@ -95,8 +98,9 @@ abstract class BaseFlags {
    public static final TogglableFlag APPLY_CONFIG_AT_RUNTIME = new TogglableFlag(
            "APPLY_CONFIG_AT_RUNTIME", true, "Apply display changes dynamically");

    public static final TogglableFlag ENABLE_TASK_STABILIZER = new TogglableFlag(
            "ENABLE_TASK_STABILIZER", false, "Stable task list across fast task switches");
    public static final ToggleableGlobalSettingsFlag ENABLE_TASK_STABILIZER
            = new ToggleableGlobalSettingsFlag("ENABLE_TASK_STABILIZER", false,
            "Stable task list across fast task switches");

    public static final TogglableFlag QUICKSTEP_SPRINGS = new TogglableFlag("QUICKSTEP_SPRINGS",
            false, "Enable springs for quickstep animations");
@@ -249,11 +253,17 @@ abstract class BaseFlags {

        @Override
        void updateStorage(Context context, boolean value) {
            if (contentResolver == null) {
                return;
            }
            Settings.Global.putInt(contentResolver, getKey(), value ? 1 : 0);
        }

        @Override
        boolean getFromStorage(Context context, boolean defaultValue) {
            if (contentResolver == null) {
                return defaultValue;
            }
            return Settings.Global.getInt(contentResolver, getKey(), defaultValue ? 1 : 0) == 1;
        }