summaryrefslogtreecommitdiffstats
path: root/core/java/android/content/SyncManager.java
diff options
context:
space:
mode:
authorAlon Albert <aalbert@google.com>2011-08-16 16:56:19 -0700
committerAlon Albert <aalbert@google.com>2011-08-16 16:58:20 -0700
commitcc6edf378e32e607037cd8e69032efbe74917984 (patch)
tree2476a6de8b3c77a73e8997e4c0eb3e1d786db956 /core/java/android/content/SyncManager.java
parent7d8fc3c911ea8e4cd1e6531118da4f72e521a944 (diff)
downloadframeworks_base-cc6edf378e32e607037cd8e69032efbe74917984.zip
frameworks_base-cc6edf378e32e607037cd8e69032efbe74917984.tar.gz
frameworks_base-cc6edf378e32e607037cd8e69032efbe74917984.tar.bz2
Check for periodic sync that is in the future
Bug: 5164762 Change-Id: If578737bcfc4f83756f75c516657afdfc601caf1
Diffstat (limited to 'core/java/android/content/SyncManager.java')
-rw-r--r--core/java/android/content/SyncManager.java7
1 files changed, 5 insertions, 2 deletions
diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java
index 5be6ec1..496da41 100644
--- a/core/java/android/content/SyncManager.java
+++ b/core/java/android/content/SyncManager.java
@@ -1573,8 +1573,11 @@ public class SyncManager implements OnAccountsUpdateListener {
final Long periodInSeconds = info.periodicSyncs.get(i).second;
// find when this periodic sync was last scheduled to run
final long lastPollTimeAbsolute = status.getPeriodicSyncTime(i);
- // compute when this periodic sync should next run
- long nextPollTimeAbsolute = lastPollTimeAbsolute + periodInSeconds * 1000;
+ // compute when this periodic sync should next run - this can be in the future
+ // for example if the user changed the time, synced and changed back.
+ final long nextPollTimeAbsolute = lastPollTimeAbsolute > nowAbsolute
+ ? nowAbsolute
+ : lastPollTimeAbsolute + periodInSeconds * 1000;
// if it is ready to run then schedule it and mark it as having been scheduled
if (nextPollTimeAbsolute <= nowAbsolute) {
final Pair<Long, Long> backoff =