-
Notifications
You must be signed in to change notification settings - Fork 14
/
monkey.sh
executable file
·48 lines (40 loc) · 1.56 KB
/
monkey.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
# Created by Sujay Davalgi
#
# Runs the monkey runner on the specified package against the selected device
#
# Usage: ./monkey.sh [<Device Serial>]
# Command line Arguments (Optional):
# $1 - Input the device serial
# IF the serial number is not provided, it will display the list of attached devices to pick from
. ./library/mainFunctions.sh
. ./library/textFormatting.sh
. ./library/deviceOperations.sh
packageName="com.google.android.music"
numberOfEvents=125000
delayBetweenEvents=200 #ms
echo -e -n "Package = $packageName\n"
echo -e -n "Events = $numberOfEvents\n"
echo -e -n "Delay = $delayBetweenEvents\n"
if [ $# -lt 1 ]; then
getDeviceChoice
else
buildDeviceSnArray
deviceSerial="$1"
fi
displaySelectedDevice $deviceSerial
formatMessage " Do you want to Run or Kill the monkey on selected device? [r/k] : " "Q"
read monkeyRunKillChoice
case $monkeyRunKillChoice in
[r/R]) #run
if [ $( isAdbDevice $deviceSerial ) == "true" ]; then
#adb -s $deviceSerial wait-for-device shell monkey -p $packageName -v $numberOfEvents --throttle $delayBetweenEvents --pct-trackball 0 --pct-syskeys 10
adb -s $deviceSerial wait-for-device shell monkey -p $packageName -c android.intent.category.LAUNCHER --ignore-security-exceptions --monitor-native-crashes --throttle $delayBetweenEvents --pct-trackball 0 --pct-syskeys 0 -s 80 -v -v -v $numberOfEvents
else
echo " Device is not in 'adb' mode"
fi
;;
[k/K]) #kill
adb -s $deviceSerial shell ps | awk '/com\.android\.commands\.monkey/ { system("adb -s $deviceSerial shell kill " $2) }'
;;
esac