public bool AnswerCall(int timeout_inMilliSeconds) { bool isPhoneRing = false; bool isTimeout = false; String argument = ""; argument += "-s " + device.ID + " shell input keyevent KEYCODE_HEADSETHOOK"; DateTime startTime = DateTime.Now; #region Wait the phone call do { isTimeout = DateTime.Now.Subtract(startTime).TotalMilliseconds > timeout_inMilliSeconds; isPhoneRing = CallState.Equals(CallStates.RINGING); Thread.Sleep(500); } while (!(isTimeout || isPhoneRing)); #endregion Wait the phone call if (isPhoneRing) { ADB_Process.RunAdbCommand(argument); //Headset } else { EndCall_InsLib(); } return(isPhoneRing); }
public string GetScreenResolution_InsLib() { String result = ""; String cmd = "-s " + device.ID + " shell dumpsys window"; ADB_Process.RunAdbCommand(cmd, ref result); Regex rgx = new Regex(@"(.+|)((i|I)(n|N)(i|I)(t|T)=)(?<Resolution>(\s|)(\d+)(\s|)(x|X)(\s|)(\d+)(\s|))(.+|)"); Match m = rgx.Match(result); if (m.Success) { result = m.Groups["Resolution"].Value.Replace(" ", ""); } else { result = "UNKNOW"; } return(result); }
public void KillLogcatprocess() { ADB_Process.KillLogcatProcess(device.ID); }
public void StartLogcatProcess(String folderOnDevice, bool isRecordRadioLog, bool isRecordEventLog) { ADB_Process.StartLogcatProcess(device.ID, folderOnDevice, isRecordRadioLog, isRecordEventLog); }
public void CaptureScreen_InsLib(Object path) { ADB_Process.CaptureScreen(device.ID, Convert.ToString(path)); }
public void KeyPress(int keycode) { String cmd = "-s " + device.ID + " shell input keyevent " + keycode.ToString(); ADB_Process.RunAdbCommand(cmd); }
public void Click(int X, int Y) { String cmd = "-s " + device.ID + " shell input tap " + X.ToString() + " " + Y.ToString(); ADB_Process.RunAdbCommand(cmd); }
public void RefreshState() { String refStr = ""; String cmd = "-s " + device.ID + " shell dumpsys telephony.registry"; if (simSlotNumber == 1) //SIM 2 { cmd += "2"; } ADB_Process.RunAdbCommand(cmd, ref refStr, false); foreach (String spilitedStr in refStr.Split('\n')) { String line = spilitedStr.Trim(); String[] spilitedLine = line.Split(new char[] { '=', ' ' }); int keywordIndex = 0; int valueIndex = 1; try { switch (spilitedLine[keywordIndex]) { #region CallState case "mCallState": valueIndex = 1; if (spilitedLine.Length > valueIndex && spilitedLine[valueIndex] != null) { callstate = (clsTelephony.CallStates)Enum.ToObject(typeof(clsTelephony.CallStates), Convert.ToInt32(spilitedLine[valueIndex])); } else { callstate = clsTelephony.CallStates.IDLE; } break; #endregion CallState #region Incoming Number case "mCallIncomingNumber": valueIndex = 1; if (spilitedLine.Length > valueIndex && spilitedLine[valueIndex] != null) { incommingCallNumber = spilitedLine[valueIndex]; } else { incommingCallNumber = ""; } break; #endregion Incoming Number #region Service State & Mibile Mode case "mServiceState": if (spilitedLine.Length > 1) { if (spilitedLine[1].ToUpper().StartsWith("SIM")) { valueIndex = 2; } else { valueIndex = 1; } if (spilitedLine.Length > valueIndex && spilitedLine[valueIndex] != null) { serviceState = (ServiceStates)Enum.ToObject(typeof(ServiceStates), Convert.ToInt32(spilitedLine[valueIndex])); } if (line.Contains("LTE") || line.Contains("WIMAX")) { MobileMoode |= MobileModes._4G; } if (line.Contains("CDMA") || line.Contains("UMTS") || line.Contains("EvDO") || line.Contains("HSDPA") || line.Contains("HSUPA") || line.Contains("HSPA")) { MobileMoode |= MobileModes._3G; } if (line.Contains("GPRS") || line.Contains("EDGE") || line.Contains("GSM")) { MobileMoode |= MobileModes._2G; } } break; #endregion Service State & Mibile Mode #region Signal Strength case "mSignalStrength": if (spilitedLine.Length > 1) { int strength = -999; try { if (spilitedLine[1].ToUpper().Contains("SIM")) //MTK Dual SIM Solution { valueIndex = spilitedLine.Length - 3; strength = Convert.ToInt32(spilitedLine[valueIndex]); strength = (int)strength / 4; } else { valueIndex = spilitedLine.Length - 6; strength = Convert.ToInt32(spilitedLine[valueIndex]); } strength = (strength == 0) ? -999 : strength; //Get 0 while no signal, replace it by -999 } catch { strength = -999; } signalStrength = strength; } break; #endregion Signal Strength #region DataActivity case "mDataActivity": valueIndex = 1; if (spilitedLine.Length > valueIndex && spilitedLine[valueIndex] != null) { dataActivity = (DataActivities)Enum.ToObject(typeof(DataActivities), Convert.ToInt32(spilitedLine[valueIndex])); } break; #endregion DataActivity #region DataConnectionState case "mDataConnectionState": valueIndex = 1; if (spilitedLine.Length > valueIndex && spilitedLine[valueIndex] != null) { dataConnectionState = (DataConnectionStates)Enum.ToObject(typeof(DataConnectionStates), Convert.ToInt32(spilitedLine[valueIndex])); } else { dataConnectionState = DataConnectionStates.UNKNOW; } break; #endregion DataConnectionState #region APN case "mDataConnectionApn": valueIndex = 1; if (spilitedLine.Length > valueIndex && spilitedLine[valueIndex] != null) { apnName = spilitedLine[valueIndex]; } else { apnName = ""; } break; #endregion APN #region This is a template //case "": // valueIndex = 1; // if(spilitedLine.Length>valueIndex && spilitedLine[valueIndex] != null){ // } // break; #endregion This is a template } } catch { } } isDataRefreshed = true; resetRefreshedFlag_Start(); }
public clsProductInfo(clsDevice device) { try { this.device = device; String refResult = ""; ADB_Process.RunAdbCommand(" -s " + device.ID + " shell cat /system/build.prop | grep \"product\"", ref refResult, false); foreach (String lineTemp in refResult.Split('\n')) { String line = lineTemp.Trim(); try { if (line.Contains("model")) { Model = line.Split('=')[1]; } else if (line.Contains("brand")) { Brand = line.Split('=')[1]; } else if (line.Contains("name")) { Name = line.Split('=')[1]; } else if (line.Contains("board")) { Board = line.Split('=')[1]; } else if (line.Contains(".abi2=")) { CPU_ABI2 = line.Split('=')[1]; } else if (line.Contains(".abi=")) { CPU_ABI = line.Split('=')[1]; } else if (line.Contains("manufacturer")) { Manufacturer = line.Split('=')[1]; } else if (line.Contains("language")) { Language = line.Split('=')[1]; } else if (line.Contains("region")) { Region = line.Split('=')[1]; } } catch { } } ADB_Process.RunAdbCommand(" -s " + device.ID + " shell cat /system/build.prop | grep \"rild.libpath\"", ref LibPath, false); LibPath = LibPath.Trim(); refResult = LibPath.ToLower(); if (refResult.Length > 0) { if (refResult.Contains("qc") || refResult.Contains("qualcomm")) { SolutionVendor = "Qualcomm"; } else if (refResult.Contains("mtk") || refResult.Contains("mediatek")) { SolutionVendor = "MTK"; } } } catch { } }
public void RefreshState() { String refStr = ""; ipAddress = ""; ssid = ""; macAddress = ""; signalLevel = 0; String cmd = "-s " + device.ID + " shell dumpsys wifi"; ADB_Process.RunAdbCommand(cmd, ref refStr, false); foreach (String spilitedStr in refStr.Split('\n')) { String line = spilitedStr.Trim(); String[] spilitedLine = line.Split(new char[] { '=', ' ' }); int keywordIndex = 0; int valueIndex = 1; try { switch (spilitedLine[keywordIndex]) { #region Enable case "Wi-Fi": valueIndex = 2; if (spilitedLine.Length > valueIndex && spilitedLine[valueIndex] != null) { enable = spilitedLine[valueIndex].ToLower().Equals("enable"); } else { enable = false; } break; #endregion Enable #region Stay-awake case "Stay-awake": // valueIndex = 2; // if (spilitedLine.Length > valueIndex && spilitedLine[valueIndex] != null) // { // } // else // { // } break; #endregion Stay-awake #region SSID case "ssid": valueIndex = 1; if (spilitedLine.Length > valueIndex && spilitedLine[valueIndex] != null) { ssid = spilitedLine[valueIndex]; } else { ssid = ""; } break; #endregion SSID #region IPAddress case "ip_address": valueIndex = 1; if (spilitedLine.Length > valueIndex && spilitedLine[valueIndex] != null) { ipAddress = spilitedLine[valueIndex]; } else { ipAddress = ""; } break; #endregion IPAddress #region MAC Address case "address": valueIndex = 1; if (spilitedLine.Length > valueIndex && spilitedLine[valueIndex] != null) { macAddress = spilitedLine[valueIndex]; } else { macAddress = ""; } break; #endregion MAC Address #region Signal Level case "mLastSignalLevel": valueIndex = 1; if (spilitedLine.Length > valueIndex && spilitedLine[valueIndex] != null) { signalLevel = Convert.ToInt32(spilitedLine[valueIndex]); } else { signalLevel = 0; } break; #endregion Signal Level } } catch { } } isDataRefreshed = true; resetRefreshedFlag_Start(); }
public void EndCall_InsLib() { ADB_Process.EndCall(device.ID); }
public void Dial(String dialNumber) { ADB_Process.Dial(device.ID, dialNumber); }