From d146f1f140ab264ad54c8e6db384ffeca245ee0d Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Fri, 1 Jun 2012 00:00:49 +0200 Subject: [PATCH] Double check GPS Lost --- OsmAnd/src/net/osmand/plus/NavigationService.java | 3 ++- .../src/net/osmand/plus/activities/MapActivity.java | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/NavigationService.java b/OsmAnd/src/net/osmand/plus/NavigationService.java index 684350ac85..f8696e32b0 100644 --- a/OsmAnd/src/net/osmand/plus/NavigationService.java +++ b/OsmAnd/src/net/osmand/plus/NavigationService.java @@ -183,7 +183,8 @@ public class NavigationService extends Service implements LocationListener { Message msg = Message.obtain(handler, new Runnable() { @Override public void run() { - if (routingHelper.getLeftDistance() > 0 && !settings.MAP_ACTIVITY_ENABLED.get()) { + if (routingHelper.getLeftDistance() > 0 && !settings.MAP_ACTIVITY_ENABLED.get() && + !handler.hasMessages(LOST_LOCATION_MSG_ID)) { routingHelper.getVoiceRouter().gpsLocationLost(); } } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 715134bc2d..5c8cef8c3d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -738,7 +738,7 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe } } - public void setLocation(Location location){ + public void setLocation(final Location location){ if(Log.isLoggable(LogUtil.TAG, Log.DEBUG)){ Log.d(LogUtil.TAG, "Location changed " + location.getProvider()); //$NON-NLS-1$ } @@ -772,7 +772,14 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe // Check with delay that gps location is not lost if(location != null && routingHelper.getLeftDistance() > 0){ Message msg = Message.obtain(uiHandler, new Runnable() { - @Override public void run() { + @Override + public void run() { + long fixTime = location.getTime(); + Location lastKnown = getLastKnownLocation(); + if(lastKnown != null && lastKnown.getTime() - fixTime < LOST_LOCATION_CHECK_DELAY) { + // false positive case, still strange how we got here with removeMessages + return; + } if (routingHelper.getLeftDistance() > 0 && settings.MAP_ACTIVITY_ENABLED.get()) { routingHelper.getVoiceRouter().gpsLocationLost(); }