• Home
  • History
  • Annotate
  • only in /development/cmds/monkey/
NameDateSize

..21-Dec-20174 KiB

Android.mk21-Dec-2017423

example_script.txt21-Dec-2017731

MODULE_LICENSE_APACHE221-Dec-20170

monkey21-Dec-2017217

NOTICE21-Dec-201710.4 KiB

README.NETWORK.txt21-Dec-20174.1 KiB

src/21-Dec-20174 KiB

README.NETWORK.txt

1SIMPLE PROTOCOL FOR AUTOMATED NETWORK CONTROL
2
3The Simple Protocol for Automated Network Control was designed to be a
4low-level way to programmability inject KeyEvents and MotionEvents
5into the input system.  The idea is that a process will run on a host
6computer that will support higher-level operations (like conditionals,
7etc.) and will talk (via TCP over ADB) to the device in Simple
8Protocol for Automated Network Control.  For security reasons, the
9Monkey only binds to localhost, so you will need to use adb to setup
10port forwarding to actually talk to the device.
11
12INITIAL SETUP
13
14Setup port forwarding from a local port on your machine to a port on
15the device:
16
17$ adb forward tcp:1080 tcp:1080
18
19Start the monkey server
20
21$ adb shell monkey --port 1080
22
23Now you're ready to run commands
24
25COMMAND LIST
26
27Individual commands are separated by newlines.  The Monkey will
28respond to every command with a line starting with OK for commands
29that executed without a problem, or a line starting with ERROR for
30commands that had problems being run.  For commands that return a
31value, that value is returned on the same line as the OK or ERROR
32response.  The value is everything after (but not include) the colon
33on that line.  For ERROR values, this could be a message indicating
34what happened.  A possible example:
35
36key down menu
37OK
38touch monkey
39ERROR: monkey not a number
40getvar sdk
41OK: donut
42getvar foo
43ERROR: no such var
44
45The complete list of commands follows:
46
47key [down|up] keycode
48
49This command injects KeyEvent's into the input system.  The keycode
50parameter refers to the KEYCODE list in the KeyEvent class
51(http://developer.android.com/reference/android/view/KeyEvent.html).
52The format of that parameter is quite flexible.  Using the menu key as
53an example, it can be 82 (the integer value of the keycode),
54KEYCODE_MENU (the name of the keycode), or just menu (and the Monkey
55will add the KEYCODE part).  Do note that this last part doesn't work
56for things like KEYCODE_1 for obvious reasons.
57
58Note that sending a full button press requires sending both the down
59and the up event for that key
60
61touch [down|up|move] x y
62
63This command injects a MotionEvent into the input system that
64simulates a user touching the touchscreen (or a pointer event).  x and
65y specify coordinates on the display (0 0 being the upper left) for
66the touch event to happen.  Just like key events, touch events at a
67single location require both a down and an up.  To simulate dragging,
68send a "touch down", then a series of "touch move" events (to simulate
69the drag), followed by a "touch up" at the final location.
70
71trackball dx dy
72
73This command injects a MotionEvent into the input system that
74simulates a user using the trackball. dx and dy indicates the amount
75of change in the trackball location (as opposed to exact coordinates
76that the touch events use)
77
78flip [open|close]
79
80This simulates the opening or closing the keyboard (like on dream).
81
82wake
83
84This command will wake the device up from sleep and allow user input.
85
86tap x y
87The tap command is a shortcut for the touch command.  It will
88automatically send both the up and the down event.
89
90press keycode
91
92The press command is a shortcut for the key command.  The keycode
93paramter works just like the key command and will automatically send
94both the up and the down event.
95
96type string
97
98This command will simulate a user typing the given string on the
99keyboard by generating the proper KeyEvents.
100
101listvar
102
103This command lists all the vars that the monkey knows about.  They are
104returned as a whitespace separated list.
105
106getvar varname
107
108This command returns the value of the given var.  listvar can be used
109to find out what vars are supported.
110
111quit
112
113Fully quit the monkey and accept no new sessions.
114
115done
116
117Close the current session and allow a new session to connect
118
119OTHER NOTES
120
121There are some convenience features added to allow running without
122needing a host process.
123
124Lines starting with a # character are considered comments.  The Monkey
125eats them and returns no indication that it did anything (no ERROR and
126no OK).
127
128You can put the Monkey to sleep by using the "sleep" command with a
129single argument, how many ms to sleep.
130