-
Notifications
You must be signed in to change notification settings - Fork 31
Add AdbRunner for adb CLI operations #283
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
Merged
+1,244
−19
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2dac552
Add AdbRunner for adb CLI operations
rmarinho a42544f
Address review: exit code check, internal visibility, doc fix
rmarinho 93aca4b
Add IEnumerable<string> overload for ParseAdbDevicesOutput
rmarinho b9be955
Add optional logger callback to BuildDeviceDescription and MergeDevic…
rmarinho e689e82
Fix nullable reference type warnings for dotnet/android compatibility
rmarinho eb63cb5
Fix regex to use explicit adb states and support tab separators
rmarinho f68600d
Log exception in GetEmulatorAvdNameAsync bare catch block
rmarinho 90ef8b5
Add emulator console fallback for AVD name resolution
rmarinho 25e7711
Simplify AdbRunner constructor: require full adb path
rmarinho b4d9a5f
AdbRunner: add ThrowIfFailed StringWriter overload, remove string Par…
rmarinho 850cb39
Replace null-forgiving operators with pattern matching, use switch ex…
rmarinho da3000c
Address review feedback: integration tests and regex comment
rmarinho 72291e2
Apply suggestions from code review
rmarinho f0ae5a0
Remove QueryAvdNameViaConsoleAsync TcpClient fallback
rmarinho ebe9099
Fix CS8620: use pattern matching for nullable serial in WaitForDevice…
rmarinho b22af8b
Return IReadOnlyList from ParseAdbDevicesOutput and MergeDevicesAndEm…
rmarinho 5bd9b01
Inline a one-line method
jonathanpeppers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/Xamarin.Android.Tools.AndroidSdk/Models/AdbDeviceInfo.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| // 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 an Android device or emulator from 'adb devices -l' output. | ||
| /// Mirrors the metadata produced by dotnet/android's GetAvailableAndroidDevices task. | ||
| /// </summary> | ||
| public class AdbDeviceInfo | ||
| { | ||
| /// <summary> | ||
| /// Serial number of the device (e.g., "emulator-5554", "0A041FDD400327"). | ||
| /// For non-running emulators, this is the AVD name. | ||
| /// </summary> | ||
| public string Serial { get; set; } = string.Empty; | ||
|
|
||
| /// <summary> | ||
| /// Human-friendly description of the device (e.g., "Pixel 7 API 35", "Pixel 6 Pro"). | ||
| /// </summary> | ||
| public string Description { get; set; } = string.Empty; | ||
|
|
||
| /// <summary> | ||
| /// Device type: Device or Emulator. | ||
| /// </summary> | ||
| public AdbDeviceType Type { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Device status: Online, Offline, Unauthorized, NoPermissions, NotRunning, Unknown. | ||
| /// </summary> | ||
| public AdbDeviceStatus Status { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// AVD name for emulators (e.g., "pixel_7_api_35"). Null for physical devices. | ||
| /// </summary> | ||
| public string? AvdName { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Device model from adb properties (e.g., "Pixel_6_Pro"). | ||
| /// </summary> | ||
| public string? Model { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Product name from adb properties (e.g., "raven"). | ||
| /// </summary> | ||
| public string? Product { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Device code name from adb properties (e.g., "raven"). | ||
| /// </summary> | ||
| public string? Device { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Transport ID from adb properties. | ||
| /// </summary> | ||
| public string? TransportId { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Whether this device is an emulator. | ||
| /// </summary> | ||
| public bool IsEmulator => Type == AdbDeviceType.Emulator; | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/Xamarin.Android.Tools.AndroidSdk/Models/AdbDeviceStatus.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // 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 the status of an Android device. | ||
| /// </summary> | ||
| public enum AdbDeviceStatus | ||
| { | ||
| Online, | ||
| Offline, | ||
| Unauthorized, | ||
| NoPermissions, | ||
| NotRunning, | ||
| Unknown | ||
| } |
13 changes: 13 additions & 0 deletions
13
src/Xamarin.Android.Tools.AndroidSdk/Models/AdbDeviceType.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // 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 the type of an Android device. | ||
| /// </summary> | ||
| public enum AdbDeviceType | ||
| { | ||
| Device, | ||
| Emulator | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.