diff --git a/app/src/main/java/se/ajpanton/notificationsmaster/module/NotificationsMasterModule.kt b/app/src/main/java/se/ajpanton/notificationsmaster/module/NotificationsMasterModule.kt index 6e6d5c5..ea27761 100644 --- a/app/src/main/java/se/ajpanton/notificationsmaster/module/NotificationsMasterModule.kt +++ b/app/src/main/java/se/ajpanton/notificationsmaster/module/NotificationsMasterModule.kt @@ -1,5 +1,7 @@ package se.ajpanton.notificationsmaster.module +import android.os.Handler +import android.os.Looper import android.util.Log import io.github.libxposed.api.XposedModule import io.github.libxposed.api.XposedModuleInterface @@ -10,12 +12,20 @@ import io.github.libxposed.api.XposedModuleInterface */ class NotificationsMasterModule : XposedModule() { override fun onSystemServerStarting(param: XposedModuleInterface.SystemServerStartingParam) { - runCatching { - SystemAlertPolicyCache.installWhenReady() - NotificationAttentionBridge(this, ::diagnoseAttentionHelperEvent).install(param.classLoader) - SystemNotificationBridge(this, ::diagnoseHelperEvent).install(param.classLoader) - }.onFailure { error -> - Log.e(TAG, "Notification bridge was not installed; leaving Android unchanged", error) + SystemAlertPolicyCache.installWhenReady() + Handler(Looper.getMainLooper()).post { + installBridge("notification attention") { + NotificationAttentionBridge(this, ::diagnoseAttentionHelperEvent).install(param.classLoader) + } + installBridge("notification enqueue") { + SystemNotificationBridge(this, ::diagnoseHelperEvent).install(param.classLoader) + } + } + } + + private fun installBridge(name: String, install: () -> Unit) { + runCatching(install).onFailure { error -> + Log.e(TAG, "$name bridge was not installed; leaving Android unchanged", error) } }