Esempio n. 1
0
        /// <inheritdoc/>
        public IEnumerable <ForwardData> ListReverse(DeviceData device)
        {
            this.EnsureDevice(device);

            using (IAdbSocket socket = this.adbSocketFactory(this.EndPoint))
            {
                socket.SendAdbRequest("host:transport:" + device.Serial);
                var response = socket.ReadAdbResponse();

                if (!response.Okay)
                {
                    return(null);
                }

                socket.SendAdbRequest($"reverse:list-forward");
                response = socket.ReadAdbResponse();

                if (!response.Okay)
                {
                    return(null);
                }

                var data = socket.ReadString();

                var parts = data.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);

                return(parts.Select(p => ForwardData.FromString(p)));
            }
        }
Esempio n. 2
0
        /// <inheritdoc/>
        public List <DeviceData> GetDevices()
        {
            using (IAdbSocket socket = this.adbSocketFactory(this.EndPoint))
            {
                socket.SendAdbRequest("host:devices-l");
                socket.ReadAdbResponse();
                var reply = socket.ReadString();

                string[] data = reply.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries);

                return(data.Select(d => DeviceData.CreateFromAdbData(d)).ToList());
            }
        }
Esempio n. 3
0
        /// <include file='IAdbClient.xml' path='/IAdbClient/ListForward/*'/>
        public IEnumerable <ForwardData> ListForward(DeviceData device)
        {
            using (IAdbSocket socket = Factories.AdbSocketFactory(this.EndPoint))
            {
                socket.SendAdbRequest($"host-serial:{device.Serial}:list-forward");
                var response = socket.ReadAdbResponse();

                var data = socket.ReadString();

                var parts = data.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);

                return(parts.Select(p => ForwardData.FromString(p)));
            }
        }
        /// <inheritdoc/>
        public string Connect(DnsEndPoint endpoint)
        {
            if (endpoint == null)
            {
                throw new ArgumentNullException(nameof(endpoint));
            }

            using (IAdbSocket socket = Factories.AdbSocketFactory(this.EndPoint))
            {
                socket.SendAdbRequest($"host:connect:{endpoint.Host}:{endpoint.Port}");
                var response = socket.ReadAdbResponse();

                return(socket.ReadString());
            }
        }
Esempio n. 5
0
        /// <inheritdoc/>
        public int CreateForward(DeviceData device, string local, string remote, bool allowRebind)
        {
            this.EnsureDevice(device);

            using (IAdbSocket socket = this.adbSocketFactory(this.EndPoint))
            {
                string rebind = allowRebind ? string.Empty : "norebind:";

                socket.SendAdbRequest($"host-serial:{device.Serial}:forward:{rebind}{local};{remote}");
                var response = socket.ReadAdbResponse();
                response = socket.ReadAdbResponse();
                var portString = socket.ReadString();

                if (portString != null && int.TryParse(portString, out int port))
                {
                    return(port);
                }

                return(0);
            }
        }