public void RefreshDevice() { var ds = new List <string>(); var result = ExtCommand.Shell("adb", "devices"); foreach (Match mch in Regex.Matches(result.Result, "\\n.*\\tdevice")) { string x = mch.Value; x = x.Substring(0, x.LastIndexOf("device")).Trim(); ds.Add(x); if (pml.FirstOrDefault(t => t.Device == x) == null) { PhoneModel pm = new PhoneModel(CQs, _logger); pm.Device = x; pm.phoneStatus = PhoneStatus.OnLine; string modresult = ExtCommand.Shell("adb", $"-s {pm.Device} shell getprop ro.product.model").Result; pm.Model = modresult.Trim(); //push 安装用的jar 包 var ss = ExtCommand.Shell("adb", $"-s {pm.Device} push {Path.Combine(Directory.GetCurrentDirectory(), @"Tools\DialogDetect.jar")} /data/local/tmp/").Result; _logger.LogInformation(ss); pml.Add(pm); } } pml.Where(t => !ds.Contains(t.Device)).ToList().ForEach(t => t.phoneStatus = PhoneStatus.OffLine); pml.Where(t => t.phoneStatus == PhoneStatus.OffLine && ds.Contains(t.Device)).ToList().ForEach(t => t.phoneStatus = PhoneStatus.OnLine); }
private void initPhone() { var result = ExtCommand.Shell("adb", "devices").Result; var result2 = ExtCommand.Shell("adb devices").Result; foreach (Match mch in Regex.Matches(result, "\\n.*\\tdevice")) { string x = mch.Value; x = x.Substring(0, x.LastIndexOf("device")).Trim(); if (pml.FirstOrDefault(t => t.Device == x) == null) { PhoneModel pm = new PhoneModel(CQs, _logger); pm.Device = x; pm.phoneStatus = PhoneStatus.OnLine; string modresult = ExtCommand.Shell("adb", $"-s {pm.Device} shell getprop ro.product.model").Result; pm.Model = modresult.Trim(); //push 安装用的jar 包 var ss = ExtCommand.Shell("adb", $"-s {pm.Device} push {Path.Combine(Directory.GetCurrentDirectory(), @"Tools/DialogDetect.jar")} /data/local/tmp/").Result; _logger.LogInformation(ss); pml.Add(pm); } } }