From 5eb40d9140ceb1abd06f3cbfbd5ab5a0a767303a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B1=A0?= <98259561+whitechi73@users.noreply.github.com> Date: Wed, 31 Jan 2024 08:57:26 +0800 Subject: [PATCH] Fix crash --- .../miko/internals/helper/NTServiceFetcher.kt | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/moe/qwq/miko/internals/helper/NTServiceFetcher.kt b/app/src/main/java/moe/qwq/miko/internals/helper/NTServiceFetcher.kt index 0ec5cb8..01d7d57 100644 --- a/app/src/main/java/moe/qwq/miko/internals/helper/NTServiceFetcher.kt +++ b/app/src/main/java/moe/qwq/miko/internals/helper/NTServiceFetcher.kt @@ -39,20 +39,24 @@ internal object NTServiceFetcher { QwQSetting.getSetting(QwQSetting.INTERCEPT_RECALL).isFailed = false kernelService.wrapperSession.javaClass.hookMethod("onMsfPush").before { - val cmd = it.args[0] as String - val buffer = it.args[1] as ByteArray - if (cmd == "trpc.msg.register_proxy.RegisterProxy.InfoSyncPush") { - val syncPush = ProtoBuf.decodeFromByteArray(buffer) - if (AioListener.onInfoSyncPush(syncPush)) { - it.args[1] = ProtoBuf.encodeToByteArray(syncPush.copy( - syncContent = syncPush.syncContent?.copy(body = ArrayList(0)) - )) - } - } else if (cmd == "trpc.msg.olpush.OlPushService.MsgPush") { - val msgPush = ProtoBuf.decodeFromByteArray(buffer) - if (AioListener.onMsgPush(msgPush)) { - it.result = Unit + runCatching { + val cmd = it.args[0] as String + val buffer = it.args[1] as ByteArray + if (cmd == "trpc.msg.register_proxy.RegisterProxy.InfoSyncPush") { + val syncPush = ProtoBuf.decodeFromByteArray(buffer) + if (AioListener.onInfoSyncPush(syncPush)) { + it.args[1] = ProtoBuf.encodeToByteArray(syncPush.copy( + syncContent = syncPush.syncContent?.copy(body = ArrayList(0)) + )) + } + } else if (cmd == "trpc.msg.olpush.OlPushService.MsgPush") { + val msgPush = ProtoBuf.decodeFromByteArray(buffer) + if (AioListener.onMsgPush(msgPush)) { + it.result = Unit + } } + }.onFailure { + XposedBridge.log(it) } }