/// <summary> /// Start the logcat watcher task. /// </summary> public void Start() { DeviceLogger.Log("Starting logcat watcher.."); if (_flushLogcat) { _terminal.ExecuteAdbCommand(new[] { "logcat", "-c" }); } _cancellationTokenSource = new CancellationTokenSource(); var commands = new List <string> { "shell", "logcat", "-s" }; commands.AddRange(_tags); var process = _terminal.StartAdbProcessWithoutShell(commands.ToArray()); var cancellationToken = _cancellationTokenSource.Token; _task = Task.Run( () => { process.StandardOutput.BaseStream.ReadTimeout = 500; while (true) { try { var output = process.StandardOutput.ReadLine(); if (!string.IsNullOrEmpty(output)) { NewOutput(output); } } catch (TimeoutException) { } if (_cancellationTokenSource.IsCancellationRequested) { DeviceLogger.Log("Logcat watcher cancellation requested, stopping task."); return; } } }, cancellationToken); }
/// <summary> /// Forward ports to the android device. /// </summary> private void ForwardPorts() { DeviceLogger.Log("Forwarding ports"); _terminal.ExecuteAdbCommand("forward", $"tcp:{_localPort}", $"tcp:{DevicePort}"); }
private string ExecuteCommand(params string[] arguments) { return(_terminal.ExecuteAdbCommand(arguments)); }