public SDBCapability(SDBDeviceInfo device) { string[] args = { "-s", device.Serial, SDBProtocol.capability }; string returnValue; using (ProcessProxy p = new ProcessProxy()) { p.StartInfo.FileName = SDBLib.GetSdbFilePath(); p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.Arguments = string.Join(" ", args); Debug.WriteLine("{0} SDBCapability command '{1}'", DateTime.Now, p.StartInfo.Arguments); p.Start(); returnValue = p.StandardOutput.ReadToEnd().Replace("\r", string.Empty); p.WaitForExit(); } IsSupported = !string.IsNullOrEmpty(returnValue); if (IsSupported) { GenCapDic(returnValue); } }
protected bool StartRemoteApplication(string sdkCode) { string appId = _sessionConfiguration.AppId; DebugWriteToOutput($"Starting launch_app({appId}; SDK={sdkCode})"); ProcessProxy launchAppProcess = SDBLib.CreateSdbProcess(true, true); if (launchAppProcess == null) { WriteToOutput(SDBLib.FormatSdbRunResult(SDBLib.SdbRunResult.CreateProcessError)); return(false); } launchAppProcess.StartInfo.Arguments = GetSdbLaunchCommand(sdkCode); string firstOutputLine = null; _launchAppStartedEvent.Reset(); launchAppProcess.OutputDataReceived += ((sender, e) => { if (!String.IsNullOrEmpty(e.Data)) { firstOutputLine = e.Data; _launchAppStartedEvent.Set(); DebugWriteToOutput($"{appId} : {e.Data}"); } }); launchAppProcess.ErrorDataReceived += ((sender, e) => { if (!String.IsNullOrEmpty(e.Data)) { DebugWriteToOutput($"{appId} [StdErr] {e.Data}"); } }); launchAppProcess.Exited += (object sender, EventArgs e) => { DebugWriteToOutput($"launch_app({appId}) finished"); launchAppProcess.Dispose(); }; Debug.WriteLine("{0} {1} StartRemoteApplication command '{2}'", DateTime.Now, this.ToString(), launchAppProcess.StartInfo.Arguments); launchAppProcess.Start(); DebugWriteProcessToOutput(launchAppProcess); try { launchAppProcess.BeginOutputReadLine(); launchAppProcess.BeginErrorReadLine(); if (_launchAppStartedEvent.WaitOne(30000)) { if (firstOutputLine.EndsWith("launch failed")) { WriteToOutput($"launch_app({appId}) failed"); return(false); } } } catch (Exception ex) { Debug.WriteLine(ex.Message); } return(true); }
private void StartCMD() { returnMsgs = new Queue <string>(); Debug.Log("启动cmd"); proxy = new ProcessProxy(); proxy.Start(); }