Skip to content

Commit bb947a5

Browse files
rmarinhoCopilot
andcommitted
Add AdbRunner for adb CLI operations
- AdbRunner: Device management, server control - AndroidDeviceInfo: Model for device metadata with state/transport enums API: - GetDevicesAsync(): List connected devices and emulators - StartServerAsync(): Start ADB server - KillServerAsync(): Stop ADB server - WaitForDeviceAsync(): Wait for device to be ready - GetDevicePropertyAsync(): Query device properties Addresses #279 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ea4dd6c commit bb947a5

2 files changed

Lines changed: 550 additions & 0 deletions

File tree

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Collections.Generic;
5+
6+
namespace Xamarin.Android.Tools
7+
{
8+
/// <summary>
9+
/// Device type classification.
10+
/// </summary>
11+
public enum AndroidDeviceType
12+
{
13+
Physical,
14+
Emulator
15+
}
16+
17+
/// <summary>
18+
/// Device connection state.
19+
/// </summary>
20+
public enum AndroidDeviceState
21+
{
22+
Unknown,
23+
Device, // Connected and ready
24+
Offline, // Device is offline
25+
Unauthorized, // USB debugging not authorized
26+
Bootloader, // Device is in bootloader mode
27+
Recovery, // Device is in recovery mode
28+
Sideload // Device is in sideload mode
29+
}
30+
31+
/// <summary>
32+
/// Information about a connected Android device or running emulator.
33+
/// </summary>
34+
public class AndroidDeviceInfo
35+
{
36+
/// <summary>
37+
/// Device serial number (e.g., "emulator-5554", "R3CN90XXXXX").
38+
/// </summary>
39+
public string Serial { get; set; } = string.Empty;
40+
41+
/// <summary>
42+
/// Display name of the device.
43+
/// </summary>
44+
public string? Name { get; set; }
45+
46+
/// <summary>
47+
/// Device manufacturer (e.g., "Google", "Samsung").
48+
/// </summary>
49+
public string? Manufacturer { get; set; }
50+
51+
/// <summary>
52+
/// Device model (e.g., "Pixel 6", "sdk_gphone64_arm64").
53+
/// </summary>
54+
public string? Model { get; set; }
55+
56+
/// <summary>
57+
/// Android SDK/API version (e.g., "35", "34").
58+
/// </summary>
59+
public string? SdkVersion { get; set; }
60+
61+
/// <summary>
62+
/// Android release version (e.g., "15", "14").
63+
/// </summary>
64+
public string? ReleaseVersion { get; set; }
65+
66+
/// <summary>
67+
/// CPU ABI (e.g., "arm64-v8a", "x86_64").
68+
/// </summary>
69+
public string? Abi { get; set; }
70+
71+
/// <summary>
72+
/// Device type (physical or emulator).
73+
/// </summary>
74+
public AndroidDeviceType Type { get; set; }
75+
76+
/// <summary>
77+
/// Device connection state.
78+
/// </summary>
79+
public AndroidDeviceState State { get; set; }
80+
81+
/// <summary>
82+
/// Whether this is an emulator.
83+
/// </summary>
84+
public bool IsEmulator => Type == AndroidDeviceType.Emulator;
85+
86+
/// <summary>
87+
/// Whether the device is connected and ready.
88+
/// </summary>
89+
public bool IsOnline => State == AndroidDeviceState.Device;
90+
91+
/// <summary>
92+
/// AVD name if this is an emulator.
93+
/// </summary>
94+
public string? AvdName { get; set; }
95+
96+
/// <summary>
97+
/// Additional device properties from getprop.
98+
/// </summary>
99+
public Dictionary<string, string> Properties { get; set; } = new Dictionary<string, string> ();
100+
101+
public override string ToString () => $"{Serial} ({Model ?? Name ?? "Unknown"}) - {State}";
102+
}
103+
}

0 commit comments

Comments
 (0)