Example #1
0
        private void InitializeAdb()
        {
            try
            {
                if (!File.Exists("adb/aapt.exe"))
                {
                    Deploy.AAPT();
                }
                if (!File.Exists("adb/adb.exe") ||
                    !File.Exists("adb/AdbWinApi.dll") ||
                    !File.Exists("adb/AdbWinUsbApi.dll"))
                {
                    Deploy.ADB();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            if (!ADB.IsStarted)
            {
                ADB.Start();
            }
        }
Example #2
0
 public bool prepareADB()
 {
     Console.WriteLine("Preparing ADB");
     if (!ADB.IntegrityCheck())
     {
         Deploy.ADB();
     }
     Console.WriteLine("Starting ADB");
     ADB.Start();
     isAdbStarted = true;
     if (ADB.Devices().ToArray().Length > 0)
     {
         //Grabs the first device in the list
         androidDevice = ADB.Devices().ToArray()[0];
     }
     return(ADB.Devices().ToArray().Length > 0);
 }
Example #3
0
        private void SetupAndroidCtrl()
        {
            // Extract AndroidCtrl files if none are found
            if (!ADB.IntegrityCheck())
            {
                _log.Info("ADB files missing, deploying");
                // If AndroidCtrl path is empty, deply to ./ToolkitData/adb
                if (String.IsNullOrEmpty(Settings.Default.ACtrl_Location))
                {
                    Deploy.ADB("./ToolkitData/platform-tools");
                    _log.Info("ADB deployed to ./ToolkitData/platform-tools");
                }
                else
                {
                    Deploy.ADB(Settings.Default.ACtrl_Location);
                    _log.Info($"ADB deployed to {Settings.Default.ACtrl_Location}");
                }
            }

            if (!Fastboot.IntegrityCheck())
            {
                _log.Info("fastboot files missing, deploying");
                // If AndroidCtrl path is empty, deply to ./ToolkitData/adb
                if (String.IsNullOrEmpty(Settings.Default.ACtrl_Location))
                {
                    Deploy.Fastboot("./ToolkitData/platform-tools");
                    _log.Info("ADB deployed to ./ToolkitData/platform-tools");
                }
                else
                {
                    Deploy.Fastboot(Settings.Default.ACtrl_Location);
                    _log.Info($"ADB deployed to {Settings.Default.ACtrl_Location}");
                }
            }

            // Start Monitoring services
            // Check if ADB server is already running, and check if it is mismatched

            if (!ADB.IsStarted || !ADB.IntegrityVersionCheck())
            {
                _log.Warn("ADB server outdated or not started");
                ADB.Stop();
                _log.Info("Starting ADB server...");
                ADB.Start();
            }
        }
Example #4
0
 public void CheckandDeploy()
 {
     if (ADB.IntegrityCheck() == false)
     {
         Deploy.ADB();
     }
     if (Fastboot.IntegrityCheck() == false)
     {
         Deploy.Fastboot();
     }
     // Check if ADB is running
     if (ADB.IsStarted)
     {
         ADB.Stop();             // Stop ADB
         ADB.Stop(true);         // Force Stop ADB
     }
     else
     {
         ADB.Start();
     }                           // Start ADB
 }
Example #5
0
        private void Window_ContentRendered(object sender, EventArgs e)
        {
            #region FileStrucCheck

            CheckFileSystem();

            #endregion

            #region Select Device

            try
            {
                if (Properties.Settings.Default["Device"].ToString() == "None")
                {
                    MessageBox.Show("Please select your device on the next screen.", "No device selected", MessageBoxButton.OK, MessageBoxImage.Information);
                    var select = new DeviceSelector();
                    select.ShowDialog();
                }
                else
                {
                    //Continue
                }

                #region Restarting ADB server
                //Stopping of ADB server
                try
                {
                    foreach (Process proc in Process.GetProcessesByName("adb"))
                    {
                        proc.Kill();
                    }

                    foreach (Process proc in Process.GetProcessesByName("fastboot"))
                    {
                        proc.Kill();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

                Thread.Sleep(2000);

                //Deployment of ADB
                Deploy.ADB();

                //After deployment of adb and fastboot files we load the main form.

                Main main = new Main();
                main.Show();

                //After loading the main form, we close this one.

                this.Close();
                #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();
            }

            #endregion
        }
        private void btnDeploy_Click(object sender, RoutedEventArgs e)
        {
            Deploy.ADB();
            _count = 0;
            if (cBVerify.IsChecked == true)
            {
                if (File.Exists("./adb/adb.exe"))
                {
                    lbladb.Content    = "Checked!";
                    lbladb.Foreground = new SolidColorBrush(Colors.Green);
                }
                else
                {
                    _count++;
                    lbladb.Content = "Not Found!";
                }
                if (File.Exists("./adb/fastboot.exe"))
                {
                    lblfastboot.Content    = "Checked!";
                    lblfastboot.Foreground = new SolidColorBrush(Colors.Green);
                }
                else
                {
                    _count++;
                    lblfastboot.Content = "Not Found!";
                }
                if (File.Exists("./adb/aapt.exe"))
                {
                    lblaapt.Content    = "Checked!";
                    lblaapt.Foreground = new SolidColorBrush(Colors.Green);
                }
                else
                {
                    _count++;
                    lblaapt.Content = "Not Found!";
                }
                if (File.Exists("./adb/AdbWinApi.dll"))
                {
                    lbladbwinapi.Content    = "Checked!";
                    lbladbwinapi.Foreground = new SolidColorBrush(Colors.Green);
                }
                else
                {
                    _count++;
                    lbladbwinapi.Content = "Not Found!";
                }
                if (File.Exists("./adb/AdbWinUsbApi.dll"))
                {
                    lbladbwinusbapi.Content    = "Checked!";
                    lbladbwinusbapi.Foreground = new SolidColorBrush(Colors.Green);
                }
                else
                {
                    _count++;
                    lbladbwinusbapi.Content = "Not Found!";
                }

                if (_count > 0)
                {
                    lblFailFiles.Content    = _count + " files failed to validate.";
                    lblFailFiles.Foreground = new SolidColorBrush(Colors.Red);
                }
                else
                {
                    lblFailFiles.Content    = "All files accounted for!";
                    lblFailFiles.Foreground = new SolidColorBrush(Colors.Green);
                }
            }
        }