Harden LSPosed bridge startup
This commit is contained in:
+16
-6
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user