最近工作用到了太多的adb命令临扮,在此總結(jié)一下
一弧圆、截屏
方式一
1.adb shell screencap -p /sdcard/demo.png
2.adb pull /sdcard/demo.png
3.adb shell rm demo.png
- 截屏保存到sdcard中
- 再從sdcard中導(dǎo)出到電腦( cmd 啟動的路徑忍宋,后面可加指定路徑)
- 刪除保存到sdcard中的圖片
方式二
adb exec-out screencap -p > demo.png
(mac)
adb shell screencap -p | sed ‘s/\r$//’ > demo.png
(windows 未嘗試)
二、錄屏
adb shell screenrecord /sdcard/demo.mp4
錄屏保存到sdcard中迄薄,默認錄制180s
adb shell screenrecord /sdcard/demo.mp4 --time-limit 10
指定錄制時間10s
adb pull /sdcard/demo.mp4
導(dǎo)出錄制的視頻
adb shell rm /sdcard/demo.mp4
三雳锋、屏幕參數(shù)
wm命令修改屏幕的參數(shù)(WindowManager)
adb shell wm
或進入shell模式后直接輸入wm
設(shè)備尺寸
adb shell wm size
查詢
adb shell wm size 720x1280
修改
adb shell wm size reset
還原
設(shè)備density
adb shell wm density
查詢
adb shell wm density 360
修改(density 120,240 ,360,480,560)
adb shell wm density reset
還原
四、查看當(dāng)前與用戶交互的activity
方式一
adb shell dumpsys activity activities | sed -En -e '/Running activities/,/Run #0/p'
方式二
adb shell dumpsys activity | grep -i run
疑難問題
1.adb pull 會拉不出來饮六,提示Permission denied
嘗試方式一其垄,重新掛載
adb root
adb remount
adb pull xx
嘗試方式二,沒有徹底root成功卤橄,復(fù)制到sdcard绿满,再拉取
cp xxx /sdcard/xxx
adb pull /sdcard/xxx