diff --git a/AdvancedSharpAdbClient.Tests/Dummys/DummyAdbSocket.cs b/AdvancedSharpAdbClient.Tests/Dummys/DummyAdbSocket.cs
index d877cad..2821b76 100644
--- a/AdvancedSharpAdbClient.Tests/Dummys/DummyAdbSocket.cs
+++ b/AdvancedSharpAdbClient.Tests/Dummys/DummyAdbSocket.cs
@@ -146,7 +146,14 @@ public void SetDevice(DeviceData device)
// to a specific device
if (device != null)
{
- SendAdbRequest($"host:transport:{device.Serial}");
+ if (uint.TryParse(device.TransportId, out uint tid))
+ {
+ SendAdbRequest($"host:transport-id:{tid}");
+ }
+ else
+ {
+ SendAdbRequest($"host:transport:{device.Serial}");
+ }
try
{
diff --git a/AdvancedSharpAdbClient/AdbSocket.Async.cs b/AdvancedSharpAdbClient/AdbSocket.Async.cs
index acaef12..367516e 100644
--- a/AdvancedSharpAdbClient/AdbSocket.Async.cs
+++ b/AdvancedSharpAdbClient/AdbSocket.Async.cs
@@ -262,7 +262,9 @@ public async Task SetDeviceAsync(DeviceData device, CancellationToken cancellati
// to a specific device
if (device != null)
{
- await SendAdbRequestAsync($"host:transport:{device.Serial}", cancellationToken).ConfigureAwait(false);
+ await (uint.TryParse(device.TransportId, out uint tid)
+ ? SendAdbRequestAsync($"host:transport-id:{tid}", cancellationToken).ConfigureAwait(false)
+ : SendAdbRequestAsync($"host:transport:{device.Serial}", cancellationToken).ConfigureAwait(false));
try
{
diff --git a/AdvancedSharpAdbClient/AdbSocket.cs b/AdvancedSharpAdbClient/AdbSocket.cs
index a063044..2cd6368 100644
--- a/AdvancedSharpAdbClient/AdbSocket.cs
+++ b/AdvancedSharpAdbClient/AdbSocket.cs
@@ -401,7 +401,14 @@ public void SetDevice(DeviceData device)
// to a specific device
if (device != null)
{
- SendAdbRequest($"host:transport:{device.Serial}");
+ if (uint.TryParse(device.TransportId, out uint tid))
+ {
+ SendAdbRequest($"host:transport-id:{tid}");
+ }
+ else
+ {
+ SendAdbRequest($"host:transport:{device.Serial}");
+ }
try
{
diff --git a/AdvancedSharpAdbClient/Models/DeviceData.cs b/AdvancedSharpAdbClient/Models/DeviceData.cs
index 3f1779d..d05fa30 100644
--- a/AdvancedSharpAdbClient/Models/DeviceData.cs
+++ b/AdvancedSharpAdbClient/Models/DeviceData.cs
@@ -107,7 +107,7 @@ public DeviceData(string data) : this()
///
/// if does not have a valid serial number; otherwise, .
///
- public bool IsEmpty => string.IsNullOrEmpty(Serial);
+ public bool IsEmpty => !uint.TryParse(TransportId, out _) && string.IsNullOrEmpty(Serial);
///
/// Creates a new instance of the class based on
@@ -208,9 +208,9 @@ public override int GetHashCode()
///
public override string ToString()
{
- if (string.IsNullOrEmpty(Serial))
+ if (IsEmpty)
{
- return $"An empty {GetType()} without {nameof(Serial)}";
+ return $"An empty {GetType()} without {nameof(TransportId)} and {nameof(Serial)}";
}
StringBuilder builder =
@@ -283,7 +283,7 @@ public static ref DeviceData EnsureDevice(ref DeviceData device, [CallerArgument
{
if (device.IsEmpty)
{
- throw new ArgumentOutOfRangeException(nameof(device), "You must specific a serial number for the device");
+ throw new ArgumentOutOfRangeException(nameof(device), "You must specific a transport ID or serial number for the device");
}
return ref device;
}