fix: wrong field name for MIUI14 in SystemUIHooker

This commit is contained in:
2024-06-16 00:07:47 +08:00
parent d2f8ef69c6
commit 28d3d7fd86

View File

@@ -662,11 +662,19 @@ object SystemUIHooker : YukiBaseHooker() {
/** /**
* Hook 状态栏通知图标最大数量 * Hook 状态栏通知图标最大数量
* @param fieldName 最大通知图标数量 的变量名
* @param instance 被 Hook 的 Method 的实例 * @param instance 被 Hook 的 Method 的实例
*/ */
private fun hookStatusBarMaxStaticIcons(fieldName: String, instance: Any) { private fun hookStatusBarMaxStaticIcons(instance: Any) {
val maxStaticIconsField = NotificationIconContainerClass.field { name = fieldName }.get(instance) val maxStaticIconsField = NotificationIconContainerClass.field {
name {
/** 旧版名称 */
val oldVersion = it == "mMaxStaticIcons"
/** 新版本名称 */
val newVersion = it == "MAX_STATIC_ICONS"
oldVersion || newVersion
}
}.get(instance)
if (statusBarMaxStaticIcons == -1 || if (statusBarMaxStaticIcons == -1 ||
/** 系统设置内修改,模块同步更新 */ /** 系统设置内修改,模块同步更新 */
moduleLastSetStatusBarMaxStaticIcons != maxStaticIconsField.int()) { moduleLastSetStatusBarMaxStaticIcons != maxStaticIconsField.int()) {
@@ -676,7 +684,6 @@ object SystemUIHooker : YukiBaseHooker() {
maxStaticIconsField.set(statusBarMaxStaticIcons) maxStaticIconsField.set(statusBarMaxStaticIcons)
return return
} }
/** 解除状态栏通知图标个数限制 */ /** 解除状态栏通知图标个数限制 */
if (isShowNotificationIcons) { if (isShowNotificationIcons) {
moduleLastSetStatusBarMaxStaticIcons = ConfigData.liftedStatusIconCount.let { if (it in 0..100) it else 5 } moduleLastSetStatusBarMaxStaticIcons = ConfigData.liftedStatusIconCount.let { if (it in 0..100) it else 5 }
@@ -966,7 +973,7 @@ object SystemUIHooker : YukiBaseHooker() {
}.hook().after { }.hook().after {
updateStatusBarIconsAlpha(instance()) updateStatusBarIconsAlpha(instance())
/** HyperOS系统设置修改通知图标个数触发此方法 */ /** HyperOS系统设置修改通知图标个数触发此方法 */
hookStatusBarMaxStaticIcons("mMaxStaticIcons", instance) hookStatusBarMaxStaticIcons(instance)
} }
method { method {
name { it == "calculateIconTranslations" || it == "calculateIconXTranslations" } name { it == "calculateIconTranslations" || it == "calculateIconXTranslations" }
@@ -979,14 +986,14 @@ object SystemUIHooker : YukiBaseHooker() {
instance<ViewGroup>().layoutParams.width = 9999 instance<ViewGroup>().layoutParams.width = 9999
} }
} }
/** 旧版方法 A13MIUI - 新版不存在 */ /** 旧版方法 (A13 MIUI) - 新版不存在 */
method { method {
name = "updateState" name = "updateState"
}.ignored().hook().before { hookStatusBarMaxStaticIcons("MAX_STATIC_ICONS", instance) } }.ignored().hook().before { hookStatusBarMaxStaticIcons(instance) }
/** 新版方法 (A14 MIUI14 / A14 HyperOS) - 旧版不存在 */ /** 新版方法 (A14 MIUI14 / A14 HyperOS) - 旧版不存在 */
method { method {
name = "onMeasure" name = "onMeasure"
}.ignored().hook().before { hookStatusBarMaxStaticIcons("mMaxStaticIcons", instance) } }.ignored().hook().before { hookStatusBarMaxStaticIcons(instance) }
/** 旧版方法 - 新版不存在 */ /** 旧版方法 - 新版不存在 */
method { method {
name = "setMaxStaticIcons" name = "setMaxStaticIcons"