diff options
author | Danesh M <daneshm90@gmail.com> | 2015-11-16 17:47:36 -0800 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2015-11-17 17:44:59 -0800 |
commit | cec65f20b0edc89c07a0dea2a9a3a9a455de28da (patch) | |
tree | b144c67da4d1dcd549d5c9b40cd524c0c2f68343 /packages/SettingsProvider | |
parent | 0df7e344da01e67624b2a3255a71fa06bdd855ef (diff) | |
download | frameworks_base-cec65f20b0edc89c07a0dea2a9a3a9a455de28da.zip frameworks_base-cec65f20b0edc89c07a0dea2a9a3a9a455de28da.tar.gz frameworks_base-cec65f20b0edc89c07a0dea2a9a3a9a455de28da.tar.bz2 |
SettingsBackupAgent : Filter out cm settings on restoration
Change-Id: If3281be2676a0cae0b534cb004a9a152925ea370
Diffstat (limited to 'packages/SettingsProvider')
-rw-r--r-- | packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java index 7a8caf5..b4543b3 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java @@ -36,8 +36,10 @@ import android.os.UserHandle; import android.provider.Settings; import android.util.Log; +import com.android.internal.util.ArrayUtils; import com.android.internal.widget.LockPatternUtils; +import cyanogenmod.providers.CMSettings; import libcore.io.IoUtils; import java.io.BufferedOutputStream; @@ -883,6 +885,37 @@ public class SettingsBackupAgent extends BackupAgentHelper { Log.d(TAG, "Restored setting: " + destination + " : "+ key + "=" + value); } } + + restoreCMSetting(cachedEntries); + } + + private void restoreCMSetting(Map<String, String> cachedEntries) { + ContentValues cmSettingsValues = new ContentValues(); + ContentResolver cr = getContentResolver(); + for (String key : cachedEntries.keySet()) { + Uri uri = null; + if (ArrayUtils.contains(CMSettings.System.LEGACY_SYSTEM_SETTINGS, key)) { + uri = CMSettings.System.CONTENT_URI; + } else if (ArrayUtils.contains(CMSettings.Secure.LEGACY_SECURE_SETTINGS, key)) { + uri = CMSettings.Secure.CONTENT_URI; + } else if (ArrayUtils.contains(CMSettings.Global.LEGACY_GLOBAL_SETTINGS, key)) { + uri = CMSettings.Global.CONTENT_URI; + } + if (uri != null) { + String value = cachedEntries.get(key); + cmSettingsValues.clear(); + cmSettingsValues.put(Settings.NameValueTable.NAME, key); + cmSettingsValues.put(Settings.NameValueTable.VALUE, value); + try { + cr.insert(uri, cmSettingsValues); + if (DEBUG) { + Log.d(TAG, "Restored cm setting: " + key + " : " + key + "=" + value); + } + } catch (IllegalArgumentException e) { + Log.e(TAG, "Failed to migrate " + key + " due to " + e.toString()); + } + } + } } /** |