工作常用命令总结 - adb
督促自己学习总结,特用文章的形式记录下来,共同进步
ADB
-s
adb -s 设备标识
pm
//清除应用所有数据
adb shell pm clear 包名
//查看已安装应用的包名列表
adb shell pm list package
adb shell pm list package -f
adb shell pm list package -f |grep key
am
//启动activity
adb shell am start -n className/packageName -a action
//启动服务
adb shell am startservice -n {包(package)名}/{包名}.{服务(service)名称} -a action
//发送Deeplink
adb shell am start -W -a android.intent.action.VIEW -d "deeplink"
//发送广播
adb shell am broadcast -a action --es StringKey StringValue --ei intKey intValue --ez boolKey boolValue
//android 10 需要指定接收方
adb shell am broadcast -a com.vivo.test.DataTest -n 包名/.类名 --ei type 17
kill 进程
adb shell am force-stop 进程名
root
adb root
adb remount
//重启设备
adb reboot
logcat
//打印log
adb logcat -c && adb logcat | grep --color -e TAG1 -e TAG2
//保存log
adb logcat -c && adb logcat > log.txt
adb logcat -c && adb logcat | tee my.log
dumpsys
adb shell dumpsys -l //查看支持的服务
//查看carsh信息
adb shell dumpsys dropbox --print > dropbox
//查看top Actvity
adb shell dumpsys activity|findstr ResumedActivit
dumpsys alarm //查询定时器服务相关信息
dumpsys activity //查询AMS服务相关信息
dumpsys window //查询WMS服务相关信息
dumpsys cpuinfo //查询CPU情况
dumpsys meminfo //查询内存情况
activity
查询activity的相关信息
dumpsys activity services|s //查询所有服务信息
dumpsys activity services|s 包名 //查询指定应用服务信息
adb shell dumpsys activity broadcasts 包名 //查询所有广播信息
adb shell dumpsys activity broadcasts|b 包名 //查询指定应用广播信息
//查询应用activity信息
adb shell dumpsys activity activities|a
adb shell dumpsys activity activities|a 包名
//查询进程信息
adb shell dumpsys activity processes|p
adb shell dumpsys activity processes|p 包名
//查看activity栈信息
adb shell dumpsys activity p com.example.handlerstudy | grep ActivityRecord
adb shell dumpsys activity | grep ActivityRecord
meminfo
查看内存消耗:
比如,View个数 Activity个数等等 内存泄露辅助命令
adb shell dumpsys meminfo com.example.leakdemo
adb shell dumpsys meminfo com.example.leakdemo -d
tcpip connect
//局域网操作
adb tcpip 5555
adb connect 192.168.1.101:5555
getprop
//查看设置prop属性
adb shell getprop key
adb shell setprop key value
screencap
//截屏
adb shell screencap -p /sdcard/test_pic.png
adb -s cc51e017 shell screencap -p /sdcard/test_pic.png
adb pull /storage/emulated/0/test_pic.png ./
adb -s cc51e017 pull /sdcard/test_pic.png ./
pull
//导出数据库
adb pull data/data/pkgName/databases
adb pull data/data/pkgName/shared_prefs
push
adb push xxx path
settings
获取系统设置属性
adb shell settings get system xxx
adb shell settings get global xxx
adb shell settings get secure xxx
Settings.System.getInt(getContentResolver(),"xxxx");
Settings.Global.getInt(getContentResolver(),"xxxx");
Settings.Secure.getInt(getContentResolver(),"xxxx");