コード例 #1
0
        private void PollForBatteryInfo()
        {
            string batteryInfo = new AdbCommand().RunCommand(@"shell dumpsys battery");

            if (String.IsNullOrEmpty(batteryInfo) || batteryInfo.StartsWith("ERROR"))
                return;

            foreach (KeyValuePair<Regex, KeyValuePair<string, Type>> kvp in _regexMapping)
            {
                var m = kvp.Key.Matches(batteryInfo);

                if (m == null || m.Count == 0 || m[0].Groups.Count < 2)
                    continue;

                string value = m[0].Groups[1].Value.Trim();
                _info.GetType().GetProperty(kvp.Value.Key).SetValue(_info, System.Convert.ChangeType(value, kvp.Value.Value), null);
            }
        }
コード例 #2
0
        private bool PollForModel()
        {
            string buildProp = new AdbCommand().RunCommand(@"shell cat /system/build.prop");

            if (String.IsNullOrEmpty(buildProp) || buildProp.StartsWith("ERROR"))
                return false;

            var m = _reModel.Matches(buildProp);

            if (m == null || m.Count == 0 || m[0].Groups.Count < 2)
                return false;

            _info.Model = m[0].Groups[1].Value.Trim();
            _info.DeviceConnected = true;

            return true;
        }