MIUI缺陷修复

成也 MIUI 败也 MIUI ,小米手机一大卖点就是 MIUI 所提供的各种便捷功能,但其对于系统的魔改导致了搞机人士的诸多不便,本篇文章将长期收集 MIUI 系统各类 “缺陷解决方案”


测试设备为 MI8 (dipper) 各功能均正常使用,其余设备相关代码可能有些许差异,按格式删除即可


防卡米

打开*/system/framework/services.jar*
使用MT管理器
反编译
搜索.method private checkSystemSelfProtection(Z)V

.method private checkSystemSelfProtection(Z)V
......

.line xxxx
...... //删除该段
.line xxxx
...... //删除该段
.line xxxx

return-void

修改后编译
重启系统


禁止还原电池白名单

打开/system/app/powerkeeper/powerkeeper.apk
取出并打开
用Dex++编辑器方式打开classes.dex,并且以代码方式搜索"Lcom/miui/powerkeeper/controller/DeviceIdleController"
进入 Lcom/miui/powerkeeper/PowerKeeperManager 这个类,并且删除代码片段:

new-instance v0, Lcom/miui/powerkeeper/controller/DeviceIdleController;

iget-object v1, p0, Lcom/miui/powerkeeper/PowerKeeperManager;->mContext:Landroid/content/Context;

invoke-direct {v0, v1, p0}, Lcom/miui/powerkeeper/controller/DeviceIdleController;-><init>(Landroid/content/Context;Lcom/miui/powerkeeper/PowerKeeperManager;)V

iput-object v0, p0, Lcom/miui/powerkeeper/PowerKeeperManager;->mDeviceIdleController:Lcom/miui/powerkeeper/controller/DeviceIdleController;
.method public getDeviceIdleController()Lcom/miui/powerkeeper/controller/DeviceIdleController;
    .registers 1

    iget-object p0, p0, Lcom/miui/powerkeeper/PowerKeeperManager;->mDeviceIdleController:Lcom/miui/powerkeeper/controller/DeviceIdleController;

    return-object p0
.end method

进入 Lcom/miui/powerkeeper/provider/PowerKeeperConfigureManager 这个类,删除代码片段:

iget-object v0, p0, Lcom/miui/powerkeeper/provider/PowerKeeperConfigureManager;->mPowerKeeperManager:Lcom/miui/powerkeeper/PowerKeeperManager;

invoke-virtual {v0}, Lcom/miui/powerkeeper/PowerKeeperManager;->getDeviceIdleController()Lcom/miui/powerkeeper/controller/DeviceIdleController;

move-result-object v0

invoke-virtual {v0}, Lcom/miui/powerkeeper/controller/Controller;->enable()V

进入 Lcom/miui/powerkeeper/statemachine/ForceDozeController 这个类,删除restoreWhiteListAppsIfQuitForceIdle()V这个方法的代码,并且加入return-void:

.method private restoreWhiteListAppsIfQuitForceIdle()V
.register 8
........ //删除此处代码
return-void
.end method

最后保存,编译,退出即可。