Use Notifications Master app ID

This commit is contained in:
ajp_anton
2026-08-16 01:57:44 +00:00
parent 572660a967
commit af3673c2e8
51 changed files with 142 additions and 142 deletions
@@ -0,0 +1,41 @@
package se.ajpanton.notificationsmaster
import android.app.Application
import android.content.pm.PackageManager
import se.ajpanton.notificationsmaster.data.EncryptedNotificationLogStore
import se.ajpanton.notificationsmaster.settings.AppFilterSettingsStore
import se.ajpanton.notificationsmaster.settings.LoggingRuleStore
import se.ajpanton.notificationsmaster.settings.LoggingType
import se.ajpanton.notificationsmaster.settings.NotificationListenerComponentController
import se.ajpanton.notificationsmaster.settings.PerAppEventSettingsStore
class NotificationLogApplication : Application() {
override fun onCreate() {
super.onCreate()
synchronizeListenerComponent()
Thread(::removeStaleAppStorage, "notification-log-storage-cleanup").start()
}
/**
* Clearing app data resets rule preferences but deliberately does not reset
* PackageManager's enabled/disabled state for the listener component.
* Reconcile it before the UI starts so fresh default rules can bind again.
*/
private fun synchronizeListenerComponent() {
val rules = LoggingRuleStore(this)
NotificationListenerComponentController.update(
this,
LoggingType.entries.associateWith(rules::ruleFor),
PerAppEventSettingsStore(this).hasEnabledEventOverride(),
)
}
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()
}
}