工作笔记--adb命令篇
1.抓log方法 (bat文件)
mkdir D:\logcat
set /p miaoshu=请描述操作:
adb logcat -v threadtime > D:\logcat\%miaoshu%_%date:~0,4%-%date:~5,2%-%date:~8,2%_%time:~0,2%-%time:~3,2%.txt
2.抓anr的方法:
adb pull data/anr/traces.txt > D:\
3. 跑monkey脚本(bat文件)
set beginTimes=1500
adb shell monkey -p com.jd.smart.fridge.launcher -p --ignore-crashes --ignore-timeouts --ignore-security-exceptions --ignore-native-crashes --monitor-native-crashes -v -v -v --throttle %beginTimes% 100000 > D:\monkey_01.txt
ping -n 40 127.0>nul
adb shell monkey -p com.jd.smart.fridge.launcher -p --ignore-crashes --ignore-timeouts --ignore-security-exceptions --ignore-native-crashes --monitor-native-crashes -v -v -v --throttle %beginTimes% 100000 >> D:\monkey_01.txt
4.录测试apk的视频、截图并导出到本地 (view.bat,screen.bat)
::安卓截图命令
adb shell screencap -p /sdcard/screen.png #-p以png的格式保存截图
@ping -n 5 127.1 >nul 2>nul
::更改当前目录为批处理本身的目录
cd/d "%~dp0"
::获取当前时间
set y=%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%
::创建目录
md %y%
::把图片导出来
adb pull /sdcard/screen.png %y%
::删除手机中所截的图
adb shell rm -r /sdcard/screen.png
::安卓录屏命令
set /p t=请输入时间(秒):5
adb shell screenrecord --time-limit %t% /sdcard/view.mp4
@ping -n 5 127.1 >nul 2>nul
::更改当前目录为批处理本身的目录
cd/d "%~dp0"
::获取当前时间
set y=%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%
::新建目录
md %y%
::把视频导出来
adb pull /sdcard/view.mp4 %y%
::删除手机中所录的视频
adb shell rm -r /sdcard/view.mp4
5.adb命令获取CPU、内存PSS
CPU:
adb shell top -m 5 > D:/CPU.txt
PSS:
set process=com.jd.smart.fridge.launcher
adb shell dumpsys meminfo %process% | findstr "Pss"
:m
adb shell dumpsys meminfo %process% | findstr "TOTAL" >> D:/PSS.txt
ping -n 5 127.0.0.1>nul
goto m