blob: b80cea9f7a8efdbda84adcc423903052df780d0f [file] [log] [blame]
Bill Napier0b1f5a92009-08-10 09:56:08 -07001SIMPLE PROTOCOL FOR AUTOMATED NETWORK CONTROL
Bill Napiera68dbdb2009-08-07 11:34:12 -07002
Bill Napier0b1f5a92009-08-10 09:56:08 -07003The 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.
Bill Napiera68dbdb2009-08-07 11:34:12 -070011
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. The Monkey may decide to return
31more information about command execution. That information would come
32on the same line after the OK or ERROR. A possible example:
33
34key down menu
35OK
36touch monkey
37ERROR: monkey not a number
38
39The complete list of commands follows:
40
41key [down|up] keycode
42
43This command injects KeyEvent's into the input system. The keycode
44parameter refers to the KEYCODE list in the KeyEvent class
45(http://developer.android.com/reference/android/view/KeyEvent.html).
46The format of that parameter is quite flexible. Using the menu key as
47an example, it can be 82 (the integer value of the keycode),
48KEYCODE_MENU (the name of the keycode), or just menu (and the Monkey
49will add the KEYCODE part). Do note that this last part doesn't work
50for things like KEYCODE_1 for obvious reasons.
51
52Note that sending a full button press requires sending both the down
53and the up event for that key
54
55touch [down|up|move] x y
56
57This command injects a MotionEvent into the input system that
58simulates a user touching the touchscreen (or a pointer event). x and
59y specify coordinates on the display (0 0 being the upper left) for
60the touch event to happen. Just like key events, touch events at a
61single location require both a down and an up. To simulate dragging,
62send a "touch down", then a series of "touch move" events (to simulate
63the drag), followed by a "touch up" at the final location.
64
65trackball dx dy
66
67This command injects a MotionEvent into the input system that
68simulates a user using the trackball. dx and dy indicates the amount
69of change in the trackball location (as opposed to exact coordinates
70that the touch events use)
71
72flip [open|close]
73
74This simulates the opening or closing the keyboard (like on dream).
75
Bill Napierad904292009-08-10 13:22:32 -070076wake
77
78This command will wake the device up from sleep and allow user input.
79
Bill Napierbdc22202009-08-10 20:50:30 -070080tap x y
81The tap command is a shortcut for the touch command. It will
82automatically send both the up and the down event.
83
84press keycode
85
86The press command is a shortcut for the key command. The keycode
87paramter works just like the key command and will automatically send
88both the up and the down event.
89
Bill Napier3faef172009-08-11 16:07:38 -070090type string
91
92This command will simulate a user typing the given string on the
93keyboard by generating the proper KeyEvents.
94
Bill Napiera68dbdb2009-08-07 11:34:12 -070095OTHER NOTES
96
97There are some convenience features added to allow running without
98needing a host process.
99
100Lines starting with a # character are considered comments. The Monkey
101eats them and returns no indication that it did anything (no ERROR and
102no OK).
103
104You can put the Monkey to sleep by using the "sleep" command with a
105single argument, how many ms to sleep.