From 4a6360689368c363f1a396a1747a3625c3c0b4bb Mon Sep 17 00:00:00 2001 From: max-klaus Date: Thu, 4 Feb 2021 12:49:52 +0300 Subject: [PATCH 1/3] Fix npe in NavigationService --- OsmAnd/src/net/osmand/plus/NavigationService.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/NavigationService.java b/OsmAnd/src/net/osmand/plus/NavigationService.java index 16f1afddcc..8e525c0f91 100644 --- a/OsmAnd/src/net/osmand/plus/NavigationService.java +++ b/OsmAnd/src/net/osmand/plus/NavigationService.java @@ -4,16 +4,13 @@ import android.app.Notification; import android.app.Service; import android.content.Context; import android.content.Intent; -import android.location.LocationManager; import android.os.Binder; import android.os.IBinder; -import android.util.Log; import android.widget.Toast; import androidx.annotation.NonNull; import net.osmand.Location; -import net.osmand.PlatformUtil; import net.osmand.plus.helpers.LocationServiceHelper; import net.osmand.plus.helpers.LocationServiceHelper.LocationCallback; import net.osmand.plus.notifications.OsmandNotification; @@ -137,10 +134,12 @@ public class NavigationService extends Service { app.setNavigationService(null); usedBy = 0; // remove updates - try { - locationServiceHelper.removeLocationUpdates(); - } catch (SecurityException e) { - // Location service permission not granted + if (locationServiceHelper != null) { + try { + locationServiceHelper.removeLocationUpdates(); + } catch (SecurityException e) { + // Location service permission not granted + } } // remove notification stopForeground(Boolean.TRUE); From ddaaaa6d432ed65a2060bd86b02cfaac81bb7932 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Thu, 4 Feb 2021 13:20:16 +0300 Subject: [PATCH 2/3] Hide off service (location) toast --- OsmAnd/src/net/osmand/plus/NavigationService.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/NavigationService.java b/OsmAnd/src/net/osmand/plus/NavigationService.java index 8e525c0f91..cb7d249d10 100644 --- a/OsmAnd/src/net/osmand/plus/NavigationService.java +++ b/OsmAnd/src/net/osmand/plus/NavigationService.java @@ -92,12 +92,6 @@ public class NavigationService extends Service { @Override public void onLocationAvailability(boolean locationAvailable) { - if (!locationAvailable) { - OsmandApplication app = (OsmandApplication) getApplication(); - if (app != null) { - app.showToastMessage(getString(R.string.off_router_service_no_gps_available)); - } - } } }); } catch (SecurityException e) { From 2fbdb121e407e76f4c9cf4aeaec0aa3c0a9cc4f2 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Thu, 4 Feb 2021 16:41:50 +0300 Subject: [PATCH 3/3] Fix npe --- .../net/osmand/plus/voice/JSMediaCommandPlayerImpl.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/voice/JSMediaCommandPlayerImpl.java b/OsmAnd/src/net/osmand/plus/voice/JSMediaCommandPlayerImpl.java index 80fd5381ab..fd9caafe2c 100644 --- a/OsmAnd/src/net/osmand/plus/voice/JSMediaCommandPlayerImpl.java +++ b/OsmAnd/src/net/osmand/plus/voice/JSMediaCommandPlayerImpl.java @@ -90,9 +90,12 @@ public class JSMediaCommandPlayerImpl extends MediaCommandPlayerImpl { if (voiceDir.getName().contains("tts")) { return false; } - for (File f : voiceDir.listFiles()) { - if (f.getName().endsWith(IndexConstants.TTSVOICE_INDEX_EXT_JS)) { - return true; + File[] files = voiceDir.listFiles(); + if (files != null) { + for (File f : files) { + if (f.getName().endsWith(IndexConstants.TTSVOICE_INDEX_EXT_JS)) { + return true; + } } } return false;