I have some expertise in this question. To my point of view you have two options:
- You can create local monkey script and run it from shell on your
device.
- You can connect your device over TCP/IP (WiFi) and store battery
consumption snapshots.
EDIT
To run monkey script from device you need to run the following command (if I do not mess smth):
adb shell monkey -v -f /mnt/sdcard/script.txt
Script in this case use a bit unusual sintax (just an example, this is a script for default contacts application for Nexus S with gingerbread):
# Start of Script
type= user
count= 150
speed= 1.0
start data >>
#launch browser com.android.contacts/.DialtactsContactsEntryActivity
LaunchActivity(com.android.contacts, com.android.contacts.DialtactsContactsEntryActivity)
UserWait(4000)
#go to favorites tab
Tap(415, 85)
UserWait(3000)
#go to phone tab
Tap(60, 85)
UserWait(3000)
#calllog
Tap(175,90)
UserWait(2000)
#contacts
Tap(300,90)
UserWait(4000)
#create new contact
DispatchPress(KEYCODE_MENU)
UserWait(2000)
Tap(360,650)
UserWait(4000)
#go name
Tap(200,340)
UserWait(8000)
DispatchString(123)
UserWait(5000)
Tap(125,385)
#launching launcher and exit com.android.launcher/com.android.launcher2.Launcher
UserWait(10000)
LaunchActivity(com.android.launcher, com.android.launcher2.Launcher)
quit
As for me, it's easier to use the second approach (and it's more error prone).
You can connect to your device over WiFi (thus, your USB cable is detached). For this you should:
- Connect your device over USB and run
adb tcpip <port_num>
- Then connect your device to a WiFi network
- Then execute on your computer (that is also connected to the
network)
adb connect <phone_ip_addres>:<port_num>
Now you can fire monkeyrunner commands over WiFi using standard way for monkeyrunner (monkeyrunner <script_name>.py
)