1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-26 02:25:50 +01:00

Catch SecurityException when Notfication access was not granted when getting media session

Fixes #1387
This commit is contained in:
Andreas Shimokawa 2019-01-10 17:30:49 +01:00
parent 629dcfdec2
commit b4bbf6186c

View File

@ -106,7 +106,7 @@ public class GBMusicControlReceiver extends BroadcastReceiver {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
MediaSessionManager mediaSessionManager =
(MediaSessionManager) context.getSystemService(Context.MEDIA_SESSION_SERVICE);
try {
List<MediaController> controllers = mediaSessionManager.getActiveSessions(
new ComponentName(context, NotificationListener.class));
try {
@ -115,6 +115,9 @@ public class GBMusicControlReceiver extends BroadcastReceiver {
} catch (IndexOutOfBoundsException e) {
LOG.error("No media controller available", e);
}
} catch (SecurityException e) {
LOG.warn("No permission to get media sessions - did not grant notification access?", e);
}
}
return audioPlayer;
}