summaryrefslogtreecommitdiffstats
path: root/packages/SettingsProvider/src/com
diff options
context:
space:
mode:
authorChristopher Tate <ctate@android.com>2009-09-22 11:57:58 -0700
committerChristopher Tate <ctate@android.com>2009-09-22 15:04:25 -0700
commit796e0f0ed531b7ff9922cd632d70d8f1da8f5829 (patch)
treea6f38b667d7a37970bca3812d8f73a4de7dd9269 /packages/SettingsProvider/src/com
parent63147705bc2893d6ad43270e04beb9ee01e2ad53 (diff)
downloadframeworks_base-796e0f0ed531b7ff9922cd632d70d8f1da8f5829.zip
frameworks_base-796e0f0ed531b7ff9922cd632d70d8f1da8f5829.tar.gz
frameworks_base-796e0f0ed531b7ff9922cd632d70d8f1da8f5829.tar.bz2
Don't restore any setting that we don't think should be backed up
The ad-hoc blacklist has been replaced by a check that whitelists each restored datum against the set of keys that we actually back up. Keys read from the restore data which are not found in the whitelist are not applied. Also adds in some more debugging output, marked to be disabled for ship.
Diffstat (limited to 'packages/SettingsProvider/src/com')
-rw-r--r--packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java39
1 files changed, 25 insertions, 14 deletions
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
index c4acf33..fb5e4e6 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
@@ -50,6 +50,7 @@ import android.util.Log;
* List of settings that are backed up are stored in the Settings.java file
*/
public class SettingsBackupAgent extends BackupHelperAgent {
+ // STOPSHIP: set DEBUG to false
private static final boolean DEBUG = true;
private static final String KEY_SYSTEM = "system";
@@ -227,6 +228,14 @@ public class SettingsBackupAgent extends BackupHelperAgent {
}
private void restoreSettings(BackupDataInput data, Uri contentUri) {
+ if (DEBUG) Log.i(TAG, "restoreSettings: " + contentUri);
+ String[] whitelist = null;
+ if (contentUri.equals(Settings.Secure.CONTENT_URI)) {
+ whitelist = Settings.Secure.SETTINGS_TO_BACKUP;
+ } else if (contentUri.equals(Settings.System.CONTENT_URI)) {
+ whitelist = Settings.System.SETTINGS_TO_BACKUP;
+ }
+
ContentValues cv = new ContentValues(2);
byte[] settings = new byte[data.getDataSize()];
try {
@@ -248,9 +257,8 @@ public class SettingsBackupAgent extends BackupHelperAgent {
if (!TextUtils.isEmpty(settingName) && !TextUtils.isEmpty(settingValue)) {
//Log.i(TAG, "Restore " + settingName + " = " + settingValue);
- // TODO: versioning rather than just an ad hoc blacklist to handle
- // older varieties of backed-up data
- if (invalidSavedSetting(contentUri, settingName, settingValue)) {
+ // Only restore settings in our list of known-acceptable data
+ if (invalidSavedSetting(whitelist, settingName)) {
continue;
}
@@ -264,20 +272,23 @@ public class SettingsBackupAgent extends BackupHelperAgent {
}
}
- private boolean invalidSavedSetting(Uri contentUri, String settingName, String settingValue) {
- // Even if these settings were stored, don't use them on restore
- if (contentUri.equals(Settings.Secure.CONTENT_URI)) {
- if (settingName.equals(Settings.Secure.PREFERRED_NETWORK_MODE)
- || settingName.equals(Settings.Secure.PREFERRED_TTY_MODE)
- || settingName.equals(Settings.Secure.CDMA_CELL_BROADCAST_SMS)
- || settingName.equals(Settings.Secure.PREFERRED_CDMA_SUBSCRIPTION)
- || settingName.equals(Settings.Secure.ENHANCED_VOICE_PRIVACY_ENABLED)) {
- if (DEBUG) Log.v(TAG, "Ignoring restore datum: " + settingName);
- return true;
+ // Returns 'true' if the given setting is one that we refuse to restore
+ private boolean invalidSavedSetting(String[] knownNames, String candidate) {
+ // no filter? allow everything
+ if (knownNames == null) {
+ return false;
+ }
+
+ // whitelisted setting? allow it
+ for (String name : knownNames) {
+ if (name.equals(candidate)) {
+ return false;
}
}
- return false;
+ // refuse everything else
+ if (DEBUG) Log.v(TAG, "Ignoring restore datum: " + candidate);
+ return true;
}
private String[] copyAndSort(String[] keys) {