Ignore foreground service notifications

This commit is contained in:
José Rebelo
2026-06-19 09:05:27 +01:00
parent 36a3fa7cd2
commit 7c21dbe819
@@ -1224,7 +1224,7 @@ public class NotificationListener extends NotificationListenerService {
return false; return false;
} }
private boolean shouldIgnoreOngoing(StatusBarNotification sbn, NotificationType type) { private boolean shouldSendOngoing(StatusBarNotification sbn, NotificationType type) {
if (isFitnessApp(sbn)) { if (isFitnessApp(sbn)) {
return true; return true;
} }
@@ -1235,18 +1235,13 @@ public class NotificationListener extends NotificationListenerService {
} }
private boolean isFitnessApp(StatusBarNotification sbn) { private boolean isFitnessApp(StatusBarNotification sbn) {
String source = sbn.getPackageName(); final String source = sbn.getPackageName();
if (source.equals("de.dennisguse.opentracks") return source.equals("de.dennisguse.opentracks")
|| source.equals("de.dennisguse.opentracks.debug") || source.equals("de.dennisguse.opentracks.debug")
|| source.equals("de.dennisguse.opentracks.nightly") || source.equals("de.dennisguse.opentracks.nightly")
|| source.equals("de.dennisguse.opentracks.playstore") || source.equals("de.dennisguse.opentracks.playstore")
|| source.equals("de.tadris.fitness") || source.equals("de.tadris.fitness")
|| source.equals("de.tadris.fitness.debug") || source.equals("de.tadris.fitness.debug");
) {
return true;
}
return false;
} }
private boolean isWorkProfile(StatusBarNotification sbn) { private boolean isWorkProfile(StatusBarNotification sbn) {
@@ -1344,13 +1339,12 @@ public class NotificationListener extends NotificationListenerService {
return true; return true;
} }
if (shouldIgnoreOngoing(sbn, type)) { if (shouldSendOngoing(sbn, type)) {
LOG.trace("Ignoring notification, ongoing"); LOG.trace("Not ignoring ongoing notification");
return false; return false;
} }
return (notification.flags & Notification.FLAG_ONGOING_EVENT) == Notification.FLAG_ONGOING_EVENT; return (notification.flags & (Notification.FLAG_ONGOING_EVENT | Notification.FLAG_FOREGROUND_SERVICE)) != 0;
} }
private static class NotificationAction { private static class NotificationAction {