diff options
| author | 2017-05-15 20:23:12 -0700 | |
|---|---|---|
| committer | 2017-05-18 17:11:13 +0000 | |
| commit | 2a968edf307fbfa4e1adcfa888d91edc0041cd70 (patch) | |
| tree | 5645bf0d88f6b7f7aa5755c2348bc8ec1c921e40 | |
| parent | 8d87842690c617772968ab887dce221e328b6f89 (diff) | |
Change currentTimeMillis to elapsedRealtime
System.currentTimeMillis does not gauntness to be monotonically
increasing, changed to SystemClock.elapsedRealtime
Bug: 38317243
Fixes: 38317243
Test: make -j 32; flash the angler device using local build
Change-Id: I3fd8f8b03655183d257d69412bc1c17cc38ccead
Merged-In: I75a70d43028e901d9f3459d6b525cac58e8e64af
| -rw-r--r-- | services/core/java/com/android/server/location/GnssLocationProvider.java | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/location/GnssLocationProvider.java b/services/core/java/com/android/server/location/GnssLocationProvider.java index 51bebb0963c9..85d89865a074 100644 --- a/services/core/java/com/android/server/location/GnssLocationProvider.java +++ b/services/core/java/com/android/server/location/GnssLocationProvider.java @@ -937,7 +937,7 @@ public class GnssLocationProvider implements LocationProviderInterface { long time = mNtpTime.getCachedNtpTime(); long timeReference = mNtpTime.getCachedNtpTimeReference(); long certainty = mNtpTime.getCacheCertainty(); - long now = System.currentTimeMillis(); + long now = SystemClock.elapsedRealtime(); if (DEBUG) { Log.d(TAG, "NTP server returned: " @@ -1444,7 +1444,8 @@ public class GnssLocationProvider implements LocationProviderInterface { // reset SV count to zero updateStatus(LocationProvider.TEMPORARILY_UNAVAILABLE, 0); - mFixRequestTime = System.currentTimeMillis(); + mFixRequestTime = SystemClock.elapsedRealtime(); + if (!hasCapability(GPS_CAPABILITY_SCHEDULING)) { // set timer to give up if we do not receive a fix within NO_FIX_TIMEOUT // and our fix interval is not short @@ -1514,7 +1515,7 @@ public class GnssLocationProvider implements LocationProviderInterface { } } - mLastFixTime = System.currentTimeMillis(); + mLastFixTime = SystemClock.elapsedRealtime(); // report time to first fix if (mTimeToFirstFix == 0 && hasLatLong) { mTimeToFirstFix = (int)(mLastFixTime - mFixRequestTime); @@ -1629,7 +1630,7 @@ public class GnssLocationProvider implements LocationProviderInterface { updateStatus(mStatus, usedInFixCount); if (mNavigating && mStatus == LocationProvider.AVAILABLE && mLastFixTime > 0 && - System.currentTimeMillis() - mLastFixTime > RECENT_FIX_TIMEOUT) { + SystemClock.elapsedRealtime() - mLastFixTime > RECENT_FIX_TIMEOUT) { // send an intent to notify that the GPS is no longer receiving fixes. Intent intent = new Intent(LocationManager.GPS_FIX_CHANGE_ACTION); intent.putExtra(LocationManager.EXTRA_GPS_ENABLED, false); |