安卓11 发送adb指令给app调用安装方法和删除方法,去安装证书和删除证书
时间: 2024-01-18 18:01:48 浏览: 169
静默安装app
可以通过以下方式使用adb命令安装和删除证书:
1. 安装证书:
```
adb push <path-to-certificate>.crt /sdcard/
adb shell settings put secure user_setup_complete 0
adb shell am start -n "com.android.settings/.Settings\$SecuritySettingsActivity"
adb shell input keyevent 20 && adb shell input keyevent 23
adb shell input keyevent 20 && adb shell input keyevent 23
adb shell input keyevent 20 && adb shell input keyevent 23
adb shell input keyevent 20 && adb shell input keyevent 23
adb shell input keyevent 20 && adb shell input keyevent 23
adb shell input keyevent 20 && adb shell input keyevent 23
adb shell input keyevent 20 && adb shell input keyevent 23
adb shell input text "test"
adb shell input keyevent 20 && adb shell input keyevent 23
adb shell input text "test"
adb shell input keyevent 20 && adb shell input keyevent 23
adb shell input keyevent 22 && adb shell input keyevent 23
adb shell input keyevent 22 && adb shell input keyevent 23
adb shell input keyevent 4 && adb shell input keyevent 4
adb shell input keyevent 3
adb shell pm uninstall -k --user 0 "com.android.certinstaller"
adb shell settings put secure user_setup_complete 1
```
2. 删除证书:
```
adb shell settings put secure user_setup_complete 0
adb shell pm uninstall -k --user 0 "com.android.certinstaller"
adb shell settings put secure user_setup_complete 1
```
在执行上述命令之前,请确保在设备上启用了开发人员选项。此外,有些设备可能需要通过root权限才能够执行这些命令。
阅读全文