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

Commit c441e4e3 authored by Alon Albert's avatar Alon Albert
Browse files

DO NOT MERGE - Clear backoffs on reconnect

Slightly modified backport from HC

Bug: 3460736
Change-Id: I155dfd34bb7abb76a10b5b58fe9a32af2449d4f1
parent 2050de5b
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -258,6 +258,7 @@ public class SyncManager implements OnAccountsUpdateListener {
            // DISCONNECTED for GPRS in any order.  if we receive the CONNECTED first, and then
            // a DISCONNECTED, we want to make sure we set mDataConnectionIsConnected to true
            // since we still have a WiFi connection.
            final boolean wasConnected = mDataConnectionIsConnected;
            switch (state) {
                case CONNECTED:
                    mDataConnectionIsConnected = true;
@@ -273,6 +274,12 @@ public class SyncManager implements OnAccountsUpdateListener {
                    // ignore the rest of the states -- leave our boolean alone.
            }
            if (mDataConnectionIsConnected) {
                if (!wasConnected) {
                    if (Log.isLoggable(TAG, Log.VERBOSE)) {
                        Log.v(TAG, "Reconnection detected: clearing all backoffs");
                    }
                    mSyncStorageEngine.clearAllBackoffs();
                }
                sendCheckAlarmsMessage();
            }
        }
+26 −0
Original line number Diff line number Diff line
@@ -525,6 +525,32 @@ public class SyncStorageEngine extends Handler {
        }
    }

    public void clearAllBackoffs() {
        boolean changed = false;
        synchronized (mAuthorities) {
            for (AccountInfo accountInfo : mAccounts.values()) {
                for (AuthorityInfo authorityInfo : accountInfo.authorities.values()) {
                    if (authorityInfo.backoffTime != NOT_IN_BACKOFF_MODE
                            || authorityInfo.backoffDelay != NOT_IN_BACKOFF_MODE) {
                        if (Log.isLoggable(TAG, Log.VERBOSE)) {
                            Log.v(TAG, "clearAllBackoffs:"
                                    + " authority:" + authorityInfo.authority
                                    + " account:" + accountInfo.account.name
                                    + " backoffTime was: " + authorityInfo.backoffTime
                                    + " backoffDelay was: " + authorityInfo.backoffDelay);
                        }
                        authorityInfo.backoffTime = NOT_IN_BACKOFF_MODE;
                        authorityInfo.backoffDelay = NOT_IN_BACKOFF_MODE;
                        changed = true;
                    }
                }
            }
        }

        if (changed) {
            reportChange(ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS);
        }
    }
    public void setDelayUntilTime(Account account, String providerName, long delayUntil) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "setDelayUntil: " + account + ", provider " + providerName