Created
May 18, 2012 01:20
-
-
Save kaz-tk/2722565 to your computer and use it in GitHub Desktop.
Use Emulator Console in MonkeyRunner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
# author :Kazushige TAKEUCHI(@myb1126) | |
import sys | |
import os | |
# おまじない1 | |
srcroot = os.path.dirname(__file__) | |
sys.path.append(srcroot) | |
# おまじない2 | |
# これからWaitForConnectionすればいい感じ | |
from java.io import File | |
from java.net import URL | |
from java.net import URLClassLoader | |
import jarray | |
urlClassLoader=URLClassLoader(jarray.array([File("ddmlib.jar").toURL()], URL)) | |
AndroidDebugBridge=urlClassLoader.loadClass("com.android.ddmlib.AndroidDebugBridge") | |
emulators =[] | |
bridge = AndroidDebugBridge.getBridge() | |
devices = bridge.getDevices() | |
for device in devices: | |
print device | |
if device.isEmulator(): | |
print "%s is Emulrator" %(device) | |
emulators.append(device) | |
pass | |
else: | |
print "%s is Not Emulrator" %(device) | |
pass | |
EmulatorConsole = urlClassLoader.loadClass("com.android.ddmlib.EmulatorConsole") | |
for device in emulators: | |
console = EmulatorConsole.getConsole(device) | |
console.call("09000000000") | |
# その他EmulatorConsoleのAPIで色々出来ます。 | |
# sendSms,sendLocation,setNetworkLatency,setNetworkSpeed | |
# GSMのモードなんかも | |
if __name__ == '__main__': | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment