Example #1
0
        // Token: 0x06000018 RID: 24 RVA: 0x000038F8 File Offset: 0x00001AF8
        private void FlashDone()
        {
            if (string.IsNullOrEmpty(this.errMsg))
            {
                bool flag = false;
                if (!string.IsNullOrEmpty(MiAppConfig.Get("checkPoint")))
                {
                    using (List <Device> .Enumerator enumerator = FlashingDevice.flashDeviceList.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Device device = enumerator.Current;
                            if (device.Name == this.devicename)
                            {
                                List <string> list = new List <string>(device.StatusList);
                                using (List <string> .Enumerator enumerator2 = list.GetEnumerator())
                                {
                                    while (enumerator2.MoveNext())
                                    {
                                        string text  = enumerator2.Current;
                                        Regex  regex = new Regex(MiAppConfig.Get("checkPoint"));
                                        if (regex.IsMatch(text.ToLower()) && text.ToLower().IndexOf("bootloader") < 0)
                                        {
                                            flag = true;
                                            Log.w(this.devicename, string.Format("catch checkpoint ({0})", MiAppConfig.Get("checkPoint")));
                                            break;
                                        }
                                    }
                                    break;
                                }
                            }
                        }
                        goto IL_100;
                    }
                }
                flag = true;
IL_100:
                if (flag)
                {
                    FlashingDevice.UpdateDeviceStatus(this.devicename, new float?(1f), "flash done", "success", true);
                    Log.w(this.devicename, "flash done");
                }
                else
                {
                    if (string.IsNullOrEmpty(this.errMsg))
                    {
                        this.errMsg = "Not catch checkpoint (" + MiAppConfig.Get("checkPoint") + "),flash is not done";
                    }
                    FlashingDevice.UpdateDeviceStatus(this.devicename, new float?(1f), this.errMsg, "error", true);
                    Log.w(this.devicename, "error:" + this.errMsg, false);
                }
            }
            else
            {
                FlashingDevice.UpdateDeviceStatus(this.devicename, new float?(1f), this.errMsg, "error", true);
                Log.w(this.devicename, "error:" + this.errMsg, false);
            }
            UsbDevice.MtkDevice.Remove(this.devicename);
        }
 // Token: 0x0600005D RID: 93 RVA: 0x000086CE File Offset: 0x000068CE
 public static string Get(string key)
 {
     if (ConfigurationManager.AppSettings[key] == null)
     {
         MiAppConfig.Add(key, "");
     }
     if (ConfigurationManager.AppSettings[key] != null)
     {
         return(ConfigurationManager.AppSettings[key].ToString());
     }
     return("");
 }
Example #3
0
        // Token: 0x0600022F RID: 559 RVA: 0x00016448 File Offset: 0x00014648
        public static List <Device> GetDevice()
        {
            List <Device> list = new List <Device>();
            string        a    = MiAppConfig.Get("chip");

            if (a == "MTK")
            {
                using (List <string> .Enumerator enumerator = UsbDevice.MtkDevice.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        string text  = enumerator.Current;
                        int    index = int.Parse(text.ToLower().Replace("com", ""));
                        list.Add(new Device
                        {
                            Index      = index,
                            Name       = text,
                            DeviceCtrl = new MTKDevice()
                        });
                    }
                    return(list);
                }
            }
            string[] devicesQc = ComPortCtrl.getDevicesQc();
            foreach (string text2 in devicesQc)
            {
                int num = int.Parse(text2.ToLower().Replace("com", ""));
                list.Add(new Device
                {
                    Index      = num,
                    Name       = text2,
                    DeviceCtrl = new SerialPortDevice()
                });
            }
            List <TreeViewUsbItem> allUsbDevices = TreeViewUsbItem.AllUsbDevices;

            Log.w("GetScriptDevices");
            List <UsbNodeConnectionInformation> scriptDevices = UsbDevice.GetScriptDevices(allUsbDevices);
            List <string> list2 = UsbDevice.GetScriptDevice().ToList <string>();

            foreach (string text3 in list2)
            {
                int num  = UsbDevice.GetDeviceIndex(text3);
                int num2 = 5;
                while (num <= 0 && num2-- >= 0)
                {
                    if (num2 < 4)
                    {
                        Thread.Sleep(200);
                    }
                    num = UsbDevice.GetDeviceIndex(text3);
                }
                list.Add(new Device
                {
                    Index      = num,
                    Name       = text3,
                    DeviceCtrl = new ScriptDevice()
                });
            }
            foreach (UsbNodeConnectionInformation usbNodeConnectionInformation in scriptDevices)
            {
                if (!string.IsNullOrEmpty(usbNodeConnectionInformation.DeviceDescriptor.SerialNumber) && list2.IndexOf(usbNodeConnectionInformation.DeviceDescriptor.SerialNumber) < 0)
                {
                    int num  = UsbDevice.GetDeviceIndex(usbNodeConnectionInformation.DeviceDescriptor.SerialNumber);
                    int num3 = 10;
                    while (num <= 0 && num3-- >= 0)
                    {
                        if (num3 < 9)
                        {
                            Thread.Sleep(200);
                        }
                        num = UsbDevice.GetDeviceIndex(usbNodeConnectionInformation.DeviceDescriptor.SerialNumber);
                    }
                    list.Add(new Device
                    {
                        Index      = num,
                        Name       = usbNodeConnectionInformation.DeviceDescriptor.SerialNumber,
                        DeviceCtrl = new ScriptDevice()
                    });
                }
            }
            return(list);
        }
Example #4
0
 // Token: 0x06000017 RID: 23 RVA: 0x000034B8 File Offset: 0x000016B8
 private void consoleMode_process_OutputDataReceived(object sender, DataReceivedEventArgs e)
 {
     if (!string.IsNullOrEmpty(e.Data))
     {
         try
         {
             string data = e.Data;
             if (data.ToLower().IndexOf("no insert comport") >= 0)
             {
                 try
                 {
                     Process process = (Process)sender;
                     this.errMsg = "no device insert";
                 }
                 catch (Exception ex)
                 {
                     Log.w(ex.Message, true);
                 }
             }
             if (!string.IsNullOrEmpty(this.errMsg) || data.ToLower().IndexOf("error") >= 0 || data.ToLower().IndexOf("fail") >= 0)
             {
                 if (string.IsNullOrEmpty(this.errMsg))
                 {
                     this.errMsg = data;
                 }
                 Process process2 = (Process)sender;
                 Log.w(this.devicename, data, false);
             }
             else
             {
                 if (data.ToLower().IndexOf("insert comport: com") >= 0)
                 {
                     string text   = data.ToLower().Replace("insert comport:", "").Trim();
                     Device device = new Device();
                     device.Index     = int.Parse(text.Replace("com", ""));
                     device.Name      = text;
                     device.StartTime = DateTime.Now;
                     this.devicename  = device.Name;
                     if (MiAppConfig.Get("chip") == "MTK")
                     {
                         device.Status = "wait for device insert";
                     }
                     else
                     {
                         device.Status = "flashing";
                     }
                     device.Progress = 0f;
                     device.IsDone   = new bool?(false);
                     device.IsUpdate = true;
                     if (this.devicename.ToLower() == device.Name.ToLower() && UsbDevice.MtkDevice.IndexOf(device.Name) < 0)
                     {
                         UsbDevice.MtkDevice.Add(device.Name);
                         FlashingDevice.consoleMode_UsbInserted = true;
                     }
                     Log.w(this.devicename, data);
                 }
                 else if (data.ToLower().IndexOf("da usb vcom") >= 0)
                 {
                     Regex regex = new Regex("\\(com.*\\)");
                     Match match = regex.Match(data.ToLower());
                     if (match.Groups.Count > 0)
                     {
                         string s = match.Groups[0].Value.Replace("com", "").Replace("(", "").Replace(")", "").Trim();
                         if (this.ini.GetIniInt("bootrom", this.devicename, 0) == 0 && !this.ini.WriteIniInt("bootrom", this.devicename, int.Parse(s)))
                         {
                             MessageBox.Show("couldn't write vcom");
                         }
                     }
                 }
                 else if (data.ToLower().IndexOf("download success") >= 0)
                 {
                     try
                     {
                         Log.w(this.devicename, e.Data, false);
                         this.FlashDone();
                     }
                     catch (Exception ex2)
                     {
                         Log.w(this.devicename, ex2.Message, false);
                     }
                     return;
                 }
                 string status   = data;
                 float? progress = null;
                 if (data.ToLower().IndexOf("percent") >= 0)
                 {
                     string text2 = data.ToLower();
                     string text3 = "percent";
                     int    num   = text2.IndexOf(text3);
                     status = text2.Substring(0, num);
                     string value = text2.Substring(num + text3.Length, text2.Length - text3.Length - num).Trim();
                     progress = new float?((float)Convert.ToInt32(value) / 100f);
                 }
                 else
                 {
                     Log.w(this.devicename, e.Data, true);
                 }
                 FlashingDevice.UpdateDeviceStatus(this.devicename, progress, status, "flashing", false);
             }
         }
         catch (Exception ex3)
         {
             try
             {
                 if (string.IsNullOrEmpty(this.errMsg))
                 {
                     this.errMsg = ex3.Message + "\r\n" + ex3.StackTrace;
                 }
                 Process process3 = (Process)sender;
             }
             catch (Exception ex4)
             {
                 Log.w(ex4.Message, true);
             }
         }
     }
 }