public static void Remove(string param, out string retValue) { string str = param.Substring("rm".Length + 1); string text; AdbCommand.ExecuteAdbCommand("shell rm " + str, out text); retValue = "Res=Pass"; }
public static void Pull(string param, out string retValue) { string str = param.Substring("pull".Length); string text; AdbCommand.ExecuteAdbCommand("pull" + str, out text); retValue = "Res=Pass"; }
/// <summary> /// 划屏幕指令 /// </summary> /// <param name="param"></param> /// <param name="retValue"></param> public static void Swipe(string param, out string retValue) { string str = param.Substring("swipe".Length + 1); string text; AdbCommand.ExecuteAdbCommand("shell input swipe " + str, out text); retValue = "Res=Pass"; }
/// <summary> /// 截屏 /// </summary> /// <param name="param"></param> /// <param name="retValue"></param> public static void ScreenCapture(string param, out string retValue) { string str = param.Substring("snap".Length + 1); string text; AdbCommand.ExecuteAdbCommand("shell screencap " + str, out text); retValue = "Res=Pass"; }
/// <summary> /// 点击 /// </summary> /// <param name="param"></param> /// <param name="retValue"></param> public static void TouchScreen(string param, out string retValue) { string str = param.Substring("touch".Length + 1); string text; AdbCommand.ExecuteAdbCommand("shell input tap " + str, out text); retValue = "Res=Pass"; }
/// <summary> /// apk 安装 /// </summary> /// <param name="apkPath"></param> /// <returns></returns> public static bool InstallApk(string apkPath) { string param = "install -r " + apkPath; string text; bool flag = AdbCommand.ExecuteAdbCommand(param, 20000, out text); Log.Debug("install " + apkPath + " return " + text); return(flag && text.Contains("Success")); }
/// <summary> /// Gps设置界面 /// </summary> /// <param name="param"></param> /// <param name="retValue"></param> public static void CtrlGps(string param, out string retValue) { string text; AdbCommand.ExecuteAdbCommand("shell am start -a android.settings.LOCATION_SOURCE_SETTINGS", out text); string str = param.Substring("ctrlGPS".Length + 1); string param2 = "shell input tap " + str; AdbCommand.ExecuteAdbCommand(param2); retValue = "Res=Pass"; }
/// <summary> /// 打开Wifi设置界面 /// </summary> /// <param name="param"></param> /// <param name="retValue"></param> public static void OpenWifiSettings(string param, out string retValue) { string text; AdbCommand.ExecuteAdbCommand("shell am start -a android.settings.WIFI_SETTINGS", out text); string str = param.Substring("openwifiset".Length + 1); string param2 = "shell input tap " + str; AdbCommand.ExecuteAdbCommand(param2); retValue = "Res=Pass"; }
/// <summary> /// SIM卡(adbcmd getval SIM1_prop_0=gsm.sim.state) /// </summary> /// <param name="name"></param> /// <param name="start"></param> /// <param name="length"></param> /// <param name="retValue"></param> public static void GetProp(string name, int start, int length, out string retValue) { string text; AdbCommand.ExecuteAdbCommand("shell getprop " + name, out text); if (start >= text.Length) { retValue = "Res=ArgumentException"; return; } length = Math.Min(length, text.Length - start); retValue = "Res=" + text.Substring(start, length); }
/// <summary> ///安装并启动 /// </summary> /// <returns></returns> public static bool InstallApkAndStart() { //string text = "GeneralDev.apk"; //if (!AdbCommand.InstallApk(text)) //{ // return false; //} string text2; AdbCommand.ExecuteAdbCommand("shell am start -n com.qwebob.generaldev/.GeneralDevActivity", out text2); if (text2.Contains("error") || text2.Contains("Error")) { return(false); } return(true); }
/// <summary> /// 包名和类名获取 /// </summary> /// <param name="retValue"></param> public static void GetFocusedActivity(out string retValue) { string text; AdbCommand.ExecuteAdbCommand("shell dumpsys activity | grep mResumedActivity", out text); int num = text.IndexOf("/."); if (num != -1) { string text2 = text.Substring(0, num); string text3 = text.Substring(num); int num2 = text2.LastIndexOf(' ') + 1; int num3 = text3.IndexOf(' ') + num; retValue = "Res=" + text.Substring(num2, num3 - num2); return; } retValue = "Res=ActivityNotFound"; }
/// <summary> /// 卸载apk /// </summary> /// <returns></returns> public static bool UninstallApk() { return(AdbCommand.UninstallApk("com.qwebob.generaldev")); }