From 9f766ebf781b770b6e1b37da084e6193698cee4c Mon Sep 17 00:00:00 2001 From: Stypox Date: Thu, 11 Jul 2024 09:30:22 +0200 Subject: [PATCH] Fix NPE in MediaSessionPlayerUi while destroying player --- .../newpipe/player/mediasession/MediaSessionPlayerUi.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/player/mediasession/MediaSessionPlayerUi.java b/app/src/main/java/org/schabi/newpipe/player/mediasession/MediaSessionPlayerUi.java index 737ebc5dd..c673e688c 100644 --- a/app/src/main/java/org/schabi/newpipe/player/mediasession/MediaSessionPlayerUi.java +++ b/app/src/main/java/org/schabi/newpipe/player/mediasession/MediaSessionPlayerUi.java @@ -38,7 +38,9 @@ public class MediaSessionPlayerUi extends PlayerUi implements SharedPreferences.OnSharedPreferenceChangeListener { private static final String TAG = "MediaSessUi"; + @Nullable private MediaSessionCompat mediaSession; + @Nullable private MediaSessionConnector sessionConnector; private final String ignoreHardwareMediaButtonsKey; @@ -198,6 +200,11 @@ public class MediaSessionPlayerUi extends PlayerUi return; } + if (sessionConnector == null) { + // sessionConnector will be null after destroyPlayer is called + return; + } + // only use the fourth and fifth actions (the settings page also shows only the last 2 on // Android 13+) final List newNotificationActions = IntStream.of(3, 4)