Install Python
Http://pydev.org/updates
Load Python.exe
Jython load Jython package, load hier package chilm Package
》》》》》》》》》》》》》》》》》》》》》》》》》》
Monkeyrunner record playback script, save as mr_rocorder.py
From Com.android.monkeyrunner import Monkeyrunner as Mr
From Com.android.monkeyrunner.recorder import Monkeyrecorder as Recorder
device = Mr.waitforconnection ()
Recorder.start (device)
Run Monkeyrunner mr_rocorder.py
monkeyplayback.py
Import Sys
Com.android.monkeyrunner Import Monkeyrunner
# The format of the file we are parsing is very carfeully constructed.
# each line corresponds to a single command. The line was split into 2
# Parts with a | Character. Text to the left of the pipe denotes
# which command to run. The text to the right of the pipe is a python
# dictionary (it can be evaled to existence) that specifies the
# Arguments for the command. In most cases, this directly maps to the
# keyword argument dictionary that could being passed to the underlying
# command.
# Lookup table to map command strings to functions this implement that
# command.
Cmd_map = {
"TOUCH": Lambda Dev, Arg:dev.touch (**arg),
"DRAG" ": Lambda Dev, Arg:dev.drag (**arg),
"Press": Lambda Dev, arg:dev.press (**arg),
"TYPE": Lambda Dev, Arg:dev.type (**arg),
"WAIT" ": Lambda Dev, arg:MonkeyRunner.sleep (**arg)
}
# Process A single file for the specified device.
def process_file (FP, device):
For line in FP:
(cmd, rest) = Line.split ("" | "" )
Try
# Parse The Pydict
Rest = eval (rest)
Except
Print "Unable to parse options"
Continue
If cmd not in Cmd_map:
print "" Unknown Command: "" + cmd
Continue
Cmd_map[cmd] (device, rest)
def main ():
FILE = sys.argv[1]
fp = open (file, "R")
device = Monkeyrunner.waitforconnection ()
Process_file (FP, device)
Fp.close ();
if __name__ = = "" __main__ "":
Main ()
Run monkeyplayback.py + recorded file name
Install FindBugs:http://findbugs.cs.umd.edu/eclipse installed in Eclipse
Use tcpdump and Wireshark to grab the bag:
ADB push <tcpdump path>/data/local/tcpdump
ADB shell chmod 6755/data/local/tcpdump
ADB shell
Cd/data/local
Tcpdump-p-vv-s 0-w/data/local/capture.pcap
ADB pull/data/local/capture.pcap d:\
Analyze network time-consuming, network protocol IP address, etc.
Detailed view of TCP, IP protocol Volume One to volume three
Eclipse + python + monkeyrunner Environment building