Example #1
0
        /// <summary>
        /// 将设备列表进行合并
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <returns></returns>
        public static DevicesList operator +(DevicesList left, DevicesList right)
        {
            var tmp = new DevicesList();

            tmp.AddRange(left);
            tmp.AddRange(right);
            return(tmp);
        }
Example #2
0
 /// <summary>
 /// 判断列表内容是否一致
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public bool Equals(DevicesList other)
 {
     if (Count != other.Count)
     {
         return(false);
     }
     foreach (DeviceBasicInfo info in this)
     {
         if (!other.Contains(info))
         {
             return(false);
         }
     }
     return(true);
 }
Example #3
0
            private void Listen()
            {
                DevicesList _new;

                while (true)
                {
                    _new = _devGetter.GetDevices();
                    //_new.ForEach((d)=> { Logger.Debug(this,d); });
                    if (_new != crtDevices)
                    {
                        Logger.Info(this, "Devices Changed");
                        crtDevices = _new;
                        this.DevicesChangedInner?.Invoke(this, new DevicesChangedEventArgs(crtDevices));
                    }
                    Thread.Sleep(_interval);
                }
            }
Example #4
0
 private static void FastbootParse(Output o, ref DevicesList devList)
 {
     try
     {
         var matches = _deviceRegex.Matches(o.All);
         foreach (Match match in matches)
         {
             devList.Add(DeviceBasicInfo.Make(
                             match.Result("${serial}"),
                             match.Result("${status}").ToDeviceState()));
         }
     }
     catch (Exception ex)
     {
         Logger.Warn("DevicesGetter", "fastboot devices parse failed", ex);
     }
 }
Example #5
0
 /// <summary>
 /// 获取已连接的设备
 /// </summary>
 /// <returns></returns>
 public DevicesList GetDevices()
 {
     lock (executer)
     {
         DevicesList devList          = new DevicesList();
         var         adbDevicesOutput = executer.Execute(adbDevicesCmd);
         if (!adbDevicesOutput.IsSuccessful)
         {
             AdbHelper.RisesAdbServerStartsFailedEvent();
             return(devList);
         }
         var fastbootDevicesOutput = executer.Execute(fbDevicesCmd);
         AdbParse(adbDevicesOutput, ref devList);
         FastbootParse(fastbootDevicesOutput, ref devList);
         return(devList);
     }
 }
Example #6
0
 public DevicesMonitorCore(int interval = defaultInterval)
 {
     this._interval = interval;
     _devGetter     = new DevicesGetter();
     crtDevices     = new DevicesList();
 }