Conversation
Add AvdManagerRunner.ListAvdSkinsAsync() static method to enumerate available AVD skins from the SDK skins/ directory and system image skin directories. Returns a deduplicated, sorted list of skin names. Includes 6 unit tests with temp directory structures and PublicAPI entries for both net10.0 and netstandard2.0. Closes #322 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a new AvdManagerRunner API to enumerate available Android emulator skins by scanning the Android SDK install, enabling tooling (IDE/extensions/CLI) to offer skin selection when creating AVDs.
Changes:
- Added
AvdManagerRunner.ListAvdSkinsAsync(sdkPath)plus internalEnumerateSkins()implementation. - Added NUnit coverage for standalone skins, system image skins, sorting/deduping, and invalid inputs.
- Updated
PublicAPI.Unshipped.txtfornetstandard2.0andnet10.0.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/Xamarin.Android.Tools.AndroidSdk-Tests/AvdManagerRunnerTests.cs | Adds unit tests validating skin enumeration behavior and input validation. |
| src/Xamarin.Android.Tools.AndroidSdk/Runners/AvdManagerRunner.cs | Implements skin enumeration and exposes the new public API. |
| src/Xamarin.Android.Tools.AndroidSdk/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt | Declares the new public API for netstandard2.0. |
| src/Xamarin.Android.Tools.AndroidSdk/PublicAPI/net10.0/PublicAPI.Unshipped.txt | Declares the new public API for net10.0. |
src/Xamarin.Android.Tools.AndroidSdk/Runners/AvdManagerRunner.cs
Outdated
Show resolved
Hide resolved
src/Xamarin.Android.Tools.AndroidSdk/Runners/AvdManagerRunner.cs
Outdated
Show resolved
Hide resolved
- Rename ListAvdSkinsAsync → ListAvdSkins (synchronous API that doesn't hide sync I/O behind Task.FromResult) - Check CancellationToken during directory enumeration loops - Catch IOException/UnauthorizedAccessException per subtree so one bad directory doesn't fail the entire listing - Fix doc comment to mention system-images scan - Update PublicAPI files and tests to match new signature Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| /// <summary> | ||
| /// Lists available AVD skins by scanning the SDK <c>skins/</c> directory | ||
| /// and <c>system-images/.../skins/</c> directories. | ||
| /// </summary> | ||
| /// <param name="sdkPath">Root path of the Android SDK.</param> | ||
| /// <param name="cancellationToken">Cancellation token checked during directory enumeration.</param> | ||
| /// <returns>Sorted list of unique skin directory names.</returns> | ||
| public static IReadOnlyList<string> ListAvdSkins (string sdkPath, CancellationToken cancellationToken = default) | ||
| { |
There was a problem hiding this comment.
PR description says the new API is ListAvdSkinsAsync(sdkPath) but the implementation adds a synchronous ListAvdSkins(...) method. Either update the PR description/issues to match the shipped API, or rename/shape the API to match the intended async contract so consumers aren’t surprised.
| // System image skins: <sdk>/system-images/<api>/<tag>/<abi>/skins/<skinName>/ | ||
| var systemImagesDir = Path.Combine (sdkPath, "system-images"); | ||
| if (Directory.Exists (systemImagesDir)) { | ||
| try { | ||
| foreach (var apiDir in Directory.EnumerateDirectories (systemImagesDir)) { | ||
| cancellationToken.ThrowIfCancellationRequested (); | ||
| try { | ||
| foreach (var tagDir in Directory.EnumerateDirectories (apiDir)) { | ||
| foreach (var abiDir in Directory.EnumerateDirectories (tagDir)) { | ||
| var imgSkinsDir = Path.Combine (abiDir, "skins"); | ||
| AddSkinDirectories (skins, imgSkinsDir); |
There was a problem hiding this comment.
cancellationToken is documented as being checked during directory enumeration, but it’s only checked once per API directory and isn’t checked while iterating tag/ABI/skin directories (and AddSkinDirectories doesn’t observe it). Please either tighten cancellation handling (check in inner loops and/or pass the token down) or update the docs/parameter if cancellation isn’t intended to be honored for the full scan.
Summary
Add a method to list available Android emulator skins from the SDK's
skins/directory and system image skin directories.Changes
AvdManagerRunner.ListAvdSkinsAsync(sdkPath)static method<sdk>/skins/for standalone skins<sdk>/system-images/<api>/<tag>/<abi>/skins/for bundled skinsIReadOnlyList<string>EnumerateSkins()method for testabilityPublicAPI.Unshipped.txtfor bothnet10.0andnetstandard2.0Related
Closes #322