From 776c7e63d3b41ee6acfa54a26a76acd32d7802de Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Tue, 29 Jan 2019 11:01:22 -0800 Subject: [PATCH] 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 --- src/com/android/launcher3/config/BaseFlags.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/config/BaseFlags.java b/src/com/android/launcher3/config/BaseFlags.java index 6ad69d78b0..fa4ebaf6b9 100644 --- a/src/com/android/launcher3/config/BaseFlags.java +++ b/src/com/android/launcher3/config/BaseFlags.java @@ -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; }