From dbe63359786d43fab0bec2b287ceff2af28cf041 Mon Sep 17 00:00:00 2001 From: ajp_anton Date: Tue, 18 Aug 2026 06:01:43 +0000 Subject: [PATCH] Harden LSPosed bridge startup --- .../module/NotificationsMasterModule.kt | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) 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) } }