aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Mertz <scott@cyngn.com>2015-03-10 16:42:55 -0700
committerZhao Wei Liew <zhaoweiliew@gmail.com>2017-03-02 08:20:52 +0000
commitc85ba5c6fd47b14017d3d96969218022daa53861 (patch)
tree60ac0f21685a48ea7b3352cc2957d1047688b2a2
parent9b558f1f75b3be8ec1c33ab4fa9fe605d2524bf5 (diff)
downloadandroid_packages_apps_LockClock-cm-11.0.tar.gz
android_packages_apps_LockClock-cm-11.0.tar.bz2
android_packages_apps_LockClock-cm-11.0.zip
LockClock: Ignore "inaccurate" locationscm-11.0
- 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
-rwxr-xr-xsrc/com/cyanogenmod/lockclock/weather/WeatherUpdateService.java6
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 64fd5c6..4b5f835 100755
--- a/src/com/cyanogenmod/lockclock/weather/WeatherUpdateService.java
+++ b/src/com/cyanogenmod/lockclock/weather/WeatherUpdateService.java
@@ -59,6 +59,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;
@@ -170,6 +171,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.