public List <PackageListInfo> ListPackages(bool includeUninstalled = false, PackageListState showState = PackageListState.All, PackageSourceType showSource = PackageSourceType.All) { // list packages [options] filter // start [options] intent var builder = new ProcessArgumentBuilder(); runner.AddSerial(AdbSerial, builder); builder.Append("shell"); builder.Append("pm"); builder.Append("list"); builder.Append("packages"); builder.Append("-f"); builder.Append("-i"); if (showState == PackageListState.OnlyDisabled) { builder.Append("-d"); } else if (showState == PackageListState.OnlyEnabled) { builder.Append("-e"); } if (showSource == PackageSourceType.OnlySystem) { builder.Append("-s"); } else if (showSource == PackageSourceType.OnlyThirdParty) { builder.Append("-3"); } if (includeUninstalled) { builder.Append("-u"); } var r = runner.RunAdb(AndroidSdkHome, builder); var results = new List <PackageListInfo>(); const string rxPackageListInfo = "^package:(?<path>.*?)=(?<package>.*?)\\s+installer=(?<installer>.*?)$"; foreach (var line in r.StandardOutput) { var m = Regex.Match(line, rxPackageListInfo, RegexOptions.Singleline); var installPath = m?.Groups?["path"]?.Value; var packageName = m?.Groups?["package"]?.Value; var installer = m?.Groups?["installer"]?.Value; if (!string.IsNullOrEmpty(installPath) && !string.IsNullOrEmpty(packageName)) { results.Add(new PackageListInfo { InstallPath = new FileInfo(installPath), PackageName = packageName, Installer = installer, }); } } return(results); }
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)); }