Android常用命令
Android常用命令
adb
adb:Android Debug Bridge
- adb devices:查看设备
- adb kill-server:关闭adb的后台进程
- adb tcpip:让Android脱离USB线的TCP连接方式
- adb connect:连接开启了TCP连接方式的手机
- adb logcat:Android日志查看
- adb bugreport:收集日志数据,用于后续的分析,比如耗电量
adb shell
adb shell本身就是一个Linux的shell,可以调用Android内置命令
- adb shell
- adb shell dumpsys
- adb shell pm
- adb shell am
- adb shell ps
- adb shell monkey
获取App的信息
- App信息
- 获取当前界面元素:adb shell dumpsys activity top
- 获取任务列表:adb shell dumpsys activity activities
- App入口
- adb logcat | grep -i displayed
- aapt dump badging mobike.apk | grep launchable-activity
- apkanalyzer最新版本的sdk中才有
- 启动应用
- adb shell am start -W -n com.xueqiu.android/.view.WelcomeActivityAlias -S
自动化测试常用命令
- adb
- pm
- 清理指定包的缓存:adb shell pm clear com.xueqiu.android
- am
- 启动指定的activity:adb shell am start -n com.xueqiu.android/.view.WelcomeActivityAlias -S
- dumpsys
- uiautomator
- adb shell uiautomator dump
- adb shell uiautomator runtest …
- input
- 模拟事件:adb shell input xxx
Android性能统计dumpsys
- 获取所有的dumpsys子命令:dumpsys | grep -i DUMP
- 获取当前activity: adb shell dumpsys activity top
- 获取activities记录,可以获取到appium依赖的原始activity:dumpsys activity activities
- 获取特定包基本信息:adb shell dumpsys package com.xueqiu.android
- 获取系统通知:adb shell dumpsys notification
- 获得内存信息:adb shell dumpsys meminfo com.android.settings
- 获取cpu信息:adb shell dumpsys cpuinfo
- 获取gpu绘制分析:adb shell dumpsys gfxinfo com.android.settings
- 获取短信:adb shell dumpsys activity broadcasts | grep senderName=
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Jing's Blog!