Skip to content

Commit 5e3d826

Browse files
authored
When connecting devices, prioritize the use of transport_id
1 parent 987a519 commit 5e3d826

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

AdvancedSharpAdbClient.Tests/Dummys/DummyAdbSocket.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ public void SetDevice(DeviceData device)
146146
// to a specific device
147147
if (device != null)
148148
{
149-
SendAdbRequest($"host:transport:{device.Serial}");
149+
if(!string.IsNullOrWhiteSpace(device.TransportId) && uint.TryParse(device.TransportId,out var tid))
150+
SendAdbRequest($"host:transport-id:{tid}");
151+
else
152+
SendAdbRequest($"host:transport:{device.Serial}");
150153

151154
try
152155
{

AdvancedSharpAdbClient/AdbSocket.Async.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,10 @@ public async Task SetDeviceAsync(DeviceData device, CancellationToken cancellati
262262
// to a specific device
263263
if (device != null)
264264
{
265-
await SendAdbRequestAsync($"host:transport:{device.Serial}", cancellationToken).ConfigureAwait(false);
265+
if(!string.IsNullOrWhiteSpace(device.TransportId) && uint.TryParse(device.TransportId,out var tid))
266+
await SendAdbRequestAsync($"host:transport-id:{tid}", cancellationToken).ConfigureAwait(false);
267+
else
268+
await SendAdbRequestAsync($"host:transport:{device.Serial}", cancellationToken).ConfigureAwait(false);
266269

267270
try
268271
{

AdvancedSharpAdbClient/AdbSocket.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,10 @@ public void SetDevice(DeviceData device)
401401
// to a specific device
402402
if (device != null)
403403
{
404-
SendAdbRequest($"host:transport:{device.Serial}");
404+
if(!string.IsNullOrWhiteSpace(device.TransportId) && uint.TryParse(device.TransportId,out var tid))
405+
SendAdbRequest($"host:transport-id:{tid}");
406+
else
407+
SendAdbRequest($"host:transport:{device.Serial}");
405408

406409
try
407410
{

0 commit comments

Comments
 (0)