Skip to content

Add AvdManagerRunner.ListDeviceProfilesAsync() for device profile enumeration#325

Open
rmarinho wants to merge 1 commit intomainfrom
features/321-list-device-profiles
Open

Add AvdManagerRunner.ListDeviceProfilesAsync() for device profile enumeration#325
rmarinho wants to merge 1 commit intomainfrom
features/321-list-device-profiles

Conversation

@rmarinho
Copy link
Copy Markdown
Member

@rmarinho rmarinho commented Apr 8, 2026

Summary

Add a method to enumerate available AVD device profiles (hardware definitions) from \�vdmanager list device.

Changes

  • Added \AvdDeviceProfile\ record (\Id, \Name, \Oem, \Tag) in \Models/\
  • Added \AvdManagerRunner.ListDeviceProfilesAsync()\ — runs \�vdmanager list device\ and parses output
  • Internal \ParseDeviceListOutput()\ static method for testability
  • 6 unit tests covering multiple profiles, empty output, Windows newlines, missing fields
  • Updated \PublicAPI.Unshipped.txt\ for both
    et10.0\ and
    etstandard2.0\

Closes #321

…meration

Add ListDeviceProfilesAsync() and ParseDeviceListOutput() to
AvdManagerRunner. Runs 'avdmanager list device' and parses the output
into AvdDeviceProfile records (Id, Name, Oem, Tag).

Includes AvdDeviceProfile record model, 6 unit tests, and PublicAPI
entries for both net10.0 and netstandard2.0.

Closes #321

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 8, 2026 16:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class support in Xamarin.Android.Tools.AndroidSdk for enumerating AVD device profiles (hardware definitions) by running avdmanager list device, returning strongly-typed results for consumers (IDE extensions, GUI tools, CLIs).

Changes:

  • Introduced AvdDeviceProfile record model (Id, Name, Oem, Tag).
  • Added AvdManagerRunner.ListDeviceProfilesAsync() plus ParseDeviceListOutput() to parse avdmanager list device output.
  • Added unit tests for parsing behavior across multiple profiles, empty/header-only output, missing name fallback, and Windows newlines; updated PublicAPI unshipped entries for both TFMs.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/Xamarin.Android.Tools.AndroidSdk-Tests/AvdManagerRunnerTests.cs Adds parsing-focused unit tests for device profile enumeration.
src/Xamarin.Android.Tools.AndroidSdk/Runners/AvdManagerRunner.cs Implements the new API to run avdmanager list device and parse results.
src/Xamarin.Android.Tools.AndroidSdk/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt Declares the new public API surface for netstandard2.0.
src/Xamarin.Android.Tools.AndroidSdk/PublicAPI/net10.0/PublicAPI.Unshipped.txt Declares the new public API surface for net10.0.
src/Xamarin.Android.Tools.AndroidSdk/Models/AvdDeviceProfile.cs Adds the new public model type representing a device profile.

{
using var stdout = new StringWriter ();
using var stderr = new StringWriter ();
var psi = ProcessUtils.CreateProcessStartInfo (avdManagerPath, "list", "device");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output from this command is horrendous:

> & 'C:\Program Files (x86)\Android\android-sdk\cmdline-tools\latest\bin\avdmanager.bat' list device
Available devices definitions:
id: 0 or "automotive_1024p_landscape"
    Name: Automotive (1024p landscape)
    OEM : Google
    Tag : android-automotive-playstore
---------
id: 1 or "automotive_1080p_landscape"
    Name: Automotive (1080p landscape)
    OEM : Google
    Tag : android-automotive
---------

If you read the --help output, they have a --compact option "suitable for scripts":

> & 'C:\Program Files (x86)\Android\android-sdk\cmdline-tools\latest\bin\avdmanager.bat' list device --help
Error: Flag '--help' is not valid for 'list device'.

Usage:
      avdmanager [global options] list device [action options]
      Global options:
  -s --silent     : Silent mode, shows errors only.
  -v --verbose    : Verbose mode, shows errors, warnings and all messages.
     --clear-cache: Clear the SDK Manager repository manifest cache.
  -h --help       : Help on a specific command.

Action "list device":
  Lists existing devices.
Options:
  -0 --null    : Terminates lines with \0 instead of \n (e.g. for xargs -0)
                 Only used by --compact.
  -c --compact : Compact output (suitable for scripts)

So, we should parse this output instead:

> & 'C:\Program Files (x86)\Android\android-sdk\cmdline-tools\latest\bin\avdmanager.bat' list device --compact
automotive_1024p_landscape
automotive_1080p_landscape
automotive_1408p_landscape_with_google_apis
automotive_1408p_landscape_with_play
automotive_distant_display
automotive_distant_display_with_play
automotive_large_portrait
automotive_portrait
automotive_ultrawide
Galaxy Nexus
desktop_large
desktop_medium
medium_phone
medium_tablet
Nexus 10
Nexus 4
Nexus 5
Nexus 5X
Nexus 6
Nexus 6P
Nexus 7 2013
Nexus 7
Nexus 9
Nexus One
Nexus S
pixel
pixel_2
pixel_2_xl
pixel_3
pixel_3_xl
pixel_3a
pixel_3a_xl
pixel_4
pixel_4_xl
pixel_4a
pixel_5
pixel_6
pixel_6_pro
pixel_6a
pixel_7
pixel_7_pro
pixel_7a
pixel_8
pixel_8_pro
pixel_8a
pixel_9
pixel_9_pro
pixel_9_pro_fold
pixel_9_pro_xl
pixel_c
pixel_fold
pixel_tablet
pixel_xl
resizable
desktop_small
small_phone
tv_1080p
tv_4k
tv_720p
wearos_large_round
wearos_rect
wearos_small_round
wearos_square
2.7in QVGA
2.7in QVGA slider
3.2in HVGA slider (ADP1)
3.2in QVGA (ADP2)
3.3in WQVGA
3.4in WQVGA
3.7 FWVGA slider
3.7in WVGA (Nexus One)
4in WVGA (Nexus S)
4.65in 720p (Galaxy Nexus)
4.7in WXGA
5.1in WVGA
5.4in FWVGA
6.7in Foldable
7in WSVGA (Tablet)
7.4in Rollable
7.6in Foldable
8in Foldable
10.1in WXGA (Tablet)
13.5in Freeform

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add AvdManagerRunner.ListDeviceProfilesAsync() for AVD device profile enumeration

3 participants