Пример #1
0
        /// <summary>
        /// Updates Internal Device List
        /// </summary>
        /// <remarks>Call this before checking for Devices, or setting a new Device, for most updated results</remarks>
        public void UpdateDeviceList()
        {
            string deviceList = "";

            this.connectedDevices.Clear();

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

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

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

                        if (line.IndexOf('\t') != -1)
                        {
                            line = line.Substring(0, line.IndexOf('\t'));
                            this.connectedDevices.Add(line);
                        }
                    }
                }
            }
        }
Пример #2
0
        private DeviceState SetState()
        {
            string state = null;

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

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

                    if (line.Contains(this.serialNumber))
                    {
                        state = line.Substring(line.IndexOf('\t') + 1);
                    }
                }
            }

            if (state == null)
            {
                using (StringReader r = new StringReader(Fastboot.Devices()))
                {
                    string line;

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

                        if (line.Contains(this.serialNumber))
                        {
                            state = line.Substring(line.IndexOf('\t') + 1);
                        }
                    }
                }
            }

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

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

            case "fastboot":
                return(DeviceState.FASTBOOT);

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

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

            default:
                return(DeviceState.UNKNOWN);
            }
        }