adb 发送广播 && 恢复出厂

adb 发送广播 && 恢复出厂

发送广播

adb shell am broadcast -a 广播名android.intent.action.BOOT_COMPLETED

这条命令可以更精确的发送到某个package,如下:

adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -c android.intent.category.HOME -n package_name/class_name

启动activity/service

在adb shell中,通过am命令行启动一个Activity程序:

从superuser源代码中摘录一段使用示例:

adb shell am start -a android.intent.action.MAIN -n com.koushikdutta.superuser/com.koushikdutta.superuser.SuperuserRequestActivity

这个示例中:

-a 表示action (android.intent.action.MAIN)

-n 表示packagename (com.koushikdutta.superuser)

SuperuserRequestActivity是对应的Activity name

关机

adb shell am broadcast -a android.intent.action.ACTION_SHUTDOWN -c android.intent.category.HOME -n com.andy.androidtest/.ShutdownBroadcastReceiver

恢复出厂设置

adb shell am broadcast -a android.intent.action.MASTER_CLEAR

10.0可以用下方法

1、

adb shell am broadcast -a android.intent.action.MASTER_CLEAR

adb shell "echo "--wipe_data\n--locale=en_US" > /cache/recovery/command"

adb shell setprop sys.powerctl reboot,recovery

2、

am broadcast -a android.intent.action.FACTORY_RESET -p android --es android.intent.extra.REASON MasterClearConfirm

相关推荐
天空之城--27 分钟前
Android输入法子系统深度解析
android
天空之城--2 小时前
Android全链路性能优化:从原理到实践的终极指南
android·性能优化
Meteors.2 小时前
Android 性能优化:05.CPU优化
android·性能优化
石头猫灯3 小时前
一次 CMS 被黑实录:完整事件思路梳理
android·学习
zhonyu鱼3 小时前
Escrcpy:用电脑键盘鼠标操作安卓手机的跨平台投屏工具
android·计算机外设·电脑
千里马学框架3 小时前
安卓开机性能优化:如何安全高效地裁剪 SystemService
android·智能手机·framework·wms·手机·性能·车载
Android打工仔3 小时前
一次 Android 拍照后卡顿的 Perfetto 定位与优化实践
android·性能优化
OpenFDE开源桌面4 小时前
实操:如何将安卓 App与Linux系统应用级融合(附代码)
android·linux
xiangxiongfly9154 小时前
Android VideoView总结
android·videoview
杉氧4 小时前
从 Modifier 到 Flexbox:React Native 布局与样式设计哲学
android·前端·react native