Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save the-eric-kwok/19b378d5ff0b02271a8307b144a4db35 to your computer and use it in GitHub Desktop.
Save the-eric-kwok/19b378d5ff0b02271a8307b144a4db35 to your computer and use it in GitHub Desktop.
使用root跳过小米USB安装应用确认

转自——使用root跳过小米USB安装应用确认(续) | LeadroyaL's website

最近又抓来一台小米手机当测试机,部署环境时候发现了新的 usb 相关功能的修改方式。

一、背景和结论

众所周知,小米手机开启 USB 安装功能,需要插入 SIM 卡登陆、需要登小米账号。我这台手机已root,懒得登陆了,就准备通过修改文件的方式来开启相关功能,还真做到了。 关键词:root,无需 xposed,无需 frida。 测试环境:miui9、miui10、miui11、miui12。

二、无需 SIM卡和小米账号,开启USB相关功能

方法:编辑配置文件和 SystemProperties,使用下方的对照表。 使用 root编辑

/data/data/com.miui.securitycenter/shared_prefs/remote_provider_preferences.xml

,修改或者插入

<boolean name="security_adb_install_enable" value="true" /> 

用于【开发者选项】——【USB 安装,允许通过 USB 安装应用】的开关。

root@virgo:/ # setprop presist.security.adbinput 1 

用于【开发者选项】——【USB 调试(安全设置),允许通过 USB 调试修改权限或者模拟点击】

root@virgo:/ # setprop presist.fastboot.enable 1 

用于【开发者选项】——【FASTBOOT 刷机模式,允许电脑通过 USB 刷机】

分析过程

搜 com.android.settings 找到一个类,点进去看到和 usb 相关的功能,搜关键词adb,找到了这两个功能。

三、绕过 USB 安装时的弹框

方法:编辑配置文件,使用下方的对照表。 使用 root编辑 /data/data/com.miui.securitycenter/shared_prefs/remote_provider_preferences.xml ,修改或者插入

<boolean name="permcenter_install_intercept_enabled" value="false" /> 

分析过程:回到我们上次提供的方法,对 SecurityCenter 的 AdbInstallActivity 的某个字段的 isEnabled 方法进行 hook,让它的返回值返回 false。我们对比一下 miui9 和 miui11 的代码,发现它们一模一样,都是访问 permcenter_install_intercept_enabled,在配置文件里没有,我们主动添加这一项即可。

再次 adb install测试, 没有弹框,完美解决!

注:实测需要在执行完以上步骤后杀掉手机管家以使更改生效

am force-stop com.miui.securitycenter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment