def logcat_get(target, out_file): """ Collect the logs from logcat. :param target: instance of devlib Android target :type target: devlib.target.AndroidTarget :param out_file: output file name :type out_file: str """ adb_command(target.adb_name, 'logcat * -d > {}'.format(out_file))
def install_apk(target, apk_path): """ Get a dictionary of installed APKs and related information :param target: instance of devlib Android target :type target: devlib.target.AndroidTarget :param apk_path: path to application :type apk_path: str """ adb_command(target.adb_name, ADB_INSTALL_CMD.format(apk_path))
def start(self, document_root, target): # Create the server, and find out the port we've been assigned... self._httpd = HTTPServer(("", 0), DifferentDirectoryHTTPRequestHandler) # (This property is expected to be read by the # DifferentDirectoryHTTPRequestHandler.translate_path method.) self._httpd.document_root = document_root _, self._port = self._httpd.server_address self._thread = ArchiveServerThread(self._httpd) self._thread.start() adb_command(target.adb_name, "reverse tcp:{0} tcp:{0}".format(self._port))
def gfxinfo_get(target, apk_name, out_file): """ Collect frame statistics for the given app. :param target: instance of devlib Android target :type target: devlib.target.AndroidTarget :param apk_name: name of the apk :type apk_name: str :param out_file: output file name :type out_file: str """ adb_command(target.adb_name, GET_FRAMESTATS_CMD.format(apk_name, out_file))
def surfaceflinger_get(target, apk_name, out_file): """ Collect SurfaceFlinger layer statistics for the given app. :param target: instance of devlib Android target :type target: devlib.target.AndroidTarget :param apk_name: name of the apk :type apk_name: str :param out_file: output file name :type out_file: str """ adb_command(target.adb_name, 'shell dumpsys SurfaceFlinger {} > {}'.format(apk_name, out_file))
def install_apk(self, filepath, timeout=None): # pylint: disable=W0221 ext = os.path.splitext(filepath)[1].lower() if ext == '.apk': return adb_command(self.adb_name, "install {}".format(filepath), timeout=timeout) else: raise TargetError( 'Can\'t install {}: unsupported format.'.format(filepath))
def clear_logcat(self): adb_command(self.adb_name, 'logcat -c', timeout=30)
def dump_logcat(self, filepath, filter=None, append=False, timeout=30): # pylint: disable=redefined-builtin op = '>>' if append else '>' filtstr = ' -s {}'.format(filter) if filter else '' command = 'logcat -d{} {} {}'.format(filtstr, op, filepath) adb_command(self.adb_name, command, timeout=timeout)
def uninstall_package(self, package): adb_command(self.adb_name, "uninstall {}".format(package), timeout=30)
def install_apk(self, filepath, timeout=None): # pylint: disable=W0221 ext = os.path.splitext(filepath)[1].lower() if ext == '.apk': return adb_command(self.adb_name, "install '{}'".format(filepath), timeout=timeout) else: raise TargetError('Can\'t install {}: unsupported format.'.format(filepath))
def stop(self, target): adb_command(target.adb_name, "reverse --remove tcp:{}".format(self._port)) self._httpd.shutdown() self._thread.join()
def hide_from_device(self, target): adb_command(target.adb_name, "reverse --remove tcp:{}".format(self._port))
def expose_to_device(self, target): adb_command(target.adb_name, "reverse tcp:{0} tcp:{0}".format(self._port))
def dump_logcat(self, filepath, filter=None, append=False, timeout=30): # pylint: disable=redefined-builtin op = ">>" if append == True else ">" filtstr = " -s {}".format(filter) if filter else "" command = "logcat -d{} {} {}".format(filtstr, op, filepath) adb_command(self.adb_name, command, timeout=timeout)