public bool LaunchApp(Device device) { string arguments = device.serial + " " + Settings.chosenApp; string launchAppResult = CommandLineExecutor.ExecuteScriptGetOutput(ADBScriptedFunctionsSettings.GetFunctionsFilePath( ADBScriptedFunctionsSettings.EScriptedFunction.getResolution), arguments, ADBScriptedFunctionsSettings.GetFilePathForOutput(ADBScriptedFunctionsSettings.EScriptedFunction.appLaunch, device) ).ToLower(); if (launchAppResult.Contains("error") || launchAppResult.Contains("exception")) { return(false); } else { return(true); } }
public Device GetDevicesResolution(Device device) { string command = "adb -s " + device.serial + " shell wm size"; string arguments = device.serial + " " + ADBScriptedFunctionsSettings.GetFilePathForOutput(ADBScriptedFunctionsSettings.EScriptedFunction.getResolution, device); string output = CommandLineExecutor.ExecuteScriptGetOutput(ADBScriptedFunctionsSettings.GetFunctionsFilePath(ADBScriptedFunctionsSettings.EScriptedFunction.getResolution), arguments, ADBScriptedFunctionsSettings.GetFilePathForOutput(ADBScriptedFunctionsSettings.EScriptedFunction.getResolution, device)); MatchCollection Matches = Regex.Matches(output, @"(\d+)"); if (Matches.Count == 2) // Correct case - two values was found (Height and Width) { device.resolutionY = Int32.Parse(Matches[0].Value); device.resolutionX = Int32.Parse(Matches[1].Value); return(device); } else // Incorrect case - output is different than expected { throw new ArgumentException("Could not get resolution for device " + device.serial + ". ADB output is: " + output); } }