Exemplo n.º 1
0
def pull_instrument_run_snapshorts():
    cmd = 'adb shell rename %s %s' % (SHELL_SNAPSHOTS_DIR_PATH, SHELL_SNAPSHOTS_DIR_NEW_PATH)
    print cmd
    if not WinSysUtils.run_sys_cmd(cmd):
        return

    time.sleep(1)
    cmd = 'adb pull %s %s' % (SHELL_SNAPSHOTS_DIR_NEW_PATH, REPORT_DIR_PATH)
    print cmd
    WinSysUtils.run_sys_cmd(cmd)
Exemplo n.º 2
0
def pull_instrument_run_snapshorts():
    cmd = 'adb shell rename %s %s' % (SHELL_SNAPSHOTS_DIR_PATH,
                                      SHELL_SNAPSHOTS_DIR_NEW_PATH)
    print cmd
    if not WinSysUtils.run_sys_cmd(cmd):
        return

    time.sleep(1)
    cmd = 'adb pull %s %s' % (SHELL_SNAPSHOTS_DIR_NEW_PATH, REPORT_DIR_PATH)
    print cmd
    WinSysUtils.run_sys_cmd(cmd)
Exemplo n.º 3
0
def adb_connect_to_device(device_ip):
    cmd = 'adb connect %s' % device_ip

    try_adb_connect_times = 3
    wait_time = 3
    for i in range(0, try_adb_connect_times):
        logging.debug('try to connect to adb device, %d times.' % (i + 1))
        WinSysUtils.run_sys_cmd(cmd)
        if verify_adb_devices_serialno():  # verify connect success
            return True
        time.sleep(wait_time)
    
    logging.error('Failed to connect to device!')
    return False
Exemplo n.º 4
0
def adb_connect_to_device(device_ip):
    cmd = 'adb connect %s' % device_ip

    try_adb_connect_times = 3
    wait_time = 3
    for i in range(0, try_adb_connect_times):
        logging.debug('try to connect to adb device, %d times.' % (i + 1))
        WinSysUtils.run_sys_cmd(cmd)
        if verify_adb_devices_serialno():  # verify connect success
            return True
        time.sleep(wait_time)

    logging.error('Failed to connect to device!')
    return False
Exemplo n.º 5
0
def change_mod_for_app_in_system():
    print 'Chmod for app to RO.'
    cmd = 'adb shell chmod 644 %s%s' % (SHELL_SYSTEM_APP_DIR_PATH,
                                        target_app_name)
    if not WinSysUtils.run_sys_cmd(cmd):
        print 'Failed to chmod for app in system!'
        exit(1)
Exemplo n.º 6
0
def change_mod_for_app_in_system():
    print 'Chmod for app to RO.'
    cmd = 'adb shell chmod 644 %s%s' % (g_const_shell_system_app_path,
                                        g_target_app_name)
    if (not WinSysUtils.run_sys_cmd(cmd)):
        print 'Failed to chmod for app in system!'
        exit(1)
Exemplo n.º 7
0
def copy_app_to_system_app_dir():
    print 'Copying app from sdcard to /system/app/'
    cmd = 'adb shell cp %s%s %s' % (SHELL_TMP_DIR_PATH, target_app_name,
                                    SHELL_SYSTEM_APP_DIR_PATH)
    if not WinSysUtils.run_sys_cmd(cmd):
        print 'Failed to copy app from sdcard to /system/app/'
        exit(1)
Exemplo n.º 8
0
def push_app_to_shell_tmp_dir():
    print 'Start to push app to shell /data/local/tmp/'
    app_full_path = os.path.join(TARGET_APP_DIR_PATH, target_app_name)
    cmd = 'adb push %s %s' % (app_full_path, SHELL_TMP_DIR_PATH)

    if not WinSysUtils.run_sys_cmd(cmd):
        print 'Failed to push app to /data/local/tmp/ !'
        exit(1)
Exemplo n.º 9
0
def push_app_to_sdcard():
    print 'Start to push app to andorid sdcard.'
    app_full_path = os.path.join(g_target_app_path, g_target_app_name)
    cmd = 'adb push %s %s' % (app_full_path, g_const_shell_sdcard_path)

    if not WinSysUtils.run_sys_cmd(cmd):
        print 'Failed to push app to sdcard!'
        exit(1)
Exemplo n.º 10
0
def copy_app_from_sdcard_to_system_app():
    print 'Copying app from sdcard to /system/app'
    cmd = 'adb shell cp %s%s %s' % (g_const_shell_sdcard_path,
                                    g_target_app_name,
                                    g_const_shell_system_app_path)
    if (not WinSysUtils.run_sys_cmd(cmd)):
        print 'Failed to copy app from sdcard to /system/app'
        exit(1)
Exemplo n.º 11
0
def rm_old_captures_on_remote():
    cmd = 'adb shell ls %s' % g_remote_tmp_dir_path
    lines_files = WinSysUtils.run_sys_cmd_and_ret_lines(cmd)
    flag_found = False
    for line in lines_files:
        if g_remote_tmp_captures_dir_name in line:
            flag_found = True
            break
    
    if flag_found:
        cmd = 'adb shell ls %s' % g_remote_tmp_captures_dir_path
        lines_capture = WinSysUtils.run_sys_cmd_and_ret_lines(cmd)
        if len(lines_capture) > 0:
            cmd = 'adb shell rm %s/*.png' % g_remote_tmp_captures_dir_path
            WinSysUtils.run_sys_cmd(cmd)
    else:
        cmd = 'adb shell mkdir -p %s' % g_remote_tmp_captures_dir_path
        WinSysUtils.run_sys_cmd(cmd)
Exemplo n.º 12
0
def open_app_details_settings(pkg_name):
    action = 'android.settings.APPLICATION_DETAILS_SETTINGS'
    cmd = 'adb shell am start -a "%s" -d "package:%s"' % (action, pkg_name)
    print cmd
    WinSysUtils.run_sys_cmd(cmd)
Exemplo n.º 13
0
def pull_instrument_run_listener_results_file(file_name):
    cmd = 'adb pull %s %s' % (SHELL_TEST_LOG_DIR_PATH + file_name,
                              REPORT_DIR_PATH)
    print cmd
    WinSysUtils.run_sys_cmd(cmd)
Exemplo n.º 14
0
def create_html_report(src_results):
    cmd = 'java -jar %s -f=%s -x=%s' % (JAR_FILE_PATH, src_results, XSLT_FILE_PATH)
    print cmd
    WinSysUtils.run_sys_cmd(cmd)
Exemplo n.º 15
0
def create_html_report(src_results):
    cmd = 'java -jar %s -f=%s -x=%s' % (JAR_FILE_PATH, src_results,
                                        XSLT_FILE_PATH)
    print cmd
    WinSysUtils.run_sys_cmd(cmd)
Exemplo n.º 16
0
def delete_old_instrument_run_listener_logs():
    cmd = 'adb shell rm -rf ' + SHELL_TEST_LOG_DIR_PATH
    print cmd
    WinSysUtils.run_sys_cmd(cmd)
Exemplo n.º 17
0
def pull_instrument_run_listener_results_file(file_name):
    cmd = 'adb pull %s %s' % (SHELL_TEST_LOG_DIR_PATH + file_name, REPORT_DIR_PATH)
    print cmd
    WinSysUtils.run_sys_cmd(cmd)
Exemplo n.º 18
0
def run_instrument_tests_v1(cmd):
    WinSysUtils.run_sys_cmd(cmd)
Exemplo n.º 19
0
def adb_stop():
    cmd = 'adb kill-server'
    WinSysUtils.run_sys_cmd(cmd)
Exemplo n.º 20
0
def adb_stop():
    cmd = 'adb kill-server'
    return WinSysUtils.run_sys_cmd(cmd)
Exemplo n.º 21
0
def delete_old_instrument_run_listener_logs():
    cmd = 'adb shell rm -rf ' + SHELL_TEST_LOG_DIR_PATH
    print cmd
    WinSysUtils.run_sys_cmd(cmd)
Exemplo n.º 22
0
def remove_exit_apk_files_in_system_app_dir():
    file_pattern = '%s.*' % target_app_name.split('.')[0]
    cmd = 'adb shell rm ' + SHELL_SYSTEM_APP_DIR_PATH + file_pattern
    print cmd
    WinSysUtils.run_sys_cmd(cmd)
Exemplo n.º 23
0
def dump_logcat_by_tag(tag, file_path):
    cmd = 'adb logcat -c && adb logcat -s %s -v time -d > %s' % (tag, file_path)
    print cmd
    WinSysUtils.run_sys_cmd(cmd)
Exemplo n.º 24
0
def pull_remote_captures_to_local():
    # pull both dir and files in the dir from remote
    cmd = 'adb pull %s %s' % (g_remote_tmp_captures_dir_path, g_local_report_dir_path)
    WinSysUtils.run_sys_cmd(cmd)