Bug 1095914 - Fix crash if GPS not available. r=vng

https://github.com/mozilla/MozStumbler/pull/1206
This commit is contained in:
Garvan Keeley 2014-11-08 09:09:00 -05:00
Родитель 5c9fd6b65d
Коммит 5e88160aab
1 изменённых файлов: 19 добавлений и 0 удалений

Просмотреть файл

@ -65,8 +65,23 @@ public class GPSScanner implements LocationListener {
}
}
private boolean isGpsAvailable(LocationManager locationManager) {
if (locationManager == null ||
locationManager.getProvider(LocationManager.GPS_PROVIDER) == null) {
String msg = "No GPS available, scanning not started.";
Log.d(LOG_TAG, msg);
AppGlobals.guiLogError(msg);
return false;
}
return true;
}
private void startPassiveMode() {
LocationManager locationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
if (!isGpsAvailable(locationManager)) {
return;
}
locationManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER,
0,
0, this);
@ -74,6 +89,10 @@ public class GPSScanner implements LocationListener {
private void startActiveMode() {
LocationManager lm = getLocationManager();
if (!isGpsAvailable(lm)) {
return;
}
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,
ACTIVE_MODE_GPS_MIN_UPDATE_TIME_MS,
ACTIVE_MODE_GPS_MIN_UPDATE_DISTANCE_M,