Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion AdvancedSharpAdbClient.Tests/Dummys/DummyAdbSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 3 additions & 1 deletion AdvancedSharpAdbClient/AdbSocket.Async.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
9 changes: 8 additions & 1 deletion AdvancedSharpAdbClient/AdbSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
8 changes: 4 additions & 4 deletions AdvancedSharpAdbClient/Models/DeviceData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public DeviceData(string data) : this()
/// <summary>
/// <see langword="false"/> if <see cref="DeviceData"/> does not have a valid serial number; otherwise, <see langword="true"/>.
/// </summary>
public bool IsEmpty => string.IsNullOrEmpty(Serial);
public bool IsEmpty => !uint.TryParse(TransportId, out _) && string.IsNullOrEmpty(Serial);

/// <summary>
/// Creates a new instance of the <see cref="DeviceData"/> class based on
Expand Down Expand Up @@ -208,9 +208,9 @@ public override int GetHashCode()
/// <inheritdoc/>
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 =
Expand Down Expand Up @@ -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;
}
Expand Down