Skip to content

HyperOS 2 启动后 smart_chg 自定义阈值会被系统覆盖 #6

Description

@leowood2000

作者你好,感谢这个模块。

我这边在 HyperOS 2 设备上遇到一个比较具体的问题:模块并不是没有生效,而是启动后写入成功,随后又被系统覆盖。

设备环境:

  • 模块版本:1.1.9 (14)
  • 作用域:com.miui.securitycenter
  • 系统:HyperOS 2 / Android 15

现象:

长按电源硬重启后,自定义断充阈值看起来失效,需要进入“省电与电池 -> 电池保护 -> 智能断充”手动点一次才恢复。

抓到的关键日志:

08:07:07.899  com.miui.securitycenter.remote  IMiCharge: 43 to 0x370011 successfully

这里模块已经成功写入 55% 对应的 0x370011

但随后很快被系统写入多个数据,应该是一些充电的参数:

08:07:08.149  com.miui.securitycenter.remote  IMiCharge: 43 to 0 successfully
08:07:08.251  com.miui.securitycenter.remote  IMiCharge: 43 to 0x10 successfully
08:07:08.375  com.miui.securitycenter.remote  IMiCharge: 43 to 0x2 successfully

后面还看到系统侧逻辑继续写入:

MiuiBatteryIntelligence: set smart charge = 262209

我看源码里目前的恢复逻辑只在 smart_chg <= 0 时补写:

(getSmartChargeValue()?.toIntOrNull() ?: 1) <= 0

但实际被覆盖后的值不一定是 0,也可能是 64262209196673 这类非 0 值,所以不会再触发补写。

我做了一个 fork 版用于测试:

  • 基于原版 1.1.9 (14),升级为 1.1.10 (15)
  • 检查当前 smart_chg 是否等于已保存的自定义阈值,而不是只判断是否为 0
  • com.miui.securitycenter.remote 注册电池广播后延迟 5 秒后复查一次
  • 如果发现被系统覆盖,就按当前保存的阈值重写一次
  • 阈值仍然动态读取,不会写死 55%

源码:

https://github.com/leowood2000/HyperSmartCharge

测试版 APK / Release:

https://github.com/leowood2000/HyperSmartCharge/releases/tag/v1.1.10-leowood

APK 直链:

https://github.com/leowood2000/HyperSmartCharge/releases/download/v1.1.10-leowood/HyperSmartCharge-1.1.10_15.apk

说明:这个 APK 是 GitHub Actions debug 签名,仅供遇到类似问题的人测试。由于签名不同,可能需要先卸载原模块,再安装该版本,并重新在 LSPosed 中启用作用域后重启。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions