From 8c0f5599a1d33920801d783f3936731d7e452449 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Mon, 9 Jan 2017 16:49:11 +0100 Subject: [PATCH] Do not try to remove notifications from the device in some obvious cases --- .../externalevents/NotificationListener.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 4ad5fa48b..70c026c15 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java @@ -392,7 +392,22 @@ public class NotificationListener extends NotificationListenerService { @Override public void onNotificationRemoved(StatusBarNotification sbn) { + //FIXME: deduplicate code + String source = sbn.getPackageName(); + Notification notification = sbn.getNotification(); + if ((notification.flags & Notification.FLAG_ONGOING_EVENT) == Notification.FLAG_ONGOING_EVENT) { + return; + } + + if (source.equals("android") || + source.equals("com.android.systemui") || + source.equals("com.android.dialer") || + source.equals("com.cyanogenmod.eleven")) { + return; + } + LOG.info("notification removed, will ask device to delete it"); + GBApplication.deviceService().onDeleteNotification((int) sbn.getPostTime()); //FIMXE: a truly unique id would be better }