Double check GPS Lost

This commit is contained in:
Victor Shcherb 2012-06-01 00:00:49 +02:00
parent 72f73faaec
commit d146f1f140
2 changed files with 11 additions and 3 deletions

View file

@ -183,7 +183,8 @@ public class NavigationService extends Service implements LocationListener {
Message msg = Message.obtain(handler, new Runnable() { Message msg = Message.obtain(handler, new Runnable() {
@Override @Override
public void run() { 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(); routingHelper.getVoiceRouter().gpsLocationLost();
} }
} }

View file

@ -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)){ if(Log.isLoggable(LogUtil.TAG, Log.DEBUG)){
Log.d(LogUtil.TAG, "Location changed " + location.getProvider()); //$NON-NLS-1$ 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 // Check with delay that gps location is not lost
if(location != null && routingHelper.getLeftDistance() > 0){ if(location != null && routingHelper.getLeftDistance() > 0){
Message msg = Message.obtain(uiHandler, new Runnable() { 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()) { if (routingHelper.getLeftDistance() > 0 && settings.MAP_ACTIVITY_ENABLED.get()) {
routingHelper.getVoiceRouter().gpsLocationLost(); routingHelper.getVoiceRouter().gpsLocationLost();
} }