List installed apps in event settings

This commit is contained in:
ajp_anton
2026-07-23 09:20:00 +00:00
parent 64dff16e8c
commit 3eba02d25b
4 changed files with 77 additions and 1 deletions
@@ -33,6 +33,7 @@ class NotificationCaptureService : NotificationListenerService() {
super.onListenerConnected()
getActiveNotifications()?.forEach { sbn ->
val snapshot = NotificationContents.snapshot(sbn)
SeenApps.markSeen(snapshot.packageName)
activeNotifications[snapshot.key] = snapshot
record(snapshot, NotificationAction.ALREADY_ACTIVE, LoggingType.APPEARING, includeContents = true)
}
@@ -40,6 +41,7 @@ class NotificationCaptureService : NotificationListenerService() {
override fun onNotificationPosted(sbn: StatusBarNotification) {
val snapshot = NotificationContents.snapshot(sbn)
SeenApps.markSeen(snapshot.packageName)
val previous = activeNotifications.put(snapshot.key, snapshot)
when {
previous == null -> record(snapshot, NotificationAction.APPEARED, LoggingType.APPEARING, includeContents = true)
@@ -54,6 +56,7 @@ class NotificationCaptureService : NotificationListenerService() {
reason: Int,
) {
val snapshot = activeNotifications.remove(sbn.key) ?: NotificationContents.snapshot(sbn)
SeenApps.markSeen(snapshot.packageName)
record(snapshot, actionForRemoval(reason), LoggingType.DISAPPEARING, includeContents = false)
}
@@ -0,0 +1,10 @@
package se.ajpanton.notificationlog.capture
import java.util.concurrent.ConcurrentHashMap
/** Process/boot-lifetime record of packages seen by the listener. */
object SeenApps {
private val packages = ConcurrentHashMap.newKeySet<String>()
fun markSeen(packageName: String) { packages += packageName }
fun snapshot(): Set<String> = packages.toSet()
}