summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorAlon Albert <aalbert@google.com>2011-08-17 10:34:35 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-08-17 10:34:35 -0700
commit14ee9a117e9c307678ae71fda070687ac0409c29 (patch)
treed648aa3e80d6e064ab0f878da11faa090d762ad7 /core/java
parentbc91ea6bfffde0dd55e6ed1a1677422da86e7462 (diff)
parentcc6edf378e32e607037cd8e69032efbe74917984 (diff)
downloadframeworks_base-14ee9a117e9c307678ae71fda070687ac0409c29.zip
frameworks_base-14ee9a117e9c307678ae71fda070687ac0409c29.tar.gz
frameworks_base-14ee9a117e9c307678ae71fda070687ac0409c29.tar.bz2
Merge "Check for periodic sync that is in the future Bug: 5164762 Change-Id: If578737bcfc4f83756f75c516657afdfc601caf1"
Diffstat (limited to 'core/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 =