diff --git a/SharpAdbClient.Tests/AdbClientTests.cs b/SharpAdbClient.Tests/AdbClientTests.cs index 917897ea..b3b1328e 100644 --- a/SharpAdbClient.Tests/AdbClientTests.cs +++ b/SharpAdbClient.Tests/AdbClientTests.cs @@ -469,6 +469,18 @@ public void ConnectHostEndpointNullTest() AdbClient.Instance.Connect((string)null); } + [TestMethod] + public void DisconnectTest() + { + var requests = new string[] { "host:disconnect:localhost:5555" }; + + this.RunTest( + OkResponse, + NoResponseMessages, + requests, + () => AdbClient.Instance.Disconnect(new DnsEndPoint("localhost", 5555))); + } + [TestMethod] [DeploymentItem("logcat.bin")] public void ReadLogTest() diff --git a/SharpAdbClient.Tests/DummyAdbClient.cs b/SharpAdbClient.Tests/DummyAdbClient.cs index cd0e3425..283e31bd 100644 --- a/SharpAdbClient.Tests/DummyAdbClient.cs +++ b/SharpAdbClient.Tests/DummyAdbClient.cs @@ -131,5 +131,10 @@ public void Unroot(DeviceData device) { throw new NotImplementedException(); } + + public void Disconnect(DnsEndPoint endpoint) + { + throw new NotImplementedException(); + } } } diff --git a/SharpAdbClient/AdbClient.cs b/SharpAdbClient/AdbClient.cs index c5bb4592..204a852a 100644 --- a/SharpAdbClient/AdbClient.cs +++ b/SharpAdbClient/AdbClient.cs @@ -519,6 +519,20 @@ protected void Root(string request, DeviceData device) } } + public void Disconnect(DnsEndPoint endpoint) + { + if (endpoint == null) + { + throw new ArgumentNullException(nameof(endpoint)); + } + + using (IAdbSocket socket = this.adbSocketFactory(this.EndPoint)) + { + socket.SendAdbRequest($"host:disconnect:{endpoint.Host}:{endpoint.Port}"); + var response = socket.ReadAdbResponse(); + } + } + /// /// Throws an if the /// parameter is , and a diff --git a/SharpAdbClient/IAdbClient.cs b/SharpAdbClient/IAdbClient.cs index 89315ca0..e520354a 100644 --- a/SharpAdbClient/IAdbClient.cs +++ b/SharpAdbClient/IAdbClient.cs @@ -103,6 +103,14 @@ public interface IAdbClient /// void Connect(DnsEndPoint endpoint); + /// + /// Disconnects a remote device from this local ADB server. + /// + /// + /// The endpoint of the remote device to disconnect. + /// + void Disconnect(DnsEndPoint endpoint); + /// void SetDevice(IAdbSocket socket, DeviceData device); diff --git a/appveyor.yml b/appveyor.yml index 80e06330..04605329 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,9 @@ image: Visual Studio 2017 +# Temporary workaround. See https://appveyor.statuspage.io/incidents/m2vdvw39kdk8 +hosts: + api.nuget.org: 93.184.221.200 + version: 2.2.{build}.0 environment: