List installed apps in event settings
This commit is contained in:
@@ -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()
|
||||
}
|
||||
Reference in New Issue
Block a user