Skip to content
This repository was archived by the owner on Jul 13, 2026. It is now read-only.
This repository was archived by the owner on Jul 13, 2026. It is now read-only.

Add ADB device tracking (host:track-devices) for real-time device monitoring #323

Description

@rmarinho

Summary

Add support for real-time device connection/disconnection monitoring via the ADB daemon socket protocol (host:track-devices-l), similar to what the AndroidSdk.Adbd NuGet package provides.

Motivation

The existing AdbRunner.GetDevicesAsync() does a one-shot adb devices -l call. For IDE extensions and developer tools that need to react immediately when devices connect/disconnect (USB plug, emulator boot, WiFi pairing), polling is suboptimal.

The ADB daemon exposes a host:track-devices-l socket command that pushes device list updates in real-time. This is a well-known protocol used by Android Studio and other tooling.

Currently, consumers like MAUI Sherpa depend on the separate AndroidSdk.Adbd NuGet (from redth/android-tools) for this functionality. Consolidating it into Xamarin.Android.Tools.AndroidSdk would reduce the dependency surface.

Proposed API

`csharp
public class AdbDeviceTracker : IDisposable
{
public AdbDeviceTracker(string? sdkPath = null, int port = 5037);

/// Starts tracking. Calls onDevicesChanged whenever the device list changes.
public Task StartAsync(
Action<IReadOnlyList<AdbDeviceInfo>> onDevicesChanged,
CancellationToken cancellationToken = default);
/// Current snapshot of tracked devices.
public IReadOnlyList<AdbDeviceInfo> CurrentDevices { get; }
public void Dispose();

}
`

Implementation Notes

  • Connect to localhost:5037 (ADB daemon)
  • Send host:track-devices-l command
  • Parse length-prefixed device list updates as they arrive
  • Auto-reconnect on connection drops with backoff
  • Reuse existing AdbDeviceInfo model

Related

  • The AndroidSdk.Adbd NuGet (redth/android-tools) has a working implementation via AdbdClient
  • The maui-labs CLI does not currently have this feature either

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions