summaryrefslogtreecommitdiffstats
path: root/packages/SettingsProvider
diff options
context:
space:
mode:
authorChristopher Tate <ctate@android.com>2009-09-18 15:51:15 -0700
committerChristopher Tate <ctate@android.com>2009-09-18 15:56:14 -0700
commita286f419084d56217f05a64f1d24c9e07917212e (patch)
treed6c4d63e55f7176e837c57467bdc25f3919aa774 /packages/SettingsProvider
parent90d8a6a449dc12fea2b56b557c243e33746d914a (diff)
downloadframeworks_base-a286f419084d56217f05a64f1d24c9e07917212e.zip
frameworks_base-a286f419084d56217f05a64f1d24c9e07917212e.tar.gz
frameworks_base-a286f419084d56217f05a64f1d24c9e07917212e.tar.bz2
Don't back up / restore certain sync-related settings
In particular, this no longer attempts to back up the on/off state of specific backend syncing [gmail/contacts/calendar], nor the "background data" toggle. The former was causing a great deal of spurious trips through backup as the notification was being tickled during general sync operation, and the latter makes little sense at restore time. Fixes these issues: b/2097613 - frequent "backup_data_changed" messages in event log b/2131662 - should not backup background data, master sync settings
Diffstat (limited to 'packages/SettingsProvider')
-rw-r--r--packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java34
-rw-r--r--packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java37
2 files changed, 19 insertions, 52 deletions
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
index 8cfd956..c4acf33 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
@@ -54,15 +54,17 @@ public class SettingsBackupAgent extends BackupHelperAgent {
private static final String KEY_SYSTEM = "system";
private static final String KEY_SECURE = "secure";
- private static final String KEY_SYNC = "sync_providers";
private static final String KEY_LOCALE = "locale";
+ // Versioning of the state file. Increment this version
+ // number any time the set of state items is altered.
+ private static final int STATE_VERSION = 1;
+
private static final int STATE_SYSTEM = 0;
private static final int STATE_SECURE = 1;
- private static final int STATE_SYNC = 2;
- private static final int STATE_LOCALE = 3;
- private static final int STATE_WIFI = 4;
- private static final int STATE_SIZE = 5; // The number of state items
+ private static final int STATE_LOCALE = 2;
+ private static final int STATE_WIFI = 3;
+ private static final int STATE_SIZE = 4; // The number of state items
private static String[] sortedSystemKeys = null;
private static String[] sortedSecureKeys = null;
@@ -101,7 +103,6 @@ public class SettingsBackupAgent extends BackupHelperAgent {
byte[] systemSettingsData = getSystemSettings();
byte[] secureSettingsData = getSecureSettings();
- byte[] syncProviders = mSettingsHelper.getSyncProviders();
byte[] locale = mSettingsHelper.getLocaleData();
byte[] wifiData = getWifiSupplicant(FILE_WIFI_SUPPLICANT);
@@ -111,8 +112,6 @@ public class SettingsBackupAgent extends BackupHelperAgent {
writeIfChanged(stateChecksums[STATE_SYSTEM], KEY_SYSTEM, systemSettingsData, data);
stateChecksums[STATE_SECURE] =
writeIfChanged(stateChecksums[STATE_SECURE], KEY_SECURE, secureSettingsData, data);
- stateChecksums[STATE_SYNC] =
- writeIfChanged(stateChecksums[STATE_SYNC], KEY_SYNC, syncProviders, data);
stateChecksums[STATE_LOCALE] =
writeIfChanged(stateChecksums[STATE_LOCALE], KEY_LOCALE, locale, data);
stateChecksums[STATE_WIFI] =
@@ -143,8 +142,6 @@ public class SettingsBackupAgent extends BackupHelperAgent {
// retain the previous WIFI state.
enableWifi(retainedWifiState == WifiManager.WIFI_STATE_ENABLED ||
retainedWifiState == WifiManager.WIFI_STATE_ENABLING);
- } else if (KEY_SYNC.equals(key)) {
- mSettingsHelper.setSyncProviders(data);
} else if (KEY_LOCALE.equals(key)) {
byte[] localeData = new byte[size];
data.readEntityData(localeData, 0, size);
@@ -160,12 +157,17 @@ public class SettingsBackupAgent extends BackupHelperAgent {
DataInputStream dataInput = new DataInputStream(
new FileInputStream(oldState.getFileDescriptor()));
- for (int i = 0; i < STATE_SIZE; i++) {
- try {
- stateChecksums[i] = dataInput.readLong();
- } catch (EOFException eof) {
- break;
+
+ try {
+ int stateVersion = dataInput.readInt();
+ if (stateVersion == STATE_VERSION) {
+ for (int i = 0; i < STATE_SIZE; i++) {
+ stateChecksums[i] = dataInput.readLong();
+ }
}
+ } catch (EOFException eof) {
+ // With the default 0 checksum we'll wind up forcing a backup of
+ // any unhandled data sets, which is appropriate.
}
dataInput.close();
return stateChecksums;
@@ -175,6 +177,8 @@ public class SettingsBackupAgent extends BackupHelperAgent {
throws IOException {
DataOutputStream dataOutput = new DataOutputStream(
new FileOutputStream(newState.getFileDescriptor()));
+
+ dataOutput.writeInt(STATE_VERSION);
for (int i = 0; i < STATE_SIZE; i++) {
dataOutput.writeLong(checksums[i]);
}
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
index 39084a7..77da8f1 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
@@ -116,43 +116,6 @@ public class SettingsHelper {
}
}
- byte[] getSyncProviders() {
- byte[] sync = new byte[1 + PROVIDERS.length];
- // TODO: Sync backup needs to be moved to SystemBackupAgent
- /*
- try {
- sync[0] = (byte) (mContentService.getListenForNetworkTickles() ? 1 : 0);
- for (int i = 0; i < PROVIDERS.length; i++) {
- sync[i + 1] = (byte)
- (mContentService.getSyncAutomatically(PROVIDERS[i]) ? 1 : 0);
- }
- } catch (RemoteException re) {
- Log.w(TAG, "Unable to backup sync providers");
- return sync;
- }
- */
- return sync;
- }
-
- void setSyncProviders(BackupDataInput backup) {
- byte[] sync = new byte[backup.getDataSize()];
-
- try {
- backup.readEntityData(sync, 0, sync.length);
- // TODO: Sync backup needs to be moved to SystemBackupAgent
- /*
- mContentService.setListenForNetworkTickles(sync[0] == 1);
- for (int i = 0; i < PROVIDERS.length; i++) {
- mContentService.setSyncProviderAutomatically(PROVIDERS[i], sync[i + 1] > 0);
- }
- } catch (RemoteException re) {
- Log.w(TAG, "Unable to restore sync providers");
- */
- } catch (java.io.IOException ioe) {
- Log.w(TAG, "Unable to read sync settings");
- }
- }
-
byte[] getLocaleData() {
Configuration conf = mContext.getResources().getConfiguration();
final Locale loc = conf.locale;