diff options
author | Amith Yamasani <yamasani@google.com> | 2012-05-03 10:19:40 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-05-03 10:19:40 -0700 |
commit | c793d62613b8cee340ce6c20856f6db81575f034 (patch) | |
tree | 13c2a3619668ba423c8273529b74d884b05a07fe | |
parent | eaca069aff710eb8776669bd5d8016d10b7d2467 (diff) | |
parent | 708d5d444bd47db96a47cf5153bdfb8b0f3b975b (diff) | |
download | frameworks_base-c793d62613b8cee340ce6c20856f6db81575f034.zip frameworks_base-c793d62613b8cee340ce6c20856f6db81575f034.tar.gz frameworks_base-c793d62613b8cee340ce6c20856f6db81575f034.tar.bz2 |
Merge "On first boot and NTP lookup, set the time even if it's not off by 5+ secs." into jb-dev
-rw-r--r-- | services/java/com/android/server/NetworkTimeUpdateService.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/services/java/com/android/server/NetworkTimeUpdateService.java b/services/java/com/android/server/NetworkTimeUpdateService.java index 1ff914f..76972bc 100644 --- a/services/java/com/android/server/NetworkTimeUpdateService.java +++ b/services/java/com/android/server/NetworkTimeUpdateService.java @@ -165,9 +165,15 @@ public class NetworkTimeUpdateService { if (mTime.getCacheAge() < POLLING_INTERVAL_MS) { final long ntp = mTime.currentTimeMillis(); mTryAgainCounter = 0; - mLastNtpFetchTime = SystemClock.elapsedRealtime(); - if (Math.abs(ntp - currentTime) > TIME_ERROR_THRESHOLD_MS) { + // If the clock is more than N seconds off or this is the first time it's been + // fetched since boot, set the current time. + if (Math.abs(ntp - currentTime) > TIME_ERROR_THRESHOLD_MS + || mLastNtpFetchTime == NOT_SET) { // Set the system time + if (DBG && mLastNtpFetchTime == NOT_SET + && Math.abs(ntp - currentTime) <= TIME_ERROR_THRESHOLD_MS) { + Log.d(TAG, "For initial setup, rtc = " + currentTime); + } if (DBG) Log.d(TAG, "Ntp time to be set = " + ntp); // Make sure we don't overflow, since it's going to be converted to an int if (ntp / 1000 < Integer.MAX_VALUE) { @@ -176,6 +182,7 @@ public class NetworkTimeUpdateService { } else { if (DBG) Log.d(TAG, "Ntp time is close enough = " + ntp); } + mLastNtpFetchTime = SystemClock.elapsedRealtime(); } else { // Try again shortly mTryAgainCounter++; |