diff options
author | Danesh M <daneshm90@gmail.com> | 2016-01-26 16:08:06 -0800 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2016-01-26 16:38:34 -0800 |
commit | bc08213d41b3407f42328f4571223d255c1c0668 (patch) | |
tree | c5a52a75dbba4f5e508b847d2abfce5ca8c7a76c /packages/SettingsProvider | |
parent | a96ede25798b4fe58e52801967bdd8c994d0839f (diff) | |
download | frameworks_base-bc08213d41b3407f42328f4571223d255c1c0668.zip frameworks_base-bc08213d41b3407f42328f4571223d255c1c0668.tar.gz frameworks_base-bc08213d41b3407f42328f4571223d255c1c0668.tar.bz2 |
SettingsProvider : Don't replay aosp defaults every boot
CYNGNOS-1619
Ensure aosp defaults are only applied ONCE
Change-Id: I8a0d1f11b006e3e8f7985f204d50d9af9a657ba2
Diffstat (limited to 'packages/SettingsProvider')
-rw-r--r-- | packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java index c361c70..f55cead 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java @@ -27,6 +27,7 @@ import android.content.ContentValues; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.content.SharedPreferences; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; @@ -51,6 +52,7 @@ import android.os.Process; import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserManager; +import android.preference.PreferenceManager; import android.provider.Settings; import android.text.TextUtils; import android.util.ArrayMap; @@ -127,6 +129,8 @@ public class SettingsProvider extends ContentProvider { private static final String TABLE_BOOKMARKS = "bookmarks"; private static final String TABLE_ANDROID_METADATA = "android_metadata"; + private static final String HAS_REPLAYED_DEFAULTS_FROM_L = "has_replayed_defaults_from_L"; + // The set of removed legacy tables. private static final Set<String> REMOVED_LEGACY_TABLES = new ArraySet<>(); static { @@ -1983,6 +1987,9 @@ public class SettingsProvider extends ContentProvider { private final class UpgradeController { private static final int SETTINGS_VERSION = 122; + /** + * This is the 12.1 database version (DO NOT INCREMENT) + */ private static final int CM_SETTINGS_DB_VERSION = 125; private final int mUserId; @@ -2014,8 +2021,9 @@ public class SettingsProvider extends ContentProvider { // force replay AOSP defaults as they get introduced // once 125 is hit, we never have to maintain this again. if ((oldVersion == newVersion || oldVersion == CM_SETTINGS_DB_VERSION)) { - if (oldVersion == CM_SETTINGS_DB_VERSION) { + if (oldVersion == CM_SETTINGS_DB_VERSION && !hasReplayedDefaultsFromL()) { forceReplayAOSPDefaults(mUserId); + setDefaultsReplayedFromLFlag(); } return; } @@ -2056,6 +2064,18 @@ public class SettingsProvider extends ContentProvider { systemSettings.setVersionLocked(newVersion); } + private boolean hasReplayedDefaultsFromL() { + SharedPreferences sharedPreferences = PreferenceManager + .getDefaultSharedPreferences(getContext()); + return sharedPreferences.getBoolean(HAS_REPLAYED_DEFAULTS_FROM_L, false); + } + + private void setDefaultsReplayedFromLFlag() { + SharedPreferences sharedPreferences = PreferenceManager + .getDefaultSharedPreferences(getContext()); + sharedPreferences.edit().putBoolean(HAS_REPLAYED_DEFAULTS_FROM_L, true).apply(); + } + private SettingsState getGlobalSettingsLocked() { return getSettingsLocked(SETTINGS_TYPE_GLOBAL, UserHandle.USER_OWNER); } |