示例#1
0
def main():
    '''
    The main function does not need any parameters and only loads the adb clas
    and exectuted the firewall_set_up function
    '''
    if len(sys.argv) < 1:
        #Test if the programm gets executed with to less parameters
        print('The programme needs no parameters')
        sys.exit(1)

    smartphone_control = adb.adb()
    smartphone_control.firewall_set_up()
示例#2
0
文件: main.py 项目: Yaque/Auto
def get_lin_img(temp, img, cut, len_col):
    img = img[cut[0]:cut[1], 0:len_col]
    
    if img.shape[0] > 0 and img.shape[1] > 0:
        cv2.imwrite("cut_img/" + str(cut[0]) + ".png", img)
        if need.shape[0] == img.shape[0] and need.shape[1] == img.shape[1]:
#             print(temp[0] + cut[0], temp[1] + 0)
#             cv2.imshow("img", img)
#             cv2.waitKey()
            cmd_str = "shell input tap " + str(temp[1] + 0 + 20) + " " + str(temp[0] + cut[0] + 20)
            print(cmd_str)
            for c in range(10):
                adb.adb(cmd_str)
        one_cut_img = []
        one_cut_img.append(temp[0] + cut[0])
        one_cut_img.append(temp[1] + 0)
        one_cut_img.append(img)
        one_cut_img.append(img.shape[0])
        one_cut_img.append(img.shape[1])
        
        temp_cut_img.append(one_cut_img)
示例#3
0
def main():
    '''
    The main function needs 3 parameters to execute it similar to the app_execution script:
    1. an application name (nothing is done with it)
    2. a video name for the first phone
    3. a video name for the second phone

    Steps:
    1. the screen records get sarted
    2. the screens of the smartphones get activated
    3. the wifi gets activated on the phones
    4. 60s are waited
    5. the wifi gets deactivated on each phone
    6. the screens get deactivated
    7. the screen records get stopped
    '''
    if len(sys.argv) < 4:
        #Test if the programm gets executed with to many parameters
        print('''
              The programme needs:
                1. an application name
                2. a video name for the first phone
                3. a video name for the second phone
                ''')
        sys.exit(1)

    app = sys.argv[1]
    video_names = [sys.argv[2], sys.argv[3]]
    smartphone_control = adb.adb()
    #Step 1
    pid_list = smartphone_control.start_screencast()
    #Step 2
    smartphone_control.activate_screen()
    #Step 3
    smartphone_control.start_wifi()
    #Step 4
    time.sleep(60)
    #Step 5
    smartphone_control.stop_wifi()
    #Step 6
    smartphone_control.sleep()
    #Step 7
    smartphone_control.stop_screencast(video_names, pid_list)
示例#4
0
def main():
    '''
    The main function needs 3 parameters to execute it similar to the app_execution script:
    1. an application name (nothing is done with it)
    2. a video name for the first phone
    3. a video name for the second phone

    Steps:
    1. the screen records get sarted
    2. the screens of the smartphones get activated
    3. the wifi gets activated on the phones
    4. 60s are waited
    5. the wifi gets deactivated on each phone
    6. the screens get deactivated
    7. the screen records get stopped
    '''
    if len(sys.argv) < 4:
        #Test if the programm gets executed with to many parameters
        print('''
              The programme needs:
                1. an application name
                2. a video name for the first phone
                3. a video name for the second phone
                ''')
        sys.exit(1)

    app = sys.argv[1]
    video_names = [sys.argv[2], sys.argv[3]] 
    smartphone_control = adb.adb()
    #Step 1
    pid_list = smartphone_control.start_screencast()
    #Step 2
    smartphone_control.activate_screen()
    #Step 3
    smartphone_control.start_wifi()
    #Step 4
    time.sleep(60)
    #Step 5
    smartphone_control.stop_wifi()
    #Step 6
    smartphone_control.sleep()
    #Step 7
    smartphone_control.stop_screencast(video_names, pid_list)
示例#5
0
def main():
    '''
    The main function does not need any parameters.
    It loads the adb clas and goes through the following steps:
    1. stop the wifi
    2. close all apps
    3. deactivate the screens
    '''
    if len(sys.argv) < 1:
        #Test if the programm gets executed with to less parameters
        print('The programme needs no parameters')
        sys.exit(1)

    smartphone_control = adb.adb()
    #Step 1
    smartphone_control.stop_wifi()
    #Step 2
    apps = smartphone_control.get_list_of_available_apps()
    for app in apps:
        smartphone_control.close_application(app)
    #Step 3
    smartphone_control.sleep()
示例#6
0
def main():
    '''
    The main function needs 4 parameters:
    1. comma seperated coordinates
    2. comma seperated coordinates
    3. a video file name for the first coordinate pair
    4. a video file name for the second coordinate pair

    Steps:
    1. the screen records get sarted
    2. the screens of the smartphones get activated
    3. the coordinates get imported
    4. the screens get deactivated
    5. the screen records get stopped
    '''
    if len(sys.argv) < 5:
        #Test if the programm gets executed with to less parameters
        print('''The programme needs:
                 1. comma seperated coordinates
                 2. comma seperated coordinates
                 3. a video file name for the first coordinate pair
                 4. a video file name for the second coordinate pair
                 ''')
        sys.exit(1)

    co1 = sys.argv[1].split(',')
    co2 = sys.argv[2].split(',')
    video_names = [sys.argv[3], sys.argv[4]]
    smartphone_control = adb.adb()
    #Step 1
    pid_list = smartphone_control.start_screencast()
    #Step 2
    smartphone_control.activate_screen()
    #Step 3
    smartphone_control.xprivacy_set_fake_location([co1, co2])
    #Step 4
    smartphone_control.sleep()
    #Step 5
    smartphone_control.stop_screencast(video_names, pid_list)
示例#7
0
def main():
    '''
    The main function needs 4 parameters:
    1. comma seperated coordinates
    2. comma seperated coordinates
    3. a video file name for the first coordinate pair
    4. a video file name for the second coordinate pair

    Steps:
    1. the screen records get sarted
    2. the screens of the smartphones get activated
    3. the coordinates get imported
    4. the screens get deactivated
    5. the screen records get stopped
    '''
    if len(sys.argv) < 5:
        #Test if the programm gets executed with to less parameters
        print('''The programme needs:
                 1. comma seperated coordinates
                 2. comma seperated coordinates
                 3. a video file name for the first coordinate pair
                 4. a video file name for the second coordinate pair
                 ''')
        sys.exit(1)

    co1 = sys.argv[1].split(',')
    co2 = sys.argv[2].split(',')
    video_names = [sys.argv[3], sys.argv[4]]
    smartphone_control = adb.adb()
    #Step 1
    pid_list = smartphone_control.start_screencast()
    #Step 2
    smartphone_control.activate_screen()
    #Step 3
    smartphone_control.xprivacy_set_fake_location([co1, co2])
    #Step 4
    smartphone_control.sleep()
    #Step 5
    smartphone_control.stop_screencast(video_names, pid_list)
示例#8
0
文件: main.py 项目: Yaque/Auto
def get_aim_img():
    adb.adb("shell screencap -p /sdcard/screen.png")
#     adb.adb("pull /sdcard/DCIM/Camera/2.jpg")
    adb.adb("pull /sdcard/screen.png")
示例#9
0
文件: main.py 项目: Yaque/Auto
need = cv2.imread("data/72.png", cv2.IMREAD_GRAYSCALE)
print(need.shape)
all_cut_img = []
temp_cut_img = []
while True:
    get_aim_img()
    img_name = "screen.png"
    one = [0,0]
    img_read = cv2.imread(img_name)
    print(img_read.shape)
    one.append(img_read)
    one.append(img_read.shape[0])
    one.append(img_read.shape[1])
    temp_cut_img.append(one)
    while len(temp_cut_img) is not 0:
        main(temp_cut_img[len(temp_cut_img) - 1][2])
    img_read_c = cv2.imread(img_name)
    j = 0
    f = open("img.txt", "w")
    for i in all_cut_img:
        cv2.rectangle(img_read_c,(i[1],i[0]),(i[1] + i[4],i[0] + i[3]),(0,255,0),3)
        cv2.imwrite("img/" + str(j) + ".png", i[2])
        f.write(str(i[0]) + "    " + str(i[1]) + "    "\
                + str(i[3]) + "    " + str(i[4]) + "\n")
        j +=1
    f.close()
#     cv2.imshow("img_read.png", img_read_c)
#     cv2.waitKey()
    img_read_c = []
    adb.adb("shell input swipe 250 1200 250 800")
示例#10
0
def main():
    '''
    The main function needs 3 parameters:
    1. an application name
    2. a video name for the first phone
    3. a video name for the second phone

    Steps:
    1. the screen records get sarted
    2. the screens of the smartphones get activated
    3. the firewalls get opened for the application
    4. the wifi gets activated on the phones
    5. the application gets started on the phones
    6. 4 messages get sent
    7. an additonal timeout is waited in the messenger
    8. the application gets closed on the phones
    9. the firewalls get closed
    10. the wifi gets deactivated on each phone
    11. the screens get deactivated
    12. the screen records get stopped
    '''
    if len(sys.argv) < 4:
        #Test if the programm gets executed with to many parameters
        print('''
              The programme needs:
                1. an application name
                2. a video name for the first phone
                3. a video name for the second phone
                ''')
        sys.exit(1)

    app = sys.argv[1]
    video_names = [sys.argv[2], sys.argv[3]]
    smartphone_control = adb.adb()
    #Step 1
    pid_list = smartphone_control.start_screencast()
    #Step 2
    smartphone_control.activate_screen()
    #Step 3
    smartphone_control.firewall_open_uid(app)
    #Step 4
    smartphone_control.start_wifi()
    #Step 5
    smartphone_control.start_application(app)
    #Step 6
    #The adb module takes turns between the phones by itself
    i = 0
    while i <4:
        smartphone_control.send_message(app)
        time.sleep(5)
        i = i+1
    #Step 7
    smartphone_control.wait_in_messenger(app)
    #Step 8
    smartphone_control.close_application(app)
    #Step 9
    smartphone_control.firewall_close_uid(app)
    #Step 10
    smartphone_control.stop_wifi()
    #Step 11
    smartphone_control.sleep()
    #Step 12
    smartphone_control.stop_screencast(video_names, pid_list)
示例#11
0
文件: main.py 项目: ywlbupt/cmw_prj
# from package.logHandler import LogHandler

from MACRO_DEFINE import *

from instr_66319D import handle_instr_66319D
from instr_cmw500 import handle_instr_cmw500

from config_default import config
from config_default import SENSE_PARAM
from adb import adb

if __name__ == '__main__':
    # instr = rm.open_resource("TCPIP0::10.237.70.10::inst0::INSTR")
    try:
        time_start = time.time()
        phone = adb()

        if "ip_cmw500" in config:
            cmw_addr = "TCPIP0::{0}::inst0::INSTR".format(config["ip_cmw500"])
        elif "gpib_cmw500" in config:
            cmw_addr = "GPIB0::{0}::INSTR".format(config["gpib_cmw500"])
        else:
            cmw_addr = handle_instr_cmw500.device_scan(handle_instr_cmw500)
        if cmw_addr:
            m = handle_instr_cmw500(cmw_addr, phone)
        else:
            m = None
        if m:
            print(m.get_instr_version())

            m.set_remote_display(state=True)
示例#12
0
 def __init__(self, all_result_path, device):
     self.all_result_path = all_result_path
     self.device = device
     self.adb = adb.adb(self.device)