Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c222a93d authored by Alon Albert's avatar Alon Albert Committed by The Android Automerger
Browse files

Check for periodic sync that is in the future

Bug: 5164762
Change-Id: If578737bcfc4f83756f75c516657afdfc601caf1
parent f56b1777
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -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 =