Пример #1
0
    def _init(self):
        self.model = self.getprop("ro.product.model").lower()
        self.exec_locations = {}

        if not DEVICE_PROPERTIES.get(self.type) or \
                not DEVICE_PROPERTIES[self.type].get(self.model):
            raise mozdevice.DMError("Unsupported device '%s' for type '%s'" %
                                    (self.model, self.type))
        self.deviceProperties = DEVICE_PROPERTIES[self.type][self.model]

        for (name, execname) in [(ORANGUTAN, "orng"),
                                 (NTPCLIENT, "ntpclient")]:
            for path in ['/data/local/', '/data/local/tmp/']:
                fullpath = posixpath.join(path, execname)
                if self.fileExists(fullpath):
                    self.exec_locations[name] = fullpath

            if not self.exec_locations.get(name):
                raise mozdevice.DMError("%s not on device! Please "
                                        "install it according to the "
                                        "documentation" % name)

        # Hack: this gets rid of the "finished charging" modal dialog that the
        # LG G2X sometimes brings up
        if self.model == 'lg-p999':
            self.executeCommand("tap", [240, 617])
Пример #2
0
    def _init(self):
        self.model = self.getprop("ro.product.model")
        self.locations = {}

        if not DEVICE_PROPERTIES.get(self.type) or \
                not DEVICE_PROPERTIES[self.type].get(self.model):
            raise mozdevice.DMError("Unsupported device '%s' for type '%s'" %
                                    (self.model, self.type))
        self.deviceProperties = DEVICE_PROPERTIES[self.type][self.model]

        for (name, path) in [("orangutan", self.DEFAULT_ORNG_LOCATION),
                             ("ntpdate", self.DEFAULT_NTPDATE_LOCATION)]:
            if not self.fileExists(path):
                raise mozdevice.DMError("%s not on device in %s! Please "
                                        "install it according to the "
                                        "documentation" % (name, path))

        # Hack: this gets rid of the "finished charging" modal dialog that the
        # LG G2X sometimes brings up
        if self.model == 'LG-P999':
            self.executeCommand("tap", [240, 617])
Пример #3
0
    def stopB2G(self):
        self._logger.info("Stopping B2G")

        if self.marionette and self.marionette.session:
            self.marionette.delete_session()
            self.marionette = None

        self.shellCheckOutput(['stop', 'b2g'])
        # Wait for a bit to make sure B2G has completely shut down.
        tries = 100
        while "b2g" in self.shellCheckOutput(['ps', 'b2g']) and tries > 0:
            tries -= 1
            time.sleep(0.1)
        if tries == 0:
            raise mozdevice.DMError("Could not kill b2g process")
Пример #4
0
    def setupMarionette(self):
        self.marionette = marionette.Marionette()
        self._logger.info("Waiting for Marionette...")
        self.marionette.wait_for_port()
        self._logger.info("Marionette ready, starting session")
        self.marionette.start_session()
        if 'b2g' not in self.marionette.session:
            raise mozdevice.DMError(
                "bad session value %s returned by start_session" %
                self.marionette.session)
        self.marionette.set_script_timeout(60000)
        self.marionette.timeouts(self.marionette.TIMEOUT_SEARCH, 10000)
        self._logger.info("Marionette ready!")

        self.b2gpopulate = B2GPopulate(self.marionette)
        self.gaiaApps = GaiaApps(self.marionette)
        self.gaiaDevice = GaiaDevice(self.marionette)
Пример #5
0
    def getAPK(self, appname, localfile):
        remote_tempfile = posixpath.join(self.getDeviceRoot(),
                                         'apk-tmp-%s' % time.time())
        for remote_apk_path in [
                '/data/app/%s-1.apk' % appname,
                '/data/app/%s-2.apk' % appname
        ]:
            if self.fileExists(remote_apk_path):
                self.shellCheckOutput([
                    'dd',
                    'if=%s' % remote_apk_path,
                    'of=%s' % remote_tempfile
                ],
                                      root=True)
                self.shellCheckOutput(['chmod', '0666', remote_tempfile],
                                      root=True)
                self.getFile(remote_tempfile, localfile)
                self.removeFile(remote_tempfile)
                return

        raise mozdevice.DMError("Unable to get APK for %s" % appname)