多年之前,用批处理写的一个Monkey自动化测试工具,可以自动进行Monkey自动化测试;
可以设定黑名单/白名单/随机Monkey测试,入门之作,仅供参考。
文末有完整源码获取方法
将以下代码复制后,保存为*.bat批处理文件即可执行;或者新建一个记事本文件,将复制的代码粘贴进去,然后将文件名后缀改为*.bat,双击即可执行;
Monkey_Test Copyright HRD 【工具说明】 monkey测试脚本,用于Android monkey测试,默认随机进行APK测试,若指定一个包名或者多个包名,请参考如下修改方法; 1.通过更改配置文件config.conf的各项参数,来决定测试哪个APK以及测试的次数; 2.通过设置黑名单和白名单,来决定测试哪些APK; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [appinfo] appCnName=HRD ----------------------------------------APK/OS的中文名字,改成实际名字,方便识别 appEnName=HRD ----------------------------------------APK/OS的英文名字,改成实际名字,方便识别 appversion=V1.0.0 ----------------------------------------APK/OS的版本号 packageName=com.mediatek.camera ------------------------APK的包名,填上实际测试的APK包名,包名获取参考【获取设备所有APK名字与包名】 packageName= package---Name=com.android.settings ------------------------若要执行此项测试,将package和Name中间的"---"删除掉即可 package---Name=com.mediatek.camera ------------------------若要执行此项测试,将package和Name中间的"---"删除掉即可 package---Name=com.android.wallpaper ------------------------若要执行此项测试,将package和Name中间的"---"删除掉即可 package---Name=com.android.settings -p com.android.wallpaper -p com.android.calculator2 -p com.mediatek.camera ------此项为运行多个APK BlacklistTest=1 ----------------------------------------若设置为1,则会做排除黑名单的随机monkey测试 WhitelistTest=0 ----------------------------------------若设置为1,则会做只测试白名单的随机monkey测试 Cycle=10000 ----------------------------------------APK的循环测试次数 delay=500 ----------------------------------------每次操作间隔的时间 特别注意: 1.以上package---Name中间的"---"删除掉之后,配置文件中只能同时存在一个packageName,否则程序会出错; 2.黑名单和白名单只能同时存在一个有效的设置项,即如果BlacklistTest=1,则必须WhitelistTest=0;反之WhitelistTest=1,则必须BlacklistTest=0;如果两个都设置为有效,程序会发生未知错误; 备注: 指定测试多个包的方法: adb shell monkey -p com.android.settings -p com.mediatek.camera -p com.android.calculator2 即packageName=XXX -p XXX -p XXX -p XXX -p XXX 上面的XXX指的是APK的包名,每多一个包名,需要在前面加上-p的参数,字母必须为小写,大写会报错; 如: packageName=com.android.settings -p com.android.wallpaper -p com.android.calculator2 -p com.mediatek.camera @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2.monkey测试的monkey log会按照日期\时间的格式进行保存,同一台设备多次运行monkey测试,LOG会按照当前具体时间做区分; 3.monkey测试完成后,logcat日志也会保存在同一个目录下; 4.monkey测试完成后,会进行设备截屏,便于查找及追溯问题点; 【使用方法】 a、保存脚本:拷贝Tools目录中的config.conf文件至新版本工具中的Tools目录下; b、修改配置:修改 config.conf 中内容为你需要测试的 APP/OS 对应的信息; c、执行脚本:双击 Monkey_Test.bat 即可; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 【更新日志】 20170116 V1.0 初版,功能初步完成,待更新; 20170117 V1.1 更新: 1.apk包名清单按照当前日期命名; 2.未插入设备之前将不会进行任何创建LOG目录的操作; 3.新增多个配置文件为预选包名,在package和Name中间加上"---"即可进行参数注销; 4.默认设定为随机测试; 5.新增多个APK包名测试的配置文件支持; 6.统一实时信息输出格式; 7.在monkey log中增加开始和结束的时间,便于追溯; 8.修复Windows10系统下注释内容报错问题; 20170218 强制结束正在执行的monkey测试_20170218_v1.2 更新: 1.修复成功执行后不显示结果的bug; 20170414_V1.2 更新: 1.可以手动设置每次操作间隔时间,默认为500,单位为毫秒(1秒=1000毫秒); 2.修复部分bug; 20170418_v1.3 更新: 1.新增如果程序崩溃或者出现异常时,monkey测试不会停止的功能,直道达到设定次数; 20170602_v1.4 更新: 1.全面优化整体架构和提示信息; 2.新增黑名单的monkey测试,测试时在配置文件config.conf中若设置BlacklistTest=1,则进行黑名单测试,黑名单中的包名不会被测试到; 3.新增白名单的monkey测试,测试时在配置文件config.conf中若设置WhitelistTest=1,则进行白名单测试,只会测试到白名单中的包名; 4.注意事项: 黑名单和白名单只能同时存在一个有效的设置项, 即如果BlacklistTest=1,则必须WhitelistTest=0; 反之WhitelistTest=1,则必须BlacklistTest=0; 如果两个都设置为有效,程序会发生未知错误; 5.黑名单的创建方法:创建一个blacklist.txt的文本文件,文件里每一行只能放一个包名,另一个包名必须换行; 6.白名单的创建方法:创建一个whitelist.txt的文本文件,文件里每一行只能放一个包名,另一个包名必须换行; 20170606 V2.0 更新: 1.全面重构monkey命令,防止程序中途停止; 2.monkey测试的LOG改为保存到平板内部存储:/sdcard/MonkeyLog.txt; 3.如果机器重复执行monkey测试,程序会自动检测是否存在monkeyLog,若有则以时间命名后将其备份到/sdcard/MonkeyLogBackup/目录下,便于后续查看Log; 20170613 V2.1 更新: 1.修改所有条件下的Moneky测试的Log过滤级别为2,即输出所有测试信息到MonkeyLog.txt里面; 20170614 V2.2 更新: 1.正常的MonkeyLog保存位置不变,新增Moneky error log保存位置为/sdcard/MonkeyError.txt,后面每进行一次Moneky测试都会自动备份MonkeyLog.txt和MonkeyError.txt; 2.修改触摸操作的事件总数量为50%; 20170824 V2.3 更新: 1.修复部分bug; 2.优化读取的软件版本信息; 3.新增可以循环执行monkey测试,执行完一台机器后,按任意键执行下一台,方便多台机器可以依次执行; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 【脚本讲解】 a、核心:Monkey命令 adb shell monkey -p %packageName% -s %c_time% --throttle 100 -v -v -v 10000 -p %packageName% 指定测试包名,%packageName%变量值来自文件config.conf中的packageName对应的值。 -s %c_time% %c_time%为执行脚本当时的时间(小时、分、秒),以时间为值即达到随机目的,也为后续需要再模拟此次测试提供事件序列。 --throttle 100 代表间隔时间,即每次操作的时间间隔,此命令的含义就是增加500ms的时间间隔。 -v -v -v 10000 -v -v -v日志级别 Level 2,最详细的日志,包括了测试中选中/未选中的Activity信息。10000即执行10000次随机事件。 核心指令2: adb shell monkey --ignore-crashes --ignore-timeouts --kill-process-after-error --ignore-security-exceptions --throttle 1000 -v -v -v 200000 【Android获取包名的方法】 标签: it 方法一: adb shell pm list package -f 将获取手机内所有apk对应的包名和路径 方法二: adb shell dumpsys window w | findstr \/ | findstr name= 先打开需要查找的apk后,再敲入以上命令 方法三: C:\Users\Administrator>adb shell shell@ONDA:/ $ logcat | grep Android.intent.category.LAUNCHER 方法四: adb shell dumpsys activity > d:\log.txt 先启动需要的查找的apk,再敲入以上命令,在stack #1下查找cmp= 方法五: C:\Users\Administrator>adb shell shell@ONDA:/ $ logcat | grep START 先启动需要查找的apk,再敲入以上命令,找到最后一个ActivityManager 方法六: 使用aapt //aapt是sdk自带的一个工具,在sdk\builds-tools\目录下 1.以QQ音乐为例,命令行中切换到aapt.exe目录执行:aapt dump badging C:\Users\Administrator\Desktop\xxxxx.apk 2.运行后的结果中以下两行分别是应用包名package和入口activity名称 package: name='com.company.xxxx launchable-activity: name='com.company.xxxx.activity.AppStarterActivity' 方法七: 查看AndroidManifest.xml 1.使用apktool反编译app:apktool d xxxxx.apk E:\apk\tmp 2.打开AndroidManifest.xml manifest节点的package属性值是应用的包名: 查找android.intent.action.MAIN和android.intent.category.LAUNCHER对应的activity,该activity对应的android:name属性既是入口activity名称, android.intent.action.MAIN决定应用程序最先启动的Activity android.intent.category.LAUNCHER决定应用程序是否显示在程序列表里
@ECHO off set Str=将MonkeyLog复制到当前目录下_V2.0_20170829 by Ruida set PCpath=.\Log title %Str% ECHO. ECHO %Str% ECHO. dir /AD %PCpath% :start color 1f ECHO 等待Android设备插入... ECHO. ECHO wait-for-device ECHO. adb wait-for-device ECHO. ECHO Start... ECHO. ECHO 已识别到Android设备... ECHO. ECHO 正在检查是否存在旧的Log文件,若存在将自动删除... ECHO. if exist %PCpath%\ rd /s /q %PCpath%\ && ECHO 正在删除旧的Log文件... && ECHO. if not exist %PCpath% md %PCpath% ECHO 正在复制中,请稍候... ECHO. title 正在复制中,请稍候... ECHO. adb pull /sdcard/MonkeyLogBackUp/. %PCpath% adb pull /sdcard/MonkeyLog.txt %PCpath% adb pull /sdcard/MonkeyError.txt %PCpath% start %PCpath% goto :eof
@ECHO OFF setlocal enabledelayedexpansion color 0E TITLE 强制结束正在执行的monkey测试_v1.4_20171017 ECHO. ECHO 强制结束正在执行的monkey测试_v1.4_20171017 ECHO. ECHO 等待设备插入... :start del /a/f/q shellps.log ECHO wait-for-device adb wait-for-device ECHO. ECHO Start ... color 1F ECHO. :APKALL adb shell ps>shellps.log For /f "tokens=2 delims= " %%a in ('type shellps.log ^| find /i "com.android.commands.monkey"') do set APKPIN=%%a echo APKPIN=%APKPIN% ping -n 2 127.0.0.1>nul if not defined APKPIN goto NOPIN ECHO adb shell kill %APKPIN% adb shell kill %APKPIN% ECHO.[ INFO ] 操作完成... ECHO.[ INFO ] 已成功关闭正在运行的Monkey后台进程,5S后程序自动退出... color 2f del /a/f/q shellps.log timeout 1 goto :eof :NOPIN COLOR CF ECHO. ECHO.[ INFO ] 未发现Monkey后台进程,5S后程序自动退出... ECHO. del /a/f/q shellps.log timeout 1 exit
echo wait-for-device adb wait-for-device adb shell pm list package -f >apklist.log echo read success !!!
package:/system/priv-app/CtsShimPrivPrebuilt/CtsShimPrivPrebuilt.apk=com.android.cts.priv.ctsshim package:/system/app/YouTube/YouTube.apk=com.google.android.youtube package:/system/priv-app/GoogleExtServices/GoogleExtServices.apk=com.google.android.ext.services package:/system/priv-app/TelephonyProvider/TelephonyProvider.apk=com.android.providers.telephony package:/system/priv-app/Velvet/Velvet.apk=com.google.android.googlequicksearchbox package:/system/priv-app/CalendarProvider/CalendarProvider.apk=com.android.providers.calendar package:/system/priv-app/MediaProvider/MediaProvider.apk=com.android.providers.media package:/system/priv-app/GoogleOneTimeInitializer/GoogleOneTimeInitializer.apk=com.google.android.onetimeinitializer package:/system/app/GoogleExtShared/GoogleExtShared.apk=com.google.android.ext.shared package:/system/priv-app/WallpaperCropper/WallpaperCropper.apk=com.android.wallpapercropper package:/system/priv-app/DocumentsUI/DocumentsUI.apk=com.android.documentsui package:/system/priv-app/ExternalStorageProvider/ExternalStorageProvider.apk=com.android.externalstorage package:/system/app/HTMLViewer/HTMLViewer.apk=com.android.htmlviewer package:/system/priv-app/MmsService/MmsService.apk=com.android.mms.service package:/system/priv-app/DownloadProvider/DownloadProvider.apk=com.android.providers.downloads package:/system/priv-app/ConfigUpdater/ConfigUpdater.apk=com.google.android.configupdater package:/system/app/SoundRecorder/SoundRecorder.apk=com.android.soundrecorder package:/system/priv-app/DefaultContainerService/DefaultContainerService.apk=com.android.defcontainer package:/system/app/DownloadProviderUi/DownloadProviderUi.apk=com.android.providers.downloads.ui package:/system/priv-app/Phonesky/Phonesky.apk=com.android.vending package:/system/app/PacProcessor/PacProcessor.apk=com.android.pacprocessor package:/system/app/CertInstaller/CertInstaller.apk=com.android.certinstaller package:/system/app/RKUpdateService/RKUpdateService.apk=android.rockchip.update.service package:/system/framework/framework-res.apk=android package:/system/priv-app/Contacts/Contacts.apk=com.android.contacts package:/system/app/Camera2/Camera2.apk=com.android.camera2 package:/system/app/EasterEgg/EasterEgg.apk=com.android.egg package:/system/priv-app/MtpDocumentsProvider/MtpDocumentsProvider.apk=com.android.mtp package:/system/app/Launcher3/Launcher3.apk=com.android.launcher3 package:/system/priv-app/BackupRestoreConfirmation/BackupRestoreConfirmation.apk=com.android.backupconfirm package:/system/priv-app/StatementService/StatementService.apk=com.android.statementservice package:/system/app/Gmail2/Gmail2.apk=com.google.android.gm package:/system/priv-app/SetupWizard/SetupWizard.apk=com.google.android.setupwizard package:/system/app/RkApkinstaller/RkApkinstaller.apk=com.android.apkinstaller package:/system/priv-app/SettingsProvider/SettingsProvider.apk=com.android.providers.settings package:/system/priv-app/SharedStorageBackup/SharedStorageBackup.apk=com.android.sharedstoragebackup package:/system/app/Music2/Music2.apk=com.google.android.music package:/system/app/PrintSpooler/PrintSpooler.apk=com.android.printspooler package:/system/app/BasicDreams/BasicDreams.apk=com.android.dreams.basic package:/system/app/RkExplorer/RkExplorer.apk=com.android.rk package:/system/priv-app/InputDevices/InputDevices.apk=com.android.inputdevices package:/system/priv-app/MusicFX/MusicFX.apk=com.android.musicfx package:/system/app/Drive/Drive.apk=com.google.android.apps.docs package:/system/app/Maps/Maps.apk=com.google.android.apps.maps package:/system/app/WebViewGoogle/WebViewGoogle.apk=com.google.android.webview package:/system/priv-app/Telecom/Telecom.apk=com.android.server.telecom package:/system/app/GoogleContactsSyncAdapter/GoogleContactsSyncAdapter.apk=com.google.android.syncadapters.contacts package:/system/app/KeyChain/KeyChain.apk=com.android.keychain package:/system/app/Chrome/Chrome.apk=com.android.chrome package:/system/priv-app/GooglePackageInstaller/GooglePackageInstaller.apk=com.google.android.packageinstaller package:/system/priv-app/GmsCore/GmsCore.apk=com.google.android.gms package:/system/priv-app/GoogleServicesFramework/GoogleServicesFramework.apk=com.google.android.gsf package:/system/app/GoogleTTS/GoogleTTS.apk=com.google.android.tts package:/system/priv-app/GooglePartnerSetup/GooglePartnerSetup.apk=com.google.android.partnersetup package:/system/app/Videos/Videos.apk=com.google.android.videos package:/system/priv-app/ProxyHandler/ProxyHandler.apk=com.android.proxyhandler package:/system/app/LatinIME/LatinIME.apk=com.android.inputmethod.latin package:/system/priv-app/GoogleFeedback/GoogleFeedback.apk=com.google.android.feedback package:/system/app/GooglePrintRecommendationService/GooglePrintRecommendationService.apk=com.google.android.printservice.recommendation package:/system/app/Photos/Photos.apk=com.google.android.apps.photos package:/system/app/CalendarGoogle/CalendarGoogle.apk=com.google.android.calendar package:/system/priv-app/ManagedProvisioning/ManagedProvisioning.apk=com.android.managedprovisioning package:/system/app/MediaFloat/MediaFloat.apk=com.android.rk.mediafloat package:/system/app/PhotoTable/PhotoTable.apk=com.android.dreams.phototable package:/system/app/PartnerBookmarksProvider/PartnerBookmarksProvider.apk=com.android.providers.partnerbookmarks package:/system/priv-app/GoogleLoginService/GoogleLoginService.apk=com.google.android.gsf.login package:/system/app/WAPPushManager/WAPPushManager.apk=com.android.smspush package:/system/app/LiveWallpapersPicker/LiveWallpapersPicker.apk=com.android.wallpaper.livepicker package:/system/priv-app/StressTest/StressTest.apk=com.cghs.stresstest package:/system/priv-app/GoogleBackupTransport/GoogleBackupTransport.apk=com.google.android.backuptransport package:/system/priv-app/StorageManager/StorageManager.apk=com.android.storagemanager package:/system/app/OpenWnn/OpenWnn.apk=jp.co.omronsoft.openwnn package:/system/app/BookmarkProvider/BookmarkProvider.apk=com.android.bookmarkprovider package:/system/priv-app/Settings/Settings.apk=com.android.settings package:/system/app/Lightning/Lightning.apk=acr.browser.barebones package:/system/app/ExactCalculator/ExactCalculator.apk=com.android.calculator2 package:/system/app/CtsShimPrebuilt/CtsShimPrebuilt.apk=com.android.cts.ctsshim package:/system/priv-app/VpnDialogs/VpnDialogs.apk=com.android.vpndialogs package:/system/app/Hangouts/Hangouts.apk=com.google.android.talk package:/system/priv-app/TeleService/TeleService.apk=com.android.phone package:/system/priv-app/Shell/Shell.apk=com.android.shell package:/system/app/WallpaperBackup/WallpaperBackup.apk=com.android.wallpaperbackup package:/system/priv-app/BlockedNumberProvider/BlockedNumberProvider.apk=com.android.providers.blockednumber package:/system/app/UserDictionaryProvider/UserDictionaryProvider.apk=com.android.providers.userdictionary package:/system/priv-app/FusedLocation/FusedLocation.apk=com.android.location.fused package:/system/app/DeskClock/DeskClock.apk=com.android.deskclock package:/system/priv-app/SystemUI/SystemUI.apk=com.android.systemui package:/system/priv-app/DeviceTest/DeviceTest.apk=com.DeviceTest package:/system/app/WallpaperPicker/WallpaperPicker.apk=com.android.wallpaperpicker package:/system/priv-app/ContactsProvider/ContactsProvider.apk=com.android.providers.contacts package:/system/app/CaptivePortalLogin/CaptivePortalLogin.apk=com.android.captiveportallogin package:/system/app/RkVideoPlayer/RkVideoPlayer.apk=android.rk.RockVideoPlayer
@ECHO OFF setlocal enableDelayedexpansion color 1F title Monkey自动测试脚本_Log生成到本机_V2.3_20181026 by HRD ECHO ============================================================== ECHO ****** ****** ECHO ****** Monkey 测试工具 ****** ECHO ***** ***** ECHO **** 作者:HRD *** ECHO ***** **** ECHO ****** 版本:V2.3 ****** ECHO ****** ****** ECHO ****** 时间:2018.10.26 ****** ECHO ============================================================== IF NOT EXIST .\Tools\config.conf GOTO EXIT ::if exist .\Tools\*.log del /f /q .\Tools\*.log For /f "tokens=2 delims==" %%a in ('type .\Tools\config.conf ^| find /i "PackageName"') do set PackageName=%%a For /f "tokens=2 delims==" %%a in ('type .\Tools\config.conf ^| find /i "AppCnName"') do set AppCnName=%%a For /f "tokens=2 delims==" %%a in ('type .\Tools\config.conf ^| find /i "AppEnName"') do set AppEnName=%%a For /f "tokens=2 delims==" %%a in ('type .\Tools\config.conf ^| find /i "AppVersion"') do set AppVersion=%%a For /f "tokens=2 delims==" %%a in ('type .\Tools\config.conf ^| find /i "Cycle"') do set Cycle=%%a For /f "tokens=2 delims==" %%a in ('type .\Tools\config.conf ^| find /i "Delay"') do set Delay=%%a For /f "tokens=2 delims==" %%a in ('type .\Tools\config.conf ^| find /i "LogPath"') do set LogPath=%%a ECHO. ECHO 准备Monkey测试... ECHO. ECHO 读取config.conf中测试配置信息... ECHO @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ECHO. type .\Tools\config.conf ECHO. ECHO @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ECHO. ECHO 请确认以上信息是否正确(按任意键可跳过此步骤)... timeout 10 :start color 1f SET c_date=%date:~0,4%%date:~5,2%%date:~8,2% SET c_time=%time:~0,2% IF /i %c_time% LSS 10 ( SET c_time=0%time:~1,1% ) SET c_time=%c_time%%time:~3,2%%time:~6,2% ::SET LogFileName=%c_date%%c_time%_MonkeyLog.txt SET LogFileName=MonkeyLog.txt ECHO. ECHO Monkey Log保存位置为: %LogPath%/%LogFileName% ECHO. ECHO Monkey Error Log保存位置为: %LogPath%/MonkeyError.txt ECHO. ECHO. ECHO 等待设备插入... ECHO wait-for-device adb wait-for-device ECHO. ECHO Start ... color 9F adb root ping -n 2 127.0.0.1>nul adb root adb remount adb remount set File=DeviceInfo.log adb shell cat /system/build.prop>%File% For /f "tokens=2 delims==" %%a in ('type %File% ^| find /i "ro.build.version.release"') do set androidOS=%%a For /f "tokens=2 delims==" %%a in ('type %File% ^| find /i "ro.product.model"') do set model=%%a For /f "tokens=2 delims==" %%a in ('type %File% ^| find /i "ro.product.brand"') do set brand=%%a For /f "tokens=2 delims==" %%a in ('type %File% ^| find /i "ro.build.version.security_patch"') do set security_patch=%%a For /f "tokens=2 delims==" %%a in ('type %File% ^| find /i "ro.build.display.id"') do set displayId=%%a For /f "tokens=2 delims==" %%a in ('type %File% ^| find /i "ro.product.locale"') do set locale=%%a For /f "tokens=2 delims==" %%a in ('type %File% ^| find /i "ro.build.type"') do set Mode=%%a For /f "tokens=2 delims==" %%a in ('type %File% ^| find /i "net.bt.name"') do set bt=%%a For /f "tokens=2 delims==" %%a in ('type %File% ^| find /i "ro.build.version.incremental"') do set OSdate=%%a ECHO 正在读取Android设备信息... if exist "%File%" del /f /q /a "%File%" ECHO 读 取 日 期:%date% %time% > "%File%" ECHO.>>"%File%" ECHO 设备信息如下:>>"%File%" ECHO.>>"%File%" ECHO @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ >> "%File%" ECHO 设 备 品 牌: %brand%>>"%File%" ECHO 设 备 型 号: %model%>>"%File%" ECHO 默 认 语 言: %locale%>>"%File%" ECHO 安卓 版本号: Android %androidOS%>>"%File%" ECHO 软件 版本号: %displayId%>>"%File%" ECHO OS 类 型: %Mode%>>"%File%" ECHO Build 日期: %OSdate%>>"%File%" ECHO @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ >> "%File%" set time1=%date% %time% ECHO. ECHO 开始时间=%time1% ECHO. ECHO 开始时间=%time1% >> "%File%" ECHO. >> "%File%" :BackupLog ECHO. ECHO 正在检查是否已存在 MonkeyLog ,若存在将自动备份... adb shell ls %LogPath%/%LogFileName% | findstr "%LogFileName%" if %errorlevel% == 0 ( adb shell ls %LogPath%/MonkeyLogBackUp/ | findstr "No such file or directory" if %errorlevel% == 0 ( adb shell mkdir %LogPath%/MonkeyLogBackUp/ ) adb shell mv %LogPath%/%LogFileName% %LogPath%/MonkeyLogBackUp/. adb shell sleep 2 adb shell rename %LogPath%/MonkeyLogBackUp/%LogFileName% %LogPath%/MonkeyLogBackUp/%c_date%%c_time%_MonkeyLog_BackUp.txt ECHO. ECHO 正在检查是否已存在 Monkey错误日志 ,若存在将自动备份... ECHO. adb shell mv %LogPath%/MonkeyError.txt %LogPath%/MonkeyLogBackUp/. adb shell sleep 2 adb shell rename %LogPath%/MonkeyLogBackUp/MonkeyError.txt %LogPath%/MonkeyLogBackUp/%c_date%%c_time%_MonkeyErrorBackUp.txt ECHO. ECHO 如下为已备份的所有的Monkey日志: adb shell ls %LogPath%/MonkeyLogBackUp/ ECHO. ECHO 旧的 Monkey日志 已备份至如下目录:%LogPath%/MonkeyLogBackUp/%c_date%%c_time%_MonkeyLog_BackUp.txt ECHO. ECHO 旧的 Monkey错误日志 已备份至如下目录:%LogPath%/MonkeyLogBackUp/%c_date%%c_time%_MonkeyErrorBackUp.txt ECHO. ) ECHO. ECHO 读取设备软件版本信息... ECHO @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ TYPE "%File%" ECHO @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ECHO. adb shell rm %LogPath%/%LogFileName% adb push "%File%" %LogPath%/. adb shell "cat %LogPath%/%File% > %LogPath%/%LogFileName%" if exist "%File%" del /f /q /a "%File%" ECHO [ 正在执行...] 使用Logcat清空Phone中log... adb logcat -c REM ECHO. 暂停2秒... ping -n 2 127.0.0.1>nul ECHO. ECHO 开始执行Monkey命令... ECHO. ECHO 准备测试的APK包名为= %PackageName% REM :::::::::::::::::Monkey测试命令:::::::::::::::::::::::: REM ::::::::::::修改策略请仅在此区域内修改::::::::::::::::: :checkPN if not defined PackageName goto NOPN ECHO 强制关闭准备测试的APK... adb shell am force-stop %PackageName% ECHO. ECHO 开始进行指定APK测试,确认测试开始执行后可以断开设备... ECHO. ECHO 请等待程序自动完成... ECHO. ECHO [ 正在执行...] "adb shell monkey -p %PackageName% -s 10000 --pct-touch 50 --ignore-crashes --ignore-timeouts --kill-process-after-error --ignore-security-exceptions --throttle %Delay% -v -v -v %Cycle% 1>> %LogPath%/%LogFileName% 2> %LogPath%/MonkeyError.txt" adb shell "monkey -p %PackageName% -s 10000 --pct-touch 50 --ignore-crashes --ignore-timeouts --kill-process-after-error --ignore-security-exceptions --throttle %Delay% -v -v -v %Cycle% 1>> %LogPath%/%LogFileName% 2> %LogPath%/MonkeyError.txt" goto MonkeyEnd :NOPN ECHO. ECHO 检测到未设置任何包名,将进行随机APK测试... find /i "BlacklistTest=1" .\Tools\config.conf if %errorlevel% == 0 goto BlackTest find /i "WhiteListTest=1" .\Tools\config.conf if %errorlevel% == 0 goto WhiteTest ECHO. ECHO 开始进行随机性APK测试,确认测试开始执行后可以断开设备... ECHO. ECHO 请等待程序自动完成... ECHO. ECHO "adb shell monkey --pct-touch 50 --ignore-crashes --ignore-timeouts --kill-process-after-error --ignore-security-exceptions --throttle %Delay% -v -v -v %Cycle% 1>> %LogPath%/%LogFileName% 2> %LogPath%/MonkeyError.txt" adb shell "monkey --pct-touch 50 --ignore-crashes --ignore-timeouts --kill-process-after-error --ignore-security-exceptions --throttle %Delay% -v -v -v %Cycle% 1>> %LogPath%/%LogFileName% 2> %LogPath%/MonkeyError.txt" :MonkeyEnd ECHO 执行Monkey命令结束... ECHO. :EXIT color 2f ECHO. ECHO [ 操作完成...] ECHO. SET time2=%date% %time% ECHO 开始时间=%time1% ECHO. ECHO 终止时间=%time2% ECHO. ECHO 请按任意键继续执行下一台机器... ECHO. ECHO @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ PAUSE>nul goto start goto :eof :BlackTest ECHO 检测到已设置 [ 黑名单 ],将进行排除[ 黑名单包名 ]的随机APK测试... if not exist .\Tools\blacklist.txt goto NoBlackList adb push .\Tools\blacklist.txt /data/local/tmp/ if errorlevel 1 goto pushfail ECHO. ECHO 黑名单列表如下: ECHO @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ TYPE .\Tools\blacklist.txt ECHO @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ECHO. ECHO. ECHO 正在进行排除[ 黑名单包名 ]的随机APK测试,确认测试开始执行后可以断开设备... ECHO. ECHO. 请等待程序自动完成... ECHO "adb shell --pct-touch 50 monkey --pkg-blacklist-file /data/local/tmp/blacklist.txt --ignore-crashes --ignore-timeouts --kill-process-after-error --ignore-security-exceptions --throttle %Delay% -v -v -v %Cycle% 1>> %LogPath%/%LogFileName% 2> %LogPath%/MonkeyError.txt" adb shell "monkey --pct-touch 50 --pkg-blacklist-file /data/local/tmp/blacklist.txt --ignore-crashes --ignore-timeouts --kill-process-after-error --ignore-security-exceptions --throttle %Delay% -v -v -v %Cycle% 1>> %LogPath%/%LogFileName% 2> %LogPath%/MonkeyError.txt" goto MonkeyEnd :WhiteTest ECHO 检测到已设置 [ 白名单 ],将进行[ 只测试 白名单包名 ]的随机APK测试... if not exist .\Tools\whitelist.txt goto NoWhiteTest adb push .\Tools\whitelist.txt /data/local/tmp/ if errorlevel 1 goto pushfail ECHO. ECHO 白名单列表如下: ECHO @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ TYPE .\Tools\whitelist.txt ECHO @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ECHO. ECHO. ECHO 正在进行[ 只测试 白名单包名 ]的随机APK测试,确认测试开始执行后可以断开设备... ECHO. ECHO 请等待程序自动完成... ECHO "adb shell monkey --pct-touch 50 --pkg-whitelist-file /data/local/tmp/whitelist.txt --ignore-crashes --ignore-timeouts --kill-process-after-error --ignore-security-exceptions --throttle %Delay% -v -v -v %Cycle% 1>> %LogPath%/%LogFileName% 2> %LogPath%/MonkeyError.txt" adb shell "monkey --pct-touch 50 --pkg-whitelist-file /data/local/tmp/whitelist.txt --ignore-crashes --ignore-timeouts --kill-process-after-error --ignore-security-exceptions --throttle %Delay% -v -v -v %Cycle% 1>> %LogPath%/%LogFileName% 2> %LogPath%/MonkeyError.txt" goto MonkeyEnd :NoBlackList color cf ECHO 未发现黑名单文件清单... ECHO. ECHO 请在程序.\Tools\目录下新增一个 blacklist.txt 的文本文件... ECHO. ECHO 请注意:文本文件中每行只能有一个包名,第二个包名需要换行... ECHO. ECHO 按任意键继续... pause goto start :pushfail color cf ECHO 复制 黑名单文件/白名单文件到平板或者手机内失败... ECHO. ECHO 按任意键继续... pause goto start :Nowhitelist.txt color cf ECHO 未发现 白名单 文件清单... ECHO. ECHO 请在程序.\Tools\目录下新增一个 whitelist.txt 的文本文件... ECHO. ECHO 请注意:文本文件中每行只能有一个包名,第二个包名需要换行... ECHO. ECHO 按任意键继续... pause goto start
每行一个包名,若启用黑名单,则黑名单中的APK包名将不会被执行
每行一个包名,若启用白名单,则只会执行白名单中的APK包名,其他的APK将不会被执行到
args: [--pct-touch, 50, --ignore-crashes, --ignore-timeouts, --kill-process-after-error, --ignore-security-exceptions, --throttle, 500, -v, -v, -v, 100000000] arg: "--pct-touch" arg: "50" arg: "--ignore-crashes" arg: "--ignore-timeouts" arg: "--kill-process-after-error" arg: "--ignore-security-exceptions" arg: "--throttle" arg: "500" arg: "-v" arg: "-v" arg: "-v" arg: "100000000" arg="--pct-touch" mCurArgData="null" mNextArg=1 argwas="--pct-touch" nextarg="50" data="50" arg="--ignore-crashes" mCurArgData="null" mNextArg=3 argwas="--ignore-crashes" nextarg="--ignore-timeouts" arg="--ignore-timeouts" mCurArgData="null" mNextArg=4 argwas="--ignore-timeouts" nextarg="--kill-process-after-error" arg="--kill-process-after-error" mCurArgData="null" mNextArg=5 argwas="--kill-process-after-error" nextarg="--ignore-security-exceptions" arg="--ignore-security-exceptions" mCurArgData="null" mNextArg=6 argwas="--ignore-security-exceptions" nextarg="--throttle" arg="--throttle" mCurArgData="null" mNextArg=7 argwas="--throttle" nextarg="500" data="500" java.io.FileNotFoundException: /data/system/theme_config/theme_compatibility.xml: open failed: ENOENT (No such file or directory) at libcore.io.IoBridge.open(IoBridge.java:496) at java.io.FileInputStream.<init>(FileInputStream.java:159) at java.io.FileInputStream.<init>(FileInputStream.java:115) at java.io.FileReader.<init>(FileReader.java:58) at miui.content.res.ThemeCompatibilityLoader.getVersion(ThemeCompatibilityLoader.java:108) at miui.content.res.ThemeCompatibilityLoader.getConfigDocumentTree(ThemeCompatibilityLoader.java:126) at miui.content.res.ThemeCompatibilityLoader.loadConfig(ThemeCompatibilityLoader.java:59) at miui.content.res.ThemeCompatibility.<clinit>(ThemeCompatibility.java:31) at miui.content.res.ThemeCompatibility.isThemeEnabled(ThemeCompatibility.java:111) at android.content.res.MiuiResourcesImpl.<clinit>(MiuiResourcesImpl.java:41) at android.content.res.Resources.<init>(Resources.java:285) at android.content.res.MiuiResources.<init>(MiuiResources.java:49) at android.content.res.Resources.getSystem(Resources.java:206) at android.util.MiuiMultiWindowAdapter.<clinit>(MiuiMultiWindowAdapter.java:79) at android.view.Display.getWidth(Display.java:745) at com.android.commands.monkey.MonkeySourceRandom.randomPoint(MonkeySourceRandom.java:330) at com.android.commands.monkey.MonkeySourceRandom.generatePointerEvent(MonkeySourceRandom.java:270) at com.android.commands.monkey.MonkeySourceRandom.generateEvents(MonkeySourceRandom.java:405) at com.android.commands.monkey.MonkeySourceRandom.getNextEvent(MonkeySourceRandom.java:494) at com.android.commands.monkey.Monkey.runMonkeyCycles(Monkey.java:1215) at com.android.commands.monkey.Monkey.run(Monkey.java:708) at com.android.commands.monkey.Monkey.main(Monkey.java:568) at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:380) Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory) at libcore.io.Linux.open(Native Method) at libcore.io.ForwardingOs.open(ForwardingOs.java:167) at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252) at libcore.io.IoBridge.open(IoBridge.java:482) ... 23 more // CRASH: com.android.vending (pid 12112) // Short Msg: java.lang.SecurityException // Long Msg: java.lang.SecurityException: Remote stack trace: at com.android.server.content.ContentService.registerContentObserver(ContentService.java:344) at android.content.IContentService$Stub.onTransact(IContentService.java:514) at android.os.Binder.execTransactInternal(Binder.java:1021) at android.os.Binder.execTransact(Binder.java:994) // Build Label: xiaomi/ginkgo/ginkgo:10/QKQ1.200114.002/V12.0.3.0.QCOCNXM:user/release-keys // Build Changelist: V12.0.3.0.QCOCNXM // Build Time: 1605613349000 // java.lang.RuntimeException: Unable to create application com.google.android.finsky.application.classic.ClassicProdApplication: java.lang.RuntimeException: Failed to load configurations for FinskyApp // at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6589) // at android.app.ActivityThread.access$1400(ActivityThread.java:226) // at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1889) // at android.os.Handler.dispatchMessage(Handler.java:107) // at android.os.Looper.loop(Looper.java:225) // at android.app.ActivityThread.main(ActivityThread.java:7564) // at java.lang.reflect.Method.invoke(Native Method) // at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) // at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) // Caused by: java.lang.RuntimeException: Failed to load configurations for FinskyApp // at dzz.aB(PG:17) // at dzz.aA(PG:17) // at dzz.ab(PG:2) // at ecd.onCreate(PG:3) // at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1190) // at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6584) // ... 8 more // Caused by: java.util.concurrent.ExecutionException: java.lang.SecurityException: Failed to find provider com.google.android.gsf.gservices for user 0; expected to find a valid ContentProvider for this authority // at atcl.a(PG:3) // at atcl.get(PG:9) // at atfm.a(PG:1) // at dzz.aB(PG:16) // ... 13 more // Caused by: java.lang.SecurityException: Failed to find provider com.google.android.gsf.gservices for user 0; expected to find a valid ContentProvider for this authority // at android.os.Parcel.createException(Parcel.java:2074) // at android.os.Parcel.readException(Parcel.java:2042) // at android.os.Parcel.readException(Parcel.java:1990) // at android.content.IContentService$Stub$Proxy.registerContentObserver(IContentService.java:1336) // at android.content.ContentResolver.registerContentObserver(ContentResolver.java:2279) // at android.content.ContentResolver.registerContentObserver(ContentResolver.java:2267) // at ammu.b(PG:2) // at ammu.b(PG:6) // at aqln.<init>(Unknown Source:5) // at aqlo.a(PG:6) // at eae.a(Unknown Source:75) // at auzv.run(Unknown Source:2) // at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462) // at java.util.concurrent.FutureTask.run(FutureTask.java:266) // at auzx.run(PG:2) // at auzz.run(Unknown Source:12) // at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) // at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) // at adtq.run(Unknown Source:7) // at java.lang.Thread.run(Thread.java:919) // Caused by: android.os.RemoteException: Remote stack trace: // at com.android.server.content.ContentService.registerContentObserver(ContentService.java:344) // at android.content.IContentService$Stub.onTransact(IContentService.java:514) // at android.os.Binder.execTransactInternal(Binder.java:1021) // at android.os.Binder.execTransact(Binder.java:994) // //
链接:https://pan.baidu.com/s/1NfsRnzfEQvriOrztBDm5vQ
提取码:2byf