From 732db339f6de279ce61d5883cf07165d56e2ab5a Mon Sep 17 00:00:00 2001 From: ACh Sulfate Date: Wed, 30 Oct 2024 21:25:53 +0800 Subject: [PATCH] refactor: refine base hook logic --- .../cc/hicore/message/chat/SessionHooker.java | 16 +++++++++++++++- .../hook/experimental/CardMsgSender.java | 14 +++++++++++--- .../hook/experimental/FakeBatteryHook.java | 8 ++++++++ .../hook/friend/FriendDeletionNotification.kt | 2 ++ .../cc/ioctl/hook/notification/AntiMessage.kt | 7 +++++++ .../hook/notification/MessageInterception.kt | 19 ++++++++++++++++--- .../cc/ioctl/hook/ui/chat/RepeaterHook.java | 9 +++++++++ .../hook/ui/main/ContactListSortHook.java | 7 +++++++ .../cc/ioctl/util/msg/MessageManager.java | 12 ++---------- .../cc/ioctl/util/msg/MessageReceiver.java | 15 ++++++++++++++- .../java/cn/lliiooll/hook/AntiRobotMessage.kt | 13 ++++++++----- .../java/com/xiaoniu/hook/CtrlEnterToSend.kt | 4 ++++ .../github/qauxv/base/RuntimeErrorTracer.kt | 10 ++++++++++ .../base/annotation/EntityAgentEntry.java | 5 +++++ .../io/github/qauxv/hook/BaseComponentHook.kt | 4 ++++ .../github/qauxv/hook/BaseHookDispatcher.kt | 19 +++++++++++++++++-- .../qauxv/hook/BasePersistBackgroundHook.kt | 4 ++++ .../qauxv/hook/CommonConfigFunctionHook.kt | 4 ++++ .../qauxv/hook/CommonSwitchFunctionHook.kt | 5 +++++ .../router/decorator/IBaseChatPieDecorator.kt | 8 ++++++-- .../IItemBuilderFactoryHookDecorator.kt | 7 ++++++- .../decorator/IStartActivityHookDecorator.kt | 10 +++++++--- .../dispacher/InputButtonHookDispatcher.java | 2 ++ .../dispacher/ItemBuilderFactoryHook.kt | 2 ++ .../router/dispacher/StartActivityHook.kt | 2 ++ app/src/main/java/me/hd/hook/FakeLocation.kt | 2 ++ app/src/main/java/me/hd/hook/FakePhone.kt | 2 ++ app/src/main/java/me/hd/hook/FakePicSize.kt | 2 ++ app/src/main/java/me/hd/hook/FakeVoiceTime.kt | 2 ++ .../java/me/ketal/base/PluginDelayableHook.kt | 3 +++ .../main/java/me/ketal/hook/FakeQQLevel.kt | 2 ++ .../java/me/ketal/hook/MultiActionHook.kt | 4 ++++ .../hook/decorator/RegexAntiMeg.kt | 2 ++ 33 files changed, 196 insertions(+), 31 deletions(-) diff --git a/app/src/main/java/cc/hicore/message/chat/SessionHooker.java b/app/src/main/java/cc/hicore/message/chat/SessionHooker.java index 7440895d20..05ff90ad02 100644 --- a/app/src/main/java/cc/hicore/message/chat/SessionHooker.java +++ b/app/src/main/java/cc/hicore/message/chat/SessionHooker.java @@ -22,10 +22,15 @@ package cc.hicore.message.chat; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import cc.hicore.QApp.QAppUtils; import cc.hicore.ReflectUtil.XField; import cc.hicore.hook.RepeaterPlus; import cc.hicore.hook.stickerPanel.Hooker.StickerPanelEntryHooker; +import com.google.common.collect.Lists; +import io.github.qauxv.base.ITraceableDynamicHook; +import io.github.qauxv.base.RuntimeErrorTracer; +import io.github.qauxv.base.annotation.EntityAgentEntry; import io.github.qauxv.util.xpcompat.XC_MethodHook; import io.github.qauxv.util.xpcompat.XposedBridge; import io.github.qauxv.base.IDynamicHook; @@ -37,9 +42,12 @@ import io.github.qauxv.util.dexkit.AIO_Destroy_QQNT; import io.github.qauxv.util.dexkit.DexKit; import io.github.qauxv.util.dexkit.DexKitTarget; +import java.util.Collections; +import java.util.List; import java.util.Stack; import me.ketal.hook.MultiActionHook; +@EntityAgentEntry @FunctionHookEntry public class SessionHooker extends BaseHookDispatcher { @@ -106,8 +114,14 @@ public boolean isEnabled() { return QAppUtils.isQQnt() && super.isEnabled(); } - public interface IAIOParamUpdate extends IDynamicHook { + public interface IAIOParamUpdate extends ITraceableDynamicHook { void onAIOParamUpdate(Object AIOParam); + + @Nullable + @Override + default List getRuntimeErrorDependentComponents() { + return Lists.asList(SessionHooker.INSTANCE, RuntimeErrorTracer.EMPTY_ARRAY); + } } } diff --git a/app/src/main/java/cc/ioctl/hook/experimental/CardMsgSender.java b/app/src/main/java/cc/ioctl/hook/experimental/CardMsgSender.java index 5041a96c84..a5533620fe 100644 --- a/app/src/main/java/cc/ioctl/hook/experimental/CardMsgSender.java +++ b/app/src/main/java/cc/ioctl/hook/experimental/CardMsgSender.java @@ -32,9 +32,11 @@ import androidx.annotation.Nullable; import cc.hicore.QApp.QAppUtils; import cc.hicore.message.chat.SessionUtils; +import com.google.common.collect.Lists; import com.tencent.qqnt.kernel.nativeinterface.ArkElement; import com.tencent.qqnt.kernel.nativeinterface.MsgElement; import io.github.qauxv.base.IDynamicHook; +import io.github.qauxv.base.RuntimeErrorTracer; import io.github.qauxv.base.annotation.FunctionHookEntry; import io.github.qauxv.base.annotation.UiItemAgentEntry; import io.github.qauxv.bridge.AppRuntimeHelper; @@ -42,6 +44,7 @@ import io.github.qauxv.dsl.FunctionEntryRouter.Locations.Auxiliary; import io.github.qauxv.remote.TransactionHelper; import io.github.qauxv.router.decorator.BaseSwitchFunctionDecorator; +import io.github.qauxv.router.decorator.IBaseChatPieDecorator; import io.github.qauxv.router.decorator.IInputButtonDecorator; import io.github.qauxv.router.dispacher.InputButtonHookDispatcher; import io.github.qauxv.util.SyncUtils; @@ -53,6 +56,7 @@ import io.github.qauxv.util.dexkit.NBaseChatPie_init; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; +import java.util.List; import me.singleneuron.data.CardMsgCheckResult; import me.singleneuron.util.KotlinUtilsKt; import mqq.app.AppRuntime; @@ -162,14 +166,14 @@ public boolean onFunBtnLongClick(@NonNull String text, @NonNull private static MsgElement getArkMsgElement(@NonNull String text) { MsgElement msgElement = new MsgElement(); - ArkElement arkElement = new ArkElement(text,null,null); + ArkElement arkElement = new ArkElement(text, null, null); msgElement.setArkElement(arkElement); msgElement.setElementType(10); return msgElement; } private void sendCard(String text, View sendBtn, EditText input, Context ctx1, AppRuntime qqApp, Parcelable session) throws Exception { - if (QAppUtils.isQQnt()){ + if (QAppUtils.isQQnt()) { try { new JSONObject(text); CardMsgCheckResult check = KotlinUtilsKt.checkCardMsg(text); @@ -205,7 +209,11 @@ private void sendCard(String text, View sendBtn, EditText input, Context ctx1, A } - + @Nullable + @Override + public List getRuntimeErrorDependentComponents() { + return Lists.newArrayList(InputButtonHookDispatcher.INSTANCE); + } @SuppressWarnings("JavaJniMissingFunction") static native boolean ntSendCardMsg(AppRuntime rt, Parcelable session, String msg) throws Exception; diff --git a/app/src/main/java/cc/ioctl/hook/experimental/FakeBatteryHook.java b/app/src/main/java/cc/ioctl/hook/experimental/FakeBatteryHook.java index 04d6217bf5..efc1b2e6c2 100644 --- a/app/src/main/java/cc/ioctl/hook/experimental/FakeBatteryHook.java +++ b/app/src/main/java/cc/ioctl/hook/experimental/FakeBatteryHook.java @@ -37,6 +37,7 @@ import cc.ioctl.fragment.FakeBatteryConfigFragment; import cc.ioctl.util.HostInfo; import io.github.qauxv.base.IEntityAgent; +import io.github.qauxv.base.RuntimeErrorTracer; import io.github.qauxv.util.xpcompat.XC_MethodHook; import io.github.qauxv.util.xpcompat.XposedBridge; import io.github.qauxv.util.xpcompat.XposedHelpers; @@ -60,6 +61,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Proxy; +import java.util.List; import kotlin.Unit; import kotlin.jvm.functions.Function1; import kotlin.jvm.functions.Function2; @@ -446,4 +448,10 @@ public Function2 getExtraSearchKeywordProvider( return null; } }; + + @Nullable + @Override + public List getRuntimeErrorDependentComponents() { + return null; + } } diff --git a/app/src/main/java/cc/ioctl/hook/friend/FriendDeletionNotification.kt b/app/src/main/java/cc/ioctl/hook/friend/FriendDeletionNotification.kt index 3352be0e7c..293cb281e5 100644 --- a/app/src/main/java/cc/ioctl/hook/friend/FriendDeletionNotification.kt +++ b/app/src/main/java/cc/ioctl/hook/friend/FriendDeletionNotification.kt @@ -31,6 +31,7 @@ import io.github.qauxv.activity.SettingsUiFragmentHostActivity.Companion.startFr import io.github.qauxv.base.IEntityAgent import io.github.qauxv.base.ISwitchCellAgent import io.github.qauxv.base.IUiItemAgent +import io.github.qauxv.base.RuntimeErrorTracer import io.github.qauxv.base.annotation.FunctionHookEntry import io.github.qauxv.base.annotation.UiItemAgentEntry import io.github.qauxv.bridge.AppRuntimeHelper @@ -53,6 +54,7 @@ object FriendDeletionNotification : BaseFunctionHook(defaultEnabled = true), IUi override var isEnabled = true override val onClickListener: ((IUiItemAgent, Activity, View) -> Unit)? = null override val extraSearchKeywordProvider: ((IUiItemAgent, Context) -> Array?)? = null + override val runtimeErrorDependentComponents: List? = null override val switchProvider by lazy { object : ISwitchCellAgent { diff --git a/app/src/main/java/cc/ioctl/hook/notification/AntiMessage.kt b/app/src/main/java/cc/ioctl/hook/notification/AntiMessage.kt index 12f92a921f..318d2734d1 100644 --- a/app/src/main/java/cc/ioctl/hook/notification/AntiMessage.kt +++ b/app/src/main/java/cc/ioctl/hook/notification/AntiMessage.kt @@ -24,6 +24,7 @@ package cc.ioctl.hook.notification import cc.ioctl.util.msg.MessageReceiver import cc.ioctl.util.MsgRecordUtil +import io.github.qauxv.base.RuntimeErrorTracer import io.github.qauxv.base.annotation.UiItemAgentEntry import io.github.qauxv.dsl.FunctionEntryRouter import io.github.qauxv.util.QQVersion @@ -57,6 +58,12 @@ object AntiMessage : MultiItemDelayableHook("qn_anti_message_items"), MessageRec return false } + override fun initOnce(): Boolean { + return MessageInterception.initialize() + } + + override val runtimeErrorDependentComponents: List = listOf(MessageInterception) + override val isAvailable: Boolean get() = requireMinQQVersion(QQVersion.QQ_8_2_0) } diff --git a/app/src/main/java/cc/ioctl/hook/notification/MessageInterception.kt b/app/src/main/java/cc/ioctl/hook/notification/MessageInterception.kt index 4a42140a94..7381f0efb0 100644 --- a/app/src/main/java/cc/ioctl/hook/notification/MessageInterception.kt +++ b/app/src/main/java/cc/ioctl/hook/notification/MessageInterception.kt @@ -24,22 +24,35 @@ package cc.ioctl.hook.notification import cc.ioctl.util.Reflex import cc.ioctl.util.msg.MessageManager -import io.github.qauxv.util.xpcompat.XC_MethodHook +import cc.ioctl.util.msg.MessageReceiver +import cn.lliiooll.hook.AntiRobotMessage +import io.github.qauxv.base.annotation.EntityAgentEntry import io.github.qauxv.base.annotation.FunctionHookEntry -import io.github.qauxv.hook.BasePersistBackgroundHook +import io.github.qauxv.hook.BaseHookDispatcher import io.github.qauxv.util.Initiator import io.github.qauxv.util.QQVersion import io.github.qauxv.util.hostInfo import io.github.qauxv.util.requireMinQQVersion +import io.github.qauxv.util.xpcompat.XC_MethodHook import me.singleneuron.data.MsgRecordData +import me.singleneuron.hook.decorator.RegexAntiMeg import xyz.nextalone.util.clazz import xyz.nextalone.util.hookAfter import xyz.nextalone.util.method import xyz.nextalone.util.methodWithSuper import xyz.nextalone.util.throwOrTrue +@EntityAgentEntry @FunctionHookEntry -object MessageInterception : BasePersistBackgroundHook() { +object MessageInterception : BaseHookDispatcher(arrayOf()) { + + override val decorators: Array = arrayOf( + // 在这里添加消息处理 + RegexAntiMeg, + AntiMessage, + AntiRobotMessage, + ) + override fun initOnce() = throwOrTrue { val callback: (XC_MethodHook.MethodHookParam) -> Unit = { param -> val msgRecordData = MsgRecordData(param.args[0]) diff --git a/app/src/main/java/cc/ioctl/hook/ui/chat/RepeaterHook.java b/app/src/main/java/cc/ioctl/hook/ui/chat/RepeaterHook.java index f651ef074e..eed905477f 100644 --- a/app/src/main/java/cc/ioctl/hook/ui/chat/RepeaterHook.java +++ b/app/src/main/java/cc/ioctl/hook/ui/chat/RepeaterHook.java @@ -53,6 +53,7 @@ import cc.ioctl.util.LayoutHelper; import cc.ioctl.util.Reflex; import io.github.qauxv.base.IEntityAgent; +import io.github.qauxv.base.RuntimeErrorTracer; import io.github.qauxv.util.xpcompat.XC_MethodHook; import io.github.qauxv.base.ISwitchCellAgent; import io.github.qauxv.base.IUiItemAgent; @@ -68,6 +69,8 @@ import io.github.qauxv.util.dexkit.CFaceDe; import io.github.qauxv.util.dexkit.DexKitTarget; import java.lang.reflect.Method; +import java.util.Collections; +import java.util.List; import kotlin.Unit; import kotlin.jvm.functions.Function1; import kotlin.jvm.functions.Function2; @@ -598,4 +601,10 @@ public static View findView(String Name, ViewGroup vg) } return null; } + + @Nullable + @Override + public List getRuntimeErrorDependentComponents() { + return null; + } } diff --git a/app/src/main/java/cc/ioctl/hook/ui/main/ContactListSortHook.java b/app/src/main/java/cc/ioctl/hook/ui/main/ContactListSortHook.java index d3195e17ac..49f7f4c4db 100644 --- a/app/src/main/java/cc/ioctl/hook/ui/main/ContactListSortHook.java +++ b/app/src/main/java/cc/ioctl/hook/ui/main/ContactListSortHook.java @@ -36,6 +36,7 @@ import io.github.qauxv.base.IEntityAgent; import io.github.qauxv.base.ISwitchCellAgent; import io.github.qauxv.base.IUiItemAgent; +import io.github.qauxv.base.RuntimeErrorTracer; import io.github.qauxv.base.annotation.FunctionHookEntry; import io.github.qauxv.base.annotation.UiItemAgentEntry; import io.github.qauxv.config.ConfigManager; @@ -320,4 +321,10 @@ public boolean isEnabled() { public void setEnabled(boolean value) { // unsupported } + + @Nullable + @Override + public List getRuntimeErrorDependentComponents() { + return null; + } } diff --git a/app/src/main/java/cc/ioctl/util/msg/MessageManager.java b/app/src/main/java/cc/ioctl/util/msg/MessageManager.java index aa838e6bd9..23f3d384a1 100644 --- a/app/src/main/java/cc/ioctl/util/msg/MessageManager.java +++ b/app/src/main/java/cc/ioctl/util/msg/MessageManager.java @@ -22,23 +22,15 @@ package cc.ioctl.util.msg; import androidx.annotation.NonNull; -import cc.ioctl.hook.notification.AntiMessage; -import cn.lliiooll.hook.AntiRobotMessage; +import cc.ioctl.hook.notification.MessageInterception; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import me.singleneuron.hook.decorator.RegexAntiMeg; import me.singleneuron.data.MsgRecordData; public class MessageManager { private static final Map MSG = new ConcurrentHashMap<>(); - private static final MessageReceiver[] receivers = { - // 在这里添加消息处理 - RegexAntiMeg.INSTANCE, - AntiMessage.INSTANCE, - AntiRobotMessage.INSTANCE, - }; public static Class intType = int.class; public static Class booleanType = boolean.class; @@ -54,7 +46,7 @@ public static void call(@NonNull MsgRecordData data) { } // 以上是为了防止消息重复广播 - for (MessageReceiver receiver : receivers) { + for (MessageReceiver receiver : MessageInterception.INSTANCE.getDecorators()) { if (receiver.onReceive(data)) { // 返回true退出遍历 break; diff --git a/app/src/main/java/cc/ioctl/util/msg/MessageReceiver.java b/app/src/main/java/cc/ioctl/util/msg/MessageReceiver.java index 4eaafd246d..71d3f04355 100644 --- a/app/src/main/java/cc/ioctl/util/msg/MessageReceiver.java +++ b/app/src/main/java/cc/ioctl/util/msg/MessageReceiver.java @@ -22,9 +22,15 @@ package cc.ioctl.util.msg; +import androidx.annotation.Nullable; +import cc.ioctl.hook.notification.MessageInterception; +import com.google.common.collect.Lists; +import io.github.qauxv.base.ITraceableDynamicHook; +import io.github.qauxv.base.RuntimeErrorTracer; +import java.util.List; import me.singleneuron.data.MsgRecordData; -public interface MessageReceiver { +public interface MessageReceiver extends ITraceableDynamicHook { /** * 当拦截到消息时会调用此方法 @@ -33,4 +39,11 @@ public interface MessageReceiver { * @return 如果返回为真将不会向下传递拦截到的消息 */ boolean onReceive(MsgRecordData data); + + @Nullable + @Override + default List getRuntimeErrorDependentComponents() { + return Lists.asList(MessageInterception.INSTANCE, RuntimeErrorTracer.EMPTY_ARRAY); + } + } diff --git a/app/src/main/java/cn/lliiooll/hook/AntiRobotMessage.kt b/app/src/main/java/cn/lliiooll/hook/AntiRobotMessage.kt index 4df1ca51f6..7d1a15252d 100644 --- a/app/src/main/java/cn/lliiooll/hook/AntiRobotMessage.kt +++ b/app/src/main/java/cn/lliiooll/hook/AntiRobotMessage.kt @@ -23,6 +23,7 @@ package cn.lliiooll.hook import cc.ioctl.hook.notification.MessageInterception import cc.ioctl.util.msg.MessageReceiver +import io.github.qauxv.base.RuntimeErrorTracer import io.github.qauxv.util.xpcompat.XposedHelpers import io.github.qauxv.base.annotation.FunctionHookEntry import io.github.qauxv.base.annotation.UiItemAgentEntry @@ -36,7 +37,7 @@ import xyz.nextalone.util.invoke // 自动已读群机器人消息 @FunctionHookEntry @UiItemAgentEntry -object AntiRobotMessage : CommonSwitchFunctionHook("ll_anti_robot_message"),MessageReceiver { +object AntiRobotMessage : CommonSwitchFunctionHook("ll_anti_robot_message"), MessageReceiver { override val name: String get() = "自动已读群机器人消息" @@ -48,14 +49,16 @@ object AntiRobotMessage : CommonSwitchFunctionHook("ll_anti_robot_message"),Mess get() = FunctionEntryRouter.Locations.Auxiliary.NOTIFICATION_CATEGORY override fun onReceive(data: MsgRecordData?): Boolean { - if (data != null && isEnabled){ + if (data != null && isEnabled) { val runtime = AppRuntimeHelper.getAppRuntime() - val service = runtime?.invoke("getRuntimeService","com.tencent.mobileqq.troop.robot.api.ITroopRobotService".clazz!!,Class::class.java) - val isRobot = service?.invoke("isRobotUin", data.senderUin!!,String::class.java)as Boolean - if (isRobot){ + val service = runtime?.invoke("getRuntimeService", "com.tencent.mobileqq.troop.robot.api.ITroopRobotService".clazz!!, Class::class.java) + val isRobot = service?.invoke("isRobotUin", data.senderUin!!, String::class.java) as Boolean + if (isRobot) { XposedHelpers.setBooleanField(data.msgRecord, "isread", true) } } return false } + + override val runtimeErrorDependentComponents: List = listOf(MessageInterception) } diff --git a/app/src/main/java/com/xiaoniu/hook/CtrlEnterToSend.kt b/app/src/main/java/com/xiaoniu/hook/CtrlEnterToSend.kt index 4939c150d7..08958b1030 100644 --- a/app/src/main/java/com/xiaoniu/hook/CtrlEnterToSend.kt +++ b/app/src/main/java/com/xiaoniu/hook/CtrlEnterToSend.kt @@ -29,11 +29,13 @@ import android.view.ViewGroup import android.widget.Button import android.widget.EditText import cc.hicore.QApp.QAppUtils +import io.github.qauxv.base.RuntimeErrorTracer import io.github.qauxv.base.annotation.FunctionHookEntry import io.github.qauxv.base.annotation.UiItemAgentEntry import io.github.qauxv.dsl.FunctionEntryRouter import io.github.qauxv.hook.CommonSwitchFunctionHook import io.github.qauxv.router.decorator.IBaseChatPieInitDecorator +import io.github.qauxv.router.dispacher.InputButtonHookDispatcher import mqq.app.AppRuntime @@ -67,4 +69,6 @@ object CtrlEnterToSend : CommonSwitchFunctionHook(), IBaseChatPieInitDecorator { } + override val runtimeErrorDependentComponents: List = listOf(InputButtonHookDispatcher.INSTANCE) + } diff --git a/app/src/main/java/io/github/qauxv/base/RuntimeErrorTracer.kt b/app/src/main/java/io/github/qauxv/base/RuntimeErrorTracer.kt index f22f06403c..0030aa1062 100644 --- a/app/src/main/java/io/github/qauxv/base/RuntimeErrorTracer.kt +++ b/app/src/main/java/io/github/qauxv/base/RuntimeErrorTracer.kt @@ -23,6 +23,16 @@ package io.github.qauxv.base interface RuntimeErrorTracer { + val runtimeErrors: List + + val runtimeErrorDependentComponents: List? + fun traceError(e: Throwable) + + companion object { + @JvmField + val EMPTY_ARRAY = arrayOf() + } + } diff --git a/app/src/main/java/io/github/qauxv/base/annotation/EntityAgentEntry.java b/app/src/main/java/io/github/qauxv/base/annotation/EntityAgentEntry.java index 8a05a9206b..28b0395d8b 100644 --- a/app/src/main/java/io/github/qauxv/base/annotation/EntityAgentEntry.java +++ b/app/src/main/java/io/github/qauxv/base/annotation/EntityAgentEntry.java @@ -27,6 +27,11 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +/** + * A passive entity agent entry, for error tracking. + *

+ * Target should be an instance of {@link io.github.qauxv.base.IEntityAgentProvider} + */ @Target({ElementType.TYPE}) @Retention(RetentionPolicy.CLASS) public @interface EntityAgentEntry { diff --git a/app/src/main/java/io/github/qauxv/hook/BaseComponentHook.kt b/app/src/main/java/io/github/qauxv/hook/BaseComponentHook.kt index 77873aa088..c6ea987e54 100644 --- a/app/src/main/java/io/github/qauxv/hook/BaseComponentHook.kt +++ b/app/src/main/java/io/github/qauxv/hook/BaseComponentHook.kt @@ -23,6 +23,7 @@ package io.github.qauxv.hook import io.github.qauxv.base.ITraceableDynamicHook +import io.github.qauxv.base.RuntimeErrorTracer import io.github.qauxv.step.Step import io.github.qauxv.util.Log import io.github.qauxv.util.SyncUtils @@ -96,4 +97,7 @@ abstract class BaseComponentHook : ITraceableDynamicHook { } Log.e(e) } + + override val runtimeErrorDependentComponents: List? + get() = null } diff --git a/app/src/main/java/io/github/qauxv/hook/BaseHookDispatcher.kt b/app/src/main/java/io/github/qauxv/hook/BaseHookDispatcher.kt index b20b826328..bc792e5894 100644 --- a/app/src/main/java/io/github/qauxv/hook/BaseHookDispatcher.kt +++ b/app/src/main/java/io/github/qauxv/hook/BaseHookDispatcher.kt @@ -22,8 +22,12 @@ package io.github.qauxv.hook +import android.content.Context import io.github.qauxv.base.IDynamicHook +import io.github.qauxv.base.IEntityAgent +import io.github.qauxv.base.IEntityAgentProvider import io.github.qauxv.base.ITraceableDynamicHook +import io.github.qauxv.base.RuntimeErrorTracer import io.github.qauxv.step.DexDeobfStep import io.github.qauxv.step.Step import io.github.qauxv.util.Log @@ -32,9 +36,9 @@ import io.github.qauxv.util.dexkit.DexKit import io.github.qauxv.util.dexkit.DexKitTarget import java.util.Arrays -abstract class BaseHookDispatcher( +abstract class BaseHookDispatcher( targets: Array? -) : ITraceableDynamicHook { +) : ITraceableDynamicHook, IEntityAgentProvider, IEntityAgent { private val mErrors: ArrayList = ArrayList() private var mInitialized = false @@ -95,6 +99,14 @@ abstract class BaseHookDispatcher( override val isApplicationRestartRequired = false + override val entityAgent: IEntityAgent get() = this + + override val titleProvider: (IEntityAgent) -> String + get() = { it.javaClass.simpleName } + + override val summaryProvider: ((IEntityAgent, Context) -> CharSequence?)? + get() = null + override var isEnabled: Boolean get() { decorators.iterator().forEach { if (it.isEnabled) return true } @@ -117,4 +129,7 @@ abstract class BaseHookDispatcher( } Log.e(e) } + + override val runtimeErrorDependentComponents: List? + get() = null } diff --git a/app/src/main/java/io/github/qauxv/hook/BasePersistBackgroundHook.kt b/app/src/main/java/io/github/qauxv/hook/BasePersistBackgroundHook.kt index ab895306f6..bb9b47596a 100644 --- a/app/src/main/java/io/github/qauxv/hook/BasePersistBackgroundHook.kt +++ b/app/src/main/java/io/github/qauxv/hook/BasePersistBackgroundHook.kt @@ -23,6 +23,7 @@ package io.github.qauxv.hook import io.github.qauxv.base.ITraceableDynamicHook +import io.github.qauxv.base.RuntimeErrorTracer import io.github.qauxv.step.Step import io.github.qauxv.util.Log import io.github.qauxv.util.SyncUtils @@ -96,4 +97,7 @@ abstract class BasePersistBackgroundHook : ITraceableDynamicHook { } Log.e(e) } + + override val runtimeErrorDependentComponents: List? + get() = null } diff --git a/app/src/main/java/io/github/qauxv/hook/CommonConfigFunctionHook.kt b/app/src/main/java/io/github/qauxv/hook/CommonConfigFunctionHook.kt index 96890ded9a..3226e12837 100644 --- a/app/src/main/java/io/github/qauxv/hook/CommonConfigFunctionHook.kt +++ b/app/src/main/java/io/github/qauxv/hook/CommonConfigFunctionHook.kt @@ -29,6 +29,7 @@ import cc.microblock.hook.pangu_spacing import io.github.qauxv.base.IEntityAgent import io.github.qauxv.base.ISwitchCellAgent import io.github.qauxv.base.IUiItemAgent +import io.github.qauxv.base.RuntimeErrorTracer import io.github.qauxv.util.SyncUtils import io.github.qauxv.util.dexkit.DexKitTarget import kotlinx.coroutines.flow.StateFlow @@ -93,4 +94,7 @@ abstract class CommonConfigFunctionHook( get() = extraSearchKeywords?.let { { _, _ -> it } } } + override val runtimeErrorDependentComponents: List? + get() = null + } diff --git a/app/src/main/java/io/github/qauxv/hook/CommonSwitchFunctionHook.kt b/app/src/main/java/io/github/qauxv/hook/CommonSwitchFunctionHook.kt index 83cca867d9..1bdfda3fe4 100644 --- a/app/src/main/java/io/github/qauxv/hook/CommonSwitchFunctionHook.kt +++ b/app/src/main/java/io/github/qauxv/hook/CommonSwitchFunctionHook.kt @@ -29,6 +29,7 @@ import cc.microblock.hook.pangu_spacing import io.github.qauxv.base.IEntityAgent import io.github.qauxv.base.ISwitchCellAgent import io.github.qauxv.base.IUiItemAgent +import io.github.qauxv.base.RuntimeErrorTracer import io.github.qauxv.util.SyncUtils import io.github.qauxv.util.dexkit.DexKitTarget import kotlinx.coroutines.flow.StateFlow @@ -93,4 +94,8 @@ abstract class CommonSwitchFunctionHook( override val extraSearchKeywordProvider: ((IUiItemAgent, Context) -> Array?)? get() = extraSearchKeywords?.let { { _, _ -> it } } } + + override val runtimeErrorDependentComponents: List? + get() = null + } diff --git a/app/src/main/java/io/github/qauxv/router/decorator/IBaseChatPieDecorator.kt b/app/src/main/java/io/github/qauxv/router/decorator/IBaseChatPieDecorator.kt index ffe120d8c1..d716cab26e 100644 --- a/app/src/main/java/io/github/qauxv/router/decorator/IBaseChatPieDecorator.kt +++ b/app/src/main/java/io/github/qauxv/router/decorator/IBaseChatPieDecorator.kt @@ -22,7 +22,11 @@ package io.github.qauxv.router.decorator -import io.github.qauxv.base.IDynamicHook +import io.github.qauxv.base.ITraceableDynamicHook import io.github.qauxv.base.RuntimeErrorTracer +import io.github.qauxv.router.dispacher.InputButtonHookDispatcher -interface IBaseChatPieDecorator : RuntimeErrorTracer, IDynamicHook +interface IBaseChatPieDecorator : ITraceableDynamicHook { + override val runtimeErrorDependentComponents: List? + get() = listOf(InputButtonHookDispatcher.INSTANCE) +} diff --git a/app/src/main/java/io/github/qauxv/router/decorator/IItemBuilderFactoryHookDecorator.kt b/app/src/main/java/io/github/qauxv/router/decorator/IItemBuilderFactoryHookDecorator.kt index 43f04f8573..dde30c5387 100644 --- a/app/src/main/java/io/github/qauxv/router/decorator/IItemBuilderFactoryHookDecorator.kt +++ b/app/src/main/java/io/github/qauxv/router/decorator/IItemBuilderFactoryHookDecorator.kt @@ -23,9 +23,11 @@ package io.github.qauxv.router.decorator import io.github.qauxv.util.xpcompat.XC_MethodHook import io.github.qauxv.base.IDynamicHook +import io.github.qauxv.base.ITraceableDynamicHook import io.github.qauxv.base.RuntimeErrorTracer +import io.github.qauxv.router.dispacher.ItemBuilderFactoryHook -interface IItemBuilderFactoryHookDecorator : IDynamicHook, RuntimeErrorTracer { +interface IItemBuilderFactoryHookDecorator : ITraceableDynamicHook { /** * Called when the ItemBuilderFactory.getMsgType is called. @@ -41,4 +43,7 @@ interface IItemBuilderFactoryHookDecorator : IDynamicHook, RuntimeErrorTracer { param: XC_MethodHook.MethodHookParam ): Boolean + override val runtimeErrorDependentComponents: List? + get() = listOf(ItemBuilderFactoryHook) + } diff --git a/app/src/main/java/io/github/qauxv/router/decorator/IStartActivityHookDecorator.kt b/app/src/main/java/io/github/qauxv/router/decorator/IStartActivityHookDecorator.kt index fe7ef977d3..df4df2c395 100644 --- a/app/src/main/java/io/github/qauxv/router/decorator/IStartActivityHookDecorator.kt +++ b/app/src/main/java/io/github/qauxv/router/decorator/IStartActivityHookDecorator.kt @@ -22,11 +22,12 @@ package io.github.qauxv.router.decorator import android.content.Intent -import io.github.qauxv.util.xpcompat.XC_MethodHook -import io.github.qauxv.base.IDynamicHook +import io.github.qauxv.base.ITraceableDynamicHook import io.github.qauxv.base.RuntimeErrorTracer +import io.github.qauxv.router.dispacher.StartActivityHook +import io.github.qauxv.util.xpcompat.XC_MethodHook -interface IStartActivityHookDecorator : IDynamicHook, RuntimeErrorTracer { +interface IStartActivityHookDecorator : ITraceableDynamicHook { /** * Called before when [android.content.Context.startActivity] is called with [Intent] @@ -38,4 +39,7 @@ interface IStartActivityHookDecorator : IDynamicHook, RuntimeErrorTracer { @Throws(Throwable::class) fun onStartActivityIntent(intent: Intent, param: XC_MethodHook.MethodHookParam): Boolean + override val runtimeErrorDependentComponents: List? + get() = listOf(StartActivityHook) + } diff --git a/app/src/main/java/io/github/qauxv/router/dispacher/InputButtonHookDispatcher.java b/app/src/main/java/io/github/qauxv/router/dispacher/InputButtonHookDispatcher.java index 5fd3095259..077ca7828d 100644 --- a/app/src/main/java/io/github/qauxv/router/dispacher/InputButtonHookDispatcher.java +++ b/app/src/main/java/io/github/qauxv/router/dispacher/InputButtonHookDispatcher.java @@ -43,6 +43,7 @@ import com.xiaoniu.hook.CtrlEnterToSend; import io.github.duzhaokun123.hook.SendTTSHook; import io.github.qauxv.R; +import io.github.qauxv.base.annotation.EntityAgentEntry; import io.github.qauxv.base.annotation.FunctionHookEntry; import io.github.qauxv.bridge.AppRuntimeHelper; import io.github.qauxv.bridge.SessionInfoImpl; @@ -69,6 +70,7 @@ import java.util.Objects; import mqq.app.AppRuntime; +@EntityAgentEntry @FunctionHookEntry public class InputButtonHookDispatcher extends BaseHookDispatcher implements SessionHooker.IAIOParamUpdate { diff --git a/app/src/main/java/io/github/qauxv/router/dispacher/ItemBuilderFactoryHook.kt b/app/src/main/java/io/github/qauxv/router/dispacher/ItemBuilderFactoryHook.kt index 7a35e1532f..bd6416a94d 100644 --- a/app/src/main/java/io/github/qauxv/router/dispacher/ItemBuilderFactoryHook.kt +++ b/app/src/main/java/io/github/qauxv/router/dispacher/ItemBuilderFactoryHook.kt @@ -22,6 +22,7 @@ package io.github.qauxv.router.dispacher import cc.hicore.QApp.QAppUtils +import io.github.qauxv.base.annotation.EntityAgentEntry import io.github.qauxv.util.xpcompat.XC_MethodHook import io.github.qauxv.util.xpcompat.XposedBridge import io.github.qauxv.base.annotation.FunctionHookEntry @@ -37,6 +38,7 @@ import me.singleneuron.hook.decorator.SimpleReceiptMessage import java.lang.reflect.Method @FunctionHookEntry +@EntityAgentEntry object ItemBuilderFactoryHook : BaseHookDispatcher( arrayOf(CItemBuilderFactory) ) { diff --git a/app/src/main/java/io/github/qauxv/router/dispacher/StartActivityHook.kt b/app/src/main/java/io/github/qauxv/router/dispacher/StartActivityHook.kt index 74b91f8335..ceb7726707 100644 --- a/app/src/main/java/io/github/qauxv/router/dispacher/StartActivityHook.kt +++ b/app/src/main/java/io/github/qauxv/router/dispacher/StartActivityHook.kt @@ -32,11 +32,13 @@ import io.github.qauxv.base.annotation.FunctionHookEntry import io.github.qauxv.hook.BaseHookDispatcher import io.github.qauxv.router.decorator.IStartActivityHookDecorator import io.github.qauxv.BuildConfig +import io.github.qauxv.base.annotation.EntityAgentEntry import me.singleneuron.hook.decorator.DisableQzoneSlideCamera import me.singleneuron.hook.decorator.ForceSystemAlbum import me.singleneuron.hook.decorator.ForceSystemFile import me.singleneuron.hook.decorator.FxxkQQBrowser +@EntityAgentEntry @FunctionHookEntry object StartActivityHook : BaseHookDispatcher(null) { diff --git a/app/src/main/java/me/hd/hook/FakeLocation.kt b/app/src/main/java/me/hd/hook/FakeLocation.kt index 13d425ada3..60e2624a74 100644 --- a/app/src/main/java/me/hd/hook/FakeLocation.kt +++ b/app/src/main/java/me/hd/hook/FakeLocation.kt @@ -32,6 +32,7 @@ import com.afollestad.materialdialogs.customview.customView import com.afollestad.materialdialogs.customview.getCustomView import com.afollestad.materialdialogs.input.getInputField import com.afollestad.materialdialogs.input.input +import io.github.qauxv.base.RuntimeErrorTracer import io.github.qauxv.base.annotation.FunctionHookEntry import io.github.qauxv.base.annotation.UiItemAgentEntry import io.github.qauxv.core.HookInstaller @@ -69,6 +70,7 @@ object FakeLocation : BaseFunctionHook( } override val uiItemLocation = FunctionEntryRouter.Locations.Entertainment.ENTERTAIN_CATEGORY override val isAvailable = requireMinQQVersion(QQVersion.QQ_8_9_88) + override val runtimeErrorDependentComponents: List? = null @SuppressLint("RestrictedApi") private fun showDialog(activity: Context) { diff --git a/app/src/main/java/me/hd/hook/FakePhone.kt b/app/src/main/java/me/hd/hook/FakePhone.kt index 85371671a8..d181110c0f 100644 --- a/app/src/main/java/me/hd/hook/FakePhone.kt +++ b/app/src/main/java/me/hd/hook/FakePhone.kt @@ -31,6 +31,7 @@ import com.afollestad.materialdialogs.customview.customView import com.afollestad.materialdialogs.customview.getCustomView import com.afollestad.materialdialogs.input.getInputField import com.afollestad.materialdialogs.input.input +import io.github.qauxv.base.RuntimeErrorTracer import io.github.qauxv.base.annotation.FunctionHookEntry import io.github.qauxv.base.annotation.UiItemAgentEntry import io.github.qauxv.core.HookInstaller @@ -70,6 +71,7 @@ object FakePhone : BaseFunctionHook( } override val uiItemLocation = FunctionEntryRouter.Locations.Simplify.UI_MISC override val isAvailable = requireMinQQVersion(QQVersion.QQ_8_9_88) + override val runtimeErrorDependentComponents: List? = null @SuppressLint("RestrictedApi") private fun showDialog(activity: Context) { diff --git a/app/src/main/java/me/hd/hook/FakePicSize.kt b/app/src/main/java/me/hd/hook/FakePicSize.kt index a68a3f11ca..aa53b6b0a2 100644 --- a/app/src/main/java/me/hd/hook/FakePicSize.kt +++ b/app/src/main/java/me/hd/hook/FakePicSize.kt @@ -27,6 +27,7 @@ import cc.ioctl.util.hookBeforeIfEnabled import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.list.listItemsSingleChoice import com.tencent.qqnt.kernel.nativeinterface.MsgElement +import io.github.qauxv.base.RuntimeErrorTracer import io.github.qauxv.base.annotation.FunctionHookEntry import io.github.qauxv.base.annotation.UiItemAgentEntry import io.github.qauxv.bridge.kernelcompat.ContactCompat @@ -73,6 +74,7 @@ object FakePicSize : BaseFunctionHook( } override val uiItemLocation = FunctionEntryRouter.Locations.Entertainment.ENTERTAIN_CATEGORY override val isAvailable = requireMinQQVersion(QQVersion.QQ_8_9_88) + override val runtimeErrorDependentComponents: List? = null private fun showDialog(activity: Context) { MaterialDialog(activity).show { diff --git a/app/src/main/java/me/hd/hook/FakeVoiceTime.kt b/app/src/main/java/me/hd/hook/FakeVoiceTime.kt index f8f14cddc0..7deb2b19ad 100644 --- a/app/src/main/java/me/hd/hook/FakeVoiceTime.kt +++ b/app/src/main/java/me/hd/hook/FakeVoiceTime.kt @@ -32,6 +32,7 @@ import com.afollestad.materialdialogs.customview.customView import com.afollestad.materialdialogs.customview.getCustomView import com.afollestad.materialdialogs.input.getInputField import com.afollestad.materialdialogs.input.input +import io.github.qauxv.base.RuntimeErrorTracer import io.github.qauxv.base.annotation.FunctionHookEntry import io.github.qauxv.base.annotation.UiItemAgentEntry import io.github.qauxv.core.HookInstaller @@ -69,6 +70,7 @@ object FakeVoiceTime : BaseFunctionHook( } override val uiItemLocation = FunctionEntryRouter.Locations.Auxiliary.MESSAGE_CATEGORY override val isAvailable = requireMinQQVersion(QQVersion.QQ_8_9_88) + override val runtimeErrorDependentComponents: List? = null @SuppressLint("RestrictedApi") private fun showDialog(activity: Context) { diff --git a/app/src/main/java/me/ketal/base/PluginDelayableHook.kt b/app/src/main/java/me/ketal/base/PluginDelayableHook.kt index aada15a458..309038ae9c 100644 --- a/app/src/main/java/me/ketal/base/PluginDelayableHook.kt +++ b/app/src/main/java/me/ketal/base/PluginDelayableHook.kt @@ -29,6 +29,7 @@ import cc.ioctl.util.HostInfo import io.github.qauxv.base.IEntityAgent import io.github.qauxv.base.ISwitchCellAgent import io.github.qauxv.base.IUiItemAgent +import io.github.qauxv.base.RuntimeErrorTracer import io.github.qauxv.config.ConfigManager import io.github.qauxv.hook.BaseFunctionHook import io.github.qauxv.util.Initiator @@ -160,4 +161,6 @@ abstract class PluginDelayableHook(keyName: String) : BaseFunctionHook(hookKey = } + override val runtimeErrorDependentComponents: List? get() = null + } diff --git a/app/src/main/java/me/ketal/hook/FakeQQLevel.kt b/app/src/main/java/me/ketal/hook/FakeQQLevel.kt index a297dfd3fe..b732ca2154 100644 --- a/app/src/main/java/me/ketal/hook/FakeQQLevel.kt +++ b/app/src/main/java/me/ketal/hook/FakeQQLevel.kt @@ -33,6 +33,7 @@ import com.afollestad.materialdialogs.customview.getCustomView import com.afollestad.materialdialogs.input.getInputField import com.afollestad.materialdialogs.input.input import io.github.qauxv.base.IUiItemAgent +import io.github.qauxv.base.RuntimeErrorTracer import io.github.qauxv.base.annotation.FunctionHookEntry import io.github.qauxv.base.annotation.UiItemAgentEntry import io.github.qauxv.bridge.AppRuntimeHelper @@ -66,6 +67,7 @@ object FakeQQLevel : BaseFunctionHook("Ketal_FakeQQLevel", } override val uiItemLocation = FunctionEntryRouter.Locations.Entertainment.ENTERTAIN_CATEGORY + override val runtimeErrorDependentComponents: List? = null private val levelKey = ConfigData("Ketal_FakeQQLevel_level") private var level: String diff --git a/app/src/main/java/me/ketal/hook/MultiActionHook.kt b/app/src/main/java/me/ketal/hook/MultiActionHook.kt index 7a6239ecd9..648be7fa5b 100644 --- a/app/src/main/java/me/ketal/hook/MultiActionHook.kt +++ b/app/src/main/java/me/ketal/hook/MultiActionHook.kt @@ -39,6 +39,7 @@ import com.github.kyuubiran.ezxhelper.utils.args import com.github.kyuubiran.ezxhelper.utils.findMethod import com.github.kyuubiran.ezxhelper.utils.newInstance import io.github.qauxv.R +import io.github.qauxv.base.RuntimeErrorTracer import io.github.qauxv.base.annotation.FunctionHookEntry import io.github.qauxv.base.annotation.UiItemAgentEntry import io.github.qauxv.bridge.AppRuntimeHelper @@ -296,4 +297,7 @@ object MultiActionHook : CommonSwitchFunctionHook( override fun onAIOParamUpdate(AIOParam: Any?) { nt_aioParam = AIOParam } + + override val runtimeErrorDependentComponents: List = listOf(SessionHooker.INSTANCE) + } diff --git a/app/src/main/java/me/singleneuron/hook/decorator/RegexAntiMeg.kt b/app/src/main/java/me/singleneuron/hook/decorator/RegexAntiMeg.kt index 2d847dc3ea..61f73fc471 100644 --- a/app/src/main/java/me/singleneuron/hook/decorator/RegexAntiMeg.kt +++ b/app/src/main/java/me/singleneuron/hook/decorator/RegexAntiMeg.kt @@ -31,6 +31,7 @@ import cc.ioctl.util.msg.MessageReceiver import com.google.android.material.dialog.MaterialAlertDialogBuilder import io.github.qauxv.util.xpcompat.XposedHelpers import io.github.qauxv.base.IUiItemAgent +import io.github.qauxv.base.RuntimeErrorTracer import io.github.qauxv.base.annotation.FunctionHookEntry import io.github.qauxv.base.annotation.UiItemAgentEntry import io.github.qauxv.dsl.FunctionEntryRouter @@ -49,6 +50,7 @@ object RegexAntiMeg : CommonConfigFunctionHook(), MessageReceiver { override val description = "使用强大的正则表达式自由屏蔽卡片消息" override val valueState: MutableStateFlow? = null override val uiItemLocation = FunctionEntryRouter.Locations.Auxiliary.NOTIFICATION_CATEGORY + override val runtimeErrorDependentComponents: List = listOf(MessageInterception) private var regexCache: Regex? = null private var regexStringCache: String = ""