diff options
| author | 2011-02-16 10:20:40 -0800 | |
|---|---|---|
| committer | 2011-02-16 10:20:40 -0800 | |
| commit | d1c3fe022efba45c43cc93694852884cb553314c (patch) | |
| tree | f94999e208c0662aad8bef518157b4ea56ab75ca | |
| parent | 9497144281b92dd5293ea734d668217bcf4e86e9 (diff) | |
| parent | ed1d253573a238fd53d27def24d298314f24d425 (diff) | |
Merge "Bring back auto clear backoff on reconnect Also, make sure it works this time by calling onBackoffChanged()"
| -rw-r--r-- | core/java/android/content/SyncManager.java | 23 | ||||
| -rw-r--r-- | core/java/android/content/SyncStorageEngine.java | 3 |
2 files changed, 22 insertions, 4 deletions
diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java index 659b9379ebe4..ebc18824b236 100644 --- a/core/java/android/content/SyncManager.java +++ b/core/java/android/content/SyncManager.java @@ -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 diff --git a/core/java/android/content/SyncStorageEngine.java b/core/java/android/content/SyncStorageEngine.java index c8ca61898319..a1e174b119b2 100644 --- a/core/java/android/content/SyncStorageEngine.java +++ b/core/java/android/content/SyncStorageEngine.java @@ -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; } } |