1.重置電池狀態(tài)
adb shell dumpsys batterystats --reset
adb shell dumpsys batterystats --enable full-wake-history
adb bugreport > xx.txt ( 保存詳細(xì)log信息够吩,包含網(wǎng)絡(luò)使用比然,屏幕喚醒,應(yīng)用使用等信息周循,配合battery?historian工具使用)
adb shell dumpsys batterystats > xx.txt (保存電量信息强法,配合battery?historian工具使用)
2.獲取adb 網(wǎng)絡(luò)占用(可以獲取到哪個進(jìn)程占用了電腦的"5037"端口,排查adb連接不上的問題)
netstat -ano | findstr "5037"
3.獲取頂層activity(獲取手機(jī)屏幕當(dāng)前的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手機(jī)獲取root權(quán)限
adb shell
su
7.殺進(jìn)程
adb shell ps
kill pid(ps的第二個元素)
8.拷貝文件到手機(jī)內(nèi)存其他地方
adb shell->su->cp ***.txt /sdcard/
9.將trace文件轉(zhuǎn)換為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
結(jié)束抓取
adb shell am profile com.cmcm.locker:locker stop
13.將耗電信息轉(zhuǎn)為html文件
H:\download\battery-historian-master\battery-historian-master
> python historian.py batterystatsS5.txt > batterystatsS5.html
(將bugreport.txt顯示出來:在h:\download\battery-historain\ 執(zhí)行g(shù)o 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.獲取內(nèi)存信息
adb -s + device + shell dumpsys meminfo + package_name
16.獲取應(yīng)用uid信息
adb shell dumpsys package com.cmcm.locker | findstr userId=
17.獲取網(wǎng)絡(luò)消耗
讀取/proc/net/xt_qtaguid/stats 下對應(yīng)uid的值,第6個是接收嚎研,第8個是發(fā)送硕淑,如果有兩行,就相加
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.保存內(nèi)存快照
adb shell am dumpheap com.cmcm.locker:locker /storage/sdcard0/locker.hprof
20.將trace轉(zhuǎn)換成html
dmtracedump.exe -h filepath > outpath(dmtracedump.exe是sdk tools里面的)
21.將設(shè)備進(jìn)入待命狀態(tài)
adb shell dumpsys battery unplug
adb shell am set-inactive <packageName> true
喚醒
adb shell am set-inactive <packageName> false
adb shellamget-inactive
22.模擬未充電狀態(tài)
adb?shell dumpsys battery?unplug
23.aapt?dump?badging?filepath |?grep?package
可以獲取包名
24.獲取系統(tǒng)版本
adb?-s?deviceId shell?getprop?ro.build.version.release
25.獲取分辨率
adb?-s?%s?shell?dumpsys?window?|?grep?init
26.獲取設(shè)備名
adb?-s?%s?shell?getprop?ro.product.model
27.清除數(shù)據(jù)
adb shell pm clear 包名