コード例 #1
0
 def apk_install_check(self, device, apk_name):
     while (True):
         apk_list = runprocess.RunProcessOut(
             "adb -s " + device + " shell pm list package -f | grep " +
             apk_name)
         if len(apk_list) <= 0:
             time.sleep(1)
         else:
             return
コード例 #2
0
 def __os_6_upper(self, apk, device):
     tmp_out_line = list()
     out_line = runprocess.RunProcessOut("adb -s " + device +
                                         " install -r -g " + apk)
     for line in out_line:
         line = line.decode("UTF-8").strip()
         tmp_out_line.append(line)
         if line == "Success":
             self.device_logs.append(device, "install_log", line, 0)
         else:
             self.device_logs.append(device, "ERROR_install", line, 0)
     self.device_install_state_dict.setdefault(device, tmp_out_line)
コード例 #3
0
 def run(self, args=list()):
     if len(args) == 0: return
     if self.is_error == True :
         for line in self.error_list :
             print (line)
         return
     if self.bPackageActivity == False and self.bPackageName == False :
         apkInfos = runprocess.RunProcessOut(config.aapt + ' ' + args[0])
         for info in apkInfos :
             info = info.decode("UTF-8").strip()
             print (info)
         return 
     self.aapt_parsing(args[0])
     if self.bPackageName == True :
         print (Fore.YELLOW + Style.BRIGHT + self.package_name + Fore.RESET + Style.NORMAL)
     if self.bPackageActivity == True :
         print (Fore.YELLOW + Style.BRIGHT + self.package_activity + Fore.RESET + Style.NORMAL)
コード例 #4
0
 def aapt_parsing(self, apk) :
     apkInfos = runprocess.RunProcessOut(config.aapt + ' ' + apk)
     if len(apkInfos) < 5 :
         for info in apkInfos :
             info = info.decode("UTF-8").strip()
             self.error_list.append(info)
         self.is_error = True
         return
     for info in apkInfos :
         info = info.decode("UTF-8").strip()
         if "package:" in info :
             info = info.split()
             info = info[1].split("'")
             self.package_name = info[1]
         elif "launchable-activity:" in info :
             info = info.split()
             info = info[1].split("'")
             self.package_activity = info[1]
コード例 #5
0
    def multi_processing(self, device) :
        """multi_processing

        각 기기 별로 프로세스 형태로 돌아감
        CPU를 모두 점유해서 사용하기 위함
        그러니 따로 사용하지 말고 apk_running으로 동작 시키는 것을 추천
        Parameters
        ----------
        self: 
        device: 동작을 진행할 기기

        Returns
        -------

        """
        #device 상태 저장
        #self.device_switch.setdefault(device, True)

        is_time_wait = False    #모두 종료 후 대기 시간으로 넘어감
        #screencap 설정
        device_path = self.temp_path + device
        if os.path.isdir(device_path) == False :
            os.mkdir(device_path)
        else :
            count = 0
            while(True)  :
                if os.path.isdir(device_path + "_" + str(count)) == True :
                    count = count + 1
                    continue
                else :
                    break
            device_path = device_path + "_" + str(count) + os.sep
            os.mkdir(device_path)
        self.device_logs.append(device, "State", "DevicePath:" + device_path, 0)
        print ("::::::::::::::::::::" + device_path + "::::::::::::::::::::::::::")
        

        screen_count = 0

        #종료 조건에 홈화면이 나올 경우도 추가
        private_focused_limit = copy.deepcopy(self.focused_limit)
        home_dumpsyswindow = androidinfo.DumpsysWindow(device)
        private_focused_limit.append(home_dumpsyswindow.mFocused)

        #시간 점검 변수들 생성
        run_timer = common.Timer()
        grant_timer = common.Timer()
        run_timer.start()
        time_focused = 0
        #시~작~
        self.device_logs.append(device, "State", "Start", run_timer.second_full_tab())
        adb = "adb -s " + device + " "
        #print ("start activity : " + self.apk_start_activity)
        runprocess.RunProcessOut(adb + "shell am start -n " + self.apk_name + '/' + self.apk_start_activity + " -a android.intent.action.MAIN -c android.intent.category.LAUNCHER")
        while True :
            time.sleep(0.1)
            dumpsyswindow = androidinfo.DumpsysWindow(device)

            #새로운 화면일 시 저장
            focused_list = self.device_logs.find_event(device, "focused")
            if len( focused_list ) :
                #print ("focused :: " + focused_list[-1].dist)
                if focused_list[-1].dist.lower().find(dumpsyswindow.mFocused.lower()) == -1 :
                    self.__screencap(device, device_path, screen_count, dumpsyswindow, run_timer)
            else :
                self.__screencap(device, device_path, screen_count, dumpsyswindow, run_timer)


            #권한 처리 (권한 화면 일 시 4초 뒤에 처리) - 소장님 의견으로는 권한 화면일 시 내부 처리에 오류가 많이 나기 때문에 일정 시간의 대기를 가지고 확인하는게 좋다고 함
            if dumpsyswindow.is_grant_activity == True :
                if grant_timer.is_running == False :
                    self.device_logs.append(device, "grant_permission", "wait grant", run_timer.second_full_tab())
                    run_timer.pause()
                    grant_timer.start()
                elif grant_timer.second_tab() > 4 :
                    self.device_logs.append(device, "grant_permission", "click grant", run_timer.second_full_tab())
                    self.__grant_permissions(device, dumpsyswindow)
                    run_timer.start()
                    grant_timer.stop()
                continue

            #print ("is Dump State : " + str(dumpsyswindow.isFocusedError()) + "  ::  " + dumpsyswindow.mFocused)
            if dumpsyswindow.isFocusedError() == True :
                self.device_logs.append(device, "focused_Error", dumpsyswindow.mFocused, run_timer.second_full_tab())
                is_time_wait = True
                break

            if is_time_wait != True :
                #정지 조건 시간
                if self.time_limit > 0 :
                    print (run_timer.second_tab())
                    if run_timer.second_tab() > self.time_limit :
                        is_time_wait = True

                #정지 조건 activity
                for focused in private_focused_limit :
                    #print ("current Focused :: " + dumpsyswindow.mFocused + "   find focused :: " + focused + "  is same :: " + str( dumpsyswindow.mFocused.find(focused) != -1 ))
                    if dumpsyswindow.mFocused.find(focused) != -1 :
                        is_time_wait = True
                        time_focused = run_timer.second_tab()
                        break

            #wait time
            if is_time_wait :
                #제한시간을 넘었을 경우 종료
                if run_timer.second_tab() > self.time_limit + self.time_wait :
                    break;
                #제한 화면을 넘었을 경우 종료
                elif time_focused > 0 and run_timer.second_tab() > time_focused + self.time_wait :
                    break;

        #로그 정리
        print ("END APKRUNNER!!!")
        self.device_logs.append(device, "State", "End", run_timer.second_full_tab())