forked from upstream-mirrors/OpenTracks
Bugfix: LocationHandler should ignore locations after stopping.
This commit is contained in:
@@ -44,6 +44,10 @@ public class LocationHandler implements LocationListener, GpsStatus.GpsStatusLis
|
|||||||
gpsStatus.start();
|
gpsStatus.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isStarted() {
|
||||||
|
return locationManager != null;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"MissingPermission"})
|
@SuppressWarnings({"MissingPermission"})
|
||||||
//TODO upgrade to AGP7.0.0/API31 started complaining about removeUpdates.
|
//TODO upgrade to AGP7.0.0/API31 started complaining about removeUpdates.
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
@@ -96,6 +100,11 @@ public class LocationHandler implements LocationListener, GpsStatus.GpsStatusLis
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onLocationChanged(@NonNull Location location) {
|
public void onLocationChanged(@NonNull Location location) {
|
||||||
|
if (!isStarted()) {
|
||||||
|
Log.w(TAG, "Location is ignored; not started.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
TrackPoint trackPoint = new TrackPoint(location, handlerServer.createNow());
|
TrackPoint trackPoint = new TrackPoint(location, handlerServer.createNow());
|
||||||
boolean isAccurate = trackPoint.fulfillsAccuracy(thresholdHorizontalAccuracy);
|
boolean isAccurate = trackPoint.fulfillsAccuracy(thresholdHorizontalAccuracy);
|
||||||
boolean isValid = LocationUtils.isValidLocation(location);
|
boolean isValid = LocationUtils.isValidLocation(location);
|
||||||
|
|||||||
Reference in New Issue
Block a user