summaryrefslogtreecommitdiffstats
path: root/services/java/com/android/server/content/SyncOperation.java
diff options
context:
space:
mode:
authorMatthew Williams <mjwilliams@google.com>2014-03-24 14:42:06 -0700
committerMatthew Williams <mjwilliams@google.com>2014-03-24 14:42:06 -0700
commitbb87ac7f9733ca9b490cb34e8a675dba083a57b7 (patch)
tree1dafdaf3def68c809f7831fecbe86c8330dc2ceb /services/java/com/android/server/content/SyncOperation.java
parentc41853cee89b391cd2d4d93205ea69c746ccfa4c (diff)
downloadframeworks_base-bb87ac7f9733ca9b490cb34e8a675dba083a57b7.zip
frameworks_base-bb87ac7f9733ca9b490cb34e8a675dba083a57b7.tar.gz
frameworks_base-bb87ac7f9733ca9b490cb34e8a675dba083a57b7.tar.bz2
DO NOT MERGE: Downgrade expedited to normal on reschedule.
bug: 12033540 Expedited was previously tracked by a redundant internal variable, ostensibly as an optimisation. This variable could differ from the value in the bundle depending on how the operation is initialised, which led to confusion. Now an expedited sync will only be treated as such on its first execution. Change-Id: Ibfc4e9e49b86c82f2364a6ef55f887705a053eb6
Diffstat (limited to 'services/java/com/android/server/content/SyncOperation.java')
-rw-r--r--services/java/com/android/server/content/SyncOperation.java50
1 files changed, 28 insertions, 22 deletions
diff --git a/services/java/com/android/server/content/SyncOperation.java b/services/java/com/android/server/content/SyncOperation.java
index 4856747..67e3b09 100644
--- a/services/java/com/android/server/content/SyncOperation.java
+++ b/services/java/com/android/server/content/SyncOperation.java
@@ -66,7 +66,8 @@ public class SyncOperation implements Comparable {
public final boolean allowParallelSyncs;
public Bundle extras;
public final String key;
- public boolean expedited;
+ /** Internal boolean to avoid reading a bundle everytime we want to compare operations. */
+ private final boolean expedited;
public SyncStorageEngine.PendingOperation pendingOperation;
/** Elapsed real time in millis at which to run this sync. */
public long latestRunTime;
@@ -79,7 +80,7 @@ public class SyncOperation implements Comparable {
* Depends on max(backoff, latestRunTime, and delayUntil).
*/
public long effectiveRunTime;
- /** Amount of time before {@link effectiveRunTime} from which this sync can run. */
+ /** Amount of time before {@link #effectiveRunTime} from which this sync can run. */
public long flexTime;
public SyncOperation(Account account, int userId, int reason, int source, String authority,
@@ -98,11 +99,16 @@ public class SyncOperation implements Comparable {
this.backoff = backoff;
final long now = SystemClock.elapsedRealtime();
// Checks the extras bundle. Must occur after we set the internal bundle.
- if (runTimeFromNow < 0 || isExpedited()) {
+ if (runTimeFromNow < 0) {
+ // Sanity check: Will always be true.
+ if (!this.extras.getBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, false)) {
+ this.extras.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
+ }
this.expedited = true;
this.latestRunTime = now;
this.flexTime = 0;
} else {
+ this.extras.remove(ContentResolver.SYNC_EXTRAS_EXPEDITED);
this.expedited = false;
this.latestRunTime = now + runTimeFromNow;
this.flexTime = flexTime;
@@ -111,6 +117,24 @@ public class SyncOperation implements Comparable {
this.key = toKey();
}
+ /** Only used to immediately reschedule a sync. */
+ SyncOperation(SyncOperation other) {
+ this.service = other.service;
+ this.account = other.account;
+ this.authority = other.authority;
+ this.userId = other.userId;
+ this.reason = other.reason;
+ this.syncSource = other.syncSource;
+ this.extras = new Bundle(other.extras);
+ this.expedited = other.expedited;
+ this.latestRunTime = SystemClock.elapsedRealtime();
+ this.flexTime = 0L;
+ this.backoff = other.backoff;
+ this.allowParallelSyncs = other.allowParallelSyncs;
+ this.updateEffectiveRunTime();
+ this.key = toKey();
+ }
+
/**
* Make sure the bundle attached to this SyncOperation doesn't have unnecessary
* flags set.
@@ -138,24 +162,6 @@ public class SyncOperation implements Comparable {
}
}
- /** Only used to immediately reschedule a sync. */
- SyncOperation(SyncOperation other) {
- this.service = other.service;
- this.account = other.account;
- this.authority = other.authority;
- this.userId = other.userId;
- this.reason = other.reason;
- this.syncSource = other.syncSource;
- this.extras = new Bundle(other.extras);
- this.expedited = other.expedited;
- this.latestRunTime = SystemClock.elapsedRealtime();
- this.flexTime = 0L;
- this.backoff = other.backoff;
- this.allowParallelSyncs = other.allowParallelSyncs;
- this.updateEffectiveRunTime();
- this.key = toKey();
- }
-
@Override
public String toString() {
return dump(null, true);
@@ -220,7 +226,7 @@ public class SyncOperation implements Comparable {
}
public boolean isExpedited() {
- return extras.getBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, false) || expedited;
+ return expedited;
}
public boolean ignoreBackoff() {