am 13006be1: Merge change 26457 into eclair
Merge commit '13006be19ef35f46effd10c422204cfe144136d6' into eclair-plus-aosp * commit '13006be19ef35f46effd10c422204cfe144136d6': Don't restore any setting that we don't think should be backed up
This commit is contained in:
@@ -50,6 +50,7 @@ import android.util.Log;
|
|||||||
* List of settings that are backed up are stored in the Settings.java file
|
* List of settings that are backed up are stored in the Settings.java file
|
||||||
*/
|
*/
|
||||||
public class SettingsBackupAgent extends BackupHelperAgent {
|
public class SettingsBackupAgent extends BackupHelperAgent {
|
||||||
|
// STOPSHIP: set DEBUG to false
|
||||||
private static final boolean DEBUG = true;
|
private static final boolean DEBUG = true;
|
||||||
|
|
||||||
private static final String KEY_SYSTEM = "system";
|
private static final String KEY_SYSTEM = "system";
|
||||||
@@ -227,6 +228,14 @@ public class SettingsBackupAgent extends BackupHelperAgent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void restoreSettings(BackupDataInput data, Uri contentUri) {
|
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);
|
ContentValues cv = new ContentValues(2);
|
||||||
byte[] settings = new byte[data.getDataSize()];
|
byte[] settings = new byte[data.getDataSize()];
|
||||||
try {
|
try {
|
||||||
@@ -248,9 +257,8 @@ public class SettingsBackupAgent extends BackupHelperAgent {
|
|||||||
if (!TextUtils.isEmpty(settingName) && !TextUtils.isEmpty(settingValue)) {
|
if (!TextUtils.isEmpty(settingName) && !TextUtils.isEmpty(settingValue)) {
|
||||||
//Log.i(TAG, "Restore " + settingName + " = " + settingValue);
|
//Log.i(TAG, "Restore " + settingName + " = " + settingValue);
|
||||||
|
|
||||||
// TODO: versioning rather than just an ad hoc blacklist to handle
|
// Only restore settings in our list of known-acceptable data
|
||||||
// older varieties of backed-up data
|
if (invalidSavedSetting(whitelist, settingName)) {
|
||||||
if (invalidSavedSetting(contentUri, settingName, settingValue)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,20 +272,23 @@ public class SettingsBackupAgent extends BackupHelperAgent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean invalidSavedSetting(Uri contentUri, String settingName, String settingValue) {
|
// Returns 'true' if the given setting is one that we refuse to restore
|
||||||
// Even if these settings were stored, don't use them on restore
|
private boolean invalidSavedSetting(String[] knownNames, String candidate) {
|
||||||
if (contentUri.equals(Settings.Secure.CONTENT_URI)) {
|
// no filter? allow everything
|
||||||
if (settingName.equals(Settings.Secure.PREFERRED_NETWORK_MODE)
|
if (knownNames == null) {
|
||||||
|| settingName.equals(Settings.Secure.PREFERRED_TTY_MODE)
|
return false;
|
||||||
|| settingName.equals(Settings.Secure.CDMA_CELL_BROADCAST_SMS)
|
}
|
||||||
|| settingName.equals(Settings.Secure.PREFERRED_CDMA_SUBSCRIPTION)
|
|
||||||
|| settingName.equals(Settings.Secure.ENHANCED_VOICE_PRIVACY_ENABLED)) {
|
// whitelisted setting? allow it
|
||||||
if (DEBUG) Log.v(TAG, "Ignoring restore datum: " + settingName);
|
for (String name : knownNames) {
|
||||||
return true;
|
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) {
|
private String[] copyAndSort(String[] keys) {
|
||||||
|
|||||||
Reference in New Issue
Block a user