mCachedSettings.getSyncAutomatically(account);
}
- notifyObservers();
+ notifyObserversIfAccountSettingsChanged();
return returnValue;
}
returnValue = mCachedSettings.getSyncAutomatically(account);
}
- notifyObservers();
+ notifyObserversIfAccountSettingsChanged();
return returnValue;
}
mCachedSettings.setSyncAutomatically(account, true);
}
- notifyObservers();
+ notifyObserversIfAccountSettingsChanged();
}
/**
mCachedSettings.setSyncAutomatically(account, false);
}
- notifyObservers();
+ notifyObserversIfAccountSettingsChanged();
}
/**
public void onStatusChanged(int which) {
if (ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS == which) {
// Sync settings have changed; update our in-memory caches
- updateMasterSyncAutomaticallySetting();
synchronized (mCachedSettings) {
mCachedSettings.updateSyncSettingsForAccount(
ChromeSigninController.get(mApplicationContext).getSignedInUser());
}
- notifyObservers();
+
+ boolean oldMasterSyncEnabled = isMasterSyncAutomaticallyEnabled();
+ updateMasterSyncAutomaticallySetting();
+ boolean didMasterSyncChanged =
+ oldMasterSyncEnabled != isMasterSyncAutomaticallyEnabled();
+ // Notify observers if MasterSync or account level settings change.
+ if (didMasterSyncChanged || getAndClearDidUpdateStatus())
+ notifyObservers();
}
}
}
return didGetStatusUpdate;
}
+ private void notifyObserversIfAccountSettingsChanged() {
+ if (getAndClearDidUpdateStatus()) {
+ notifyObservers();
+ }
+ }
+
private void notifyObservers() {
- if (!getAndClearDidUpdateStatus()) return;
for (SyncSettingsChangedObserver observer : mObservers) {
observer.syncSettingsChanged();
}