def monkey_run(device_id, count): package = Config.get_package_info()[0] brand = Adb.get_brand(device_id) monkey_log = LogPath(brand, device_id).get_monkey_log_path() args = f"adb -s {device_id} shell monkey -p {package} -s 100 --throttle 100 " \ f"--ignore-crashes --ignore-timeouts --monitor-native-crashes --pct-appswitch 20 " \ f"--pct-majornav 15 --pct-nav 10 --pct-touch 40 --pct-motion 15 -v -v -v {count} " \ f"> {monkey_log}" Shell.run(args)
def is_install(did): """判断是否安装爱库存""" out = Shell.run( f"adb -s {did} shell pm list package -e com.aikucun.akapp") if out: return True return False
def uninstall(did, package): """卸载APP""" out = Shell.run(f"adb -s {did} uninstall {package}") if "Success" in out: return True else: return False
def install(did, file_name): """安装APP""" out = Shell.run(f"adb -s {did} install -r {APK_PATH}/{file_name}") if "Success" in out: return True else: return False
def check_file_exits(file_path, file_name): """检查文件是否存在""" logger.info(f"{file_path}/{file_name}") result = Shell.run(f"find {file_path} -name {file_name}") if result: return True logger.info("发现最新安装包") return False
def get_device_list(): """获取连接的设备列表""" out = Shell.run("adb devices") o_list = out.split("\n")[1:] device_list = [] for each in o_list: e = each.split("\t") if e[1] == "device": device_list.append(e[0]) return device_list
def get_os_version(did): """获取手机系统版本""" return Shell.run( f"adb -s {did} shell getprop ro.build.version.release")
def get_brand(did): """获取手机品牌""" return Shell.run(f"adb -s {did} shell getprop ro.product.brand")
def quit_app(did, package): """退出APP""" Shell.run(f"adb -s {did} shell am force-stop {package}")
def start_app(did, package): """启动APP""" activity = f"{package}.activity.StartActivity" Shell.run(f"adb -s {did} shell am start -n {package}/{activity}")
def clear_directory(del_path): Shell.run(f"rm -rf {del_path}/*.apk")
def check_exist(des_path, apk_name): result = Shell.run(f"find {des_path} -name {apk_name}") if result == "": return False return True
def du_sh(path): """Get the description about the size of a path. :param path: the path, could be a file or a directory. """ return Shell.run('du -sh {}'.format(path))
def run(self): # Adb.start_app(self.did, self.package) Adb.cat_log(self.did, self.log_path.get_cat_log_path()) Shell.run(self.get_args()) Adb.quit_app(self.did, self.package)