diff options
| author | 2022-02-25 14:54:33 +0000 | |
|---|---|---|
| committer | 2022-02-28 11:37:27 +0000 | |
| commit | fe7af3e5d24aa18dc8af11d469bd3f2972b92323 (patch) | |
| tree | 544b18b9e01b83407c7e7a54c4168600a5706a02 | |
| parent | faedb36fb794e3230a421c3bb286e954dd935284 (diff) | |
Fix bug in NetworkTimeUpdateService
Reset try again counter after a successful NTP refresh
Reset alarm to run at exactly mPollingIntervalMs after the last
NTP update.
Bug: b/217357882
Test: Existing unit tests still pass.
Change-Id: Ibee93ab305f5bcaa149007c15d12c583227678b9
| -rw-r--r-- | services/core/java/com/android/server/NetworkTimeUpdateService.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/NetworkTimeUpdateService.java b/services/core/java/com/android/server/NetworkTimeUpdateService.java index a0f239d43927..fcde533fe05c 100644 --- a/services/core/java/com/android/server/NetworkTimeUpdateService.java +++ b/services/core/java/com/android/server/NetworkTimeUpdateService.java @@ -171,7 +171,9 @@ public class NetworkTimeUpdateService extends Binder { >= mPollingIntervalMs) { if (DBG) Log.d(TAG, "Stale NTP fix; forcing refresh"); boolean isSuccessful = mTime.forceRefresh(); - if (!isSuccessful) { + if (isSuccessful) { + mTryAgainCounter = 0; + } else { String logMsg = "forceRefresh() returned false: cachedNtpResult=" + cachedNtpResult + ", currentElapsedRealtimeMillis=" + currentElapsedRealtimeMillis; @@ -188,7 +190,8 @@ public class NetworkTimeUpdateService extends Binder { && cachedNtpResult.getAgeMillis(currentElapsedRealtimeMillis) < mPollingIntervalMs) { // Obtained fresh fix; schedule next normal update - resetAlarm(mPollingIntervalMs); + resetAlarm(mPollingIntervalMs + - cachedNtpResult.getAgeMillis(currentElapsedRealtimeMillis)); // Suggest the time to the time detector. It may choose use it to set the system clock. TimestampedValue<Long> timeSignal = new TimestampedValue<>( |