Skip to content

Commit

Permalink
[Sync] Ensure the user has a chance to change their settings on Android.
Browse files Browse the repository at this point in the history
Using onCreate and onDestroy means that the user can go into the Google
Activity Controls or Sync settings subpages without triggering sync.
Note that leaving the sync page will still cause sync to start, but at
that point it seems safe to assume the settings are good.

BUG=613340

Review-Url: https://codereview.chromium.org/1988133005
Cr-Commit-Position: refs/heads/master@{#395081}
  • Loading branch information
maxbogue authored and Commit bot committed May 20, 2016
1 parent 45983aa commit 0acf90e
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ public class AccountManagementFragment extends PreferenceFragment
public void onCreate(Bundle savedState) {
super.onCreate(savedState);

// Prevent sync from starting if it hasn't already to give the user a chance to change
// their sync settings.
ProfileSyncService syncService = ProfileSyncService.get();
if (syncService != null) {
syncService.setSetupInProgress(true);
}

mGaiaServiceType = AccountManagementScreenHelper.GAIA_SERVICE_TYPE_NONE;
if (getArguments() != null) {
mGaiaServiceType =
Expand Down Expand Up @@ -156,6 +163,17 @@ public void onPause() {
}
}

@Override
public void onDestroy() {
super.onDestroy();

// Allow sync to begin syncing if it hasn't yet.
ProfileSyncService syncService = ProfileSyncService.get();
if (syncService != null) {
syncService.setSetupInProgress(false);
}
}

/**
* Initiate fetching the user accounts data (images and the full name).
* Fetched data will be sent to observers of ProfileDownloader.
Expand Down Expand Up @@ -489,7 +507,9 @@ public void onSignOutDialogDismissed(boolean signOutClicked) {
@Override
public void syncStateChanged() {
SyncPreference pref = (SyncPreference) findPreference(PREF_SYNC_SETTINGS);
pref.updateSyncSummaryAndIcon();
if (pref != null) {
pref.updateSyncSummaryAndIcon();
}

// TODO(crbug/557784): Show notification for sync error
}
Expand Down

0 comments on commit 0acf90e

Please sign in to comment.