import sys
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage
def browse(d):
d.startActivity(uri='http://www.baidu.com',component="com.android.browser/.BrowserActivity")
MonkeyRunner.sleep(5.0)
d.press('KEYCODE_BUTTON_SELECT', MonkeyDevice.DOWN_AND_UP)
def call(d):
d.startActivity(component="com.android.contacts/.TwelveKeyDialer")
print "Start Activity"
MonkeyRunner.sleep(1.0)
d.type("10086")
# Call number.
print "Call"
d.touch(190, 800, 'DOWN_AND_UP');
print "Wait 5 sec"
MonkeyRunner.sleep(5.0)
d.press('KEYCODE_CALL', MonkeyDevice.DOWN_AND_UP)
d.startActivity(component="com.android.phone/.InCallScreen")
MonkeyRunner.sleep(1.0)
print "Wait 5 sec"
MonkeyRunner.sleep(5.0)
# HangUp Call
print "Hang Up"
d.press('KEYCODE_ENDCALL', MonkeyDevice.DOWN_AND_UP)
def endcall(d):
d.touch(140, 760, 'DOWN_AND_UP')
MonkeyRunner.sleep(3)
print "dialing..."
d.type('10086')
MonkeyRunner.sleep(3)
d.touch(240, 740, 'DOWN_AND_UP')
MonkeyRunner.sleep(3)
print "hanging up..."
d.touch(240, 600, 'DOWN_AND_UP')
def main():
print "Start"
device = MonkeyRunner.waitForConnection()
if not device:
print "Couldn't get connection"
sys.exit()
print "Found device"
call(device)
endcall(device)
browse(device)
if __name__ == '__main__':
main()