def uninstall(f): # apk = APK(f) # package = apk.get_package() package = get_package(f) adb = ADBManager() adb.uninstall(package) return 0, None
def installd(f): apk = APK(f) package = apk.get_package() adb = ADBManager() adb.uninstall(package) code, msg = adb.install(f) checkIsInstalledSuccess(msg) return 0, None
def photo(file_path): adb = ADBManager() if adb.is_no_device(): print(u"该功能需要连接手机或者模拟器,请确保手机或者模拟器已经启动") return -1, None # 此处要注意从配置文件中读取出来的数值属于字符串类型,需要转换为数值类型 scale = float(Utils.get_value_from_confing('ScaleSize', 'Scale')) if not scale: # 如果配置文件未设置Scale字段 scale = 0.5 image_file = os.path.splitext(file_path)[0] + '.png' print(image_file) adb.get_screenshot(image_file, scale) # 将图片复制到剪贴板需要先将图片数据写到内存中 # image = Image.open(image_file) # output = io.BytesIO() # image.convert("RGB").save(output, "BMP") # data = output.getvalue()[14:] # output.close() # win32clipboard.OpenClipboard() # win32clipboard.EmptyClipboard() # win32clipboard.SetClipboardData(win32con.CF_DIB, data) # win32clipboard.CloseClipboard() # print(u'图片已经复制到了剪贴板,您可直接粘贴使用') return 0, None
def viewphone(f): adb = ADBManager() if len(adb.get_devices()) == 0: print(u"该功能需要连接手机或者模拟器,请确保手机或者模拟器已经启动") return 0, None ret, model = adb.shell('getprop ro.product.model') ret, name = adb.shell('getprop ro.product.name') ret, release = adb.shell('getprop ro.build.version.release') ret, sdk = adb.shell('getprop ro.build.version.sdk') ret, cpu = adb.shell('getprop ro.product.cpu.abi') ret, cpu2 = adb.shell('getprop ro.product.cpu.abi2') ret, serialno = adb.shell('getprop ro.serialno') ret, imei = adb.shell('getprop gsm.sim.imei') ret, androidid = adb.shell('getprop net.hostname') ret, description = adb.shell('getprop ro.build.description') ret, mac = adb.shell('cat /sys/class/net/wlan0/address') ret, size = adb.shell('wm size') if ret == 0: size = star.find('size: (.*?)\s', size) infoFile = os.path.splitext(f)[0] + '_phone.txt' star.log('手机类型:' + model, infoFile) star.loga('手机名称:' + name, infoFile) star.loga('系统版本:' + release, infoFile) star.loga('API版本:' + sdk, infoFile) star.loga('CPU:' + cpu, infoFile) star.loga('CPU2:' + cpu2, infoFile) star.loga('MAC:' + mac, infoFile) star.loga('序列号:' + serialno, infoFile) star.loga('IMEI:' + imei, infoFile) star.loga('AndroidId:' + androidid, infoFile) star.loga('描述信息:' + description, infoFile) if size is not None: # 获取分辨率如果失败size将会是None对象,此时不能使用+连接 star.loga('分辨率:' + size, infoFile) if os.path.exists(infoFile): star.run_cmd_asyn(['notepad', infoFile]) return 1, None
def installr(f): adb = ADBManager() code, msg = adb.install(f, '-r') checkIsInstalledSuccess(msg) return 0, None