From a641ceeb8917a2edcfb8ca06d03b80ecc1449795 Mon Sep 17 00:00:00 2001 From: klxiaoniu Date: Sun, 16 Jul 2023 18:45:27 +0800 Subject: [PATCH] fix: HideQZMTitleBarEntrance --- .../hook/qzone/HideQZMTitleBarEntrance.kt | 42 +++++++++++-------- .../github/qauxv/util/dexkit/DexKitTarget.kt | 7 ++++ 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/cc/ioctl/hook/qzone/HideQZMTitleBarEntrance.kt b/app/src/main/java/cc/ioctl/hook/qzone/HideQZMTitleBarEntrance.kt index af010e4ba3..753fdef794 100644 --- a/app/src/main/java/cc/ioctl/hook/qzone/HideQZMTitleBarEntrance.kt +++ b/app/src/main/java/cc/ioctl/hook/qzone/HideQZMTitleBarEntrance.kt @@ -28,6 +28,7 @@ import android.view.ViewGroup import android.widget.ImageView import cc.ioctl.util.Reflex import cc.ioctl.util.hookAfterIfEnabled +import com.github.kyuubiran.ezxhelper.utils.hookBefore import io.github.qauxv.base.annotation.FunctionHookEntry import io.github.qauxv.base.annotation.UiItemAgentEntry import io.github.qauxv.dsl.FunctionEntryRouter @@ -35,6 +36,8 @@ import io.github.qauxv.hook.CommonSwitchFunctionHook import io.github.qauxv.util.Initiator import io.github.qauxv.util.QQVersion import io.github.qauxv.util.SyncUtils +import io.github.qauxv.util.dexkit.DexKit +import io.github.qauxv.util.dexkit.NQZMoment_EntranceEnabled import io.github.qauxv.util.requireMinQQVersion /** @@ -42,7 +45,8 @@ import io.github.qauxv.util.requireMinQQVersion */ @[FunctionHookEntry UiItemAgentEntry] object HideQZMTitleBarEntrance : CommonSwitchFunctionHook( - targetProc = SyncUtils.PROC_MAIN or SyncUtils.PROC_QZONE + targetProc = SyncUtils.PROC_MAIN or SyncUtils.PROC_QZONE, + targets = arrayOf(NQZMoment_EntranceEnabled) ) { override val name = "隐藏QQ空间此刻按钮" @@ -55,22 +59,26 @@ object HideQZMTitleBarEntrance : CommonSwitchFunctionHook( override val isAvailable: Boolean get() = requireMinQQVersion(QQVersion.QQ_8_9_25) override fun initOnce(): Boolean { - val kQZMTitleBarEntranceManager = Initiator.loadClass("com.qzone.reborn.qzmoment.itemview.QZMTitleBarEntranceManager") - // com.tencent.mobileqq.zplan_impl.R.id.qzm_entrance_root - val qzm_entrance_root = Initiator.loadClass("com.tencent.mobileqq.R\$id") - .getDeclaredField("qzm_entrance_root").get(null) as Int - check(qzm_entrance_root != 0) { "qzm_entrance_root not found" } - hookAfterIfEnabled( - Reflex.findSingleMethod( - kQZMTitleBarEntranceManager, Void.TYPE, false, - Context::class.java, ViewGroup::class.java, ImageView::class.java - ), - ) { - // Log.e("HideQZMTitleBarEntrance here", Throwable()) - val view = it.args[1] as ViewGroup - val entrance: View? = view.findViewById(qzm_entrance_root) - entrance?.visibility = View.GONE - it.result = null + try { + val kQZMTitleBarEntranceManager = Initiator.loadClass("com.qzone.reborn.qzmoment.itemview.QZMTitleBarEntranceManager") + // com.tencent.mobileqq.zplan_impl.R.id.qzm_entrance_root + val qzm_entrance_root = Initiator.loadClass("com.tencent.mobileqq.R\$id") + .getDeclaredField("qzm_entrance_root").get(null) as Int + check(qzm_entrance_root != 0) { "qzm_entrance_root not found" } + hookAfterIfEnabled( + Reflex.findSingleMethod( + kQZMTitleBarEntranceManager, Void.TYPE, false, + Context::class.java, ViewGroup::class.java, ImageView::class.java + ), + ) { + // Log.e("HideQZMTitleBarEntrance here", Throwable()) + val view = it.args[1] as ViewGroup + val entrance: View? = view.findViewById(qzm_entrance_root) + entrance?.visibility = View.GONE + it.result = null + } + } catch (_: Exception) { + DexKit.requireMethodFromCache(NQZMoment_EntranceEnabled).hookBefore { it.result = false } } return true } diff --git a/app/src/main/java/io/github/qauxv/util/dexkit/DexKitTarget.kt b/app/src/main/java/io/github/qauxv/util/dexkit/DexKitTarget.kt index 663dc60c62..b14ea7397e 100644 --- a/app/src/main/java/io/github/qauxv/util/dexkit/DexKitTarget.kt +++ b/app/src/main/java/io/github/qauxv/util/dexkit/DexKitTarget.kt @@ -719,3 +719,10 @@ data object TroopEnterEffect_QQNT : DexKitTarget.UsingStr() { override val filter = DexKitFilter.allowAll // 理论上非NT也能用,但祖法不可变 } + +data object NQZMoment_EntranceEnabled : DexKitTarget.UsingStr() { + override val findMethod: Boolean = true + override val traitString = arrayOf("KEY_OPEN_QZMOMENT_ENTRANCE") + override val declaringClass = "" + override val filter = DexKitFilter.strInClsName("com/qzone/reborn/qzmoment/util") +}