Fix npe in NavigationService

This commit is contained in:
max-klaus 2021-02-04 12:49:52 +03:00
parent 4dc202dbc9
commit 4a63606893

View file

@ -4,16 +4,13 @@ import android.app.Notification;
import android.app.Service; import android.app.Service;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.location.LocationManager;
import android.os.Binder; import android.os.Binder;
import android.os.IBinder; import android.os.IBinder;
import android.util.Log;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.PlatformUtil;
import net.osmand.plus.helpers.LocationServiceHelper; import net.osmand.plus.helpers.LocationServiceHelper;
import net.osmand.plus.helpers.LocationServiceHelper.LocationCallback; import net.osmand.plus.helpers.LocationServiceHelper.LocationCallback;
import net.osmand.plus.notifications.OsmandNotification; import net.osmand.plus.notifications.OsmandNotification;
@ -137,10 +134,12 @@ public class NavigationService extends Service {
app.setNavigationService(null); app.setNavigationService(null);
usedBy = 0; usedBy = 0;
// remove updates // remove updates
try { if (locationServiceHelper != null) {
locationServiceHelper.removeLocationUpdates(); try {
} catch (SecurityException e) { locationServiceHelper.removeLocationUpdates();
// Location service permission not granted } catch (SecurityException e) {
// Location service permission not granted
}
} }
// remove notification // remove notification
stopForeground(Boolean.TRUE); stopForeground(Boolean.TRUE);