合并拉取请求 #233

* 修改 隐藏 SIM 卡 的方法

* 修改 隐藏 SIM 卡 的方法
This commit is contained in:
Howie
2023-02-27 16:36:06 +08:00
committed by GitHub
parent bc26ba512c
commit 317340bf6f

View File

@@ -2,22 +2,24 @@ package com.lt2333.simplicitytools.hooks.rules.t.systemui
import com.github.kyuubiran.ezxhelper.utils.findMethod import com.github.kyuubiran.ezxhelper.utils.findMethod
import com.github.kyuubiran.ezxhelper.utils.hookBefore import com.github.kyuubiran.ezxhelper.utils.hookBefore
import com.github.kyuubiran.ezxhelper.utils.putObject
import com.lt2333.simplicitytools.utils.getObjectField
import com.lt2333.simplicitytools.utils.hasEnable import com.lt2333.simplicitytools.utils.hasEnable
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
object HideSimIconForT : HookRegister() { object HideSimIconForT : HookRegister() {
override fun init() { override fun init() {
findMethod("com.android.systemui.statusbar.phone.StatusBarSignalPolicy") { findMethod("com.android.systemui.statusbar.StatusBarMobileView") {
name == "hasCorrectSubs" && parameterTypes[0] == MutableList::class.java name == "applyMobileState"
}.hookBefore { }.hookBefore {
val list = it.args[0] as MutableList<*> val mobileIconState = it.args[0]
val size = list.size val subId = mobileIconState.getObjectField("subId") as Int
hasEnable("hide_sim_two_icon", extraCondition = { size == 2 }) { hasEnable("hide_sim_one_icon", extraCondition = { subId == 1 }) {
list.removeAt(1) mobileIconState.putObject("visible", false)
} }
hasEnable("hide_sim_one_icon", extraCondition = { size >= 1 }) { hasEnable("hide_sim_two_icon", extraCondition = { subId == 2 }) {
list.removeAt(0) mobileIconState.putObject("visible", false)
} }
} }
} }