public static IEnumerable <Avd> ListAvdsFromFiles() { var folder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".android", "avd"); if (Directory.Exists(folder)) { var files = Directory.EnumerateFiles(folder, "*.ini", SearchOption.TopDirectoryOnly); foreach (var file in files) { Avd avd = default; try { var ini = Avd.ParseIni(file); if (ini.TryGetValue("path", out var avdPath)) { if (Directory.Exists(avdPath)) { avd = Avd.From(avdPath); } } } catch { } if (avd != null) { yield return(avd); } } } }
public IEnumerable <Avd> ListAvds() { var r = new List <Avd>(); var lines = run("list", "avd"); var str = string.Join("\n", lines); var matches = rxListAvds.Matches(str); if (matches != null && matches.Count > 0) { foreach (Match m in matches) { var path = m.Groups?["path"]?.Value; if (!string.IsNullOrEmpty(path) && Directory.Exists(path)) { var avd = Avd.From(path); var parsedName = m.Groups?["name"]?.Value; if (string.IsNullOrEmpty(avd.Name) && !string.IsNullOrEmpty(parsedName)) { avd.Name = parsedName; } var parsedDevice = m.Groups?["device"]?.Value; if (string.IsNullOrEmpty(avd.Device) && !string.IsNullOrEmpty(parsedDevice)) { avd.Device = parsedDevice; } var parsedTarget = m.Groups?["target"]?.Value; if (string.IsNullOrEmpty(avd.Target) && !string.IsNullOrEmpty(parsedTarget)) { avd.Target = parsedTarget; } var parsedBasedOn = m.Groups?["basedon"]?.Value; if (string.IsNullOrEmpty(avd.BasedOn) && !string.IsNullOrEmpty(parsedBasedOn)) { avd.BasedOn = parsedBasedOn; } r.Add(avd); } } } return(r); }