-
Notifications
You must be signed in to change notification settings - Fork 31
Add AVD skin enumeration API #326
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -122,6 +122,66 @@ public async Task DeleteAvdAsync (string name, CancellationToken cancellationTok | |
| ProcessUtils.ThrowIfFailed (exitCode, $"avdmanager delete avd --name {name}", stderr); | ||
| } | ||
|
|
||
| /// <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) | ||
| { | ||
| if (string.IsNullOrWhiteSpace (sdkPath)) | ||
| throw new ArgumentException ("SDK path must not be empty.", nameof (sdkPath)); | ||
|
|
||
| return EnumerateSkins (sdkPath, cancellationToken); | ||
| } | ||
|
|
||
| internal static IReadOnlyList<string> EnumerateSkins (string sdkPath, CancellationToken cancellationToken = default) | ||
| { | ||
| var skins = new SortedSet<string> (StringComparer.OrdinalIgnoreCase); | ||
|
|
||
| // Standalone skins: <sdk>/skins/<skinName>/ | ||
| var skinsDir = Path.Combine (sdkPath, "skins"); | ||
| AddSkinDirectories (skins, skinsDir); | ||
|
|
||
| // 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); | ||
|
Comment on lines
+148
to
+158
|
||
| } | ||
| } | ||
| } catch (IOException) { | ||
| } catch (UnauthorizedAccessException) { | ||
| } | ||
| } | ||
| } catch (IOException) { | ||
| } catch (UnauthorizedAccessException) { | ||
| } | ||
| } | ||
|
|
||
| return skins.ToList (); | ||
| } | ||
|
|
||
| static void AddSkinDirectories (SortedSet<string> skins, string directory) | ||
| { | ||
| if (!Directory.Exists (directory)) | ||
| return; | ||
| try { | ||
| foreach (var skinDir in Directory.EnumerateDirectories (directory)) | ||
| skins.Add (Path.GetFileName (skinDir)); | ||
| } catch (IOException) { | ||
| } catch (UnauthorizedAccessException) { | ||
| } | ||
| } | ||
|
|
||
| internal static IReadOnlyList<AvdInfo> ParseAvdListOutput (string output) | ||
| { | ||
| var avds = new List<AvdInfo> (); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR description says the new API is
ListAvdSkinsAsync(sdkPath)but the implementation adds a synchronousListAvdSkins(...)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.