make the SyncManager listen for backgroun data setting changes and do a sync when the setting is enabled
diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java
index eff6f52..1c61324d 100644
--- a/core/java/android/content/SyncManager.java
+++ b/core/java/android/content/SyncManager.java
@@ -208,6 +208,15 @@
}
};
+ private BroadcastReceiver mBackgroundDataSettingChanged = new BroadcastReceiver() {
+ public void onReceive(Context context, Intent intent) {
+ if (getConnectivityManager().getBackgroundDataSetting()) {
+ scheduleSync(null /* account */, null /* authority */, new Bundle(), 0 /* delay */,
+ false /* onlyThoseWithUnknownSyncableState */);
+ }
+ }
+ };
+
public void onAccountsUpdated(Account[] accounts) {
// remember if this was the first time this was called after an update
final boolean justBootedUp = mAccounts == null;
@@ -351,6 +360,9 @@
intentFilter = new IntentFilter(Intent.ACTION_BOOT_COMPLETED);
context.registerReceiver(mBootCompletedReceiver, intentFilter);
+ intentFilter = new IntentFilter(ConnectivityManager.ACTION_BACKGROUND_DATA_SETTING_CHANGED);
+ context.registerReceiver(mBackgroundDataSettingChanged, intentFilter);
+
intentFilter = new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW);
intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_OK);
context.registerReceiver(mStorageIntentReceiver, intentFilter);
@@ -687,8 +699,8 @@
if (isLoggable) {
Log.d(TAG, "scheduleSync: sync of " + account + ", " + authority
+ " is not allowed, dropping request");
- continue;
}
+ continue;
}
}
if (isLoggable) {