Merge "DO NOT MERGE - Clear backoffs on reconnect" into gingerbread
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user