Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 49763e42 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 7480

* changes:
  Make sync not start until setup wizard is done.
parents c3350ab5 8294fadb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1588,7 +1588,7 @@ class SyncManager implements OnAccountsUpdatedListener {
                            ContentResolver.SYNC_EXTRAS_MANUAL, false);
                    final boolean syncAutomatically =
                            mSyncStorageEngine.getSyncAutomatically(op.account, op.authority)
                                    || mSyncStorageEngine.getMasterSyncAutomatically();
                                    && mSyncStorageEngine.getMasterSyncAutomatically();
                    boolean syncAllowed =
                            manualSync || (backgroundDataUsageAllowed && syncAutomatically);
                    if (!syncAllowed) {
+16 −7
Original line number Diff line number Diff line
@@ -111,6 +111,8 @@ public class SyncStorageEngine extends Handler {
    private static final int MSG_WRITE_STATISTICS = 2;
    private static final long WRITE_STATISTICS_DELAY = 1000*60*30; // 1/2 hour

    private static final boolean SYNC_ENABLED_DEFAULT = false;
    
    public static class PendingOperation {
        final Account account;
        final int syncSource;
@@ -158,7 +160,7 @@ public class SyncStorageEngine extends Handler {
            this.account = account;
            this.authority = authority;
            this.ident = ident;
            enabled = true;
            enabled = SYNC_ENABLED_DEFAULT;
        }
    }
    
@@ -376,23 +378,30 @@ public class SyncStorageEngine extends Handler {
    }

    public void setSyncAutomatically(Account account, String providerName, boolean sync) {
        boolean wasEnabled;
        synchronized (mAuthorities) {
            AuthorityInfo authority = getAuthorityLocked(account, providerName,
                    "setSyncAutomatically");
            if (authority != null) {
            AuthorityInfo authority = getOrCreateAuthorityLocked(account, providerName, -1, false);
            wasEnabled = authority.enabled;
            authority.enabled = sync;
            }
            writeAccountInfoLocked();
        }

        if (!wasEnabled && sync) {
            mContext.getContentResolver().requestSync(account, providerName, new Bundle());
        }
        reportChange(ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS);
    }

    public void setMasterSyncAutomatically(boolean flag) {
        boolean old;
        synchronized (mAuthorities) {
            old = mMasterSyncAutomatically;
            mMasterSyncAutomatically = flag;
            writeAccountInfoLocked();
        }
        if (!old && flag) {
            mContext.getContentResolver().requestSync(null, null, new Bundle());
        }
        reportChange(ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS);
        mContext.sendBroadcast(SYNC_CONNECTION_SETTING_CHANGED_INTENT);
    }