示例#1
0
    def waitForConnection(timeout, deviceId=".*"):
        """
        Waits for the workstation to connect to the device.

          Args:
            timeout - The timeout in seconds to wait. The default is to wait 
                      indefinitely.
            deviceId - A regular expression that specifies the device name. See the 
                       documentation for 'adb' in the Developer Guide to learn more 
                       about device names.
        """
        if timeout:
            tstart = time.time()
            tend = tstart + timeout

        adb = ADB()
        print("adb version = %s" % adb.version())
        while not timeout or time.time() < tend:
            for devid, state in adb.devices():
                if state == 'device' and re.match(deviceId, devid):
                    adb.serialnr = devid
                    mlib = Monkey.launchmonkey(adb)

                    if mlib:
                        return MonkeyDevice(adb, mlib)
            time.sleep(0.2)
示例#2
0
def start():
    import sys
    fn = sys.argv[1]

    adb = ADB()
    print("adb version = %s" % adb.version())
    for serial, state in adb.devices():
        adb.serialnr = serial

    cap = adb.makecapture()
    img = cap.capture()
    img.save(fn)
示例#3
0
 def connect(self, pin):
     self.adb = ADB()
     self.adb.connect()
     self.mon = Monkey.launchmonkey(self.adb)
     return self.unlockphone(pin)