def adb_connect_with_root(device_ip): if not AdbUtils.adb_connect_to_device(device_ip): # adb connect print 'Error, when adb connect to the device!' exit(1) # fix pending issue when run adb root command # if not run_cmd_adb_root_from_subprocess(): # print 'Error, when run adb as root!' # exit(1) run_cmd_adb_root_from_subprocess_and_kill() if not AdbUtils.adb_connect_to_device(device_ip): # adb connect as root print 'Error, when adb connect to the device with root!' exit(1)
def loop_run_test(during): i = 0 cmd = build_instrument_cmd_v2() start_time = int(time.clock()) while 1: if not AdbUtils.verify_adb_devices_serialno(): if not AdbUtils.adb_connect_to_device(g_device_ip): logging.error('device is disconnect!') exit(1) run_instrument_tests_v2(cmd) time.sleep(3) i += 1 logging.info('run ui test %d times.' % i) cur_run_time = int(time.clock()) - start_time logging.info('current run time: %d minutes %d seconds' % (cur_run_time / 60, cur_run_time % 60)) if ((cur_run_time - start_time) > during): break # END LOOP global g_total_run_times g_total_run_times = i
def connect_to_device_with_root(): if not AdbUtils.adb_connect_to_device(target_device_ip): print 'Failed adb connect to ' + target_device_ip exit(1) if not run_cmd_adb_root_from_subprocess_and_reconnect(): print 'Failed adb root and reconnect to ' + target_device_ip exit(1)
def run_cmd_adb_root_from_subprocess_and_reconnect(): cmd = 'adb root' print 'run adb root and reconnect.' p = subprocess.Popen(cmd, shell=True) time.sleep(1) p.kill() # no return back for 'adb root' and kill instead return AdbUtils.adb_connect_to_device(target_device_ip)
def connect_to_device_with_root(): if not AdbUtils.adb_connect_to_device(g_target_device_ip): print 'Failed adb connect to %s' % g_target_device_ip exit(1) if not AdbUtils.adb_connect_with_root(g_target_device_ip): print 'Failed adb root and connect to %s' % g_target_device_ip exit(1)