24 lines
975 B
Kotlin
24 lines
975 B
Kotlin
package se.ajpanton.notificationlog
|
|
|
|
import android.app.Application
|
|
import android.content.pm.PackageManager
|
|
import se.ajpanton.notificationlog.data.EncryptedNotificationLogStore
|
|
import se.ajpanton.notificationlog.settings.AppFilterSettingsStore
|
|
import se.ajpanton.notificationlog.settings.PerAppEventSettingsStore
|
|
|
|
class NotificationLogApplication : Application() {
|
|
override fun onCreate() {
|
|
super.onCreate()
|
|
Thread(::removeStaleAppStorage, "notification-log-storage-cleanup").start()
|
|
}
|
|
|
|
private fun removeStaleAppStorage() {
|
|
val installedPackages = packageManager.getInstalledApplications(
|
|
PackageManager.ApplicationInfoFlags.of(0),
|
|
).mapTo(mutableSetOf()) { it.packageName }
|
|
AppFilterSettingsStore(this).removeUninstalledPackages(installedPackages)
|
|
PerAppEventSettingsStore(this).removeUninstalledPackages(installedPackages)
|
|
EncryptedNotificationLogStore(this).removeOrphanedImages()
|
|
}
|
|
}
|