private void install_Script() { if (File.Exists(selectedScriptPath)) { toolInstalling = true; saveToTestCaseList(); //push TestCaseList.txt ADB_Process.RunAdbCommand("push \"" + android_TestCaseList_Path + "\" /sdcard/ATST/Scripts/", true); //push Script ADB_Process.RunAdbCommand("push \"" + selectedScriptPath + "\" /sdcard/ATST/Scripts/"); String scriptSourceFolder = Path.GetDirectoryName(selectedScriptPath); try { String tcFunctionsPath = scriptSourceFolder + "\\TC.Functions"; if (File.Exists(tcFunctionsPath)) { ADB_Process.RunAdbCommand("push \"" + tcFunctionsPath + "\" /sdcard/ATST/Scripts/"); } } catch { } try { String variableSettingsPath = scriptSourceFolder + "\\Variable.Settings"; if (File.Exists(variableSettingsPath)) { ADB_Process.RunAdbCommand("push \"" + variableSettingsPath + "\" /sdcard/ATST/Scripts/"); } } catch { } toolInstalling = false; } }
private void checkConnectedDevice_Runnable() { while (deviceCheck_Flag) { switch (platform.ToLower()) { case "ce": if (CE_Process.Connected) { deviceList = new List <Device_Infomation>(); deviceList.Add(new Device_Infomation("WinCE device", "Connected")); } else { deviceList.Clear(); if (ConnectedDevicesChangedEventHandler != null) { ConnectedDevicesChangedEventHandler(this, new EventArgs()); } } break; case "android": { deviceList = ADB_Process.GetDeivcesList(); } break; } if (connetedDevicesCount != deviceList.Count) { connetedDevicesCount = deviceList.Count; if (ConnectedDevicesChangedEventHandler != null) { ConnectedDevicesChangedEventHandler(this, new EventArgs()); } } if (connetedDevicesCount == 1 && platform.ToLower().Equals("android")) { String rtnString = "", reguexNetCfg = @"wlan\d+\s*\S*\s*(?<IP>\s*\d+\s*.\s*\d+\s*.\s*\d+\s*.\s*\d+\s*)\s*\S*\s*\S*\s*(?<MAC>\s*[a-fA-f0-9]+\s*:\s*[a-fA-f0-9]+\s*:\s*[a-fA-f0-9]+\s*:\s*[a-fA-f0-9]+\s*:\s*[a-fA-f0-9]+\s*:\s*[a-fA-f0-9]+\s*)"; ADB_Process.RunAdbCommand("shell netcfg", ref rtnString); Regex regNetcfg = new Regex(reguexNetCfg); Match m = regNetcfg.Match(rtnString); if (m.Success) { device_IPAddress = m.Groups["IP"].Value.Equals("0.0.0.0") ? "" :m.Groups["IP"].Value; } else { device_IPAddress = ""; } } else { device_IPAddress = ""; } updateDeviceConnection(); Thread.Sleep(1000); } }
private void downloadLogFiles() { logList.Clear(); String remoteLogFolder = ""; switch (frmMain.Platform.ToLower()) { case "ce": { remoteLogFolder = @"\Application\"; String searchingCriterion = @"Log-*.txt"; logList = CE_Process.GetFileList(remoteLogFolder, searchingCriterion); foreach (String log in logList) { CE_Process.GetFileFormDevice(log, FormToolSettings.LogFolder + "\\"); } } break; case "android": remoteLogFolder = "/sdcard/"; String outputString = ""; String argGetLogFiles = "shell ls \"" + remoteLogFolder + "\"Log-*.txt"; #region Get log file list if (deviceID.Length > 0) { argGetLogFiles = "-s " + deviceID + " " + argGetLogFiles; } ADB_Process.RunAdbCommand(argGetLogFiles, ref outputString); if (outputString.ToLower().Contains("No such file or directory".ToLower())) { //Log file does not exist. } else { outputString = outputString.Replace("\r", "").TrimEnd('\n').Trim(); logList.AddRange(outputString.Split('\n')); } #endregion Get log file list #region pull the log file(s) to PC String argPullLog = ""; foreach (String log in logList) { argPullLog = "pull \"" + log + "\" \"" + FormToolSettings.LogFolder + "\""; if (deviceID.Length > 0) { argPullLog = "-s " + deviceID + " " + argPullLog; } ADB_Process.RunAdbCommand(argPullLog); } #endregion pull the log file(s) to PC break; default: break; } }
public FormMain() { InitializeComponent(); this.Text = Title + " V" + Version; ADB_Process.startADB(); loadDefaultSettings(); startDeivceCheck(); menuActionSelected(this.menuTRSReader, new EventArgs()); //Select Install Page by default; }
private void btnStop_Click(object sender, EventArgs e) { ADB_Process.RunAdbCommand("shell sh /sdcard/ATST/Core/ATST.Forcestop", false); updateStatus("Precondition process stoped.", Color.Black); }
private void install_APIFunctions() { ADB_Process.RunAdbCommand("install -r \"" + android_APIFunction_Path + "\"", true); }
private void checkDevProcessRunning_Runnable() { while (checkDev_Flag) { if (mainForm.ConnectedDevices.Count > 0) { if (!isDevChecking) { isDevChecking = true; String myPID = "", standardOutput = ""; try { #region GetMyPID ADB_Process.RunAdbCommand("shell cat /sdcard/ATST/ToolInfo/MyPID", ref standardOutput); myPID = standardOutput.Trim(new char[] { '\n', '\r' }); #endregion GetMyPID try { Convert.ToInt32(myPID); //myPID若存在必定為Integer型態,若沒有發生Exception代表myPID取得成功 #region 確認ATSP Process是否存在 ADB_Process.RunAdbCommand("shell ps " + myPID, ref standardOutput); String strReturnValue = standardOutput.Trim(new char[] { '\n', '\r' }); String[] myProcessStatus = strReturnValue.Split(new char[] { '\n', '\r' }); if (myProcessStatus.Count() > 1) { #region Check pause or running try { ADB_Process.RunAdbCommand("shell cat /sdcard/ATST/ToolInfo/Pause.txt", ref standardOutput, false); String pauseInfo = standardOutput.Trim(new char[] { '\n', '\r' }).Trim(); if (pauseInfo.Equals("1")) { Status = RunningStatus.Pause; } else { Status = RunningStatus.Run; } } catch { //If no pause.txt here, means it's running. Status = RunningStatus.Run; } #endregion Check pause or running } else { Status = RunningStatus.Stop; } #endregion 確認ATSP Process是否存在 } catch { Status = RunningStatus.Stop; //It's stoped when fail to get myPID. } if (tdRun == null) { if (Status.Equals(RunningStatus.Run)) { updateStatus("Tool is still running in the background now...", Color.Black); } else if (Status.Equals(RunningStatus.Pause)) { updateStatus("Tool is paused", Color.Black); } } } catch (Exception ex) { updateStatus("Exception occur : " + ex.Message, Color.Crimson); Status = RunningStatus.Stop; } finally { isDevChecking = false; } } } refreshButtonEnable(); Thread.Sleep(1000); } }