Fixed notification remove callback by looking up the original id

This commit is contained in:
dakhnod 2019-10-20 01:49:21 +02:00
parent 5c0c5ed952
commit 12bf3e43ca
2 changed files with 14 additions and 5 deletions

View File

@ -629,6 +629,9 @@ public class NotificationListener extends NotificationListenerService {
@Override
public void onNotificationRemoved(StatusBarNotification sbn) {
LOG.info("Notification removed: " + sbn.getPackageName());
int originalId = (int) mNotificationHandleLookup.lookupByValue(sbn.getPostTime());
if (GBApplication.isRunningLollipopOrLater()) {
LOG.info("Notification removed: " + sbn.getPackageName() + ", category: " + sbn.getNotification().category);
if (Notification.CATEGORY_CALL.equals(sbn.getNotification().category) && activeCallPostTime == sbn.getPostTime()) {
@ -638,17 +641,14 @@ public class NotificationListener extends NotificationListenerService {
GBApplication.deviceService().onSetCallState(callSpec);
}
}
// FIXME: DISABLED for now
/*
if (shouldIgnore(sbn))
return;
Prefs prefs = GBApplication.getPrefs();
if (prefs.getBoolean("autoremove_notifications", false)) {
if (prefs.getBoolean("autoremove_notifications", true)) {
LOG.info("notification removed, will ask device to delete it");
GBApplication.deviceService().onDeleteNotification((int) sbn.getPostTime());
GBApplication.deviceService().onDeleteNotification(originalId);
}
*/
}

View File

@ -53,4 +53,13 @@ public class LimitedQueue {
}
return null;
}
synchronized public Object lookupByValue(Object value){
for (Pair entry : list) {
if (value.equals(entry.second)) {
return entry.first;
}
}
return null;
}
}