From 9402ebd1cd8c3550949024233c4ca71725b29c09 Mon Sep 17 00:00:00 2001 From: Nacho Date: Mon, 6 Oct 2025 10:54:41 +0800 Subject: [PATCH 1/3] fix(GetChannelArk): fix sometimes crash --- .../moe/ono/creator/GetChannelArkDialog.java | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/moe/ono/creator/GetChannelArkDialog.java b/app/src/main/java/moe/ono/creator/GetChannelArkDialog.java index 14188830..b60c6ee3 100644 --- a/app/src/main/java/moe/ono/creator/GetChannelArkDialog.java +++ b/app/src/main/java/moe/ono/creator/GetChannelArkDialog.java @@ -26,7 +26,6 @@ import com.lxj.xpopup.core.BottomPopupView; import com.lxj.xpopup.util.XPopupUtils; -import org.json.JSONException; import org.json.JSONObject; import java.io.IOException; @@ -38,6 +37,7 @@ import moe.ono.hooks.item.developer.GetCookie; import moe.ono.ui.CommonContextWrapper; import moe.ono.util.AppRuntimeHelper; +import moe.ono.util.ContextUtils; import moe.ono.util.Logger; import moe.ono.util.Session; import moe.ono.util.SyncUtils; @@ -154,24 +154,20 @@ public void onResponse(@NonNull Call call, @NonNull Response response) { String result = response.body().string(); SyncUtils.runOnUiThread(() -> { - JSONObject json = null; - try { - json = new JSONObject(result); - } catch (JSONException e) { - Toasts.error(v.getContext(), "JSON 解析失败"); - } - assert json != null; - String base64 = Objects.requireNonNull(json.optJSONObject("data")).optString("signed_ark"); - byte[] decodedBytes = Base64.getDecoder().decode(base64); - String ark = new String(decodedBytes); try { + JSONObject json = new JSONObject(result); + String base64 = Objects.requireNonNull(json.optJSONObject("data")).optString("signed_ark"); + byte[] decodedBytes = Base64.getDecoder().decode(base64); + String ark = new String(decodedBytes); PacketHelperDialog.send_ark_msg(ark, Session.getContact()); - } catch (JSONException e) { - Toasts.error(v.getContext(), "发送失败"); + } catch (Exception e) { + Logger.e(e); + Toasts.error(ContextUtils.getCurrentActivity(), "发生错误, 请检查参数是否完整"); } }); } catch (Exception e) { Logger.e(e); + Toasts.error(ContextUtils.getCurrentActivity(), "发生错误, 请检查参数是否完整"); } } }); From dbbe7cd7bdc5ae164c810439bdae6cd2c83bbb35 Mon Sep 17 00:00:00 2001 From: Nacho Date: Mon, 6 Oct 2025 11:07:52 +0800 Subject: [PATCH 2/3] feat(PacketHelper): add send xml --- .../moe/ono/creator/PacketHelperDialog.java | 22 ++++++++++ .../ono/hooks/base/api/QQMsgRespHandler.kt | 41 +++++++++---------- .../main/res/layout/element_sender_layout.xml | 8 ++++ 3 files changed, 50 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/moe/ono/creator/PacketHelperDialog.java b/app/src/main/java/moe/ono/creator/PacketHelperDialog.java index 79e46b48..1c9664d1 100644 --- a/app/src/main/java/moe/ono/creator/PacketHelperDialog.java +++ b/app/src/main/java/moe/ono/creator/PacketHelperDialog.java @@ -88,6 +88,7 @@ import moe.ono.R; import moe.ono.bridge.Nt_kernel_bridge; import moe.ono.bridge.kernelcompat.ContactCompat; +import moe.ono.hooks.base.api.QQMsgRespHandler; import moe.ono.hooks.protocol.QPacketHelperKt; import moe.ono.hooks.base.util.Toasts; import moe.ono.util.AppRuntimeHelper; @@ -95,6 +96,7 @@ import moe.ono.util.Logger; import moe.ono.util.SafUtils; import moe.ono.util.SyncUtils; +import moe.ono.util.Utils; @SuppressLint({"ResourceType", "StaticFieldLeak"}) public class PacketHelperDialog extends BottomPopupView { @@ -260,6 +262,11 @@ protected void onCreate() { mRgSendBy.setVisibility(GONE); forwardConfig.setVisibility(GONE); break; + case "xml": + editText.setHint("Xml..."); + mRgSendBy.setVisibility(GONE); + forwardConfig.setVisibility(GONE); + break; case "text": editText.setHint("纯文本..."); mRgSendBy.setVisibility(GONE); @@ -300,6 +307,21 @@ protected void onCreate() { } else if (send_type.equals("text")){ send_text_msg(text, contactCompat); return; + } else if (send_type.equals("xml")) { + try { + String hex = Utils.bytesToHex(QQMsgRespHandler.Companion.compressData(text)); + String pb = "{\n" + + " \"12\": {\n" + + " \"1\": \"hex->"+hex+"\",\n" + + " \"2\": 35\n" + + " }\n" + + "}"; + setContentForLongmsg(pb); + } catch (Exception e) { + Toasts.error(getContext(), "发生错误"); + Logger.e(e); + } + return; } // protobuf diff --git a/app/src/main/java/moe/ono/hooks/base/api/QQMsgRespHandler.kt b/app/src/main/java/moe/ono/hooks/base/api/QQMsgRespHandler.kt index 01b7e6ff..706c6d0d 100644 --- a/app/src/main/java/moe/ono/hooks/base/api/QQMsgRespHandler.kt +++ b/app/src/main/java/moe/ono/hooks/base/api/QQMsgRespHandler.kt @@ -6,7 +6,6 @@ import com.tencent.qqnt.kernel.nativeinterface.PushExtraInfo import de.robv.android.xposed.XposedHelpers.callMethod import kotlinx.io.core.ByteReadPacket import kotlinx.io.core.readBytes -import kotlinx.serialization.json.* import moe.ono.R import moe.ono.bridge.ntapi.RelationNTUinAndUidApi.getUinFromUid import moe.ono.common.CheckUtils @@ -46,8 +45,6 @@ import org.json.JSONObject import java.io.ByteArrayOutputStream import java.util.UUID import java.util.zip.Deflater -import kotlin.random.Random -import kotlin.random.nextUInt @HookItem(path = "API/QQMsgRespHandler") class QQMsgRespHandler : ApiHookItem() { @@ -445,25 +442,27 @@ class QQMsgRespHandler : ApiHookItem() { } - private fun compressData(data: String): ByteArray { - val inputBytes = data.toByteArray(Charsets.UTF_8) - val deflater = Deflater(Deflater.DEFAULT_COMPRESSION, false) - deflater.setInput(inputBytes) - deflater.finish() - - val outputStream = ByteArrayOutputStream() - val buffer = ByteArray(1024) - while (!deflater.finished()) { - val count = deflater.deflate(buffer) - outputStream.write(buffer, 0, count) - } - deflater.end() - val compressedBytes = outputStream.toByteArray() - val result = ByteArray(compressedBytes.size + 1) - result[0] = 0x01 - System.arraycopy(compressedBytes, 0, result, 1, compressedBytes.size) + companion object { + fun compressData(data: String): ByteArray { + val inputBytes = data.toByteArray(Charsets.UTF_8) + val deflater = Deflater(Deflater.DEFAULT_COMPRESSION, false) + deflater.setInput(inputBytes) + deflater.finish() + + val outputStream = ByteArrayOutputStream() + val buffer = ByteArray(1024) + while (!deflater.finished()) { + val count = deflater.deflate(buffer) + outputStream.write(buffer, 0, count) + } + deflater.end() + val compressedBytes = outputStream.toByteArray() + val result = ByteArray(compressedBytes.size + 1) + result[0] = 0x01 + System.arraycopy(compressedBytes, 0, result, 1, compressedBytes.size) - return result + return result + } } fun appendToContentArray(original: JSONObject, newContent: Any) { diff --git a/app/src/main/res/layout/element_sender_layout.xml b/app/src/main/res/layout/element_sender_layout.xml index 9d9006d5..c276b3da 100644 --- a/app/src/main/res/layout/element_sender_layout.xml +++ b/app/src/main/res/layout/element_sender_layout.xml @@ -61,6 +61,14 @@ android:textSize="15sp" /> + + Date: Mon, 6 Oct 2025 15:14:31 +0800 Subject: [PATCH 3/3] chore(ProfileCardMenu): remove unused import --- .../main/java/moe/ono/hooks/item/profile/ProfileCardMenu.kt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/src/main/java/moe/ono/hooks/item/profile/ProfileCardMenu.kt b/app/src/main/java/moe/ono/hooks/item/profile/ProfileCardMenu.kt index 6e57c68d..4f4bbc55 100644 --- a/app/src/main/java/moe/ono/hooks/item/profile/ProfileCardMenu.kt +++ b/app/src/main/java/moe/ono/hooks/item/profile/ProfileCardMenu.kt @@ -3,9 +3,6 @@ package moe.ono.hooks.item.profile import OidbSvcTrpcTcp0Xfe12 import android.annotation.SuppressLint import android.app.Activity -import android.content.ClipData -import android.content.ClipboardManager -import android.content.Context import android.os.Bundle import android.os.Handler import android.os.Looper @@ -20,7 +17,6 @@ import io.noties.markwon.Markwon import moe.ono.hooks._base.BaseSwitchFunctionHookItem import moe.ono.hooks._core.annotation.HookItem import moe.ono.hooks.base.util.Toasts -import moe.ono.hooks.base.util.Toasts.TYPE_INFO import moe.ono.service.QQInterfaces.Companion.receive import moe.ono.service.QQInterfaces.Companion.sendOidbSvcTrpcTcp import moe.ono.ui.CommonContextWrapper