diff options
| author | Nick Pelly <npelly@google.com> | 2012-07-18 13:13:37 -0700 |
|---|---|---|
| committer | Nick Pelly <npelly@google.com> | 2012-07-20 10:07:07 -0700 |
| commit | 2eeeec248a38ff33999c83f4b8d5bab7d50e79d2 (patch) | |
| tree | 2886aaefdd09bbafa7853dbbbb29aa866846045f /services/java/com/android/server/LocationManagerService.java | |
| parent | b8acd060d409f0e81ab3510b429cb86d3f34adb8 (diff) | |
| download | frameworks_base-2eeeec248a38ff33999c83f4b8d5bab7d50e79d2.zip frameworks_base-2eeeec248a38ff33999c83f4b8d5bab7d50e79d2.tar.gz frameworks_base-2eeeec248a38ff33999c83f4b8d5bab7d50e79d2.tar.bz2 | |
Improve Location object.
Add getElapsedRealtimeNano():
Currently Location just has getTime() and setTime() based on UTC time.
This is entirely unreliable since it is not guaranteed monotonic.
There is a lot of code that compares fix age based on deltas -
and it is all broken in the case of a system clock change. System
clock can change when switching cellular networks (and in some
cases when switching towers).
Document the meaning of getAccuracy():
It is the horizontal, 95% confidence radius.
Make some fields mandatory if they are reported by a LocationProvider:
All Locations returned by a LocationProvider must include at the
minimum a lat, long, timestamps, and accuracy. This is necessary
to perform fused location. There are no public API's for applications
to feed locations into a location provider so this should not cause
any breakage.
If a LocationProvider does not fill in enough fields on a Location
object then it is dropped, and logged.
Bug: 4305998
Change-Id: I7df77125d8a64e174d7bc8c2708661b4f33461ea
Diffstat (limited to 'services/java/com/android/server/LocationManagerService.java')
| -rw-r--r-- | services/java/com/android/server/LocationManagerService.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java index 06b056d..1498a11 100644 --- a/services/java/com/android/server/LocationManagerService.java +++ b/services/java/com/android/server/LocationManagerService.java @@ -1532,6 +1532,11 @@ public class LocationManagerService extends ILocationManager.Stub implements Run throw new SecurityException("Requires INSTALL_LOCATION_PROVIDER permission"); } + if (!location.isComplete()) { + Log.w(TAG, "Dropping incomplete location: " + location); + return; + } + mLocationHandler.removeMessages(MESSAGE_LOCATION_CHANGED, location); Message m = Message.obtain(mLocationHandler, MESSAGE_LOCATION_CHANGED, location); m.arg1 = (passive ? 1 : 0); @@ -1588,7 +1593,8 @@ public class LocationManagerService extends ILocationManager.Stub implements Run // Check whether sufficient time has passed long minTime = record.mMinTime; - if (loc.getTime() - lastLoc.getTime() < minTime - MAX_PROVIDER_SCHEDULING_JITTER) { + long delta = (loc.getElapsedRealtimeNano() - lastLoc.getElapsedRealtimeNano()) / 1000000L; + if (delta < minTime - MAX_PROVIDER_SCHEDULING_JITTER) { return false; } |
