在做android测试的时候,有时候写几个简单的批处理,能够对工作有事半功倍之效。
下面列举部分工作过程中遇到的命令,供有需要的朋友们参考。
安装所有应用:
@echo off echo 等待设备连接 adb wait-for-device set input=%1 echo 已连接 if "%input%" neq "" ( echo 安装 %input% adb install -r %input% echo %1% 安装完毕 ) else ( for /r %%i in (*.apk) do ( echo 安装 %%i adb install -r %%i echo %%i 安装完毕 ) ) pause
启动系统设置:
@echo off adb wait-for-device adb shell am start com.android.settings/.Settings
启动桌面应用:
@echo off adb wait-for-device adb shell am start -a android.intent.action.MAIN -c android.intent.category.HOME
启动服务:
@echo off :loop adb wait-for-device adb shell am startservice -a com.tuyou.tsd.cardvr.service.VideoRec ::ping 127.0.0.1 -n 10 > nul ::goto loop
开始录制视频:
@echo off adb wait-for-device adb shell am broadcast -a tsd.event.cardvr.start_record
停止录制视频:
@echo off adb wait-for-device adb shell am broadcast -a tsd.event.cardvr.stop_record
auto test monkey:
@set %repeat=0 :BEGIN @set /a repeat=repeat+1 @adb shell monkey --ignore-crashes --monitor-native-crashes -v 320000 > monkey_%repeat%.txt @ping -n 8 127.0>nul @adb reboot @ping -n 40 127.0>nul @goto BEGIN
安装应用:
@echo off echo *********************************************** echo ***** XXX设备端App安装工具---HaoChuang ***** echo *********************************************** pause adb devices set DIR=E:\AutoBuild\Version_20150817 cd /d %DIR% G: adb install -r %DIR%\TSD-Launcher*.apk echo "1.Launcher 已安装!" adb install -r %DIR%\TSD-SystemSetting*.apk echo "2.设置 已安装!" adb install -r %DIR%\TSD-VoiceAssistant*.apk echo "3.语音助手 已安装!" adb install -r %DIR%\TSD-Update*.apk echo "4.更新 已安装!" adb install -r %DIR%\TSD-CarDVR*.apk echo "5.行车记录 已安装!" adb install %DIR%\TSD-Nav*.apk echo "6.导航 已安装!" adb install -r %DIR%\TSD-MUSIC*.apk echo "7.音频 已安装!" adb install -r %DIR%\TSD-Podcast*.apk echo "8.播客 已安装!" adb install -r %DIR%\TSD-News*.apk echo "9.新闻 已安装!" rem ping 123.45.67.89 -n 1 -w 10000 > nul rem echo "没有找到devices,请检查设备是否连接成功" pause & exit
卸载应用:
@echo offecho ***********************************************echo ***** XXX设备端App卸载工具---HaoChuang *****echo ***********************************************pause adb uninstall com.test.hao;echo "1.Launcher 已卸载!" adb uninstall com.test.hao.settings;echo "2.设置 已卸载!" adb uninstall com.test.hao.voice;echo "3.语音助手 已卸载!" adb uninstall com.test.hao.updatesoft;echo "4.更新 已卸载!" adb uninstall com.test.hao.cardvr;echo "5.行车记录 已卸载!" adb uninstall com.test.hao.navigation;echo "6.导航 已卸载!" adb uninstall com.test.hao.audio;echo "7.音频 已卸载!" adb uninstall com.test.hao.podcast;echo "7.播客 已卸载!" adb uninstall com.test.hao.news;echo "7.新闻 已卸载!" rem ping 123.45.67.89 -n 1 -w 10000 > nul rem echo "没有找到devices,请检查设备是否连接成功"pause & exit
如上。
时间: 2024-11-09 10:04:17