Commit e4b8a337 authored by Boris Sazonov's avatar Boris Sazonov Committed by Commit Bot

[Unity][Android] Use UnifiedConsentServiceBridge to update sync prefs

This CL changes SyncAndServicesPreferences to make
UnifiedConsentServiceBridge.isUnifiedConsentGiven a source of truth when
updating prefs. Before, mUseSyncAndAllServices was used in some places,
leading to inconsistencies when UnifiedConsent state can't be changed
(for example, because of a custom passphrase).

Bug: 882884
Change-Id: Ie9be1b73284a7a818c21d702c47712b787d52846
Reviewed-on: https://chromium-review.googlesource.com/1219927Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590349}
parent 2036d4f6
......@@ -484,7 +484,7 @@ public class SyncAndServicesPreferences extends PreferenceFragment
/** Enables sync if any of the data types is selected, otherwise disables sync. */
private void updateSyncStateFromSelectedModelTypes() {
boolean shouldEnableSync = mUseSyncAndAllServices.isChecked()
boolean shouldEnableSync = UnifiedConsentServiceBridge.isUnifiedConsentGiven()
|| !getSelectedModelTypes().isEmpty() || !canDisableSync();
if (mIsSyncEnabled == shouldEnableSync) return;
mIsSyncEnabled = shouldEnableSync;
......@@ -537,7 +537,7 @@ public class SyncAndServicesPreferences extends PreferenceFragment
updateSyncStateFromSelectedModelTypes();
if (!mIsSyncEnabled) return;
boolean syncEverything = mUseSyncAndAllServices.isChecked();
boolean syncEverything = UnifiedConsentServiceBridge.isUnifiedConsentGiven();
mProfileSyncService.setPreferredDataTypes(syncEverything, getSelectedModelTypes());
// Update the invalidation listener with the set of types we are enabling.
InvalidationController invController = InvalidationController.get();
......@@ -686,7 +686,7 @@ public class SyncAndServicesPreferences extends PreferenceFragment
* sync being turned on and the engine initialization completing.
*/
private void updateDataTypeState() {
boolean syncEverything = mUseSyncAndAllServices.isChecked();
boolean syncEverything = UnifiedConsentServiceBridge.isUnifiedConsentGiven();
boolean passwordSyncConfigurable = mProfileSyncService.isEngineInitialized()
&& mProfileSyncService.isCryptographerReady();
boolean hasCustomPassphrase = mProfileSyncService.isEngineInitialized()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment