From dd1b276b4658dfb56ae3929a57555aa6b7e6fabb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=93=83=E6=9F=92=E6=9F=92?= Date: Sun, 8 Dec 2024 18:11:17 +0800 Subject: [PATCH] re-fix: DualRowSignalHookV --- .../statusbar/model/DualRowSignalHookV.kt | 134 +++++++++--------- 1 file changed, 66 insertions(+), 68 deletions(-) diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/DualRowSignalHookV.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/DualRowSignalHookV.kt index 5235cce4b..e8b6e0489 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/DualRowSignalHookV.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/DualRowSignalHookV.kt @@ -260,92 +260,95 @@ class DualRowSignalHookV : BaseHook() { private fun setDualSignalIcon() { val setImageCallback = IMethodHookCallback { param -> - val isSetMethod = "access\$setImageResWithTintLight" == param.method.name - if (isSetMethod) { - val icon = param.args[0] as ImageView + val icon = param.args[0] as ImageView - if (icon.id == getIdByName("mobile_signal")) { - val signalGroup = icon.parent as FrameLayout + if (icon.id == getIdByName("mobile_signal")) { + val signalGroup = icon.parent as FrameLayout - val subId = XposedHelpers.getAdditionalInstanceField(icon, "subId") + val isSetMethod = "access\$setImageResWithTintLight" == param.method.name + val subId = XposedHelpers.getAdditionalInstanceField(icon, "subId") - if (mobileInfo.subId != ID_SUB_NO_DATA_SIM) { - val isUseTint: Boolean - val isLight: Boolean + if (mobileInfo.subId != ID_SUB_NO_DATA_SIM) { + val isUseTint: Boolean + val isLight: Boolean + if (isSetMethod) { val pair = param.args[2] isUseTint = pair.callMethodAs("getFirst") isLight = pair.callMethodAs("getSecond") + } else { + isUseTint = (param.args[1] as Boolean) + isLight = (param.args[2] as Boolean) + } - if (subId == null || subId != mobileInfo.subId) { - param.result = null - return@IMethodHookCallback - } + if (subId == null || subId != mobileInfo.subId) { + param.result = null + return@IMethodHookCallback + } - val (mobileSignalIconId, mobileRoamIconId) = getDualSignalIconPairResId( - isUseTint, isLight - ) - if (mobileSignalIconId != null && mobileRoamIconId != null) { - icon.post { - icon.setImageResource(mobileSignalIconId) - signalGroup.findViewWithTag("mobile_signal2")?.let { - it.setImageResource(mobileRoamIconId) - it.imageTintList = icon.imageTintList - } + val (mobileSignalIconId, mobileRoamIconId) = getDualSignalIconPairResId( + isUseTint, isLight + ) + if (mobileSignalIconId != null && mobileRoamIconId != null) { + icon.post { + icon.setImageResource(mobileSignalIconId) + signalGroup.findViewWithTag("mobile_signal2")?.let { + it.setImageResource(mobileRoamIconId) + it.imageTintList = icon.imageTintList } } } - - param.result = null - } else if (icon.tag == "mobile_signal2") { - param.result = null - } else { - // 指示器等 } - } else { - for (icon in param.thisObject.getObjectField("\$tintViewList") as List<*>) { - if (icon is ImageView) { - if (icon.id == getIdByName("mobile_signal")) { + param.result = null + } else if (icon.tag == "mobile_signal2") { + param.result = null + } else { + // 指示器等 + } + } - val signalGroup = icon.parent as FrameLayout + val setImageCallbackNew = IMethodHookCallback { param -> + for (icon in param.thisObject.getObjectField("\$tintViewList") as List<*>) { + if (icon is ImageView) { + if (icon.id == getIdByName("mobile_signal")) { - val subId = XposedHelpers.getAdditionalInstanceField(icon, "subId") - val triple = param.thisObject.getObjectField("L\$0") + val signalGroup = icon.parent as FrameLayout - if (mobileInfo.subId != ID_SUB_NO_DATA_SIM) { + val subId = XposedHelpers.getAdditionalInstanceField(icon, "subId") + val triple = param.thisObject.getObjectField("L\$0") - val isUseTint: Boolean = triple!!.callMethodAs("getFirst") - val isLight: Boolean = triple!!.callMethodAs("getSecond") + if (mobileInfo.subId != ID_SUB_NO_DATA_SIM) { + val isUseTint: Boolean = triple!!.callMethodAs("getFirst") + val isLight: Boolean = triple.callMethodAs("getSecond") - if (subId == null || subId != mobileInfo.subId) { - param.result = null - return@IMethodHookCallback - } + if (subId == null || subId != mobileInfo.subId) { + param.result = null + return@IMethodHookCallback + } - val (mobileSignalIconId, mobileRoamIconId) = getDualSignalIconPairResId( - isUseTint, isLight - ) - if (mobileSignalIconId != null && mobileRoamIconId != null) { - icon.post { - icon.setImageResource(mobileSignalIconId) - signalGroup.findViewWithTag("mobile_signal2")?.let { - it.setImageResource(mobileRoamIconId) - it.imageTintList = icon.imageTintList - } + val (mobileSignalIconId, mobileRoamIconId) = getDualSignalIconPairResId( + isUseTint, isLight + ) + if (mobileSignalIconId != null && mobileRoamIconId != null) { + icon.post { + icon.setImageResource(mobileSignalIconId) + signalGroup.findViewWithTag("mobile_signal2")?.let { + it.setImageResource(mobileRoamIconId) + it.imageTintList = icon.imageTintList } } } - - param.result = null - } else if (icon.tag == "mobile_signal2") { - param.result = null - } else { - // 指示器等 } - } + param.result = null + } else if (icon.tag == "mobile_signal2") { + param.result = null + } else { + // 指示器等 + } } + } } @@ -357,17 +360,12 @@ class DualRowSignalHookV : BaseHook() { before(setImageCallback) } } catch (_: Exception) { - /*findAndHookMethod("com.android.systemui.statusbar.pipeline.mobile.ui.binder.MiuiMobileIconBinder\$bind\$1\$1\$5\$1", "invokeSuspend", Object::class.java, object : MethodHook(){ - override fun after(param: MethodHookParam?) { - setDualSignalIcon() - } - })*/ - - loadClass("com.android.systemui.statusbar.pipeline.mobile.ui.binder.MiuiMobileIconBinder\$bind\$1\$1\$5\$1").methodFinder() + // 感觉不是很好,等有缘人改一下,先这样 + loadClass("com.android.systemui.statusbar.pipeline.mobile.ui.binder.MiuiMobileIconBinder\$bind\$1\$1\$5\$1").methodFinder() .filterByName("invokeSuspend") .single() .createHook { - after(setImageCallback) + after(setImageCallbackNew) } }