Revert "Make the SyncManager timeout syncs if it takes too long to bind to them."
This reverts commit bf3c634dc5bea1d6188efaba159b1ecbc038a4f7
Bug: 5290505
Change-Id: I11a681b48360f5c200a0602c4daf30ae82b4209c
diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java
index 9678d48..684c4fe 100644
--- a/core/java/android/content/SyncManager.java
+++ b/core/java/android/content/SyncManager.java
@@ -191,12 +191,6 @@
private static final long SYNC_ALARM_TIMEOUT_MIN = 30 * 1000; // 30 seconds
private static final long SYNC_ALARM_TIMEOUT_MAX = 2 * 60 * 60 * 1000; // two hours
- /**
- * The amount of time (in milliseconds) to wait after attempting a bind
- * before canceling a sync and disabling the sync adapter
- */
- public static final long BIND_TIMEOUT_MS = 5 * 60 * 1000;
-
public void onAccountsUpdated(Account[] accounts) {
// remember if this was the first time this was called after an update
final boolean justBootedUp = mAccounts == INITIAL_ACCOUNTS_ARRAY;
@@ -1074,9 +1068,6 @@
pw.print(" - ");
pw.print(activeSyncContext.mSyncOperation.dump(false));
pw.println();
- if (activeSyncContext.mSyncAdapter == null) {
- pw.println(" **** Waiting for onServiceConnected ****");
- }
}
synchronized (mSyncQueue) {
@@ -1433,7 +1424,6 @@
public void handleMessage(Message msg) {
long earliestFuturePollTime = Long.MAX_VALUE;
long nextPendingSyncTime = Long.MAX_VALUE;
- long nextBindTimeoutTime = Long.MAX_VALUE;
// Setting the value here instead of a method because we want the dumpsys logs
// to have the most recent value used.
@@ -1441,7 +1431,6 @@
waitUntilReadyToRun();
mDataConnectionIsConnected = readDataConnectionState();
mSyncManagerWakeLock.acquire();
- nextBindTimeoutTime = auditRunningSyncsForStuckBindsLocked();
// 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
// logic that considers the next steps to take based on the set of pending syncs
@@ -1543,7 +1532,6 @@
break;
}
} finally {
- nextPendingSyncTime = Math.min(nextBindTimeoutTime, nextPendingSyncTime);
manageSyncNotificationLocked();
manageSyncAlarmLocked(earliestFuturePollTime, nextPendingSyncTime);
mSyncTimeTracker.update();
@@ -1552,36 +1540,6 @@
}
/**
- * Looks to see if any of the active syncs have been waiting for a bind for too long,
- * and if so the sync is canceled and the sync adapter is disabled for that account.
- * @return the earliest time that an active sync can have waited too long to bind,
- * relative to {@link android.os.SystemClock#elapsedRealtime()}.
- */
- private long auditRunningSyncsForStuckBindsLocked() {
- final long now = SystemClock.elapsedRealtime();
- long oldest = Long.MAX_VALUE;
- for (ActiveSyncContext active : mActiveSyncContexts) {
- if (active.mSyncAdapter == null) {
- final long timeoutTime = active.mStartTime + BIND_TIMEOUT_MS;
- if (timeoutTime < now) {
- Log.w(TAG, "canceling long-running bind and disabling sync for "
- + active.mSyncOperation.account + ", authority "
- + active.mSyncOperation.authority);
- runSyncFinishedOrCanceledLocked(null, active);
- ContentResolver.setIsSyncable(active.mSyncOperation.account,
- active.mSyncOperation.authority, 0);
- } else {
- if (oldest > timeoutTime) {
- oldest = timeoutTime;
- }
- }
- }
- }
-
- return oldest;
- }
-
- /**
* Turn any periodic sync operations that are ready to run into pending sync operations.
* @return the desired start time of the earliest future periodic sync operation,
* in milliseconds since boot
@@ -1861,17 +1819,13 @@
synchronized (mSyncQueue){
mSyncQueue.remove(candidate);
}
- ActiveSyncContext newSyncContext = dispatchSyncOperation(candidate);
- if (newSyncContext != null) {
- nextReadyToRunTime = Math.min(nextReadyToRunTime,
- newSyncContext.mStartTime + BIND_TIMEOUT_MS);
- }
+ dispatchSyncOperation(candidate);
}
return nextReadyToRunTime;
}
- private ActiveSyncContext dispatchSyncOperation(SyncOperation op) {
+ private boolean dispatchSyncOperation(SyncOperation op) {
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "dispatchSyncOperation: we are going to sync " + op);
Log.v(TAG, "num active syncs: " + mActiveSyncContexts.size());
@@ -1888,7 +1842,7 @@
Log.d(TAG, "can't find a sync adapter for " + syncAdapterType
+ ", removing settings for it");
mSyncStorageEngine.removeAuthority(op.account, op.authority);
- return null;
+ return false;
}
ActiveSyncContext activeSyncContext =
@@ -1901,10 +1855,10 @@
if (!activeSyncContext.bindToSyncAdapter(syncAdapterInfo)) {
Log.e(TAG, "Bind attempt failed to " + syncAdapterInfo);
closeActiveSyncContext(activeSyncContext);
- return null;
+ return false;
}
- return activeSyncContext;
+ return true;
}
private void runBoundToSyncAdapter(final ActiveSyncContext activeSyncContext,