def _init_adb(self): if self._adb_remote: with self._change_dir(): log.info( subprocess.check_output("{} connect {}".format( self._adb_name, self._adb_remote))) if not self._serial: devices_info = self.devices() log.debug(devices_info) if not devices_info: raise Exception("当前没有已连接的安卓设备") if len(devices_info) > 1: log.error(devices_info) print("当前通过数据线连接的安卓设备有") for i in devices_info: print(i) print("") raise Exception("同时有多个安卓设备连接着电脑,需要指定serialno.") else: self._serial = devices_info[0] # get_app_cpu_using 使用 self._func_data['cpu_cost'] = None self._func_data['cpu_cost_update_time'] = None
def _init_adb(self): if self._adb_remote: with self._change_dir(): log.info(subprocess.check_output("{} connect {}".format(self._adb_name, self._adb_remote))) if not self._serial: devices_info = self.devices() log.debug(devices_info) if not devices_info: raise Exception("当前没有已连接的安卓设备") if len(devices_info) > 1: log.error(devices_info) print("当前通过数据线连接的安卓设备有") for i in devices_info: print(i) print("") raise Exception("同时有多个安卓设备连接着电脑,需要指定serialno.") else: self._serial = devices_info[0] # get_app_cpu_using 使用 self._func_data['cpu_cost'] = None self._func_data['cpu_cost_update_time'] = None
def stop_app(self, package): log.info(self.adb_shell('am force-stop {}'.format(package)))
def start_app(self, component): log.info(self.adb_shell("am start -n {}".format(component)))
def start_server(): log.debug('adb start-server') log.info(os.popen('adb.exe start-server').read())
def current_pid(self): result = self.adb_shell("ps|{} {}".format(self._findstr, self.current_package_name)) log.info(result) return result[0].split()[1]
#! /usr/bin/env python # -*- coding: UTF-8 -*- from util.tool import log if __name__ == '__main__': log.set_level_to_info() log.debug("debug msg") log.info("info msg") log.warn("warn msg") log.error("error msg")