From 94683a863dfd3cd56062c42b26d23f2f288d8ee2 Mon Sep 17 00:00:00 2001 From: Dmitriy Bogdanov Date: Wed, 11 Mar 2020 13:53:25 +0400 Subject: [PATCH] Fix VoIP call handling during "Do Not Disturb" mode Also honor notification blacklist for such calls. --- .../externalevents/NotificationListener.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java index feaed0651..1571fd8a1 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java @@ -253,15 +253,6 @@ public class NotificationListener extends NotificationListenerService { notificationStack.remove(sbn.getPackageName()); notificationStack.add(sbn.getPackageName()); - Prefs prefs = GBApplication.getPrefs(); - if (GBApplication.isRunningLollipopOrLater()) { - if (NotificationCompat.CATEGORY_CALL.equals(sbn.getNotification().category) - && prefs.getBoolean("notification_support_voip_calls", false)) { - handleCallNotification(sbn); - return; - } - } - if (shouldIgnoreNotifications()) return; if (shouldIgnoreSource(sbn)) { @@ -271,14 +262,7 @@ public class NotificationListener extends NotificationListenerService { if (handleMediaSessionNotification(sbn)) return; - if (shouldIgnoreNotification(sbn)) { - LOG.info("Ignoring notification"); - return; - } - switch (GBApplication.getGrantedInterruptionFilter()) { - case NotificationManager.INTERRUPTION_FILTER_ALL: - break; case NotificationManager.INTERRUPTION_FILTER_ALARMS: case NotificationManager.INTERRUPTION_FILTER_NONE: return; @@ -287,6 +271,20 @@ public class NotificationListener extends NotificationListenerService { return; } + Prefs prefs = GBApplication.getPrefs(); + if (GBApplication.isRunningLollipopOrLater()) { + if (NotificationCompat.CATEGORY_CALL.equals(sbn.getNotification().category) + && prefs.getBoolean("notification_support_voip_calls", false)) { + handleCallNotification(sbn); + return; + } + } + + if (shouldIgnoreNotification(sbn)) { + LOG.info("Ignoring notification"); + return; + } + String source = sbn.getPackageName().toLowerCase(); Notification notification = sbn.getNotification(); if (notificationOldRepeatPrevention.containsKey(source)) { @@ -672,6 +670,11 @@ public class NotificationListener extends NotificationListenerService { notificationStack.remove(sbn.getPackageName()); + if (shouldIgnoreNotifications()) return; + if (shouldIgnoreSource(sbn)) return; + + if (handleMediaSessionNotification(sbn)) return; + if (GBApplication.isRunningLollipopOrLater()) { if(Notification.CATEGORY_CALL.equals(sbn.getNotification().category) && activeCallPostTime == sbn.getPostTime()) { @@ -684,9 +687,6 @@ public class NotificationListener extends NotificationListenerService { } // FIXME: DISABLED for now - if (shouldIgnoreNotifications()) return; - if (shouldIgnoreSource(sbn)) return; - if (handleMediaSessionNotification(sbn)) return; if (shouldIgnoreNotification(sbn)) return; Prefs prefs = GBApplication.getPrefs();