def run_adb_command(adb_type, command): if adb_type == "local": adb_cmd = EMULATOR_LOCAL_PTOOLS_DIR + ADB_CMD elif adb_type == "path": adb_cmd = ADB_CMD else: print_error("ADB type error!") os.exit(1) return run_command(adb_cmd + " " + command)
def is_local_emulator_valid(): print_info("Checking local emulator version...") if os.path.isdir(EMULATOR_LOCAL_TOOLS_DIR): result = run_command( [EMULATOR_LOCAL_TOOLS_DIR + EMULATOR_CMD, EMULATOR_OPT_VER]) if result["success"]: print_info("OK: using local %s" % result["out"].split("\n")[0]) return True else: print_error("KO: Local emulator error = %s." % result["err"]) else: print_error("KO: Local folder not exists.") return False
def is_local_adb_valid(): print_info("Checking local adb version...") if os.path.isdir(EMULATOR_LOCAL_PTOOLS_DIR): result = run_command( [EMULATOR_LOCAL_PTOOLS_DIR + ADB_CMD, EMULATOR_OPT_VER]) if result["err"] and result["err"].find(ADB_VERSION_LINE) != -1: print_info("OK: using local %s" % result["err"].split("\n")[0]) return True else: print_error("KO: Local emulator error = %s." % result["err"]) else: print_error("KO: Local folder not exists.") return False
def copy_xposed_file(args, xposed_files): sys_dir = get_real_path(args.sys_dir) xpo_dir = get_real_path(args.xpo_dir) print_info("Copying %s ---> %s..." % (xpo_dir, sys_dir)) for src_file in xposed_files: if src_file.find(XPOSED_TRAIL) != -1: dst_file = src_file.strip(XPOSED_TRAIL) else: dst_file = src_file # Check dir check_missing_dir(sys_dir+ dst_file, args.simulation) cmd = "cp %s %s" %(xpo_dir+src_file, sys_dir+ dst_file) ret = running.run_command(cmd, args.simulation) if not ret["success"]: print "Error in running command " + cmd else: print_debug(cmd)
def is_path_emulator_valid(): print_info("Checking system emulator version...") result = run_command([EMULATOR_CMD, EMULATOR_OPT_VER]) if result["success"]: emulatorVersion = result["out"].split("\n")[0] if is_emulator_version_valid(emulatorVersion): print_info("OK: %s" % emulatorVersion) return True else: print_error("KO: Emulator version %s obsolete." % emulatorVersion) else: exception = result["exception"] if result["err"]: print_error(result["err"]) return False if exception == None: return False if exception.errno == os.errno.ENOENT: print_error("Android emulator is not available in PATH:\n" + os.getenv("PATH")) else: print "Error: " + exception return False
def copy_data(args, cmds): sys_dir = get_real_path(args.sys_dir) try: su_dir = get_real_path(args.su_dir) except Exception, e: print_error("Error: " + e.message) sys.exit() print_info("%s ---> %s" % (su_dir, sys_dir)) for cmd in cmds: sub_dir = (sys_dir + cmd.dst).split("/") final_path = (sys_dir + cmd.dst)[0:-(len(sub_dir[-1]))] if not os.path.exists(final_path): running.run_command("mkdir -p " + final_path, args.simulation) copy_cmd = "cp -f %s %s" % (su_dir + cmd.src, sys_dir + cmd.dst) print_debug(copy_cmd) exit_status = running.run_command(copy_cmd, args.simulation) if not exit_status["success"]: print "Error copying %s" % sys_dir + cmd.dst return chmod_cmd = "chmod %s %s" % (cmd.chmod, sys_dir + cmd.dst) print_debug(chmod_cmd) exit_status = running.run_command(chmod_cmd, args.simulation) if not exit_status["success"]: print "Error with chmod for %s" % sys_dir + cmd.dst return