-
Notifications
You must be signed in to change notification settings - Fork 33
Add AvdManagerRunner.ListDeviceProfilesAsync() for device profile enumeration #325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Xamarin.Android.Tools; | ||
|
|
||
| /// <summary> | ||
| /// Represents a hardware device profile (e.g., "pixel_7", "Nexus 5X") from <c>avdmanager list device --compact</c>. | ||
| /// </summary> | ||
| public record AvdDeviceProfile (string Id); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -122,6 +122,35 @@ public async Task DeleteAvdAsync (string name, CancellationToken cancellationTok | |
| ProcessUtils.ThrowIfFailed (exitCode, $"avdmanager delete avd --name {name}", stderr); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Lists available device profiles (hardware definitions) using <c>avdmanager list device --compact</c>. | ||
| /// </summary> | ||
| public async Task<IReadOnlyList<AvdDeviceProfile>> ListDeviceProfilesAsync (CancellationToken cancellationToken = default) | ||
| { | ||
|
Comment on lines
+125
to
+129
|
||
| using var stdout = new StringWriter (); | ||
| using var stderr = new StringWriter (); | ||
| var psi = ProcessUtils.CreateProcessStartInfo (avdManagerPath, "list", "device", "--compact"); | ||
| logger.Invoke (TraceLevel.Verbose, "Running: avdmanager list device --compact"); | ||
| var exitCode = await ProcessUtils.StartProcess (psi, stdout, stderr, cancellationToken, environmentVariables).ConfigureAwait (false); | ||
|
|
||
| ProcessUtils.ThrowIfFailed (exitCode, "avdmanager list device --compact", stderr, stdout); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 💡 Pattern — Nice: passing both Rule: Include stdout in error diagnostics (Postmortem |
||
|
|
||
| return ParseCompactDeviceListOutput (stdout.ToString ()); | ||
| } | ||
|
|
||
| internal static IReadOnlyList<AvdDeviceProfile> ParseCompactDeviceListOutput (string output) | ||
| { | ||
| var profiles = new List<AvdDeviceProfile> (); | ||
|
|
||
| foreach (var line in output.Split ('\n')) { | ||
| var trimmed = line.Trim (); | ||
| if (trimmed.Length > 0) | ||
| profiles.Add (new AvdDeviceProfile (trimmed)); | ||
| } | ||
|
|
||
| return profiles; | ||
| } | ||
|
|
||
| internal static IReadOnlyList<AvdInfo> ParseAvdListOutput (string output) | ||
| { | ||
| var avds = new List<AvdInfo> (); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.