diff --git a/SharpAdbClient.Tests/AdbClientTests.cs b/SharpAdbClient.Tests/AdbClientTests.cs index 65a4f882..1fa9e5c2 100644 --- a/SharpAdbClient.Tests/AdbClientTests.cs +++ b/SharpAdbClient.Tests/AdbClientTests.cs @@ -20,7 +20,28 @@ public class AdbClientTests : SocketBasedTests [ExpectedException(typeof(ArgumentNullException))] public void ConstructorNullTest() { - new AdbClient(null); + new AdbClient(null, Factories.AdbSocketFactory); + } + + [TestMethod] + [ExpectedException(typeof(NotSupportedException))] + public void ConstructorInvalidEndPointTest() + { + new AdbClient(new CustomEndPoint(), Factories.AdbSocketFactory); + } + + [TestMethod] + public void ConstructorTest() + { + var adbClient = new AdbClient(); + Assert.IsNotNull(adbClient); + Assert.IsNotNull(adbClient.EndPoint); + Assert.IsInstanceOfType(adbClient.EndPoint, typeof(IPEndPoint)); + + var endPoint = (IPEndPoint)adbClient.EndPoint; + + Assert.AreEqual(IPAddress.Loopback, endPoint.Address); + Assert.AreEqual(AdbClient.AdbServerPort, endPoint.Port); } [TestMethod] diff --git a/SharpAdbClient.Tests/AdbServerTests.cs b/SharpAdbClient.Tests/AdbServerTests.cs index 849d5f99..4d337b8b 100644 --- a/SharpAdbClient.Tests/AdbServerTests.cs +++ b/SharpAdbClient.Tests/AdbServerTests.cs @@ -1,4 +1,5 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; +using Moq; using SharpAdbClient.Exceptions; using System; using System.Net; @@ -9,30 +10,36 @@ namespace SharpAdbClient.Tests [TestClass] public class AdbServerTests { + private Func adbCommandLineClientFactory; private DummyAdbSocket socket; private DummyAdbCommandLineClient commandLineClient; + private Func adbSocketFactory; + private AdbClient adbClient; + private AdbServer adbServer; [TestInitialize] public void Initialize() { - Factories.Reset(); - this.socket = new DummyAdbSocket(); - Factories.AdbSocketFactory = (endPoint) => this.socket; + this.adbSocketFactory = (endPoint) => this.socket; this.commandLineClient = new DummyAdbCommandLineClient(); - Factories.AdbCommandLineClientFactory = (version) => this.commandLineClient; + this.adbCommandLineClientFactory = (version) => this.commandLineClient; + + this.adbClient = new AdbClient(AdbClient.DefaultEndPoint, this.adbSocketFactory); + this.adbServer = new AdbServer(this.adbClient, this.adbCommandLineClientFactory); } [TestMethod] public void GetStatusNotRunningTest() { - Factories.AdbSocketFactory = (endPoint) => - { - throw new SocketException(AdbServer.ConnectionRefused); - }; + var adbClientMock = new Mock(); + adbClientMock.Setup(c => c.GetAdbVersion()) + .Throws(new SocketException(AdbServer.ConnectionRefused)); - var status = AdbServer.Instance.GetStatus(); + var adbServer = new AdbServer(adbClientMock.Object, this.adbCommandLineClientFactory); + + var status = adbServer.GetStatus(); Assert.IsFalse(status.IsRunning); Assert.IsNull(status.Version); } @@ -43,7 +50,7 @@ public void GetStatusRunningTest() this.socket.Responses.Enqueue(AdbResponse.OK); this.socket.ResponseMessages.Enqueue("0020"); - var status = AdbServer.Instance.GetStatus(); + var status = this.adbServer.GetStatus(); Assert.AreEqual(0, this.socket.Responses.Count); Assert.AreEqual(0, this.socket.ResponseMessages.Count); @@ -58,24 +65,30 @@ public void GetStatusRunningTest() [ExpectedException(typeof(SocketException))] public void GetStatusOtherSocketExceptionTest() { - Factories.AdbSocketFactory = (endPoint) => + this.adbSocketFactory = (endPoint) => { throw new SocketException(); }; - var status = AdbServer.Instance.GetStatus(); + this.adbClient = new AdbClient(AdbClient.DefaultEndPoint, this.adbSocketFactory); + this.adbServer = new AdbServer(this.adbClient, this.adbCommandLineClientFactory); + + var status = this.adbServer.GetStatus(); } [TestMethod] [ExpectedException(typeof(Exception))] public void GetStatusOtherExceptionTest() { - Factories.AdbSocketFactory = (endPoint) => + this.adbSocketFactory = (endPoint) => { throw new Exception(); }; - var status = AdbServer.Instance.GetStatus(); + this.adbClient = new AdbClient(AdbClient.DefaultEndPoint, this.adbSocketFactory); + this.adbServer = new AdbServer(this.adbClient, this.adbCommandLineClientFactory); + + var status = this.adbServer.GetStatus(); } [TestMethod] @@ -85,7 +98,7 @@ public void StartServerAlreadyRunningTest() this.socket.Responses.Enqueue(AdbResponse.OK); this.socket.ResponseMessages.Enqueue("0020"); - var result = AdbServer.Instance.StartServer(null, false); + var result = this.adbServer.StartServer(null, false); Assert.AreEqual(StartServerResult.AlreadyRunning, result); @@ -100,7 +113,7 @@ public void StartServerOutdatedRunningNoExecutableTest() this.socket.Responses.Enqueue(AdbResponse.OK); this.socket.ResponseMessages.Enqueue("0010"); - var result = AdbServer.Instance.StartServer(null, false); + var result = this.adbServer.StartServer(null, false); Assert.AreEqual(1, this.socket.Requests.Count); Assert.AreEqual("host:version", this.socket.Requests[0]); @@ -110,12 +123,15 @@ public void StartServerOutdatedRunningNoExecutableTest() [ExpectedException(typeof(AdbException))] public void StartServerNotRunningNoExecutableTest() { - Factories.AdbSocketFactory = (endPoint) => + this.adbSocketFactory = (endPoint) => { throw new SocketException(AdbServer.ConnectionRefused); }; - var result = AdbServer.Instance.StartServer(null, false); + this.adbClient = new AdbClient(AdbClient.DefaultEndPoint, this.adbSocketFactory); + this.adbServer = new AdbServer(this.adbClient, this.adbCommandLineClientFactory); + + var result = this.adbServer.StartServer(null, false); } [TestMethod] @@ -128,7 +144,7 @@ public void StartServerOutdatedRunningTest() Assert.IsFalse(this.commandLineClient.ServerStarted); - var result = AdbServer.Instance.StartServer("adb.exe", false); + var result = this.adbServer.StartServer("adb.exe", false); Assert.IsTrue(this.commandLineClient.ServerStarted); @@ -140,16 +156,19 @@ public void StartServerOutdatedRunningTest() [TestMethod] public void StartServerNotRunningTest() { - Factories.AdbSocketFactory = (endPoint) => + this.adbSocketFactory = (endPoint) => { throw new SocketException(AdbServer.ConnectionRefused); }; + this.adbClient = new AdbClient(AdbClient.DefaultEndPoint, this.adbSocketFactory); + this.adbServer = new AdbServer(this.adbClient, this.adbCommandLineClientFactory); + this.commandLineClient.Version = new Version(1, 0, 32); Assert.IsFalse(this.commandLineClient.ServerStarted); - var result = AdbServer.Instance.StartServer("adb.exe", false); + var result = this.adbServer.StartServer("adb.exe", false); Assert.IsTrue(this.commandLineClient.ServerStarted); } @@ -164,7 +183,7 @@ public void StartServerIntermediateRestartRequestedRunningTest() Assert.IsFalse(this.commandLineClient.ServerStarted); - var result = AdbServer.Instance.StartServer("adb.exe", true); + var result = this.adbServer.StartServer("adb.exe", true); Assert.IsTrue(this.commandLineClient.ServerStarted); @@ -183,7 +202,7 @@ public void StartServerIntermediateRestartNotRequestedRunningTest() Assert.IsFalse(this.commandLineClient.ServerStarted); - var result = AdbServer.Instance.StartServer("adb.exe", false); + var result = this.adbServer.StartServer("adb.exe", false); Assert.IsFalse(this.commandLineClient.ServerStarted); @@ -191,32 +210,11 @@ public void StartServerIntermediateRestartNotRequestedRunningTest() Assert.AreEqual("host:version", this.socket.Requests[0]); } - [TestMethod] - public void ConstructorTest() - { - var adbServer = new AdbServer(); - Assert.IsNotNull(adbServer); - Assert.IsNotNull(adbServer.EndPoint); - Assert.IsInstanceOfType(adbServer.EndPoint, typeof(IPEndPoint)); - - var endPoint = (IPEndPoint)adbServer.EndPoint; - - Assert.AreEqual(IPAddress.Loopback, endPoint.Address); - Assert.AreEqual(AdbServer.AdbServerPort, endPoint.Port); - } - - [TestMethod] - [ExpectedException(typeof(NotSupportedException))] - public void ConstructorInvalidEndPointTest() - { - var adbServer = new AdbServer(new CustomEndPoint()); - } - [TestMethod] [ExpectedException(typeof(ArgumentNullException))] - public void ConstructorNullEndPointTest() + public void ConstructorAdbClientNullTest() { - var adbServer = new AdbServer(null); + var adbServer = new AdbServer(null, this.adbCommandLineClientFactory); } } } diff --git a/SharpAdbClient.Tests/DeviceCommands/DeviceExtensionsTests.cs b/SharpAdbClient.Tests/DeviceCommands/DeviceExtensionsTests.cs index 4965f3d2..007ad9fa 100644 --- a/SharpAdbClient.Tests/DeviceCommands/DeviceExtensionsTests.cs +++ b/SharpAdbClient.Tests/DeviceCommands/DeviceExtensionsTests.cs @@ -143,7 +143,13 @@ public void ListProcessesTest() @"1 (init) S 0 0 0 0 -1 1077944576 2680 83280 0 179 0 67 16 39 20 0 1 0 2 17735680 143 18446744073709551615 134512640 135145076 4288071392 4288070744 134658736 0 0 0 65536 18446744071580117077 0 0 17 1 0 0 0 0 0 135152736 135165080 142131200 4288073690 4288073696 4288073696 4288073714 0 2 (kthreadd) S 0 0 0 0 -1 2129984 0 0 0 0 0 0 0 0 20 0 1 0 2 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744071579254310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 (ksoftirqd/0) S 2 0 0 0 -1 69238848 0 0 0 0 0 23 0 0 20 0 1 0 7 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744071579284070 0 0 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0"); + adbClient.Commands.Add("cat /proc/1/cmdline /proc/1/stat /proc/2/cmdline /proc/2/stat /proc/3/cmdline /proc/3/stat ", +@" +1 (init) S 0 0 0 0 -1 1077944576 2680 83280 0 179 0 67 16 39 20 0 1 0 2 17735680 143 18446744073709551615 134512640 135145076 4288071392 4288070744 134658736 0 0 0 65536 18446744071580117077 0 0 17 1 0 0 0 0 0 135152736 135165080 142131200 4288073690 4288073696 4288073696 4288073714 0 +2 (kthreadd) S 0 0 0 0 -1 2129984 0 0 0 0 0 0 0 0 20 0 1 0 2 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744071579254310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +3 (ksoftirqd/0) S 2 0 0 0 -1 69238848 0 0 0 0 0 23 0 0 20 0 1 0 7 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744071579284070 0 0 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0"); var device = new DeviceData(); var processes = device.ListProcesses().ToArray(); diff --git a/SharpAdbClient.Tests/DeviceMonitorTests.cs b/SharpAdbClient.Tests/DeviceMonitorTests.cs index 64426f60..ab6a7cfa 100644 --- a/SharpAdbClient.Tests/DeviceMonitorTests.cs +++ b/SharpAdbClient.Tests/DeviceMonitorTests.cs @@ -140,6 +140,8 @@ public void DeviceConnectedTest() [TestMethod] public void StartInitialDeviceListTest() { + this.Socket.WaitForNewData = true; + using (DeviceMonitor monitor = new DeviceMonitor(this.Socket)) { DeviceMonitorSink sink = new DeviceMonitorSink(monitor); @@ -226,6 +228,8 @@ public void AdbKilledTest() var dummyAdbServer = new DummyAdbServer(); AdbServer.Instance = dummyAdbServer; + this.Socket.WaitForNewData = true; + using (DeviceMonitor monitor = new DeviceMonitor(this.Socket)) { base.RunTest( @@ -250,7 +254,7 @@ public void AdbKilledTest() [TestCategory("IntegrationTest")] public void DisposeMonitorTest() { - using (DeviceMonitor monitor = new DeviceMonitor(new AdbSocket(AdbServer.Instance.EndPoint))) + using (DeviceMonitor monitor = new DeviceMonitor(new AdbSocket(AdbClient.Instance.EndPoint))) { monitor.Start(); Thread.Sleep(1000); diff --git a/SharpAdbClient.Tests/DummyAdbClient.cs b/SharpAdbClient.Tests/DummyAdbClient.cs index fbcfc466..f5727d23 100644 --- a/SharpAdbClient.Tests/DummyAdbClient.cs +++ b/SharpAdbClient.Tests/DummyAdbClient.cs @@ -18,6 +18,9 @@ public Dictionary Commands public Collection ReceivedCommands { get; private set; } = new Collection(); + public EndPoint EndPoint + { get; private set; } + public void Connect(DnsEndPoint endpoint) { throw new NotImplementedException(); diff --git a/SharpAdbClient.Tests/SocketBasedTests.cs b/SharpAdbClient.Tests/SocketBasedTests.cs index 3442ff62..aed143bf 100644 --- a/SharpAdbClient.Tests/SocketBasedTests.cs +++ b/SharpAdbClient.Tests/SocketBasedTests.cs @@ -66,10 +66,10 @@ protected void Initialize(bool integrationTest, bool doDispose) this.IntegrationTest = false; #endif - this.EndPoint = AdbServer.Instance.EndPoint; + this.EndPoint = AdbClient.Instance.EndPoint; this.Socket = (IDummyAdbSocket)Factories.AdbSocketFactory(this.EndPoint); - AdbClient.Instance = new AdbClient(AdbServer.Instance.EndPoint); + AdbClient.Instance = new AdbClient(); } /// diff --git a/SharpAdbClient/AdbClient.cs b/SharpAdbClient/AdbClient.cs index 3b743107..5c6adb15 100644 --- a/SharpAdbClient/AdbClient.cs +++ b/SharpAdbClient/AdbClient.cs @@ -44,6 +44,11 @@ public class AdbClient : IAdbClient /// public const string DefaultEncoding = "ISO-8859-1"; + /// + /// The port at which the Android Debug Bridge server listens by default. + /// + public const int AdbServerPort = 5037; + /// /// The default port to use when connecting to a device over TCP/IP. /// @@ -54,20 +59,41 @@ public class AdbClient : IAdbClient /// private static IAdbClient instance = null; + private Func adbSocketFactory; + + /// + /// Initializes a new instance of the class. + /// + public AdbClient() + : this(new IPEndPoint(IPAddress.Loopback, AdbServerPort), Factories.AdbSocketFactory) + { + } + /// /// Initializes a new instance of the class. /// /// /// The at which the adb server is listening. /// - public AdbClient(EndPoint endPoint) + public AdbClient(EndPoint endPoint, Func adbSocketFactory) { if (endPoint == null) { throw new ArgumentNullException(); } + if (!(endPoint is IPEndPoint || endPoint is DnsEndPoint)) + { + throw new NotSupportedException("Only TCP endpoints are supported"); + } + + if (adbSocketFactory == null) + { + throw new ArgumentNullException(nameof(adbSocketFactory)); + } + this.EndPoint = endPoint; + this.adbSocketFactory = adbSocketFactory; } /// @@ -85,7 +111,7 @@ public static IAdbClient Instance { if (instance == null) { - instance = new AdbClient(AdbServer.Instance.EndPoint); + instance = new AdbClient(); } return instance; @@ -97,6 +123,14 @@ public static IAdbClient Instance } } + public static EndPoint DefaultEndPoint + { + get + { + return new IPEndPoint(IPAddress.Loopback, DefaultPort); + } + } + /// /// Gets the at which the adb server is listening. /// @@ -150,7 +184,7 @@ public static byte[] CreateAdbForwardRequest(string address, int port) /// public int GetAdbVersion() { - using (var socket = Factories.AdbSocketFactory(this.EndPoint)) + using (var socket = this.adbSocketFactory(this.EndPoint)) { socket.SendAdbRequest("host:version"); var response = socket.ReadAdbResponse(); @@ -163,7 +197,7 @@ public int GetAdbVersion() /// public void KillAdb() { - using (IAdbSocket socket = Factories.AdbSocketFactory(this.EndPoint)) + using (IAdbSocket socket = this.adbSocketFactory(this.EndPoint)) { socket.SendAdbRequest("host:kill"); @@ -175,7 +209,7 @@ public void KillAdb() /// public List GetDevices() { - using (IAdbSocket socket = Factories.AdbSocketFactory(this.EndPoint)) + using (IAdbSocket socket = this.adbSocketFactory(this.EndPoint)) { socket.SendAdbRequest("host:devices-l"); socket.ReadAdbResponse(); @@ -219,7 +253,7 @@ public void CreateForward(DeviceData device, string local, string remote, bool a { this.EnsureDevice(device); - using (IAdbSocket socket = Factories.AdbSocketFactory(this.EndPoint)) + using (IAdbSocket socket = this.adbSocketFactory(this.EndPoint)) { string rebind = allowRebind ? string.Empty : "norebind:"; @@ -239,7 +273,7 @@ public void RemoveForward(DeviceData device, int localPort) { this.EnsureDevice(device); - using (IAdbSocket socket = Factories.AdbSocketFactory(this.EndPoint)) + using (IAdbSocket socket = this.adbSocketFactory(this.EndPoint)) { socket.SendAdbRequest($"host-serial:{device.Serial}:killforward:tcp:{localPort}"); var response = socket.ReadAdbResponse(); @@ -251,7 +285,7 @@ public void RemoveAllForwards(DeviceData device) { this.EnsureDevice(device); - using (IAdbSocket socket = Factories.AdbSocketFactory(this.EndPoint)) + using (IAdbSocket socket = this.adbSocketFactory(this.EndPoint)) { socket.SendAdbRequest($"host-serial:{device.Serial}:killforward-all"); var response = socket.ReadAdbResponse(); @@ -263,7 +297,7 @@ public IEnumerable ListForward(DeviceData device) { this.EnsureDevice(device); - using (IAdbSocket socket = Factories.AdbSocketFactory(this.EndPoint)) + using (IAdbSocket socket = this.adbSocketFactory(this.EndPoint)) { socket.SendAdbRequest($"host-serial:{device.Serial}:list-forward"); var response = socket.ReadAdbResponse(); @@ -281,7 +315,7 @@ public async Task ExecuteRemoteCommandAsync(string command, DeviceData device, I { this.EnsureDevice(device); - using (IAdbSocket socket = Factories.AdbSocketFactory(this.EndPoint)) + using (IAdbSocket socket = this.adbSocketFactory(this.EndPoint)) { cancellationToken.Register(() => socket.Dispose()); @@ -367,7 +401,7 @@ public async Task RunLogServiceAsync(DeviceData device, Action message // The 'log' service has been deprecated, see // https://android.googlesource.com/platform/system/core/+/7aa39a7b199bb9803d3fd47246ee9530b4a96177 - using (IAdbSocket socket = Factories.AdbSocketFactory(this.EndPoint)) + using (IAdbSocket socket = this.adbSocketFactory(this.EndPoint)) { this.SetDevice(socket, device); @@ -419,7 +453,7 @@ public void Reboot(string into, DeviceData device) var request = $"reboot:{into}"; - using (IAdbSocket socket = Factories.AdbSocketFactory(this.EndPoint)) + using (IAdbSocket socket = this.adbSocketFactory(this.EndPoint)) { this.SetDevice(socket, device); socket.SendAdbRequest(request); @@ -435,7 +469,7 @@ public void Connect(DnsEndPoint endpoint) throw new ArgumentNullException(nameof(endpoint)); } - using (IAdbSocket socket = Factories.AdbSocketFactory(this.EndPoint)) + using (IAdbSocket socket = this.adbSocketFactory(this.EndPoint)) { socket.SendAdbRequest($"host:connect:{endpoint.Host}:{endpoint.Port}"); var response = socket.ReadAdbResponse(); diff --git a/SharpAdbClient/AdbServer.cs b/SharpAdbClient/AdbServer.cs index 5be928e8..bb3986ba 100644 --- a/SharpAdbClient/AdbServer.cs +++ b/SharpAdbClient/AdbServer.cs @@ -26,11 +26,6 @@ namespace SharpAdbClient /// public class AdbServer : IAdbServer { - /// - /// The port at which the Android Debug Bridge server listens by default. - /// - public const int AdbServerPort = 5037; - /// /// The minum version of adb.exe that is supported by this library. /// @@ -70,34 +65,40 @@ public class AdbServer : IAdbServer /// private static string cachedAdbPath; + private readonly IAdbClient adbClient; + + /// + /// Gets or sets a function that returns a new instance of a class that implements the + /// interface, that can be used to interact with the + /// adb.exe command line client. + /// + private readonly Func adbCommandLineClientFactory; + /// /// Initializes a new instance of the class. /// public AdbServer() - : this(new IPEndPoint(IPAddress.Loopback, AdbServerPort)) + : this(AdbClient.Instance, Factories.AdbCommandLineClientFactory) { } /// - /// Initializes a new instance of the class, and the specific at which - /// the server should be listening. + /// Initializes a new instance of the class. /// - /// - /// The at which the server should be listening. - /// - public AdbServer(EndPoint endPoint) + public AdbServer(IAdbClient adbClient, Func adbCommandLineClientFactory) { - if (endPoint == null) + if (adbClient == null) { - throw new ArgumentNullException(nameof(endPoint)); + throw new ArgumentNullException(nameof(AdbClient)); } - if (!(endPoint is IPEndPoint || endPoint is DnsEndPoint)) + if (adbCommandLineClientFactory == null) { - throw new NotSupportedException("Only TCP endpoints are supported"); + throw new ArgumentNullException(nameof(adbCommandLineClientFactory)); } - this.EndPoint = endPoint; + this.adbCommandLineClientFactory = adbCommandLineClientFactory; + this.adbClient = adbClient; } /// @@ -106,16 +107,13 @@ public AdbServer(EndPoint endPoint) public static IAdbServer Instance { get; set; } = new AdbServer(); - /// - public EndPoint EndPoint { get; private set; } - /// public StartServerResult StartServer(string adbPath, bool restartServerIfNewer) { var serverStatus = this.GetStatus(); Version commandLineVersion = null; - var commandLineClient = Factories.AdbCommandLineClientFactory(adbPath); + var commandLineClient = this.adbCommandLineClientFactory(adbPath); if (commandLineClient.IsValidAdbFile(adbPath)) { @@ -151,7 +149,7 @@ public StartServerResult StartServer(string adbPath, bool restartServerIfNewer) throw new ArgumentNullException(nameof(adbPath)); } - AdbClient.Instance.KillAdb(); + this.adbClient.KillAdb(); serverStatus.IsRunning = false; serverStatus.Version = null; @@ -194,7 +192,7 @@ public AdbServerStatus GetStatus() // Try to connect to a running instance of the adb server try { - int versionCode = AdbClient.Instance.GetAdbVersion(); + int versionCode = this.adbClient.GetAdbVersion(); return new AdbServerStatus() { diff --git a/SharpAdbClient/Factories.cs b/SharpAdbClient/Factories.cs index b2e7366c..0d6fc515 100644 --- a/SharpAdbClient/Factories.cs +++ b/SharpAdbClient/Factories.cs @@ -60,10 +60,10 @@ public static Func SyncServiceFactory public static void Reset() { AdbSocketFactory = (endPoint) => new AdbSocket(endPoint); - AdbClientFactory = (endPoint) => new AdbClient(endPoint); + AdbClientFactory = (endPoint) => new AdbClient(endPoint, Factories.AdbSocketFactory); AdbCommandLineClientFactory = (path) => new AdbCommandLineClient(path); SyncServiceFactory = (device) => new SyncService(device); - AdbClient.Instance = new AdbClient(AdbServer.Instance.EndPoint); + AdbClient.Instance = new AdbClient(); } } } diff --git a/SharpAdbClient/IAdbClient.cs b/SharpAdbClient/IAdbClient.cs index 5c881f1f..a7aeb03f 100644 --- a/SharpAdbClient/IAdbClient.cs +++ b/SharpAdbClient/IAdbClient.cs @@ -18,6 +18,11 @@ namespace SharpAdbClient /// public interface IAdbClient { + /// + /// Gets the at which the Android Debug Bridge server is listening. + /// + EndPoint EndPoint { get; } + // The individual services are listed in the same order as // https://android.googlesource.com/platform/system/core/+/master/adb/SERVICES.TXT diff --git a/SharpAdbClient/IAdbServer.cs b/SharpAdbClient/IAdbServer.cs index ac195efc..ea87178b 100644 --- a/SharpAdbClient/IAdbServer.cs +++ b/SharpAdbClient/IAdbServer.cs @@ -13,11 +13,6 @@ namespace SharpAdbClient /// public interface IAdbServer { - /// - /// Gets the at which the Android Debug Bridge server is listening. - /// - EndPoint EndPoint { get; } - /// /// Starts the adb server if it was not previously running. /// diff --git a/SharpAdbClient/SyncService.cs b/SharpAdbClient/SyncService.cs index 805b8148..c18116f5 100644 --- a/SharpAdbClient/SyncService.cs +++ b/SharpAdbClient/SyncService.cs @@ -59,7 +59,7 @@ public class SyncService : ISyncService, IDisposable /// The device on which to interact with the files. /// public SyncService(DeviceData device) - : this(Factories.AdbSocketFactory(AdbServer.Instance.EndPoint), device) + : this(Factories.AdbSocketFactory(AdbClient.Instance.EndPoint), device) { }