From 846c74aa86370fb88cb21445aeb8398757bdbd7c Mon Sep 17 00:00:00 2001 From: Daniele Gobbetti Date: Sun, 18 Dec 2016 18:00:16 +0100 Subject: [PATCH] Forward also group summary notifications, if they contain wearable actions. Hopefully helps with #456 Tested with conversations and there is no regression. Also a specific workaround for telegram was removed, hopefully this does not break #395 --- .../externalevents/NotificationListener.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 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 5264422a0..c3cd2b3c7 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java @@ -34,7 +34,6 @@ import nodomain.freeyourgadget.gadgetbridge.model.AppNotificationType; import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec; import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec; import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec; -import nodomain.freeyourgadget.gadgetbridge.model.NotificationType; import nodomain.freeyourgadget.gadgetbridge.service.DeviceCommunicationService; import nodomain.freeyourgadget.gadgetbridge.util.LimitedQueue; import nodomain.freeyourgadget.gadgetbridge.util.Prefs; @@ -190,19 +189,13 @@ public class NotificationListener extends NotificationListenerService { if (!prefs.getBoolean("notifications_generic_whenscreenon", false)) { PowerManager powermanager = (PowerManager) getSystemService(POWER_SERVICE); if (powermanager.isScreenOn()) { - LOG.info("Not forwarding notification, screen seems to be on and settings do not allow this"); +// LOG.info("Not forwarding notification, screen seems to be on and settings do not allow this"); return; } } - //don't forward group summary notifications to the wearable, they are meant for the android device only - if ((notification.flags & Notification.FLAG_GROUP_SUMMARY) == Notification.FLAG_GROUP_SUMMARY) { - LOG.info("Not forwarding notification, FLAG_GROUP_SUMMARY is set. Notification flags: " + notification.flags); - return; - } - if ((notification.flags & Notification.FLAG_ONGOING_EVENT) == Notification.FLAG_ONGOING_EVENT) { - LOG.info("Not forwarding notification, FLAG_ONGOING_EVENT is set. Notification flags: " + notification.flags); +// LOG.info("Not forwarding notification, FLAG_ONGOING_EVENT is set. Notification flags: " + notification.flags); return; } @@ -266,8 +259,9 @@ public class NotificationListener extends NotificationListenerService { NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(notification); List actions = wearableExtender.getActions(); - if (actions.isEmpty() && notificationSpec.type == NotificationType.TELEGRAM) { - return; // workaround for duplicate telegram message + if (actions.isEmpty() && (notification.flags & Notification.FLAG_GROUP_SUMMARY) == Notification.FLAG_GROUP_SUMMARY) { //this could cause #395 to come back + LOG.info("Not forwarding notification, FLAG_GROUP_SUMMARY is set and no wearable action present. Notification flags: " + notification.flags); + return; } for (NotificationCompat.Action act : actions) {