public void UpdateDeviceList()
        {
            string deviceList = null;

            _connectedDevices.Clear();

            deviceList = Adb.Devices();


            if (deviceList.Length > 29)
            {
                using (StringReader s = new StringReader(deviceList))
                {
                    string line = null;

                    while (!(s.Peek() == -1))
                    {
                        line = s.ReadLine();

                        if (line.StartsWith("List") || line.StartsWith("\r\n") || string.IsNullOrEmpty(line.Trim()))
                        {
                            continue;
                        }

                        if (!(line.IndexOf('\t') == -1))
                        {
                            line = line.Substring(0, line.IndexOf('\t'));
                            _connectedDevices.Add(line);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private DeviceState SetState()
        {
            string state = null;

            using (StringReader r = new StringReader(Adb.Devices()))
            {
                string line = null;

                while (!(r.Peek() == -1))
                {
                    line = r.ReadLine();

                    if (!(line == null))
                    {
                        if (line.Contains(_serialNumber))
                        {
                            state = line.Substring(line.IndexOf('\t') + 1);
                        }
                    }
                }
            }

            switch (state)
            {
            case "device":
                return(DeviceState.ONLINE);

            case "recovery":
                return(DeviceState.RECOVERY);

            case "sideload":
                return(DeviceState.SIDELOAD);

            case "unauthorized":
                return(DeviceState.UNAUTHORIZED);

            default:

                return(DeviceState.UNKNOWN);
            }
        }