adb基础命令
2021-10-23 00:00:11 星期六
android debug bridge
组成:
客户端 adb client
服务端 adb server
手机端 adbd
一,启动
package 包:是 Android 应用的唯一标志
Activity 活动页: Android 应用页面,一个页面就是一个 Activity
获取当前页面名:
adb shell "dumpsys window | grep mCurrentFocus"
获取启动页面的 activity:
adb logcat ActivityManager:I | findstr "cmp"
启动页面:
adb shell am start -n <包名>/<avticity名>
二,adb shell
查看目录结构 :adb shell ls
查看系统当前日期 :adb shell date
查看系统 CPU 使用情况 :adb shell cat /proc/cpuinfo
查看系统内存使用情况 :adb shell cat /proc/meminfo
显示所有应用 :adb shell pm list packages
显示系统自带应用 :adb shell pm list packages -s
显示第 3 方应用 :adb shell pm list packages -3
查看当前页面名:adb shell "dumpsys window |grep mCurrentFocus"
清除应用数据及缓存:adb shell pm clear <包名>
三,日志
1,级别
V — 明细 verbose(最低优先级)
D — 调试 debug
I — 信息 info
W — 警告 warn
E — 错误 error
F — 严重错误 fatal
S — 无记载 silent(最高优先级,绝不会输出任何内容)
2,参数
adb logcat 打印默认日志数据
adb logcat -v time 打印时间
adb logcat -v color 使用不同的颜色来显示每个优先级
adb logcat -f
adb logcat > log.log 保存日志到PC上
adb logcat -c 清理已存在的日志
adb logcat -v time "*:W" 打印 Warning 及以上级别的日志
四,模拟按键
模拟点击:adb shell tap x坐标 y坐标
模拟输入:adb shell input text <输入内容>
模拟滑动:adb shell swipe <起点x> <起点y> <终点x> <终点y> <滑动时长>
返回键:adb shell input keyevent 4
Home键:adb shell input keyevent 3(置应用于后台运行)
音量放大:adb shell input keyevent 24
音量缩小:adb shell input keyevent 25
五,性能指标
查看当前系统 CPU 使用情况:adb shell dumpsys cpuinfo
查看当前系统的内存:adb shell dumpsys meminfo
查看某个应用的内存:adb shell dumpsys meminfo <应用名>
电池电量:adb shell dumpsys battery
posted on 2021-10-23 00:08 Bear_in_autumn 阅读(26) 评论(0) 收藏 举报