From 17f4dfb7c4a2b4606b7b8dac70fbac738af505f2 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Fri, 25 May 2018 18:25:44 +0300 Subject: [PATCH 1/3] Fix OsmAndLocationProvider#scheduleCheckIfGpsLost --- .../osmand/plus/OsmAndLocationProvider.java | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java index 69394cb8fe..52da10c065 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java @@ -691,7 +691,8 @@ public class OsmAndLocationProvider implements SensorEventListener { private void scheduleCheckIfGpsLost(final net.osmand.Location location) { final RoutingHelper routingHelper = app.getRoutingHelper(); - if (location != null) { + if (location != null && routingHelper.isFollowingMode() && routingHelper.getLeftDistance() > 0 + && simulatePosition == null) { final long fixTime = location.getTime(); app.runMessageInUIThreadAndCancelPrevious(LOST_LOCATION_MSG_ID, new Runnable() { @@ -709,25 +710,23 @@ public class OsmAndLocationProvider implements SensorEventListener { setLocation(null); } }, LOST_LOCATION_CHECK_DELAY); - if (routingHelper.isFollowingMode() && routingHelper.getLeftDistance() > 0 && simulatePosition == null) { - app.runMessageInUIThreadAndCancelPrevious(START_SIMULATE_LOCATION_MSG_ID, new Runnable() { + app.runMessageInUIThreadAndCancelPrevious(START_SIMULATE_LOCATION_MSG_ID, new Runnable() { - @Override - public void run() { - net.osmand.Location lastKnown = getLastKnownLocation(); - if (lastKnown != null && lastKnown.getTime() > fixTime) { - // false positive case, still strange how we got here with removeMessages - return; - } - List tunnel = routingHelper.getUpcomingTunnel(1000); - if(tunnel != null) { - simulatePosition = new SimulationProvider(); - simulatePosition.startSimulation(tunnel, location); - simulatePositionImpl(); - } + @Override + public void run() { + net.osmand.Location lastKnown = getLastKnownLocation(); + if (lastKnown != null && lastKnown.getTime() > fixTime) { + // false positive case, still strange how we got here with removeMessages + return; } - }, START_LOCATION_SIMULATION_DELAY); - } + List tunnel = routingHelper.getUpcomingTunnel(1000); + if(tunnel != null) { + simulatePosition = new SimulationProvider(); + simulatePosition.startSimulation(tunnel, location); + simulatePositionImpl(); + } + } + }, START_LOCATION_SIMULATION_DELAY); } } From ae2df017ef08bbc0d2a363ce7d4c5a983798868e Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Fri, 25 May 2018 18:32:46 +0300 Subject: [PATCH 2/3] Add check for "setLocation(null)" --- OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java index 52da10c065..81ddb09e66 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java @@ -706,8 +706,10 @@ public class OsmAndLocationProvider implements SensorEventListener { gpsSignalLost = true; if (routingHelper.isFollowingMode() && routingHelper.getLeftDistance() > 0) { routingHelper.getVoiceRouter().gpsLocationLost(); + if (simulatePosition == null) { + setLocation(null); + } } - setLocation(null); } }, LOST_LOCATION_CHECK_DELAY); app.runMessageInUIThreadAndCancelPrevious(START_SIMULATE_LOCATION_MSG_ID, new Runnable() { From 27b88ea389eb58b98a48b6f7d7ddabb993e0bc8d Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Fri, 25 May 2018 18:40:28 +0300 Subject: [PATCH 3/3] Fix check for "setLocation(null)" --- OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java index 81ddb09e66..c98be15d2e 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java @@ -704,11 +704,10 @@ public class OsmAndLocationProvider implements SensorEventListener { return; } gpsSignalLost = true; - if (routingHelper.isFollowingMode() && routingHelper.getLeftDistance() > 0) { + if (routingHelper.isFollowingMode() && routingHelper.getLeftDistance() > 0 + && simulatePosition == null) { routingHelper.getVoiceRouter().gpsLocationLost(); - if (simulatePosition == null) { - setLocation(null); - } + setLocation(null); } } }, LOST_LOCATION_CHECK_DELAY);