From a0e9dfbec22e21f1292acab0b5731f94ca2c530d Mon Sep 17 00:00:00 2001 From: Colin Edwards Date: Tue, 23 Apr 2024 00:22:09 -0500 Subject: [PATCH] android: null check intent in onStartCommand For some reason the type annotations here show @NonNull but that is actually false according to the documentation under service. This may be null if the service is being restarted after its process has gone away, and it had previously returned anything except START_STICKY_COMPATIBILITY. --- android/app/src/main/java/org/musicpd/Main.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/java/org/musicpd/Main.java b/android/app/src/main/java/org/musicpd/Main.java index 3c4ad5464..5f440b964 100644 --- a/android/app/src/main/java/org/musicpd/Main.java +++ b/android/app/src/main/java/org/musicpd/Main.java @@ -133,11 +133,11 @@ public class Main extends Service implements Runnable { @Override public int onStartCommand(Intent intent, int flags, int startId) { - if (Objects.equals(intent.getAction(), SHUTDOWN_ACTION)) { + if (intent != null && Objects.equals(intent.getAction(), SHUTDOWN_ACTION)) { stop(); } else { start(); - if (intent.getBooleanExtra("wakelock", false)) + if (intent != null && intent.getBooleanExtra("wakelock", false)) setWakelockEnabled(true); } return START_STICKY;