public void RefreshDevices()
        {
            string s = null;

            this._connectedDevices.Clear();
            s = ADB.Devices();
            if (s.Length > 0x1d)
            {
                using (StringReader reader = new StringReader(s))
                {
                    while (reader.Peek() != -1)
                    {
                        string item = reader.ReadLine();
                        if ((!item.StartsWith("List") && !item.StartsWith("\r\n")) && ((item.Trim() != "") && (item.IndexOf('\t') != -1)))
                        {
                            item = item.Substring(0, item.IndexOf('\t'));
                            if (!item.ToLower().Contains("emulator"))
                            {
                                this._connectedDevices.Add(item);
                            }
                        }
                    }
                }
            }
            if (!this._disableFastboot)
            {
                s = Fastboot.Devices();
                if (s.Length > 0)
                {
                    using (StringReader reader2 = new StringReader(s))
                    {
                        while (reader2.Peek() != -1)
                        {
                            string str3 = reader2.ReadLine();
                            if ((!str3.StartsWith("List") && !str3.StartsWith("\r\n")) && ((str3.Trim() != "") && (str3.IndexOf('\t') != -1)))
                            {
                                str3 = str3.Substring(0, str3.IndexOf('\t'));
                                if (!str3.ToLower().Contains("emulator"))
                                {
                                    this._connectedDevices.Add(str3);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private DeviceState SetState()
        {
            string str = null;

            using (StringReader reader = new StringReader(ADB.Devices()))
            {
                while (reader.Peek() != -1)
                {
                    string str2 = reader.ReadLine();
                    if (str2.Contains(this._serialNumber))
                    {
                        str = str2.Substring(str2.IndexOf('\t') + 1);
                    }
                }
            }
            if (str == null)
            {
                using (StringReader reader2 = new StringReader(Fastboot.Devices()))
                {
                    while (reader2.Peek() != -1)
                    {
                        string str3 = reader2.ReadLine();
                        if (str3.Contains(this._serialNumber))
                        {
                            str = str3.Substring(str3.IndexOf('\t') + 1);
                        }
                    }
                }
            }
            switch (str)
            {
            case "device":
                return(DeviceState.ONLINE);

            case "offline":
                return(DeviceState.OFFLINE);

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

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