public static List <string> AdbShell(this ICakeContext context, string shellCommand, AdbToolSettings settings = null) { var t = GetAdbTool(context); return(t.Shell(shellCommand, settings)); }
public static List <AdbPermissionGroupInfo> PmListPermissions(this ICakeContext context, bool onlyDangerous = false, bool onlyUserVisible = false, AdbToolSettings settings = null) { var t = GetAdbTool(context); return(t.ListPermissions(onlyDangerous, onlyUserVisible, settings)); }
public List <AdbDeviceInfo> GetDevices(AdbToolSettings settings = null) { var devices = new List <AdbDeviceInfo>(); if (settings == null) { settings = new AdbToolSettings(); } //adb devices -l var builder = new ProcessArgumentBuilder(); builder.Append("devices"); builder.Append("-l"); var p = RunProcess(settings, builder, new ProcessSettings { RedirectStandardOutput = true, }); p.WaitForExit(); foreach (var line in p.GetStandardOutput().Skip(1)) { var parts = Regex.Split(line, "\\s+"); var d = new AdbDeviceInfo { Serial = parts[0].Trim() }; foreach (var part in parts.Skip(1)) { var bits = part.Split(new[] { ':' }, 2); if (bits == null || bits.Length != 2) { continue; } switch (bits[0].ToLower()) { case "usb": d.Usb = bits[1]; break; case "product": d.Product = bits[1]; break; case "model": d.Model = bits[1]; break; case "device": d.Device = bits[1]; break; } } devices.Add(d); } return(devices); }
public static void PmCreateUser(this ICakeContext context, string userName, AdbToolSettings settings = null) { var t = GetAdbTool(context); t.CreateUser(userName, settings); }
public static int PmGetMaxUsers(this ICakeContext context, AdbToolSettings settings = null) { var t = GetAdbTool(context); return(t.GetMaxUsers(settings)); }
public static AdbInstallLocation PmGetInstallLocation(this ICakeContext context, AdbToolSettings settings = null) { var t = GetAdbTool(context); return(t.GetInstallLocation(settings)); }
public static List <AdbPackageListInfo> PmListPackages(this ICakeContext context, bool includeUninstalled = false, PackageListState showState = PackageListState.All, PackageSourceType showSource = PackageSourceType.All, AdbToolSettings settings = null) { var t = GetAdbTool(context); return(t.ListPackages(includeUninstalled, showState, showSource, settings)); }
public static void AdbDisconnect(this ICakeContext context, string deviceIp = null, int port = 5555, AdbToolSettings settings = null) { var t = GetAdbTool(context); t.Disconnect(deviceIp, port, settings); }
public bool Push(DirectoryPath localDirectorySource, DirectoryPath remoteDirectoryDestination, AdbToolSettings settings = null) { return(push(settings, localDirectorySource.MakeAbsolute(environment).FullPath, remoteDirectoryDestination.MakeAbsolute(environment).FullPath)); }
public static string AdbVersion(this ICakeContext context, AdbToolSettings settings = null) { var t = GetAdbTool(context); return(t.Version(settings)); }
public static void AdbStartServer(this ICakeContext context, AdbToolSettings settings = null) { var t = GetAdbTool(context); t.StartServer(settings); }
public static bool AdbWaitForEmulatorToBoot(this ICakeContext context, TimeSpan timeout, AdbToolSettings settings = null) { var booted = false; for (int i = 0; i < timeout.TotalSeconds; i++) { if (AdbShell(context, "getprop dev.bootcomplete", settings).Any(l => l.Contains("1"))) { booted = true; break; } else { System.Threading.Thread.Sleep(1000); } } return(booted); }
public static void AdbScreenRecord(this ICakeContext context, FilePath saveToLocalFile, System.Threading.CancellationToken?recordingCancelToken = null, TimeSpan?timeLimit = null, int?bitrateMbps = null, int?width = null, int?height = null, bool rotate = false, bool logVerbose = false, AdbToolSettings settings = null) { var t = GetAdbTool(context); t.ScreenRecord(saveToLocalFile, recordingCancelToken, timeLimit, bitrateMbps, width, height, rotate, logVerbose, settings); }
public static void AdbScreenCapture(this ICakeContext context, FilePath saveToLocalFile, AdbToolSettings settings = null) { var t = GetAdbTool(context); t.ScreenCapture(saveToLocalFile, settings); }
public static void PmRevoke(this ICakeContext context, string packageName, string permission, AdbToolSettings settings = null) { var t = GetAdbTool(context); t.Revoke(packageName, permission, settings); }
public List <string> Logcat(AdbLogcatOptions options = null, string filter = null, AdbToolSettings settings = null) { // logcat[option][filter - specs] if (settings == null) { settings = new AdbToolSettings(); } if (options == null) { options = new AdbLogcatOptions(); } // adb uninstall -k <package> // -k keeps data & cache dir var builder = new ProcessArgumentBuilder(); AddSerial(settings.Serial, builder); builder.Append("logcat"); if (options.BufferType != AdbLogcatBufferType.Main) { builder.Append("-b"); builder.Append(options.BufferType.ToString().ToLowerInvariant()); } if (options.Clear || options.PrintSize) { if (options.Clear) { builder.Append("-c"); } else if (options.PrintSize) { builder.Append("-g"); } } else { // Always dump, since we want to return and not listen to logcat forever // in the future might be nice to add an alias that takes a cancellation token // and can pipe output until that token is cancelled. //if (options.Dump) builder.Append("-d"); if (options.OutputFile != null) { builder.Append("-f"); builder.AppendQuoted(options.OutputFile.MakeAbsolute(environment).FullPath); if (options.NumRotatedLogs.HasValue) { builder.Append("-n"); builder.Append(options.NumRotatedLogs.Value.ToString()); } var kb = options.LogRotationKb ?? 16; builder.Append("-r"); builder.Append(kb.ToString()); } if (options.SilentFilter) { builder.Append("-s"); } if (options.Verbosity != AdbLogcatOutputVerbosity.Brief) { builder.Append("-v"); builder.Append(options.Verbosity.ToString().ToLowerInvariant()); } } var output = new List <string>(); RunAdb(settings, builder, out output); return(output); }
public static void PmSetInstallLocation(this ICakeContext context, AdbInstallLocation location, AdbToolSettings settings = null) { var t = GetAdbTool(context); t.SetInstallLocation(location, settings); }
public void ScreenRecord(FilePath saveToLocalFile, System.Threading.CancellationToken?recordingCancelToken = null, TimeSpan?timeLimit = null, int?bitrateMbps = null, int?width = null, int?height = null, bool rotate = false, bool logVerbose = false, AdbToolSettings settings = null) { // screenrecord[options] filename if (settings == null) { settings = new AdbToolSettings(); } var guid = Guid.NewGuid().ToString(); var remoteFile = "/sdcard/" + guid + ".mp4"; // adb uninstall -k <package> // -k keeps data & cache dir var builder = new ProcessArgumentBuilder(); AddSerial(settings.Serial, builder); builder.Append("shell"); builder.Append("screenrecord"); if (timeLimit.HasValue) { builder.Append("--time-limit"); builder.Append(((int)timeLimit.Value.TotalSeconds).ToString()); } if (bitrateMbps.HasValue) { builder.Append("--bit-rate"); builder.Append((bitrateMbps.Value * 1000000).ToString()); } if (width.HasValue && height.HasValue) { builder.Append("--size"); builder.Append("{0}x{1}", width, height); } if (rotate) { builder.Append("--rotate"); } if (logVerbose) { builder.Append("--verbose"); } builder.Append(remoteFile); var output = new List <string>(); if (recordingCancelToken.HasValue) { RunAdb(settings, builder, recordingCancelToken.Value, out output); } else { RunAdb(settings, builder, out output); } Pull(remoteFile, saveToLocalFile, settings); Shell("rm " + remoteFile, settings); }
public static void PmSetPermissionEnforced(this ICakeContext context, string permission, bool enforced, AdbToolSettings settings = null) { var t = GetAdbTool(context); t.SetPermissionEnforced(permission, enforced, settings); }
public static FilePath PmPathToPackage(this ICakeContext context, string packageName, AdbToolSettings settings = null) { var t = GetAdbTool(context); return(t.PathToPackage(packageName, settings)); }
public static void PmTrimCaches(this ICakeContext context, string desiredFreeSpace, AdbToolSettings settings = null) { var t = GetAdbTool(context); t.TrimCaches(desiredFreeSpace, settings); }
public static void PmUninstall(this ICakeContext context, string packageName, bool keepDataAndCache = false, AdbToolSettings settings = null) { var t = GetAdbTool(context); t.Uninstall(packageName, keepDataAndCache, settings); }
public static void PmRemoveUser(this ICakeContext context, string userId, AdbToolSettings settings = null) { var t = GetAdbTool(context); t.RemoveUser(userId, settings); }
public static void PmClear(this ICakeContext context, string packageName, AdbToolSettings settings = null) { var t = GetAdbTool(context); t.Clear(packageName, settings); }
public static List <string> PmListPermissionGroups(this ICakeContext context, AdbToolSettings settings = null) { var t = GetAdbTool(context); return(t.ListPermissionGroups(settings)); }
public static void PmEnable(this ICakeContext context, string packageOrComponent, AdbToolSettings settings = null) { var t = GetAdbTool(context); t.Enable(packageOrComponent, settings); }
public static List <string> PmListLibraries(this ICakeContext context, AdbToolSettings settings = null) { var t = GetAdbTool(context); return(t.ListLibraries(settings)); }
public static void PmDisableUser(this ICakeContext context, string packageOrComponent, string forUser = null, AdbToolSettings settings = null) { var t = GetAdbTool(context); t.DisableUser(packageOrComponent, forUser, settings); }
public bool Pull(FilePath remoteFileSource, FilePath localFileDestination, AdbToolSettings settings = null) { return(pull(settings, remoteFileSource.MakeAbsolute(environment).FullPath, localFileDestination.MakeAbsolute(environment).FullPath)); }
public static List <AdbDeviceInfo> AdbDevices(this ICakeContext context, AdbToolSettings settings = null) { var t = GetAdbTool(context); return(t.GetDevices(settings)); }