mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-30 05:37:43 +00:00
Fix SecurityException if the notifications permission was revoked
This commit is contained in:
parent
96ecd620cf
commit
7ed4efedc3
@ -106,6 +106,10 @@ public class NotificationsPlugin extends Plugin implements NotificationReceiver.
|
||||
|
||||
@Override
|
||||
public boolean checkRequiredPermissions() {
|
||||
return hasNotificationsPermission();
|
||||
}
|
||||
|
||||
private boolean hasNotificationsPermission() {
|
||||
//Notifications use a different kind of permission, because it was added before the current runtime permissions model
|
||||
String notificationListenerList = Settings.Secure.getString(context.getContentResolver(), "enabled_notification_listeners");
|
||||
return StringUtils.contains(notificationListenerList, context.getPackageName());
|
||||
@ -506,6 +510,9 @@ public class NotificationsPlugin extends Plugin implements NotificationReceiver.
|
||||
}
|
||||
|
||||
private void sendCurrentNotifications(NotificationReceiver service) {
|
||||
if (!hasNotificationsPermission()) {
|
||||
return;
|
||||
}
|
||||
StatusBarNotification[] notifications = service.getActiveNotifications();
|
||||
if (notifications != null) { //Can happen only on API 23 and lower
|
||||
for (StatusBarNotification notification : notifications) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user