Пример #1
0
        private void DeviceDetectionService()
        {
            ADB.Start();
            // Here we initiate the BASE Fastboot instance
            Fastboot.Instance();

            //This will starte a thread which checks every 10 sec for connected devices and call the given callback
            if (Fastboot.ConnectionMonitor.Start())
            {
                //Here we define our callback function which will be raised if a device connects or disconnects
                Fastboot.ConnectionMonitor.Callback += ConnectionMonitorCallback;

                // Here we check if ADB is running and initiate the BASE ADB instance (IsStarted() will everytime check if the BASE ADB class exists, if not it will create it)
                if (ADB.IsStarted)
                {
                    //Here we check for connected devices
                    SetDeviceList();

                    //This will starte a thread which checks every 10 sec for connected devices and call the given callback
                    if (ADB.ConnectionMonitor.Start())
                    {
                        ADB.ConnectionMonitor.Callback += ConnectionMonitorCallback;
                    }
                    //Here we define our callback function which will be raised if a device connects or disconnects
                }
            }
        }
Пример #2
0
        private void btnHtcDev_Click(object sender, RoutedEventArgs e)
        {
            if (deviceselector.Items.Count == 0)
            {
                MessageBox.Show("A device has not been detected as of yet. Wait 10 seconds or diagnose the issue.", "No Device", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            IDDeviceState state = General.CheckDeviceState(ADB.Instance().DeviceID);

            if (state == IDDeviceState.DEVICE)
            {
                ADB.Instance().Reboot(IDBoot.BOOTLOADER);
                CidDialog ciddiag = CidDialog.Instance;
                ciddiag.Add(Fastboot.Instance().OEM.GetIdentifierToken());
                ciddiag.Show();
                MessageBox.Show("You must continue from the HTC Dev website.", "Redirecting to HTCDev.com", MessageBoxButton.OK, MessageBoxImage.Information);
                System.Diagnostics.Process.Start("http://www.htcdev.com/bootloader/");
            }
            else if (state == IDDeviceState.FASTBOOT)
            {
                CidDialog ciddiag = CidDialog.Instance;
                ciddiag.Add(Fastboot.Instance().OEM.GetIdentifierToken());
                ciddiag.Show();
                MessageBox.Show("You must continue from the HTC Dev website.", "Redirecting to HTCDev.com", MessageBoxButton.OK, MessageBoxImage.Information);
                System.Diagnostics.Process.Start("http://www.htcdev.com/bootloader/");
            }
        }
Пример #3
0
 private void btnFbtGo_Click(object sender, RoutedEventArgs e)
 {
     if (cBFbtCmds.Text == "Reboot")
     {
         Fastboot.Instance().Reboot(IDBoot.REBOOT);
     }
     else if (cBFbtCmds.Text == "Reboot Bootloader")
     {
         Fastboot.Instance().Reboot(IDBoot.BOOTLOADER);
     }
     else if (cBFbtCmds.Text == "RebootRUU")
     {
         Fastboot.Instance().OEM.RebootRUU();
     }
     else if (cBFbtCmds.Text == "Read CID")
     {
         CidDialog ciddiag = CidDialog.Instance;
         ciddiag.Add(Fastboot.Instance().OEM.ReadCid());
         ciddiag.Show();
     }
     else if (cBFbtCmds.Text == "Show Identifier Token")
     {
         CidDialog ciddiag = CidDialog.Instance;
         ciddiag.Add(Fastboot.Instance().OEM.GetIdentifierToken());
         ciddiag.Show();
     }
     else if (cBFbtCmds.Text == "Relock Bootloader")
     {
         if (MessageBox.Show("Are you sure you want to relock the bootloader?", "Are you sure you want to relock?", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
         {
             CidDialog ciddiag = CidDialog.Instance;
             ciddiag.Add(Fastboot.Instance().OEM.Lock());
             ciddiag.Show();
         }
         else
         {
             //No
         }
     }
     else if (cBFbtCmds.Text == "S-On Bootloader")
     {
         if (MessageBox.Show("Are you sure you want to S-On?", "Are you sure you want to S-On?", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
         {
             CidDialog ciddiag = CidDialog.Instance;
             ciddiag.Add(Fastboot.Instance().OEM.WriteSecureFlag("3"));
             ciddiag.Show();
         }
         else
         {
             //No
         }
     }
     else
     {
         MessageBox.Show("You have not selected a command.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Пример #4
0
        private void btnUnlock_Click(object sender, RoutedEventArgs e)
        {
            // Create OpenFileDialog
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

            // Set filter for file extension and default file extension
            dlg.DefaultExt = "*.*";
            dlg.Filter     = "All Files (*.*)|*.*";

            // Display OpenFileDialog by calling ShowDialog method
            Nullable <bool> result = dlg.ShowDialog();

            // Get the selected file name and display in a TextBox
            if (result == true)
            {
                // Open document
                string filename = dlg.FileName;
                tbToken.Text = filename;
            }

            Main m = new Main();

            IDDeviceState state = General.CheckDeviceState(ADB.Instance().DeviceID);

            if (state == IDDeviceState.DEVICE)
            {
                ADB.Instance().Reboot(IDBoot.BOOTLOADER);

                MessageBoxResult messageResult = MessageBox.Show("Unlocking the bootloader will wipe all DATA on your phone. Are you sure you want to continue?", "Erase DATA!", MessageBoxButton.YesNo, MessageBoxImage.Information);
                if (messageResult == MessageBoxResult.Yes)
                {
                    m.Add(Fastboot.Instance().Flash(IDDevicePartition.UNLOCKTOKEN, tbToken.Text));
                }
                if (messageResult == MessageBoxResult.No)
                {
                    //No
                }
            }
            else if (state == IDDeviceState.FASTBOOT)
            {
                MessageBoxResult messageResult = MessageBox.Show("Unlocking the bootloader will wipe all DATA on your phone. Are you sure you want to continue?", "Erase DATA!", MessageBoxButton.YesNo, MessageBoxImage.Information);
                if (messageResult == MessageBoxResult.Yes)
                {
                    m.Add(Fastboot.Instance().Flash(IDDevicePartition.UNLOCKTOKEN, tbToken.Text));
                }
                if (messageResult == MessageBoxResult.No)
                {
                    //No
                }
            }
            else
            {
                MessageBox.Show("A device was not detected... Please ensure that you have the correct drivers configured and that they are working!", "Device is not detected...", MessageBoxButton.OK, MessageBoxImage.Asterisk);
            }
        }
Пример #5
0
        private void btnFBTGo_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                switch (lbFastboot.SelectedValue.ToString())
                {
                case "Flash":
                {
                    var fbtsel = new FastbootSelector();
                    ToolkitM9.FastbootSelector.Settings.Selector = "Flash";
                    fbtsel.ShowDialog();
                }
                break;

                case "Erase":
                {
                    var fbtsel = new FastbootSelector();
                    ToolkitM9.FastbootSelector.Settings.Selector = "Erase";
                    fbtsel.ShowDialog();
                }
                break;

                case "Boot":
                {
                    var fbtsel = new FastbootSelector();
                    ToolkitM9.FastbootSelector.Settings.Selector = "Boot";
                    fbtsel.ShowDialog();
                }
                break;

                case "Reboot":
                {
                    this.Add(Fastboot.Instance().Reboot(IDBoot.REBOOT));
                }
                break;

                case "Reboot Bootloader":
                {
                    this.Add(Fastboot.Instance().Reboot(IDBoot.BOOTLOADER));
                }
                break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    "An error has occured! A log file has been placed in the Logs folder. Please report this error, with the log file, in the toolkit thread on XDA. Links in the 'File' menu!",
                    "Critical Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                string fileDateTime = DateTime.Now.ToString("MMddyyyy") + "_" + DateTime.Now.ToString("HHmmss");
                var    file         = new StreamWriter("./Data/Logs/" + fileDateTime + ".txt");
                file.WriteLine(ex);
                file.Close();
            }
        }
Пример #6
0
        private void btnExec_Click(object sender, RoutedEventArgs e)
        {
            if (cBFbtOem.Text == "")
            {
                MessageBox.Show("You must select a command to execute!");
            }
            else if (cBFbtOem.Text == "RebootRUU")
            {
                Fastboot.Instance().OEM.RebootRUU();
            }
            else if (cBFbtOem.Text == "Lock Bootloader")
            {
                TaskDialogOptions config = new TaskDialogOptions();

                config.Owner           = this;
                config.Title           = "Are you sure?";
                config.MainInstruction = "You are about to RELOCK the bootloader.";
                config.Content         = "You will need to go through an unlocking procedure again"
                                         + "to unlock the bootloader. (Either through HTCDev or the ADB Bootloader Commands)";
                config.CommandButtons = new string[] {
                    "No", "No", "Yes"
                };
                config.MainIcon = VistaTaskDialogIcon.Information;

                TaskDialogResult res = TaskDialog.Show(config);
                if (res.CommandButtonResult == 0)
                {
                }
                else if (res.CommandButtonResult == 1)
                {
                }
                else if (res.CommandButtonResult == 2)
                {
                    CidDialog ciddiag = CidDialog.Instance;
                    ciddiag.Show();
                    ciddiag.Add(Fastboot.Instance().OEM.Lock());
                }
            }
        }
Пример #7
0
        private void btnBoot_Click(object sender, RoutedEventArgs e)
        {
            if (tBFbtPath.Text == "")
            {
                if (MessageBox.Show("You have not selected a file. Would you like to select one now?", "Missing File", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                {
                    // Create OpenFileDialog
                    Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

                    // Set filter for file extension and default file extension
                    dlg.DefaultExt = "";
                    dlg.Filter     = "All Files (*.*)|*.*";
                    dlg.Title      = "Locate Files";

                    // Display OpenFileDialog by calling ShowDialog method
                    Nullable <bool> result = dlg.ShowDialog();

                    // Get the selected file name and display in a TextBox
                    if (result == true)
                    {
                        // Open document
                        string filename = dlg.FileName;
                        tBFbtPath.Text = filename;
                    }
                }
                else
                {
                    //nothing
                }
            }
            else
            {
                CidDialog ciddiag = CidDialog.Instance;
                ciddiag.Show();
                ciddiag.Add(Fastboot.Instance().Boot(tBFbtPath.Text, "", 10));
            }
        }
Пример #8
0
        private void btnConfirm_Click(object sender, RoutedEventArgs e)
        {
            if (Settings.Recovery.ToString() == "1")
            {
                if (ADB.Instance().GetState() == IDDeviceState.DEVICE)
                {
                    MessageBoxResult messageResult = MessageBox.Show("Your phone needs to be in 'fastboot USB' mode. Would you like to reboot into it now?", "Reboot to bootloader required!", MessageBoxButton.YesNo, MessageBoxImage.Information);
                    if (messageResult == MessageBoxResult.Yes)
                    {
                        tBRecoveryStatus.Text = "Rebooting into Bootloader...";
                        ADB.Instance().Reboot(IDBoot.BOOTLOADER);
                        tBRecoveryStatus.Text = "Waiting for device...";

                        if (cbFlashDownload.IsChecked == true)
                        {
                            Task.Delay(10000).ContinueWith(_ =>
                            {
                                tBRecoveryStatus.Text = "Rebooting into Download Mode...";
                                Fastboot.Instance().OEM.RebootRUU();
                            });
                        }

                        Task.Delay(10000).ContinueWith(_ =>
                        {
                            tBRecoveryStatus.Text = "Flashing recovery...";
                            Fastboot.Instance().Flash(IDDevicePartition.RECOVERY, "./Data/Recoveries/Recovery1.img");

                            App.Current.Dispatcher.Invoke((Action) delegate
                            {
                                tBRecoveryStatus.Text = "Rebooting...";
                                Fastboot.Instance().Reboot(IDBoot.REBOOT);
                            });
                        }
                                                       );
                    }
                }
                else if (ADB.Instance().GetState() == IDDeviceState.FASTBOOT)
                {
                    tBRecoveryStatus.Text = "Flashing recovery...";
                    Fastboot.Instance().Flash(IDDevicePartition.RECOVERY, "./Data/Recoveries/Recovery1.img");

                    App.Current.Dispatcher.Invoke((Action) delegate
                    {
                        tBRecoveryStatus.Text = "Rebooting...";
                        Fastboot.Instance().Reboot(IDBoot.REBOOT);
                    });
                }
            }
            else if (Settings.Recovery.ToString() == "2")
            {
                if (ADB.Instance().GetState() == IDDeviceState.DEVICE)
                {
                    MessageBoxResult messageResult = MessageBox.Show("Your phone needs to be in 'fastboot USB' mode. Would you like to reboot into it now?", "Reboot to bootloader required!", MessageBoxButton.YesNo, MessageBoxImage.Information);
                    if (messageResult == MessageBoxResult.Yes)
                    {
                        //tBRecoveryStatus.Text = "Rebooting into Bootloader...";
                        ADB.Instance().Reboot(IDBoot.BOOTLOADER);
                        tBRecoveryStatus.Text = "Waiting for device...";

                        //Rebooting into RUU mode if cheked.
                        if (cbFlashDownload.IsChecked == true)
                        {
                            Task.Delay(10000).ContinueWith(_ =>
                            {
                                tBRecoveryStatus.Text = "Rebooting into Download Mode...";
                                Fastboot.Instance().OEM.RebootRUU();
                            });
                        }

                        Task.Delay(10000).ContinueWith(_ =>
                        {
                            //tBRecoveryStatus.Text = "Flashing recovery...";
                            Fastboot.Instance().Flash(IDDevicePartition.RECOVERY, "./Data/Recoveries/Recovery2.img");

                            App.Current.Dispatcher.Invoke((Action) delegate
                            {
                                //tBRecoveryStatus.Text = "Rebooting...";
                                Fastboot.Instance().Reboot(IDBoot.REBOOT);
                            });
                        }
                                                       );
                    }
                }
                else if (ADB.Instance().GetState() == IDDeviceState.FASTBOOT)
                {
                    //tBRecoveryStatus.Text = "Flashing recovery...";
                    Fastboot.Instance().Flash(IDDevicePartition.RECOVERY, "./Data/Recoveries/Recovery2.img");

                    App.Current.Dispatcher.Invoke((Action) delegate
                    {
                        //tBRecoveryStatus.Text = "Rebooting...";
                        Fastboot.Instance().Reboot(IDBoot.REBOOT);
                    });
                }
            }
        }
Пример #9
0
        private void btnUnlockCode_Click(object sender, RoutedEventArgs e)
        {
            IDDeviceState state = General.CheckDeviceState(ADB.Instance().DeviceID);

            if (state == IDDeviceState.DEVICE)
            {
                tBUnlockStatus.Text = "Rebooting into the bootloader...";
                ADB.Instance().Reboot(IDBoot.BOOTLOADER);

                using (StreamWriter sw = File.CreateText("./Data/token.txt"))
                {
                    List <string> _token = new List <string>();
                    foreach (string line in Fastboot.Instance().OEM.GetIdentifierToken())
                    {
                        GroupCollection groups = Regex.Match(line, @"^\(bootloader\)\s{1,}(?<PART>.*?)$").Groups;
                        string          part   = groups["PART"].Value;
                        if (String.IsNullOrEmpty(part) == false && Regex.IsMatch(part, @"^<{1,}.*?>{1,}$") == false)
                        {
                            _token.Add(part);
                        }
                    }

                    tBUnlockStatus.Text = "Collecting token...";

                    //the final string which u can write to an file
                    string token = String.Join("\n", _token.ToArray());
                    sw.WriteLine(token.ToString());

                    sw.WriteLine(" ");
                    sw.WriteLine("Please copy everything above this line!");
                    sw.WriteLine(" ");
                    sw.WriteLine("Next, sign into your HTC Dev account on the webpage that just opened.");
                    sw.WriteLine("If you do not have an account, create and activate an account with your email, then come back to this link.");
                    sw.WriteLine("http://www.htcdev.com/bootloader/unlock-instructions/page-3");
                    sw.WriteLine("Then, paste the Token ID you just copied at the bottom of the webpage.");
                    sw.WriteLine("Hit submit, and wait for the email with the unlock file.");
                    sw.WriteLine(" ");
                    sw.WriteLine("Once you have received the unlock file, download it and continue on to the next step, unlocking your bootloader.");
                    sw.WriteLine("This file is saved as token.txt in the Data folder if you need it in the future.");
                    sw.Close();
                }

                MessageBox.Show("The token is saved as token.txt in the Data folder. Further instructions are there. Please press OK to dismiss...");
                //Process.Start("./Data/token.txt");

                MessageBoxResult messageResult = MessageBox.Show("The package has been secured! Your unlock code is located '/Data/token.txt'. Would you like to reboot now?", "Token Obtained!", MessageBoxButton.YesNo, MessageBoxImage.Information);
                if (messageResult == MessageBoxResult.Yes)
                {
                    Fastboot.Instance().Reboot(IDBoot.REBOOT);
                    Process.Start("http://www.htcdev.com/bootloader/unlock-instructions/page-3");
                    Process.Start(System.AppDomain.CurrentDomain.BaseDirectory + "/Data/token.txt");
                    MessageBox.Show("Next Step!", "Once you have recieved the unlock file from HTC, you can move on to the next step, unlocking your bootloader!", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                if (messageResult == MessageBoxResult.No)
                {
                    Process.Start("http://www.htcdev.com/bootloader/unlock-instructions/page-3");
                    Process.Start(System.AppDomain.CurrentDomain.BaseDirectory + "/Data/token.txt");
                    MessageBox.Show("Next Step!", "Once you have recieved the unlock file from HTC, you can move on to the next step, unlocking your bootloader! More information is also avaliable in the /Data/token.txt file.", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            else if (state == IDDeviceState.FASTBOOT)
            {
                using (StreamWriter sw = File.CreateText("./Data/token.txt"))
                {
                    List <string> _token = new List <string>();
                    foreach (string line in Fastboot.Instance().OEM.GetIdentifierToken())
                    {
                        GroupCollection groups = Regex.Match(line, @"^\(bootloader\)\s{1,}(?<PART>.*?)$").Groups;
                        string          part   = groups["PART"].Value;
                        if (String.IsNullOrEmpty(part) == false && Regex.IsMatch(part, @"^<{1,}.*?>{1,}$") == false)
                        {
                            _token.Add(part);
                        }
                    }

                    tBUnlockStatus.Text = "Collecting token...";

                    //the final string which u can write to an file
                    string token = String.Join("\n", _token.ToArray());
                    sw.WriteLine(token.ToString());

                    sw.WriteLine(" ");
                    sw.WriteLine("Please copy everything above this line!");
                    sw.WriteLine(" ");
                    sw.WriteLine("Next, sign into your HTC Dev account on the webpage that just opened.");
                    sw.WriteLine("If you do not have an account, create and activate an account with your email, then come back to this link.");
                    sw.WriteLine("http://www.htcdev.com/bootloader/unlock-instructions/page-3");
                    sw.WriteLine("Then, paste the Token ID you just copied at the bottom of the webpage.");
                    sw.WriteLine("Hit submit, and wait for the email with the unlock file.");
                    sw.WriteLine(" ");
                    sw.WriteLine("Once you have received the unlock file, download it and continue on to the next step, unlocking your bootloader.");
                    sw.WriteLine("This file is saved as token.txt in the Data folder if you need it in the future.");
                    sw.Close();
                }

                MessageBoxResult messageResult = MessageBox.Show("The package has been secured! Your unlock code is located '/Data/token.txt'. Would you like to reboot now?", "Token Obtained!", MessageBoxButton.YesNo, MessageBoxImage.Information);
                if (messageResult == MessageBoxResult.Yes)
                {
                    Fastboot.Instance().Reboot(IDBoot.REBOOT);
                    Process.Start("http://www.htcdev.com/bootloader/unlock-instructions/page-3");
                    Process.Start(System.AppDomain.CurrentDomain.BaseDirectory + "/Data/token.txt");
                    MessageBox.Show("Next Step!", "Once you have recieved the unlock file from HTC, you can move on to the next step, unlocking your bootloader!", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                if (messageResult == MessageBoxResult.No)
                {
                    Process.Start("http://www.htcdev.com/bootloader/unlock-instructions/page-3");
                    Process.Start(System.AppDomain.CurrentDomain.BaseDirectory + "/Data/token.txt");
                    MessageBox.Show("Next Step!", "Once you have recieved the unlock file from HTC, you can move on to the next step, unlocking your bootloader! More information is also avaliable in the /Data/token.txt file.", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            else
            {
                MessageBox.Show("A device was not detected... Please ensure that you have the correct drivers configured and that they are working!", "Device is not detected...", MessageBoxButton.OK, MessageBoxImage.Asterisk);
            }
        }
Пример #10
0
 private void btnErase_Click(object sender, RoutedEventArgs e)
 {
     if (deviceselector.Text == "")
     {
         MessageBox.Show("A device has not been detected! Please wait 10 seconds or diagnose the issue!", "No device detected", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     else
     {
         if (cBFbtPart.Text == "")
         {
             MessageBox.Show("You cannot continue unless you select a partition.", "Partition not Selected", MessageBoxButton.OK, MessageBoxImage.Information);
         }
         else
         {
             if (cBFbtPart.Text == "Boot")
             {
                 CidDialog ciddiag = CidDialog.Instance;
                 ciddiag.Show();
                 ciddiag.Add(Fastboot.Instance().Erase(IDDevicePartition.BOOT));
             }
             else if (cBFbtPart.Text == "Cache")
             {
                 CidDialog ciddiag = CidDialog.Instance;
                 ciddiag.Show();
                 ciddiag.Add(Fastboot.Instance().Erase(IDDevicePartition.CACHE));
             }
             else if (cBFbtPart.Text == "Data")
             {
                 CidDialog ciddiag = CidDialog.Instance;
                 ciddiag.Show();
                 ciddiag.Add(Fastboot.Instance().Erase(IDDevicePartition.DATA));
             }
             else if (cBFbtPart.Text == "Hboot")
             {
                 CidDialog ciddiag = CidDialog.Instance;
                 ciddiag.Show();
                 ciddiag.Add(Fastboot.Instance().Erase(IDDevicePartition.HBOOT));
             }
             else if (cBFbtPart.Text == "Kernel")
             {
                 CidDialog ciddiag = CidDialog.Instance;
                 ciddiag.Show();
                 ciddiag.Add(Fastboot.Instance().Erase(IDDevicePartition.KERNEL));
             }
             else if (cBFbtPart.Text == "Misc")
             {
                 CidDialog ciddiag = CidDialog.Instance;
                 ciddiag.Show();
                 ciddiag.Add(Fastboot.Instance().Erase(IDDevicePartition.MISC));
             }
             else if (cBFbtPart.Text == "Radio")
             {
                 CidDialog ciddiag = CidDialog.Instance;
                 ciddiag.Show();
                 ciddiag.Add(Fastboot.Instance().Erase(IDDevicePartition.RADIO));
             }
             else if (cBFbtPart.Text == "Ramdisk")
             {
                 CidDialog ciddiag = CidDialog.Instance;
                 ciddiag.Show();
                 ciddiag.Add(Fastboot.Instance().Erase(IDDevicePartition.RAMDISK));
             }
             else if (cBFbtPart.Text == "Recovery")
             {
                 CidDialog ciddiag = CidDialog.Instance;
                 ciddiag.Show();
                 ciddiag.Add(Fastboot.Instance().Erase(IDDevicePartition.RECOVERY));
             }
             else if (cBFbtPart.Text == "System")
             {
                 CidDialog ciddiag = CidDialog.Instance;
                 ciddiag.Show();
                 ciddiag.Add(Fastboot.Instance().Erase(IDDevicePartition.SYSTEM));
             }
             else if (cBFbtPart.Text == "Unlock Token")
             {
                 CidDialog ciddiag = CidDialog.Instance;
                 ciddiag.Show();
                 ciddiag.Add(Fastboot.Instance().Erase(IDDevicePartition.UNLOCKTOKEN));
             }
             else if (cBFbtPart.Text == "Zip")
             {
                 CidDialog ciddiag = CidDialog.Instance;
                 ciddiag.Show();
                 ciddiag.Add(Fastboot.Instance().Erase(IDDevicePartition.ZIP));
             }
         }
     }
 }
Пример #11
0
        private void btnFbtFlash_Click(object sender, RoutedEventArgs e)
        {
            if (tBFbtPath.Text == "")
            {
                if (MessageBox.Show("You have not selected a file to complete the command. \nWould you like to locate one now?", "Missing File", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                {
                    // Create OpenFileDialog
                    Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

                    // Set filter for file extension and default file extension
                    dlg.DefaultExt = "";
                    dlg.Filter     = "All Files (*.*)|*.*";
                    dlg.Title      = "Locate Files";

                    // Display OpenFileDialog by calling ShowDialog method
                    Nullable <bool> result = dlg.ShowDialog();

                    // Get the selected file name and display in a TextBox
                    if (result == true)
                    {
                        // Open document
                        string filename = dlg.FileName;
                        tBFbtPath.Text = filename;
                    }
                }
                else
                {
                    MessageBox.Show("You cannot continue unless you select a file.", "Missing File", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            else if (cBFbtPart.Text == "")
            {
                MessageBox.Show("You cannot continue unless you select a partition.", "Partition not Selected", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                if (cBFbtPart.Text == "Boot")
                {
                    CidDialog ciddiag = CidDialog.Instance;
                    ciddiag.Show();
                    ciddiag.Add(Fastboot.Instance().Flash(IDDevicePartition.BOOT, tBFbtPath.Text));
                }
                else if (cBFbtPart.Text == "Cache")
                {
                    CidDialog ciddiag = CidDialog.Instance;
                    ciddiag.Show();
                    ciddiag.Add(Fastboot.Instance().Flash(IDDevicePartition.CACHE, tBFbtPath.Text));
                }
                else if (cBFbtPart.Text == "Data")
                {
                    CidDialog ciddiag = CidDialog.Instance;
                    ciddiag.Show();
                    ciddiag.Add(Fastboot.Instance().Flash(IDDevicePartition.DATA, tBFbtPath.Text));
                }
                else if (cBFbtPart.Text == "Hboot")
                {
                    CidDialog ciddiag = CidDialog.Instance;
                    ciddiag.Show();
                    ciddiag.Add(Fastboot.Instance().Flash(IDDevicePartition.HBOOT, tBFbtPath.Text));
                }
                else if (cBFbtPart.Text == "Kernel")
                {
                    CidDialog ciddiag = CidDialog.Instance;
                    ciddiag.Show();
                    ciddiag.Add(Fastboot.Instance().Flash(IDDevicePartition.KERNEL, tBFbtPath.Text));
                }
                else if (cBFbtPart.Text == "Misc")
                {
                    CidDialog ciddiag = CidDialog.Instance;
                    ciddiag.Show();
                    ciddiag.Add(Fastboot.Instance().Flash(IDDevicePartition.MISC, tBFbtPath.Text));
                }
                else if (cBFbtPart.Text == "Radio")
                {
                    CidDialog ciddiag = CidDialog.Instance;
                    ciddiag.Show();
                    ciddiag.Add(Fastboot.Instance().Flash(IDDevicePartition.RADIO, tBFbtPath.Text));
                }
                else if (cBFbtPart.Text == "Ramdisk")
                {
                    CidDialog ciddiag = CidDialog.Instance;
                    ciddiag.Show();
                    ciddiag.Add(Fastboot.Instance().Flash(IDDevicePartition.RAMDISK, tBFbtPath.Text));
                }
                else if (cBFbtPart.Text == "Recovery")
                {
                    CidDialog ciddiag = CidDialog.Instance;
                    ciddiag.Show();
                    ciddiag.Add(Fastboot.Instance().Flash(IDDevicePartition.RECOVERY, tBFbtPath.Text));
                }
                else if (cBFbtPart.Text == "System")
                {
                    CidDialog ciddiag = CidDialog.Instance;
                    ciddiag.Show();
                    ciddiag.Add(Fastboot.Instance().Flash(IDDevicePartition.SYSTEM, tBFbtPath.Text));
                }
                else if (cBFbtPart.Text == "Unlock Token")
                {
                    CidDialog ciddiag = CidDialog.Instance;
                    ciddiag.Show();
                    ciddiag.Add(Fastboot.Instance().Flash(IDDevicePartition.UNLOCKTOKEN, tBFbtPath.Text));
                }
                else if (cBFbtPart.Text == "Zip")
                {
                    CidDialog ciddiag = CidDialog.Instance;
                    ciddiag.Show();
                    ciddiag.Add(Fastboot.Instance().Flash(IDDevicePartition.ZIP, tBFbtPath.Text));
                }
            }
        }
Пример #12
0
        void workerDeploy_DoWork(object sender, DoWorkEventArgs e)
        {
            if (File.Exists("./adb/adb.exe"))
            {
            }
            else
            {
                _count++;
            }
            if (File.Exists("./adb/fastboot.exe"))
            {
            }
            else
            {
                _count++;
            }
            if (File.Exists("./adb/aapt.exe"))
            {
            }
            else
            {
                _count++;
            }
            if (File.Exists("./adb/AdbWinApi.dll"))
            {
            }
            else
            {
                _count++;
            }
            if (File.Exists("./adb/AdbWinUsbApi.dll"))
            {
            }
            else
            {
                _count++;
            }

            if (_count > 0)
            {
                MessageBoxResult result = MessageBox.Show("The ADB and Fastboot files have not been deployed correctly. \nWould you like to deploy now? \nNot deploying will make this kit useless.", "Deployment Issue", MessageBoxButton.YesNo, MessageBoxImage.Error);
                if (result == MessageBoxResult.Yes)
                {
                    this.Dispatcher.Invoke((Action)(() =>
                    {
                        Start start = new Start();
                        start.ShowDialog();
                    }));
                }
                else
                {
                    // Cancel code here
                    MessageBox.Show("You must deploy the ADB and Fastboot utilities, otherwise the application will NOT work!", "Not Operable", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            else
            {
                ADB.Start();

                // Here we initiate the BASE Fastboot instance
                Fastboot.Instance();

                //This will starte a thread which checks every 10 sec for connected devices and call the given callback
                if (Fastboot.DeviceConnectionMonitor(true))
                {
                    //Here we define our callback function which will be raised if a device connects or disconnects
                    Fastboot.SetDeviceConnectionMonitorCallback = (CallbackDeviceConnectionMonitor)CheckDeviceState;
                }

                // Here we check if ADB is running and initiate the BASE ADB instance (IsStarted() will everytime check if the BASE ADB class exists, if not it will create it)
                if (ADB.IsStarted())
                {
                    //Here we check for connected devices
                    SetDeviceList();

                    //This will starte a thread which checks every 10 sec for connected devices and call the given callback
                    if (ADB.DeviceConnectionMonitor(true))
                    {
                        //Here we define our callback function which will be raised if a device connects or disconnects
                        ADB.SetDeviceConnectionMonitorCallback = (CallbackDeviceConnectionMonitor)CheckDeviceState;
                    }
                }
            }
        }
Пример #13
0
        private void btnGoFlash_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                #region Flash
                if (Settings.Selector == "Flash")
                {
                    switch (cbPartition.Text)
                    {
                    case "Boot":
                    {
                        if (tbFilepath.Text == "")
                        {
                            MessageBox.Show("You must browse for a file to flash! Please select a file.", "Missing file!", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        else
                        {
                            Fastboot.Instance().Flash(IDDevicePartition.BOOT, Quote.Text + tbFilepath.Text + Quote.Text);
                        }
                    }
                    break;

                    case "Cache":
                    {
                        if (tbFilepath.Text == "")
                        {
                            MessageBox.Show("You must browse for a file to flash! Please select a file.", "Missing file!", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        else
                        {
                            Fastboot.Instance().Flash(IDDevicePartition.CACHE, Quote.Text + tbFilepath.Text + Quote.Text);
                        }
                    }
                    break;

                    case "Data":
                    {
                        if (tbFilepath.Text == "")
                        {
                            MessageBox.Show("You must browse for a file to flash! Please select a file.", "Missing file!", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        else
                        {
                            Fastboot.Instance().Flash(IDDevicePartition.DATA, Quote.Text + tbFilepath.Text + Quote.Text);
                        }
                    }
                    break;

                    case "Hboot":
                    {
                        if (tbFilepath.Text == "")
                        {
                            MessageBox.Show("You must browse for a file to flash! Please select a file.", "Missing file!", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        else
                        {
                            Fastboot.Instance().Flash(IDDevicePartition.HBOOT, Quote.Text + tbFilepath.Text + Quote.Text);
                        }
                    }
                    break;

                    case "Kernel":
                    {
                        if (tbFilepath.Text == "")
                        {
                            MessageBox.Show("You must browse for a file to flash! Please select a file.", "Missing file!", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        else
                        {
                            Fastboot.Instance().Flash(IDDevicePartition.KERNEL, Quote.Text + tbFilepath.Text + Quote.Text);
                        }
                    }
                    break;

                    case "Misc":
                    {
                        if (tbFilepath.Text == "")
                        {
                            MessageBox.Show("You must browse for a file to flash! Please select a file.", "Missing file!", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        else
                        {
                            Fastboot.Instance().Flash(IDDevicePartition.MISC, Quote.Text + tbFilepath.Text + Quote.Text);
                        }
                    }
                    break;

                    case "Radio":
                    {
                        if (tbFilepath.Text == "")
                        {
                            MessageBox.Show("You must browse for a file to flash! Please select a file.", "Missing file!", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        else
                        {
                            Fastboot.Instance().Flash(IDDevicePartition.RADIO, Quote.Text + tbFilepath.Text + Quote.Text);
                        }
                    }
                    break;

                    case "Ramdisk":
                    {
                        if (tbFilepath.Text == "")
                        {
                            MessageBox.Show("You must browse for a file to flash! Please select a file.", "Missing file!", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        else
                        {
                            Fastboot.Instance().Flash(IDDevicePartition.RAMDISK, Quote.Text + tbFilepath.Text + Quote.Text);
                        }
                    }
                    break;

                    case "Recovery":
                    {
                        if (tbFilepath.Text == "")
                        {
                            MessageBox.Show("You must browse for a file to flash! Please select a file.", "Missing file!", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        else
                        {
                            Fastboot.Instance().Flash(IDDevicePartition.RECOVERY, Quote.Text + tbFilepath.Text + Quote.Text);
                        }
                    }
                    break;

                    case "System":
                    {
                        if (tbFilepath.Text == "")
                        {
                            MessageBox.Show("You must browse for a file to flash! Please select a file.", "Missing file!", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        else
                        {
                            Fastboot.Instance().Flash(IDDevicePartition.SYSTEM, Quote.Text + tbFilepath.Text + Quote.Text);
                        }
                    }
                    break;

                    case "Unlock Token":
                    {
                        if (tbFilepath.Text == "")
                        {
                            MessageBox.Show("You must browse for a file to flash! Please select a file.", "Missing file!", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        else
                        {
                            Fastboot.Instance().Flash(IDDevicePartition.UNLOCKTOKEN, Quote.Text + tbFilepath.Text + Quote.Text);
                        }
                    }
                    break;

                    case "Zip":
                    {
                        if (tbFilepath.Text == "")
                        {
                            MessageBox.Show("You must browse for a file to flash! Please select a file.", "Missing file!", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        else
                        {
                            Fastboot.Instance().Flash(IDDevicePartition.ZIP, Quote.Text + tbFilepath.Text + Quote.Text);
                        }
                    }
                    break;
                    }
                    #endregion
                }
                #region Erase
                else if (Settings.Selector == "Erase")
                {
                    switch (cbPartition.Text)
                    {
                    case "Boot":
                    {
                        Fastboot.Instance().Erase(IDDevicePartition.BOOT);
                    }
                    break;

                    case "Cache":
                    {
                        Fastboot.Instance().Erase(IDDevicePartition.CACHE);
                    }
                    break;

                    case "Data":
                    {
                        Fastboot.Instance().Erase(IDDevicePartition.DATA);
                    }
                    break;

                    case "Hboot":
                    {
                        MessageBox.Show("You cannot erase the " + cbPartition.Text + " partition!", "Protected Partition!", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    break;

                    case "Kernel":
                    {
                        Fastboot.Instance().Erase(IDDevicePartition.KERNEL);
                    }
                    break;

                    case "Misc":
                    {
                        Fastboot.Instance().Erase(IDDevicePartition.MISC);
                    }
                    break;

                    case "Radio":
                    {
                        Fastboot.Instance().Erase(IDDevicePartition.RADIO);
                    }
                    break;

                    case "Ramdisk":
                    {
                        Fastboot.Instance().Erase(IDDevicePartition.RAMDISK);
                    }
                    break;

                    case "Recovery":
                    {
                        Fastboot.Instance().Erase(IDDevicePartition.RECOVERY);
                    }
                    break;

                    case "System":
                    {
                        Fastboot.Instance().Erase(IDDevicePartition.SYSTEM);
                    }
                    break;

                    case "Unlock Token":
                    {
                        MessageBox.Show("You cannot erase the " + cbPartition.Text + " partition!", "Protected Partition!", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    break;

                    case "Zip":
                    {
                        MessageBox.Show("You cannot erase the " + cbPartition.Text + " partition!", "Protected Partition!", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    break;
                    }
                    #endregion
                }
                #region boot
                else if (Settings.Selector == "Boot")
                {
                    if (tbFilepath.Text == "")
                    {
                        MessageBox.Show("You must browse for a file to boot from! Please select a file.", "Missing file!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    else
                    {
                        Fastboot.Instance().Boot(Quote.Text + tbFilepath.Text + Quote.Text);
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    "An error has occured! A log file has been placed in the Logs folder. Please report this error, with the log file, in the toolkit thread on XDA. Links in the 'File' menu!",
                    "Critical Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                string fileDateTime = DateTime.Now.ToString("MMddyyyy") + "_" + DateTime.Now.ToString("HHmmss");
                var    file         = new StreamWriter("./Data/Logs/" + fileDateTime + ".txt");
                file.WriteLine(ex);
                file.Close();
            }
        }