def show_connect_result(self, serial): list1 = serial.split(":") ip = list1[0] port = list1[1] if len(list1) > 1 else "" list1 = util_atool.devices(False)['device'] serial = '' for ss in list1: if ss.find(ip) != -1: serial = ss break if serial: d = device.DeviceData(serial) d.getprop() setting_atool.update_recent(d.product_name, ip, port) self.show_recent() utils.showinfo('已连接至 {0} {1}'.format(d.product_name, ip)) # self.top_win.destroy() else: utils.showinfo('连接失败!\n1.可能IP不正确;\n' '2.对应设备未开启 adb 调试;\n' '3.有些设备仅允许一个adb连接,关开一次adb调试设置可解决重置连接;') if utils.main is not None: utils.main.show_devices()
def show_device_name(self): if self.data is None: return product_name = self.data.product_name # self.text['text'] = "已连接至 "+product_name self.txt['text'] = "已瞄准\n" + product_name self.top_win.title(product_name) d_list = util_atool.devices(False)['device'] if d_list.count(self.serial) == 0: self.txt['text'] = "{}\n{已断开连接}" + product_name
def show_devices(self): """刷新设备列表""" win = self.frame_device widgets = self.device_list serials = self.get_serials() # 找出消失的对象索引值 dc = util_atool.devices(True) serials_new = dc['device'] index_list = [] for i in range(len(serials)): s = serials[i] if not serials_new.count(s): index_list.append(i) # 销毁对象 while len(index_list): i = index_list.pop() w = widgets[i] w.grid_forget() # w.destroy() widgets.pop(i) serials.pop(i) # 创建新添加的 for s in serials_new: if not serials.count(s): w = widget_device.DeviceItem(win) w.set_serial(s) widgets.append(w) serials.append(s) count = 0 for w in widgets: w.grid(column=0, row=count, sticky=tk.NW) count += 1 if not len(widgets): txt = self.replace_txt if txt is None: txt = tk.Label(win) txt.grid(column=0, row=0) self.device_list = widgets # 提示需要授权的设备 serials_unauthorized = dc['unauthorized'] if len(serials_unauthorized): utils.showinfo("下列设备需要授权(允许USB调试)\n(强制“刷新设备列表”将重新弹出授权提示):\n" + "\n".join(serials_unauthorized))
def show_devices_force(self): """强制刷新设备列表 """ dc = util_atool.devices(True) arr = dc['device'] util_atool.kill_server() ips = [] for s in arr: if s.find('192.168.') != -1: ip = s.split(':')[0] ips.append(ip) for ip in ips: util_atool.connect(ip) self.show_devices()
def __show_result(serial): """连接mumu模拟器 显示结果""" list1 = serial.split(":") ip = list1[0] port = list1[1] if len(list1) > 1 else "" list1 = util_atool.devices(False)['device'] serial = '' for ss in list1: if ss.find(ip) != -1: serial = ss break if serial: d = device.DeviceData(serial) d.getprop() setting_atool.update_recent(d.product_name, ip, port) utils.showinfo('已连接至 {0} {1}'.format(d.product_name, ip)) else: utils.showinfo('连接失败!\n请先启动mumu模拟器') if utils.main is not None: utils.main.show_devices()
def process(self, is_right_click=False, op=''): if not op: index = self.cbb.current() op = self.cbb_ops[index] if op == OP.SEPARATOR: return if op[0:6] == "_need_": need_cbb = True else: need_cbb = False # 需要包名时,判断包名 # 合格的包名添加到下拉列表 package = self.cbb_item.get_package() if need_cbb: if not package: utils.showinfo('请 选择/输入 包名') return if package.count('.') < 2: utils.showinfo('包名无效') return self.cbb_item.append(package) # 检查设备断开情况 serial = self.serial d_list = util_atool.devices(False)['device'] if not OP.DISCONNECT and not d_list.count(serial): utils.showinfo('此设备已断开连接') return rec_second = 0 # 启动应用 if op == OP.RUN: self.op_run(is_right_click) # 退出应用 elif op == OP.STOP: self.op_am_stop(is_right_click) # 清除数据 elif op == OP.CLEAR: self.op_pm_clear(package, is_right_click) # 当前正在运行 elif op == OP.ACTIVITY_CUR_RUN: self.op_am_cur(is_right_click) # 卸载应用 elif op == OP.UNINSTALL: self.op_uninstall(is_right_click) # 应用列表 elif op == OP.AM_LIST: self.op_am_list(is_right_click) # 下载apk elif op == OP.PULL_APK: self.op_pull_apk(is_right_click) # 设备信息 elif op == OP.DEVICE_INFO: self.op_device_info() # 命令行 elif op == OP.COPY_CMD: self.op_copy_cmd() # 发送文本 elif op == OP.SEND_Text: self.op_send_text() # 发送文本,配合 clipper elif op == OP.CLIPPER: self.op_clipper(is_right_click) # log elif op == OP.LOG_CLEAR: self.op_log_clear() elif op == OP.LOG_FAST: self.op_log_fast() # 布局边界 elif op == OP.DEBUG_LAYOUT: self.op_layout(is_right_click) # 断开连接 elif op == OP.DISCONNECT: self.op_disconnect() # 开启wifi调试 elif op == OP.WIFI_DEBUG: self.op_wifi_debug() # 显示遥控器 elif op == OP.REMOTER: self.op_remote() # 安装 elif op == OP.INSTALL: self.op_install(is_right_click) # scrcpy elif op == OP.SCRCPY: self.op_scrcpy() # 更改分辨率 elif op == OP.SIZE_CUSTOM: self.op_size(op, is_right_click) elif op == OP.SIZE_SCALE: self.op_size(op, is_right_click) elif op == OP.SIZE_ORIGINAL: self.op_size(op, is_right_click) # 华为手机一键解锁 elif op == OP.HUAWEI_UNLOCK: self.op_huawei_unlock() # 打开设置 elif op == OP.OPEN_SETTINGS: self.op_open_settings() # 截屏 elif op == OP.SCREEN_SHOT: self.op_screen_shot(is_right_click) # 录屏 elif op == OP.REC_30: rec_second = 30 elif op == OP.REC_60: rec_second = 60 elif op == OP.REC_120: rec_second = 130 elif op == OP.REC_180: rec_second = 180 elif op == OP.REC_300: rec_second = 300 if rec_second: self.op_record(rec_second)