--- layout: post title: 使用adb管理安卓设备上的软件 subtitle: 卸载安卓手机自带应用 date: 2023-07-04 author: Duter2016 header-img: img/post-bg-debug.png catalog: true music-id: music-idfull: tags: - Android - adb --- ### 安装adb Android 调试桥 (adb) 是一种功能多样的命令行工具,可让您与设备进行通信。adb 命令可用于执行各种设备操作,例如安装和调试应用。 adb下载:[https://developer.android.google.cn/studio/releases/platform-tools?hl=zh-cn](https://developer.android.google.cn/studio/releases/platform-tools?hl=zh-cn) adb使用:[https://developer.android.google.cn/studio/command-line/adb?hl=zh-cn#pm](https://developer.android.google.cn/studio/command-line/adb?hl=zh-cn#pm) 使用如下命令安装adb `sudo apt install adb` 安装完adb,在终端输入`adb`命令就会显示详细信息,如下: ``` $ adb Android Debug Bridge version 1.0.41 Version 28.0.2-debian Installed as /usr/lib/android-sdk/platform-tools/adb ``` ### 连接手机 以安卓手机为例。进入系统设置 》关于手机 》连点版本号 》找到新出现的开发人员选项 》打开usb调试 ![](https://cdn.jsdelivr.net/gh/Duter2016/GitNote-images/Images/2023/07/adb001.png) usb连接手机和电脑,在终端输入`adb devices`,然后手机上会弹出“是否允许USB调试”,点击确定。 List of devices attached下会显示已连接的安卓设备。 ![](https://cdn.jsdelivr.net/gh/Duter2016/GitNote-images/Images/2023/07/adb002.png) ### 管理手机自带软件 输入 `adb shell pm list packages` ,会列出手机里所有安装的软件(包括系统软件)。 或者用如下命令,将软件输出保存为文本文件: `adb shell pm list packages > '/home/uername/下载/adb.txt'` ![](https://cdn.jsdelivr.net/gh/Duter2016/GitNote-images/Images/2023/07/adb003.png) 光看包名可能不知道其对应的软件,可以借助额外工具比如“一个木函”来验证。 ![](https://cdn.jsdelivr.net/gh/Duter2016/GitNote-images/Images/2023/07/adb004.png) 现在安卓设备普遍预装了大量软件,其中有很多不能停用不能卸载,在后台运行又占内存又费电,还时不时推送广告。 用adb就可以对付这些顽固的预装软件。 停用软件:`adb shell pm disable-user 包名` 重新启用:`adb shell enable 包名` 卸载软件:`adb shell pm uninstall --user 0 包名` 重新安装:`adb shell pm install-existing --user 0 包名` 通过adb卸载预装软件后,对应的apk安装包并不会被删除,这就是为什么卸载后还能重新安装! ![](https://cdn.jsdelivr.net/gh/Duter2016/GitNote-images/Images/2023/07/adb005.png) ** 操作前一定要做好功课!不同机型和预装软件请自行在网上搜索相关教程。** ### 卸载软件参考 比如小米手机各个软件包名及是否可以卸载,可以参考: [《ikun工具箱同款列表&问题解释》](https://www.bilibili.com/read/cv21604570/) [《MIUI 13 System Apps》](https://gist.github.com/mcxiaoke/0a4c639d04e94c45eb6c787c0f98940a) 我卸载了如下自带软件: ``` adb shell pm uninstall --user 0 com.miui.contentextension 传送门 adb shell pm uninstall --user 0 com.miui.miservice 服务与反馈 adb shell pm uninstall --user 0 com.miui.hybrid 快应用服务框架 adb shell pm uninstall --user 0 com.miui.hybrid.accessory 智慧生活(SmartScenes) adb shell pm uninstall --user 0 com.mipay.wallet 小米钱包 1 adb shell pm uninstall --user 0 com.xiaomi.payment 米币支付 adb shell pm uninstall --user 0 com.miui.nextpay 小米支付 adb shell pm uninstall --user 0 com.miui.newhome 内容中心 1 adb shell pm uninstall --user 0 com.sohu.inputmethod.sogou.xiaomi 搜狗输入法小米版 ``` 其他品牌手机自行搜索!谨慎删除! ## 参考 * [004-使用adb管理安卓设备上的软件](https://bbs.deepin.org/post/258897) * [ikun工具箱同款列表&问题解释](https://www.bilibili.com/read/cv21604570/) * [MIUI 13 System Apps](https://gist.github.com/mcxiaoke/0a4c639d04e94c45eb6c787c0f98940a)