def apk_uninstall(self, apk): aapt = maapt.aapt() aapt.aapt_parsing(apk) if aapt.is_error == True: print("APK Error !!") for error_line in aapt.error_list: self.device_logs.append("none", "ERROR_APK", error_line, 0) return apk_name = aapt.package_name for device in self.device_finder.find_list: runprocess.RunProcessWait("adb -s " + device + " uninstall " + apk_name)
def __grant_permissions(self, device, dumpsys_window) : """__grant_permissions 자동으로 앱의 권한을 허용 Parameters ---------- self: device: 권한을 허용할 기기 dumpsys_window: Returns ------- """ device_ui_info = androidinfo.DeviceUIInfo() device_ui_info.window_point_parsing(device, dumpsys_window.app_size_x, dumpsys_window.app_size_y) resource_info = device_ui_info.search_clickable_resource_id("com.android.packageinstaller:id/permission_allow_button") runprocess.RunProcessWait("adb -s " + device + " shell input tap " + str(resource_info.x1 + ((resource_info.x2 - resource_info.x1) / 2)) + " " + str(resource_info.y1 + ((resource_info.y2 - resource_info.y1)/2)))
def apk_install(self, apk): aapt = maapt.aapt() aapt.aapt_parsing(apk) if aapt.is_error == True: print("APK Error !!") for error_line in aapt.error_list: self.device_logs.append("none", "ERROR_APK", error_line, 0) return apk_name = aapt.package_name #임시 작업 #apk_activity = aapt.package_activity #print ("APK : " + apk + " Name : " + apk_name + " Activity : " + apk_activity) self.device_finder.find_device_list() if len(self.device_finder.find_list) == 0: print("None Target devices") self.device_logs.append("none", "ERROR_INSTALL", "DEVICE_NONE", 0) return else: ##################################################### print("Process Count :: " + str(len(self.device_finder.find_list))) with ProcessPoolExecutor( max_workers=len(self.device_finder.find_list)) as exe: for device in self.device_finder.find_list: runprocess.RunProcessWait("adb -s " + device + " shell pm uninstall " + apk_name) if self.device_finder.device_dict.get( device).manufacturer == "Xiaomi": exe.submit(self.mi_device_install, apk, device) else: exe.submit(self.normal_device_install, apk, device) time.sleep(0.1) exe.shutdown(wait=True) ##################################################### for device in self.device_finder.find_list: self.apk_install_check(device, apk_name) self.device_logs.prints(device)
def mi_device_install(self, apk, device): #Thread install & focused install_thread = None if int(self.device_finder.device_dict.get(device).ver_sdk) < 23: install_thread = threading.Thread(target=self.__os_6_under, args=(apk, device)) install_thread.start() else: install_thread = threading.Thread(target=self.__os_6_upper, args=(apk, device)) install_thread.start() #mFocused while True: time.sleep(1) dumpsys_window = androidinfo.DumpsysWindow(device) print(dumpsys_window.mFocused) if dumpsys_window.mFocused.find( """com.android.packageinstaller/com.android.packageinstaller.PackageInstallerActivity""" ) != -1: break state_dict = self.device_install_state_dict.get(device) if state_dict != None: bCheck = False for line in state_dict: if line.lower().find("failed") != -1: bCheck = True break if bCheck == True: return #Button Click device_ui_info = androidinfo.DeviceUIInfo() device_ui_info.window_point_parsing(device, dumpsys_window.app_size_x, dumpsys_window.app_size_y) resource_info = device_ui_info.search_clickable_resource_id( "com.android.packageinstaller:id/ok_button") runprocess.RunProcessWait("adb -s " + device + " shell input tap " + \ str(resource_info.x1 + ((resource_info.x2 - resource_info.x1) / 2)) + " " + \ str(resource_info.y1 + ((resource_info.y2 - resource_info.y1)/2)))
#pass apk_installer.apk_install(apk) for a in range(2) : #while(True) : apk_runner = apkrunner.ApkRunner() apk_runner.set_apk([apk, ]) apk_runner.apk_start_activity = activity #apk_runner.focused_limit.append(activity) device_finder.find_device_list() for device in device_finder.find_list : runprocess.RunProcessWait("adb -s " + device + " logcat -c") apk_runner.time_limit = 10 apk_runner.time_wait = 3 apk_runner.apk_running() print(Fore.CYAN + Back.MAGENTA + Style.BRIGHT + "APK RUNNER END GO FILE CHECK" + Fore.RESET + Back.RESET + Style.NORMAL) for device in apk_runner.device_finder.find_list : focused_error_list = apk_runner.device_logs.find_event(device, "focused_Error") if len(focused_error_list) > 0 : file_head = device + "logs" file_tail = ".txt" png_tail = ".png" count = 0 while(True) : print ("FILE UNIQUE SETTING : " + str(count))