def loop_snap_dump(self): dn.dnld( self._target, 'screencap /sdcard/Pictures/%s/%s.dump' % (self._target, 'screen_snap')) while True: file_mod_time = self.get_FileModifyTime(self._second_dump_path) file_size_m = self.get_FileSize(self._second_dump_path) if file_mod_time and file_mod_time != self._dump_time_cache and file_size_m != 0: self._dump_time_cache = file_mod_time break
def img_push(self, snp_path=''): snp_path = snp_path or self.create_ram_unid() self.v_sleep(1000) path_imx = dn.screen_snap(self._target, snp_path) self.v_sleep(2400) self.snap_img_cache_path = path_imx return path_imx
def set_log(self, fn_name): try: log_path_snap = FILE_PARENT_FOLDER + 'log\\' + self.v_now_time( ) + '\\' self.v_create_dir(log_path_snap) with open(log_path_snap + 'error.txt', 'a', encoding='utf-8') as file_obj: file_obj.write(str(fn_name)) img_path = dn.screen_snap(self._target, 'error') shutil.copy(img_path, log_path_snap + 'error.png') except Exception as e: traceback.print_exc() print(e)
def change_imei_and_restart(self): try: dn.quit(self._target) self.v_sleep(1000) dn.change_device_data(self._target) self.v_sleep(1000) dn.launch(self._target) dn_times = 0 while True: self.v_sleep(1000) if dn.is_running(self._target): break else: dn_times += 1 if (dn_times > 120): dn_times = 0 dn.launch(self._target) print('%s restarting' % (self._target)) return True except Exception as e: traceback.print_exc() print(e)
def get_running_emu(): return dn.list_running()
def clean_app(self): return dn.clear_app(self._target)
def install_app(self, path): if (not path): return False return dn.install(self._target, path)
def un_install_app(self): dn.uninstall(self._target) self.v_sleep(2000) return True
def delect_file(self, file_path): dn.del_file_libs(self._target, file_path)
def key_code_press(self, key_num): dn.key_code_event(self._target, key_num)
def text_into(self, text): dn.input_text(self._target, text)
def move_to(self, x, y): dn.dnld( self._target, "sendevent dev/input/event2 3 53 %s\nsendevent dev/input/event2 3 54 %s\nsendevent dev/input/event2 0 0 0\n" % (x, y))
def touch_up(self): dn.dnld( self._target, "sendevent dev/input/event2 3 57 -1\nsendevent dev/input/event2 1 330 0\nsendevent dev/input/event2 1 325 0\nsendevent dev/input/event2 0 0 0\n" )
def touch_down(self): dn.dnld( self._target, "sendevent dev/input/event2 3 57 0\nsendevent dev/input/event2 1 330 1\nsendevent dev/input/event2 1 325 1\n" )
def v_run_apk(self): dn.invokeapp(self._target) self.v_sleep(2000) return True
def copy_file(self, old_path, new_path): dn.copy_file(self._target, old_path, new_path)
def click(self, x, y, delay, ramdom_time=0): ramdom_add = delay + random.uniform(0, ramdom_time) ra_x, ra_y = self.v_ramdom_xy(x, y) dn.touch(self._target, ra_x, ra_y, ramdom_add)
def swipe(self, x1, y1, x2, y2, delay, ramdom_time=0): ramdom_add = delay + random.uniform(0, ramdom_time) ra_x1, ra_y1 = self.v_ramdom_xy(x1, y1) ra_x2, ra_y2 = self.v_ramdom_xy(x2, y2) dn.swipe(self._target, (ra_x1, ra_y1), (ra_x2, ra_y2), ramdom_add)