Complete settings controls and refresh behavior
This commit is contained in:
@@ -8,6 +8,7 @@ import java.io.BufferedOutputStream
|
||||
import java.io.DataInputStream
|
||||
import java.io.DataOutputStream
|
||||
import java.io.FileNotFoundException
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* An atomically replaced encrypted event log. It keeps every persisted log field
|
||||
@@ -16,6 +17,7 @@ import java.io.FileNotFoundException
|
||||
class EncryptedNotificationLogStore(context: Context) {
|
||||
private val lock = Any()
|
||||
private val file = AtomicFile(context.filesDir.resolve(FILE_NAME))
|
||||
private val imageDirectory = File(context.filesDir, IMAGE_DIRECTORY_NAME)
|
||||
private val cipher = AesGcmCipher(LogEncryptionKeyProvider().getOrCreate())
|
||||
|
||||
fun readAll(): List<NotificationLogEntry> = synchronized(lock) {
|
||||
@@ -34,6 +36,7 @@ class EncryptedNotificationLogStore(context: Context) {
|
||||
|
||||
fun clear() = synchronized(lock) {
|
||||
file.delete()
|
||||
imageDirectory.listFiles()?.forEach(File::delete)
|
||||
}
|
||||
|
||||
private fun write(entries: List<NotificationLogEntry>) {
|
||||
@@ -79,5 +82,6 @@ class EncryptedNotificationLogStore(context: Context) {
|
||||
const val FILE_VERSION = 1
|
||||
const val MAX_IV_BYTES = 32
|
||||
const val MAX_CIPHER_TEXT_BYTES = 50 * 1024 * 1024
|
||||
const val IMAGE_DIRECTORY_NAME = "notification-images"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user