Disable system-level events on Android monkey
Asked Answered
H

2

11

While monkey testing my app

% adb shell monkey -p com.foo.bar --throttle 1000 -v 14400

I notice that it accesses various system settings on my device like audio control and taking screen shots. According to http://developer.android.com/tools/help/monkey.html, this is the way it was meant to behave.

The Monkey is a program that runs on your emulator or device and generates pseudo-random streams of user events such as clicks, touches, or gestures, as well as a number of system-level events.

Is it possible to exclude the system level events so the monkey completely focuses on my target app?

I looked at the '-c' option for constraints, but looking at the available Intents at http://developer.android.com/reference/android/content/Intent.html, I don't seem to see anything related to disabling such system level events.

Any pointers?

Hoarding answered 3/1, 2014 at 19:58 Comment(1)
Update: I also tried to configure the run to have 0 percent chance of running certain events, which did not seem to help. % adb shell monkey -p com.yahoo.mobile.client.android.fantasyfootball --pct-syskeys 0 --pct-anyevent 0 --throttle 1000 -v 14400Hoarding
O
14

By setting the -pct-sysevents to zero.

However, while using the monkey command, there is a small catch, which is regarding the order of events.

-v is a verbosity flag.

COUNT must appear at the very end in the command

adb shell monkey -p your.package.name -v --pct-syskeys 0 9999
adb shell monkey -p your.package.name -v --pct-syskeys 0 COUNT

The command usage is given below.

usage: monkey [-p ALLOWED_PACKAGE [-p ALLOWED_PACKAGE] ...]
              [-c MAIN_CATEGORY [-c MAIN_CATEGORY] ...]
              [--ignore-crashes] [--ignore-timeouts]
              [--ignore-security-exceptions]
              [--monitor-native-crashes] [--ignore-native-crashes]
              [--kill-process-after-error] [--hprof]
              [--pct-touch PERCENT] [--pct-motion PERCENT]
              [--pct-trackball PERCENT] [--pct-syskeys PERCENT]
              [--pct-nav PERCENT] [--pct-majornav PERCENT]
              [--pct-appswitch PERCENT] [--pct-flip PERCENT]
              [--pct-anyevent PERCENT] [--pct-pinchzoom PERCENT]
              [--pkg-blacklist-file PACKAGE_BLACKLIST_FILE]
              [--pkg-whitelist-file PACKAGE_WHITELIST_FILE]
              [--wait-dbg] [--dbg-no-events]
              [--setup scriptfile] [-f scriptfile [-f scriptfile] ...]
              [--port port]
              [-s SEED] [-v [-v] ...]
              [--throttle MILLISEC] [--randomize-throttle]
              [--profile-wait MILLISEC]
              [--device-sleep-time MILLISEC]
              [--randomize-script]
              [--script-log]
              [--bugreport]
              [--periodic-bugreport]
              COUNT

All options are explained: https://developer.android.com/studio/test/monkey.html

Obstetric answered 30/4, 2015 at 13:41 Comment(1)
you saved my day with the bolded text. thanks!Tripitaka
R
1

I've managed to change the "system" events ratio by setting the --pct-syskeys a much higher value.

In my case, the monkey keep showing the notification area and changing wifi settings (my app is wifi-only) and this parameter solved the problem.

Raeannraeburn answered 25/3, 2014 at 16:7 Comment(1)
But if you set --pct-syskeys to a much higher value, there is more chance to generate such events. I think that @Obstetric answer is the correct one, to set it to 0.Keep

© 2022 - 2024 — McMap. All rights reserved.