Export retained notification images in HTML

This commit is contained in:
ajp_anton
2026-07-23 10:51:07 +00:00
parent 6eb9058595
commit dd1c9e5a01
8 changed files with 123 additions and 7 deletions
@@ -77,17 +77,20 @@ class NotificationCaptureService : NotificationListenerService() {
) {
if (!NotificationRuleEvaluator.allows(ruleStore.ruleFor(loggingType), snapshot.packageName)) return
val appName = appName(snapshot.packageName)
val retainImage = includeContents && snapshot.imageBytes != null &&
NotificationRuleEvaluator.allows(ruleStore.ruleFor(LoggingType.IMAGE_CONTENT), snapshot.packageName)
val entry = NotificationLogEntry(
recordedAtEpochMillis = System.currentTimeMillis(),
packageName = snapshot.packageName,
appName = appName,
action = action,
contents = if (includeContents) visibleContents(snapshot) else null,
imageId = if (retainImage) java.util.UUID.randomUUID().toString() else null,
)
writeExecutor.execute {
try {
if (includeContents && snapshot.imageBytes != null && NotificationRuleEvaluator.allows(ruleStore.ruleFor(LoggingType.IMAGE_CONTENT), snapshot.packageName)) {
imageStore.save(entry.id, snapshot.imageBytes)
if (retainImage) {
imageStore.save(entry.imageId!!, snapshot.imageBytes!!)
}
logStore.append(entry)
} catch (error: Exception) {