Merge "Bring back auto clear backoff on reconnect Also, make sure it works this time by calling onBackoffChanged()"
This commit is contained in:
@@ -237,10 +237,28 @@ public class SyncManager implements OnAccountsUpdateListener {
|
||||
private BroadcastReceiver mConnectivityIntentReceiver =
|
||||
new BroadcastReceiver() {
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
sendCheckAlarmsMessage();
|
||||
final boolean wasConnected = mDataConnectionIsConnected;
|
||||
|
||||
// don't use the intent to figure out if network is connected, just check
|
||||
// ConnectivityManager directly.
|
||||
mDataConnectionIsConnected = isNetworkConnected();
|
||||
if (mDataConnectionIsConnected) {
|
||||
if (!wasConnected) {
|
||||
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
||||
Log.v(TAG, "Reconnection detected: clearing all backoffs");
|
||||
}
|
||||
mSyncStorageEngine.clearAllBackoffs(mSyncQueue);
|
||||
}
|
||||
sendCheckAlarmsMessage();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private boolean isNetworkConnected() {
|
||||
NetworkInfo networkInfo = getConnectivityManager().getActiveNetworkInfo();
|
||||
return (networkInfo != null) && networkInfo.isConnected();
|
||||
}
|
||||
|
||||
private BroadcastReceiver mShutdownIntentReceiver =
|
||||
new BroadcastReceiver() {
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
@@ -1411,8 +1429,7 @@ public class SyncManager implements OnAccountsUpdateListener {
|
||||
// to have the most recent value used.
|
||||
try {
|
||||
waitUntilReadyToRun();
|
||||
NetworkInfo networkInfo = getConnectivityManager().getActiveNetworkInfo();
|
||||
mDataConnectionIsConnected = (networkInfo != null) && networkInfo.isConnected();
|
||||
mDataConnectionIsConnected = isNetworkConnected();
|
||||
mSyncManagerWakeLock.acquire();
|
||||
// Always do this first so that we be sure that any periodic syncs that
|
||||
// are ready to run have been converted into pending syncs. This allows the
|
||||
|
||||
@@ -525,7 +525,7 @@ public class SyncStorageEngine extends Handler {
|
||||
}
|
||||
}
|
||||
|
||||
public void clearAllBackoffs() {
|
||||
public void clearAllBackoffs(SyncQueue syncQueue) {
|
||||
boolean changed = false;
|
||||
synchronized (mAuthorities) {
|
||||
for (AccountInfo accountInfo : mAccounts.values()) {
|
||||
@@ -541,6 +541,7 @@ public class SyncStorageEngine extends Handler {
|
||||
}
|
||||
authorityInfo.backoffTime = NOT_IN_BACKOFF_MODE;
|
||||
authorityInfo.backoffDelay = NOT_IN_BACKOFF_MODE;
|
||||
syncQueue.onBackoffChanged(accountInfo.account, authorityInfo.authority, 0);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user