From 5e3d8260f160bda0e0a81635872f71797c1553f9 Mon Sep 17 00:00:00 2001 From: shamork Date: Wed, 5 Jun 2024 12:02:41 +0800 Subject: [PATCH] When connecting devices, prioritize the use of transport_id --- AdvancedSharpAdbClient.Tests/Dummys/DummyAdbSocket.cs | 5 ++++- AdvancedSharpAdbClient/AdbSocket.Async.cs | 5 ++++- AdvancedSharpAdbClient/AdbSocket.cs | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/AdvancedSharpAdbClient.Tests/Dummys/DummyAdbSocket.cs b/AdvancedSharpAdbClient.Tests/Dummys/DummyAdbSocket.cs index d877cad..36c35db 100644 --- a/AdvancedSharpAdbClient.Tests/Dummys/DummyAdbSocket.cs +++ b/AdvancedSharpAdbClient.Tests/Dummys/DummyAdbSocket.cs @@ -146,7 +146,10 @@ public void SetDevice(DeviceData device) // to a specific device if (device != null) { - SendAdbRequest($"host:transport:{device.Serial}"); + if(!string.IsNullOrWhiteSpace(device.TransportId) && uint.TryParse(device.TransportId,out var 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..6334e7f 100644 --- a/AdvancedSharpAdbClient/AdbSocket.Async.cs +++ b/AdvancedSharpAdbClient/AdbSocket.Async.cs @@ -262,7 +262,10 @@ public async Task SetDeviceAsync(DeviceData device, CancellationToken cancellati // to a specific device if (device != null) { - await SendAdbRequestAsync($"host:transport:{device.Serial}", cancellationToken).ConfigureAwait(false); + if(!string.IsNullOrWhiteSpace(device.TransportId) && uint.TryParse(device.TransportId,out var tid)) + await SendAdbRequestAsync($"host:transport-id:{tid}", cancellationToken).ConfigureAwait(false); + else + await SendAdbRequestAsync($"host:transport:{device.Serial}", cancellationToken).ConfigureAwait(false); try { diff --git a/AdvancedSharpAdbClient/AdbSocket.cs b/AdvancedSharpAdbClient/AdbSocket.cs index a063044..b3a16dd 100644 --- a/AdvancedSharpAdbClient/AdbSocket.cs +++ b/AdvancedSharpAdbClient/AdbSocket.cs @@ -401,7 +401,10 @@ public void SetDevice(DeviceData device) // to a specific device if (device != null) { - SendAdbRequest($"host:transport:{device.Serial}"); + if(!string.IsNullOrWhiteSpace(device.TransportId) && uint.TryParse(device.TransportId,out var tid)) + SendAdbRequest($"host:transport-id:{tid}"); + else + SendAdbRequest($"host:transport:{device.Serial}"); try {