summaryrefslogtreecommitdiffstats
path: root/core/java/android/content/SyncQueue.java
diff options
context:
space:
mode:
authorFred Quintana <fredq@google.com>2010-03-29 22:20:26 -0700
committerFred Quintana <fredq@google.com>2010-03-30 18:31:27 -0700
commit77c560f3d7891d9ae1ad714b5f65a22ff4f4c06b (patch)
tree49aa93b937e099258601e4c1d2566d4144650704 /core/java/android/content/SyncQueue.java
parent23243acabdf8ff6022395cf67632c8387d286989 (diff)
downloadframeworks_base-77c560f3d7891d9ae1ad714b5f65a22ff4f4c06b.zip
frameworks_base-77c560f3d7891d9ae1ad714b5f65a22ff4f4c06b.tar.gz
frameworks_base-77c560f3d7891d9ae1ad714b5f65a22ff4f4c06b.tar.bz2
- changed periodic sync scheduling to just creating pending
and changed the "get next operation to sync" logic just look at pending syncs, rather than them and periodic syncs - made syncoperation dup-detection ignore the initialization sync extra - made the sync dispatcher treat initialization syncs as just a regular sync request and also made it explicitly set or clear the initialization extra based on whether the sync adapter was in the syncable or unknown state - change the getNextSync logic to prioritize syncable "unknown" syncs above everything else (since they should be fast and are important) - make it reschedule completed initialization syncs if the sync adapter is now marked syncable - fix some logging in SyncStorageEngine - change SyncStorageEngine to not reuse authority ids when one is removed http://b/issue?id=2531359 http://b/issue?id=2429638 Change-Id: I79805b582da74f4f0b6193eafaff24c2371d51e8
Diffstat (limited to 'core/java/android/content/SyncQueue.java')
-rw-r--r--core/java/android/content/SyncQueue.java26
1 files changed, 20 insertions, 6 deletions
diff --git a/core/java/android/content/SyncQueue.java b/core/java/android/content/SyncQueue.java
index 432277f..28baa0d 100644
--- a/core/java/android/content/SyncQueue.java
+++ b/core/java/android/content/SyncQueue.java
@@ -16,6 +16,7 @@
package android.content;
+import com.google.android.collect.Lists;
import com.google.android.collect.Maps;
import android.util.Pair;
@@ -120,14 +121,16 @@ public class SyncQueue {
/**
* Find the operation that should run next. Operations are sorted by their earliestRunTime,
- * prioritizing expedited operations. The earliestRunTime is adjusted by the sync adapter's
- * backoff and delayUntil times, if any.
+ * prioritizing first those with a syncable state of "unknown" that aren't retries then
+ * expedited operations.
+ * The earliestRunTime is adjusted by the sync adapter's backoff and delayUntil times, if any.
* @return the operation that should run next and when it should run. The time may be in
* the future. It is expressed in milliseconds since boot.
*/
public Pair<SyncOperation, Long> nextOperation() {
SyncOperation best = null;
long bestRunTime = 0;
+ boolean bestSyncableIsUnknownAndNotARetry = false;
for (SyncOperation op : mOperationsMap.values()) {
long opRunTime = op.earliestRunTime;
if (!op.extras.getBoolean(ContentResolver.SYNC_EXTRAS_IGNORE_BACKOFF, false)) {
@@ -137,12 +140,23 @@ public class SyncQueue {
Math.max(opRunTime, delayUntil),
backoff != null ? backoff.first : 0);
}
- // if the expedited state of both ops are the same then compare their runtime.
- // Otherwise the candidate is only better than the current best if the candidate
- // is expedited.
+ // we know a sync is a retry if the intialization flag is set, since that will only
+ // be set by the sync dispatching code, thus if it is set it must have already been
+ // dispatched
+ final boolean syncableIsUnknownAndNotARetry =
+ !op.extras.getBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE, false)
+ && mSyncStorageEngine.getIsSyncable(op.account, op.authority) < 0;
+ // if the unsyncable state differs, make the current the best if it is unsyncable
+ // else, if the expedited state differs, make the current the best if it is expedited
+ // else, make the current the best if it is earlier than the best
if (best == null
- || (best.expedited == op.expedited ? opRunTime < bestRunTime : op.expedited)) {
+ || ((bestSyncableIsUnknownAndNotARetry == syncableIsUnknownAndNotARetry)
+ ? (best.expedited == op.expedited
+ ? opRunTime < bestRunTime
+ : op.expedited)
+ : syncableIsUnknownAndNotARetry)) {
best = op;
+ bestSyncableIsUnknownAndNotARetry = syncableIsUnknownAndNotARetry;
bestRunTime = opRunTime;
}
}