def root(self): cmd = "%sroot " % self._target() L.debug(str(self._adb(cmd))) self.kill() if self.WIFI: self.tcpip() else: self.usb() self.connect()
def am(self, cmd): """ Interface of Android 'am' Command. :arg string cmd: android command. :return string: adb result """ if "am" in cmd: L.debug("command include [am]. : %s" % cmd) cmd = "am %s" % cmd return self._adb.shell(cmd)
def getprop(self, prop): """ Interface of Android 'getprop' Command. :arg string prop: property name. ex) ro.secure :return string: adb result. """ if "getprop" in prop: L.debug("command include [getprop]. : %s" % prop) cmd = "getprop %s" % prop return self._adb.shell(cmd)
def input(self, cmd): """ Interface of Android Input Command. :arg string cmd: command. :return string: adb result. """ if "input" in cmd: L.debug("command include [input]. : %s" % cmd) cmd = "input %s" % cmd return self._adb.shell(cmd)
def setprop(self, prop, value): """ Interface of Android 'setprop' Command. :arg string prop: property name :arg string value: property value :return string: adb result. """ if "setprop" in prop: L.debug("command include [setprop]. : %s" % prop) cmd = "setprop %s %s" % (prop, value) return self._adb.shell(cmd)
def _set_profile(self, name): class_name = "_" + name for fdn in os.listdir(PROFILE_PATH): try: if fdn.endswith("__init__.py"): pass elif fdn.endswith(".py") and (name in fdn): prof = fdn.replace(".py", "") f,n,d = imp.find_module(str(prof)) module = imp.load_module(prof,f,n,d) self.profile = getattr(module, class_name) self.profile.SERIAL = name except Exception as e: L.debug('=== Error Exception ===') L.debug('type : ' + str(type(e))) L.debug('args : ' + str(e.args)) L.debug('message : ' + e.message) L.debug('e : ' + str(e))
def shell(self, cmd, timeout=TIMEOUT): if "shell" in cmd: L.debug("command include [shell]. : %s" % cmd) cmd = "%sshell %s" % (self._target(), cmd) return self._adb(cmd, timeout)
def pull(self, src, dst): L.debug("[pull]. : %s -> %s" % (src, dst)) cmd = "%spull %s %s" % (self._target(), src, dst) return self._adb(cmd)
def _adb(self, cmd, timeout=TIMEOUT): if "adb" in cmd: L.debug("command include [adb]. : %s" % cmd) cmd = "adb %s" % cmd return self.__exec(cmd, timeout)
def _text(self, cmd): if "text" in cmd: L.debug("command include [text]. : %s" % cmd) cmd = "text %s" % cmd return self.input(cmd)
def remount(self): L.info(self._adb.remount());time.sleep(5)
def remount(self): cmd = "%sremount " % self._target() L.debug(self._adb(cmd))
def kill(self): L.debug("Kill This Process.") self.proc.terminate()
def adb(self, cmd, timeout=TIMEOUT): if "adb" in cmd: L.debug("command include [adb]. : %s" % cmd) cmd = "%s %s" % (self._target(), cmd) return self._adb(cmd, timeout)
def uninstall(self, application): cmd = "%suninstall %s" % (self._target(), application) L.debug(self._adb(cmd))
def install(self, application, timeout=TIMEOUT): cmd = "%sinstall -r %s" % (self._target(), application) L.debug(self._adb(cmd, timeout))
def restart(self): cmd = "%sreboot" % self._target() L.debug(self._adb(cmd))