Skip to content

Commit

Permalink
chore: Send no to the AVD creation
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Dec 9, 2024
1 parent 3c2c82b commit 108ee90
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
22 changes: 12 additions & 10 deletions UnoCheck/AndroidSdk/AvdManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public override FileInfo FindToolPath(DirectoryInfo androidSdkHome)
}


public (bool success, string[] output) Create(string name, string sdkId, string device = null, string abi = null, string path = null, string tag = null, bool force = false, bool interactive = false)
public (bool success, string[] output) Create(string name, string sdkId, string device = null, string path = null, string tag = null, bool force = false, bool interactive = false)
{
var args = new List<string> {
"create", "avd", "--name", name, "--package", $"\"{sdkId}\""
Expand All @@ -87,12 +87,6 @@ public override FileInfo FindToolPath(DirectoryInfo androidSdkHome)
args.Add($"\"{path}\"");
}

if (!string.IsNullOrEmpty(abi))
{
args.Add("--abi");
args.Add($"\"{abi}\"");
}

if (force)
args.Add("--force");

Expand All @@ -102,7 +96,7 @@ public override FileInfo FindToolPath(DirectoryInfo androidSdkHome)
args.Add($"\"{path}\"");
}

return AvdManagerRun(args.ToArray());
return AvdManagerRun("no", args.ToArray());
}

public (bool success, string[] output) Delete(string name)
Expand All @@ -128,7 +122,7 @@ public override FileInfo FindToolPath(DirectoryInfo androidSdkHome)
args.Add(newName);
}

return AvdManagerRun(args.ToArray());
return AvdManagerRun(null, args.ToArray());
}

static Regex rxListTargets = new Regex(@"id:\s+(?<id>[^\n]+)\s+Name:\s+(?<name>[^\n]+)\s+Type\s?:\s+(?<type>[^\n]+)\s+API level\s?:\s+(?<api>[^\n]+)\s+Revision\s?:\s+(?<revision>[^\n]+)", RegexOptions.Multiline | RegexOptions.Compiled);
Expand Down Expand Up @@ -284,7 +278,7 @@ public IEnumerable<AvdDevice> ListDevices()
}


(bool success, string[] output) AvdManagerRun(params string[] args)
(bool success, string[] output) AvdManagerRun(string forcedInput = null, params string[] args)
{
var adbManager = FindToolPath(AndroidSdkHome);
var java = Java;
Expand Down Expand Up @@ -331,6 +325,14 @@ public IEnumerable<AvdDevice> ListDevices()
Util.Log($"Running {proc.StartInfo.FileName} {proc.StartInfo.Arguments} in {proc.StartInfo.WorkingDirectory}");

proc.Start();

if (!string.IsNullOrWhiteSpace(forcedInput))
{
proc.StandardInput.WriteLine(forcedInput);
proc.StandardInput.Flush();
proc.StandardInput.Close();
}

proc.BeginOutputReadLine();
proc.BeginErrorReadLine();
proc.WaitForExit();
Expand Down
3 changes: 1 addition & 2 deletions UnoCheck/Checkups/AndroidEmulatorCheckup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ public override Task<DiagnosticResult> Examine(SharedState history)
device: preferredDevice?.Id,
tag: "google_apis",
force: true,
interactive: true,
abi: Util.IsArm64 ? armArch : "x86_64");
interactive: true);

foreach (var msg in result.output)
{
Expand Down

0 comments on commit 108ee90

Please sign in to comment.