Created
November 24, 2020 17:15
-
-
Save subtleGradient/ecbb247d91cebd6afbef85e706d1affc to your computer and use it in GitHub Desktop.
monkeydancer.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash -l | |
| # set -x | |
| echo "Usage: $0 -s $SERIAL < /path/to/script.monkey" 1>&2 | |
| echo " More info: https://github.com/android/platform_development/blob/master/cmds/monkey/README.NETWORK.txt" 1>&2 | |
| echo " Example: https://github.com/android/platform_development/blob/master/cmds/monkey/example_script.txt" 1>&2 | |
| echo "" 1>&2 | |
| echo " type 'Hello World'" 1>&2 | |
| echo " press KEYCODE_ENTER" 1>&2 | |
| echo "" 1>&2 | |
| function fail { | |
| echo "$1" 1>&2 | |
| exit 1 | |
| } | |
| function kill_monkey { | |
| adb "$@" shell "ps|grep com.android.commands.monkey" |cut -d" " -f6|xargs adb "$@" shell kill | |
| } | |
| function onEXIT { | |
| if [[ "$ADB_PID" != "" ]]; then | |
| kill "$ADB_PID" | |
| fi | |
| kill_monkey | |
| } | |
| trap onEXIT EXIT | |
| kill_monkey | |
| adb "$@" forward tcp:7080 tcp:1080 || fail "Unable to forward port" | |
| adb "$@" shell "monkey --port 1080 -vvvvvvv" & | |
| ADB_PID=$! | |
| sleep 2 | |
| cat | nc localhost 7080 | |
| echo "quit" | nc localhost 7080 | |
| sleep 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment