adb命令调试的收集
原创
©著作权归作者所有:来自51CTO博客作者抱琴司棋侍书入画的原创作品,请联系作者获取转载授权,否则将追究法律责任
文章目录
- 重启adb
- 安装&卸载apk
- 传送文件
- 与app相关
- 与设备相关
- 多设备选择
- 与屏幕相关
- 截屏&录屏
- 开闭wifi连接
- 系统应用
- 使用sdk下platform-tools的sqlite3查看数据库
重启adb
安装&卸载apk
// 安装debug版本的apk
adb install -t 包名
传送文件
adb push xxx.txt sdcard/temp_dir
adb pull sdcard/temp_dir/xxx.txt d:/catfcae
与app相关
// 案例
adb shell am force-stop cc.catface.app
// 案例1
adb shell am start -n com.eiot.mic/c.mic.mic.MainActivity
// 案例2(Starting: Intent { cmp=me.jessyan.mvparms.demo/.mvp.ui.activity.UserActivity })
adb shell am start -n me.jessyan.mvparms.demo/me.jessyan.mvparms.demo.mvp.ui.activity.UserActivity
- 查看当前显示的app包名及activity包类路径
adb shell dumpsys window windows | findstr "Current"
adb shell pm list package
adb shell dumpsys package 包名
// 可以使用管道符号grep[linux]/findstr[win]过滤信息,如下查看版本号和版本名
adb shell dumpsys package 包名 | findstr versionCode
adb shell dumpsys package 包名 | findstr versionName
- 查看设备当前heap使用情况
可以在进入某activity前和退出后分别打印对比查看在该activity堆的使用情况,分析有无内存泄漏
adb shell dumpsys meminfo 包名 -d
安装&设置输入法
- adb安装输入法apk
adb install -t 某输入法apk的绝对路径.apk
- 进设备系统设置页设置输入法
adb shell am start -n com.android.settings/.Settings
- 查看设备已安装输入法列表
- 设置默认输入法
adb shell ime set com.iflytek.inputmethod/.FlyIME
与设备相关
adb shell getprop ro.product.model
adb shell
cat system/build.prop
adb shell "cat /system/build.prop | grep "product"
adb shell getprop ro.product.cpu.abi
adb shell getprop ro.build.version.release
adb shell getprop ro.build.version.sdk
adb -d shell getprop ro.product.model
adb -d shell getprop ro.product.brand
// 方式二
adb shell getprop ro.serialno
- 获取手机的IMEI(三种方式但因手机和系统限制不一定能获取)
// 方式一
adb shell dumpsys iphonesubinfo
// 方式二(其中Device ID即为IMEI号)
adb shell getprop gsm.baseband.imei
// 方式三(该方式需处理获取到的信息)
adb shell service call iphonesubinfo 1
adb shell cat /sys/class/net/wlan0/address
adb shell cat /proc/meminfo
// 魅族手机
adb shell df /mnt/shell/emulated
// 其他手机
adb shell df /data
adb shell getprop | findstr dalvik.vm.heapgrowthlimit
多设备选择
C:\Users\catface>adb devices
List of devices attached
0123456789ABCDEF device
311904300101401 device
adb -s 311904300101401 shell
// 操作模拟器
adb -e
// 操作真实设备
adb -d
与屏幕相关
adb shell "dumpsys window | grep mUnrestrictedScreen"
adb shell content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:0
- 旋转屏幕(i代表旋转方向,取值范围为0,1,2,3)
adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1
截屏&录屏
adb shell screencap -p /sdcard/xxx.png
// 普通录制
adb shell screenrecord /sdcard/xxx.mp4
// 指定时长(如不指定默认录制180s)
adb shell screenrecord --time-limit 10 /sdcard/xxx.mp4
// 指定分辨率
adb shell screenrecord --size 1280*720 /sdcard/xxx.mp4
开闭wifi连接
adb shell svc wifi enable
adb shell svc wifi disable
系统应用
adb shell am start -n com.android.settings/.Settings
adb shell am start -n com.android.settings/.SubSettings
adb shell input keyevent KEYCODE_BACK
adb shell input keyevent 4
使用sdk下platform-tools的sqlite3查看数据库
菜鸟sqlite教程
// 打开数据库
sqlite3 .db数据库文件绝对路径
// 格式化查看结果
sqlite> .header on
sqlite> .mode column
sqlite> .timer on
// 查看数据库数据
sqlite> select * from 表名;
// 查看表结构
sqlite> .schema 表名
// 更多sqlite语法
sqlite> .help