1.重置电池状态
adb shell dumpsys batterystats --reset
adb shell dumpsys batterystats --enable full-wake-history
adb bugreport > xx.txt ( 保存详细log信息,包含网络使用,屏幕唤醒,应用使用等信息,配合battery historian工具使用)
adb shell dumpsys batterystats > xx.txt (保存电量信息,配合battery historian工具使用)
2.获取adb 网络占用(可以获取到哪个进程占用了电脑的"5037"端口,排查adb连接不上的问题)
netstat -ano | findstr "5037"
3.获取顶层activity(获取手机屏幕当前的activity名称)
adb shell dumpsys activity | findstr "mFocused"
4.获取某个包的安装位置
adb shell pm path 包名
5.adb 用wifi 连接
adb tcpip 5555
adb connect 10.60.212.107
6.root手机获取root权限
adb shell
su
7.杀进程
adb shell ps
kill pid(ps的第二个元素)
8.拷贝文件到手机内存其他地方
adb shell->su->cp ***.txt /sdcard/
9.将trace文件转换为html文件
dmtracedump -h ***.trace > output.html
10.dmtracedump -g ***.png ***.trace
11.启动activity
adb shell am start -n 包名/activity名(activity得是launch属性)
12.开始抓取trace信息
adb shell am profile com.cmcm.locker:locker start /mnt/sdcard/BatteryTest.trace
结束抓取
adb shell am profile com.cmcm.locker:locker stop
13.将耗电信息转为html文件
H:\download\battery-historian-master\battery-historian-master
> python historian.py batterystatsS5.txt > batterystatsS5.html
(将bugreport.txt显示出来:在h:\download\battery-historain\ 执行go run cmd/battery-historian/battery-historian.go,在浏览器输入http://localhost:9999/,加载txt文件
http://blog.csdn.net/caroline_wendy/article/details/50769915
https://github.com/google/battery-historian)
14.获取cpu信息
adb -s + device + shell dumpsys cpuinfo | findstr "com.cmcm.locker:locker"
15.获取内存信息
adb -s + device + shell dumpsys meminfo + package_name
16.获取应用uid信息
adb shell dumpsys package com.cmcm.locker | findstr userId=
17.获取网络消耗
读取/proc/net/xt_qtaguid/stats 下对应uid的值,第6个是接收,第8个是发送,如果有两行,就相加
18.获取tcpdump
http://www.cnblogs.com/likwo/archive/2012/09/06/2673944.html
adb push tcpdump /data/local/tcpdump
adb shell chmod 6755 /data/local/tcpdump
adb shell
su
cd /data/local/
./tcpdump -i any -p -s 0 -w /sdcard/capture.pcap
adb pull /sdcard/capture.pcap E:\Desktop\forTest\capture.pcap
19.保存内存快照
adb shell am dumpheap com.cmcm.locker:locker /storage/sdcard0/locker.hprof
20.将trace转换成html
dmtracedump.exe -h filepath > outpath(dmtracedump.exe是sdk tools里面的)
21.将设备进入待命状态
adb shell dumpsys battery unplug
adb shell am set-inactive <packageName> true
唤醒
adb shell am set-inactive <packageName> false
adb shellamget-inactive
22.模拟未充电状态
adb shell dumpsys battery unplug
23.aapt dump badging filepath | grep package
可以获取包名
24.获取系统版本
adb -s deviceId shell getprop ro.build.version.release
25.获取分辨率
adb -s %s shell dumpsys window | grep init
26.获取设备名
adb -s %s shell getprop ro.product.model
27.清除数据
adb shell pm clear 包名