/// <summary> /// Executes an <see cref="AdbCommand"/> on the running Adb Server Asynchronously via <see cref="Task"/> /// </summary> /// <remarks>This should be used if you do not want the output of the command returned. Good for quick abd shell commands</remarks> /// <param name="command">Instance of <see cref="AdbCommand"/></param> /// <returns>Output of <paramref name="command"/> run on server</returns> public static Task ExecuteAdbCommandNoReturnAsync(AdbCommand command) { return(Task.Factory.StartNew(() => { Command.RunProcessNoReturn(AndroidController.Instance.ResourceDirectory + AdbExe, command.Command, command.Timeout); })); }
/// <summary> /// Executes an <see cref="AdbCommand"/> on the running Adb Server /// </summary> /// <remarks>This should be used if you do not want the output of the command returned. Good for quick abd shell commands</remarks> /// <param name="command">Instance of <see cref="AdbCommand"/></param> /// <returns>Output of <paramref name="command"/> run on server</returns> public static void ExecuteAdbCommandNoReturn(AdbCommand command) { lock (Lock) { Command.RunProcessNoReturn(AndroidController.Instance.ResourceDirectory + AdbExe, command.Command, command.Timeout); } }
/// <summary> /// Gets a Dictionary<c> string / ListingType></c> containing all the files and folders in the directory added as a parameter. /// </summary> /// The directory you'd like to list the files and folders from. /// E.G.: /system/bin/ /// <returns>See <see cref="Dictionary"/></returns> public Dictionary <string, ListingType> GetFilesAndDirectories(string location) { if (location == null || string.IsNullOrEmpty(location) || Regex.IsMatch(location, @"\s")) { throw new ArgumentException("rootDir must not be null or empty!"); } var filesAndDirs = new Dictionary <string, ListingType>(); AdbCommand cmd = null; if (_device.BusyBox.IsInstalled) { cmd = Adb.FormAdbShellCommand(_device, true, "busybox", "ls", "-a", "-p", "-l", location); } else { cmd = Adb.FormAdbShellCommand(_device, true, "ls", "-a", "-p", "-l", location); } using (var reader = new StringReader(Adb.ExecuteAdbCommand(cmd))) { string line = null; while (reader.Peek() != -1) { line = reader.ReadLine(); if (!string.IsNullOrEmpty(line) && !Regex.IsMatch(line, @"\s")) { filesAndDirs.Add(line, line.EndsWith("/") ? ListingType.Directory : ListingType.File); } } } return(filesAndDirs); }
/// <summary> /// Executes an <see cref="AdbCommand"/> on the running Adb Server Asynchronously via <see cref="Task"/> /// </summary> /// <remarks>This should be used if you want the output of the command returned</remarks> /// <param name="command">Instance of <see cref="AdbCommand"/></param> /// <param name="forceRegular">Forces Output of stdout, not stderror if any</param> /// <returns>Output of <paramref name="command"/> run on server</returns> public static Task <string> ExecuteAdbCommandAsync(AdbCommand command, bool forceRegular = false) { return(Task <string> .Factory.StartNew(() => { var result = Command.RunProcessReturnOutput(AndroidController.Instance.ResourceDirectory + AdbExe, command.Command, forceRegular, command.Timeout); return result; })); }
/// <summary> /// Executes an <see cref="AdbCommand"/> on the running Adb Server Asynchronously via <see cref="Task"/> /// </summary> /// <param name="command">Instance of <see cref="AdbCommand"/></param> /// <returns>Exit code of the process</returns> public static Task <int> ExecuteAdbCommandReturnExitCodeAsync(AdbCommand command) { return(Task <int> .Factory.StartNew(() => { var result = -1; result = Command.RunProcessReturnExitCode(AndroidController.Instance.ResourceDirectory + AdbExe, command.Command, command.Timeout); return result; })); }
/// <summary> /// Executes an <see cref="AdbCommand"/> on the running Adb Server /// </summary> /// <param name="command">Instance of <see cref="AdbCommand"/></param> /// <returns>Exit code of the process</returns> public static int ExecuteAdbCommandReturnExitCode(AdbCommand command) { var result = -1; lock (Lock) { result = Command.RunProcessReturnExitCode(AndroidController.Instance.ResourceDirectory + AdbExe, command.Command, command.Timeout); } return(result); }
/// <summary> /// Executes an <see cref="AdbCommand"/> on the running Adb Server /// </summary> /// <remarks>This should be used if you want the output of the command returned</remarks> /// <param name="command">Instance of <see cref="AdbCommand"/></param> /// <param name="forceRegular">Forces Output of stdout, not stderror if any</param> /// <returns>Output of <paramref name="command"/> run on server</returns> public static string ExecuteAdbCommand(AdbCommand command, bool forceRegular = false) { var result = ""; lock (Lock) { result = Command.RunProcessReturnOutput(AndroidController.Instance.ResourceDirectory + AdbExe, command.Command, forceRegular, command.Timeout); } return(result); }
/// <summary> /// Executes an <see cref="AdbCommand"/> on the running Adb Server /// </summary> /// <param name="command"></param> /// <returns></returns> public static async void ExecuteAdbCommandWithOutstream(AdbCommand command) { await Command.RunProcessOutputStream(AndroidController.Instance.ResourceDirectory + AdbExe, command.Command, command.Timeout); }