diff options
author | Scott Mertz <scott@cyngn.com> | 2015-03-10 16:42:55 -0700 |
---|---|---|
committer | Scott Mertz <scott@cyngn.com> | 2015-03-11 23:17:28 +0000 |
commit | f1da736e118eb3d4160170c4ae572174186961b2 (patch) | |
tree | 32b28d054a23b3fe69fc6b4b5eb8c50464a84d90 | |
parent | 6bbcc51df1673678d1ede11c5ed41fa13748f2ab (diff) | |
download | android_packages_apps_LockClock-f1da736e118eb3d4160170c4ae572174186961b2.tar.gz android_packages_apps_LockClock-f1da736e118eb3d4160170c4ae572174186961b2.tar.bz2 android_packages_apps_LockClock-f1da736e118eb3d4160170c4ae572174186961b2.zip |
LockClock: Ignore "inaccurate" locations
- Location manager can report locations for any level of accuracy. Filter
locations that are generally not useful.
- Set location accuracy threshold to 50km.
Change-Id: I225ed4e74edec6c5089d886c61f8d78f09b11b34
-rw-r--r-- | src/com/cyanogenmod/lockclock/weather/WeatherUpdateService.java | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/com/cyanogenmod/lockclock/weather/WeatherUpdateService.java b/src/com/cyanogenmod/lockclock/weather/WeatherUpdateService.java index 662bab4..a228ec7 100644 --- a/src/com/cyanogenmod/lockclock/weather/WeatherUpdateService.java +++ b/src/com/cyanogenmod/lockclock/weather/WeatherUpdateService.java @@ -58,6 +58,7 @@ public class WeatherUpdateService extends Service { private static final long LOCATION_REQUEST_TIMEOUT = 5L * 60L * 1000L; // request for at most 5 minutes private static final long OUTDATED_LOCATION_THRESHOLD_MILLIS = 10L * 60L * 1000L; // 10 minutes + private static final float LOCATION_ACCURACY_THRESHOLD_METERS = 50000; private WeatherUpdateTask mTask; @@ -169,6 +170,11 @@ public class WeatherUpdateService extends Service { Location location = lm.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER); if (D) Log.v(TAG, "Current location is " + location); + if (location != null && location.getAccuracy() > LOCATION_ACCURACY_THRESHOLD_METERS) { + if (D) Log.d(TAG, "Ignoring inaccurate location"); + location = null; + } + // If lastKnownLocation is not present (because none of the apps in the // device has requested the current location to the system yet) or outdated, // then try to get the current location use the provider that best matches the criteria. |