Complete secure log viewing and retention
This commit is contained in:
+13
-2
@@ -91,10 +91,17 @@ class NotificationCaptureService : NotificationListenerService() {
|
||||
writeExecutor.execute {
|
||||
try {
|
||||
if (retainImage) {
|
||||
imageStore.save(entry.imageId!!, snapshot.imageBytes!!)
|
||||
try {
|
||||
imageStore.save(entry.imageId!!, snapshot.imageBytes!!)
|
||||
} catch (error: Exception) {
|
||||
Log.w(TAG, "Could not retain notification image; keeping the text event", error)
|
||||
logStore.append(entry.copy(imageId = null))
|
||||
return@execute
|
||||
}
|
||||
}
|
||||
logStore.append(entry)
|
||||
} catch (error: Exception) {
|
||||
entry.imageId?.let(imageStore::delete)
|
||||
Log.e(TAG, "Could not persist notification log entry", error)
|
||||
}
|
||||
}
|
||||
@@ -107,7 +114,10 @@ class NotificationCaptureService : NotificationListenerService() {
|
||||
val image = snapshot.hasImage && NotificationRuleEvaluator.allows(
|
||||
ruleStore.ruleFor(LoggingType.IMAGE_CONTENT), snapshot.packageName,
|
||||
)
|
||||
return listOfNotNull(text, if (image) "[image]" else null).joinToString(" — ").ifEmpty { null }
|
||||
return listOfNotNull(text, if (image) "[image]" else null)
|
||||
.joinToString(" — ")
|
||||
.take(MAX_CONTENT_CHARACTERS)
|
||||
.ifEmpty { null }
|
||||
}
|
||||
|
||||
private fun appName(packageName: String): String = try {
|
||||
@@ -147,5 +157,6 @@ class NotificationCaptureService : NotificationListenerService() {
|
||||
|
||||
private companion object {
|
||||
const val TAG = "NotificationCapture"
|
||||
const val MAX_CONTENT_CHARACTERS = 16_000
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user