Beispiel #1
0
        private void pbConnectDevice_Click(object sender, EventArgs e)
        {
            if (!connected)
            {
                android = AndroidController.Instance;

                string serial;

                android.UpdateDeviceList();

                if (android.HasConnectedDevices)
                {
                    serial = android.ConnectedDevices[0];
                    device = android.GetConnectedDevice(serial);
                    pbConnectDevice.Image = Properties.Resources.DroidConnected;
                    connected = true;
                }
                else
                {
                    android.Dispose();
                    android = null;
                    connected = false;
                }
            }
            else
            {
                android.Dispose();
                android = null;
                pbConnectDevice.Image = Properties.Resources.DroidGreyConnect;
                connected = false;
            }
        }
Beispiel #2
0
 /// <summary>
 /// Releases all resources used by <see cref="AndroidController"/>
 /// </summary>
 /// <remarks>Needs to be called when application has finished using <see cref="AndroidController"/></remarks>
 public void Dispose()
 {
     if (Adb.ServerRunning)
     {
         Adb.KillServer();
         Thread.Sleep(1000);
     }
     AndroidController.instance = null;
 }
Beispiel #3
0
 private void bwAndroid_DoWork(object sender, DoWorkEventArgs e)
 {
     switch (sAndroidAction)
     {
         case "checkDevices":
             android = AndroidController.Instance;
             android.UpdateDeviceList();
             break;
         case "installAPK":
             InstallAPK();
             break;
         case "reinstallAPK":
             InstallAPK(true);
             break;
     }
 }
        private void deviceRecognition_DoWork(object sender, DoWorkEventArgs e)
        {
            _android = AndroidController.Instance;
            try
            {
                _android.UpdateDeviceList();
                if (_android.HasConnectedDevices)
                {
                    _device = _android.GetConnectedDevice(_android.ConnectedDevices[0]);
                    switch (_device.State.ToString())
                    {
                        case "ONLINE":
                            if (_device.BuildProp.GetProp("ro.product.model") == null)
                            {
                            }
                            else
                            {
                                MessageBox.Show(_device.BuildProp.GetProp("ro.product.model"));
                                DeviceTextBox.Text = _device.BuildProp.GetProp("ro.product.model");
                            }
                            break;

                        case "FASTBOOT":

                            break;

                        case "RECOVERY":

                            break;

                        case "UNKNOWN":

                            break;
                    }

                }
                else
                {

                }
                _android.Dispose();
            }
            catch (Exception)
            {

            }
        }
        private void deviceRecognition_DoWork(object sender, DoWorkEventArgs e)
        {
            _android = AndroidController.Instance;
            try
            {
                _android.UpdateDeviceList();
                if (_android.HasConnectedDevices)
                {
                    _device = _android.GetConnectedDevice(_android.ConnectedDevices[0]);
                    switch (_device.State.ToString())
                    {
                        case "ONLINE":
                            if (_device.BuildProp.GetProp("ro.product.model") == null)
                            {
                                deviceLabel.Text = "Device: " + _device.SerialNumber;
                                statusLabel.Text = @"Status: Online";
                                statusLabel.Location = new Point(deviceLabel.Location.X + deviceLabel.Width,
                                    deviceLabel.Location.Y);
                                statusProgressSpinner.Location = new Point(statusLabel.Location.X + statusLabel.Width,
                                    statusLabel.Location.Y);
                                deviceProgressSpinner.Visible = false;
                                statusProgressSpinner.Visible = false;
                                refreshSpinner.Visible = false;
                            }
                            else
                            {
                                deviceLabel.Text = "Device: " + _device.BuildProp.GetProp("ro.product.model");
                                statusLabel.Text = @"Status: Online";
                                statusLabel.Location = new Point(deviceLabel.Location.X + deviceLabel.Width,
                                    deviceLabel.Location.Y);
                                statusProgressSpinner.Location = new Point(statusLabel.Location.X + statusLabel.Width,
                                    statusLabel.Location.Y);
                                deviceProgressSpinner.Visible = false;
                                statusProgressSpinner.Visible = false;
                                refreshSpinner.Visible = false;
                            }
                            break;

                        case "FASTBOOT":
                            deviceLabel.Text = "Device: " + _device.SerialNumber;
                            statusLabel.Text = @"Status: Fastboot";
                            statusLabel.Location = new Point(deviceLabel.Location.X + deviceLabel.Width,
                                deviceLabel.Location.Y);
                            statusProgressSpinner.Location = new Point(statusLabel.Location.X + statusLabel.Width,
                                statusLabel.Location.Y);
                            deviceProgressSpinner.Visible = false;
                            statusProgressSpinner.Visible = false;
                            refreshSpinner.Visible = false;
                            break;

                        case "RECOVERY":
                            deviceLabel.Text = "Device: " + _device.SerialNumber;
                            statusLabel.Text = @"Status: Recovery";
                            statusLabel.Location = new Point(deviceLabel.Location.X + deviceLabel.Width,
                                deviceLabel.Location.Y);
                            statusProgressSpinner.Location = new Point(statusLabel.Location.X + statusLabel.Width,
                                statusLabel.Location.Y);
                            deviceProgressSpinner.Visible = false;
                            statusProgressSpinner.Visible = false;
                            refreshSpinner.Visible = false;
                            break;

                        case "UNKNOWN":
                            deviceLabel.Text = "Device: " + _device.SerialNumber;
                            statusLabel.Text = @"Status: Unknown";
                            statusLabel.Location = new Point(deviceLabel.Location.X + deviceLabel.Width,
                                deviceLabel.Location.Y);
                            statusProgressSpinner.Location = new Point(statusLabel.Location.X + statusLabel.Width,
                                statusLabel.Location.Y);
                            deviceProgressSpinner.Visible = false;
                            statusProgressSpinner.Visible = false;
                            break;
                    }
                    deviceProgressSpinner.Visible = false;
                    refreshSpinner.Visible = false;
                }
                else
                {
                    deviceLabel.Text = @"Device: Not Found!";
                    statusLabel.Text = @"Status: Not Found!";
                    statusLabel.Location = new Point(deviceLabel.Location.X + deviceLabel.Width,
                        deviceLabel.Location.Y);
                    statusProgressSpinner.Location = new Point(statusLabel.Location.X + statusLabel.Width,
                        statusLabel.Location.Y);
                    deviceProgressSpinner.Visible = false;
                    statusProgressSpinner.Visible = false;
                    refreshSpinner.Visible = false;
                }
                _android.Dispose();
                reloadButton.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(this,
                    @"An error has occured! A log file has been placed in the Logs folder within the Data folder. Please send the file to WindyCityRockr or post the file in the toolkit thread.",
                    @"Houston, we have a problem!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                string fileDateTime = DateTime.Now.ToString("MMddyyyy") + "_" + DateTime.Now.ToString("HHmmss");
                var file = new StreamWriter("./Data/Logs/" + fileDateTime + ".txt");
                file.WriteLine(ex);
                file.Close();
            }
        }
        private async void UpdateDevice()
        {
            _android = AndroidController.Instance;
            try
            {
                Log.AddLogItem("Detecting Device...", "DEVICE");
                await TaskEx.Run(() => _android.UpdateDeviceList());
                if (await TaskEx.Run(() => _android.HasConnectedDevices))
                {
                    _device = await TaskEx.Run(() => _android.GetConnectedDevice(_android.ConnectedDevices[0]));
                    switch (_device.State.ToString())
                    {
                        case "ONLINE":
                            this.Dispatcher.BeginInvoke((Action)delegate()
                            {
                                statusLabel.Content = "Online";
                                statusEllipse.Fill = Brushes.Green;
                                Log.AddLogItem("Connected: Online.", "DEVICE");
                            });
                            break;

                        case "FASTBOOT":
                            this.Dispatcher.BeginInvoke((Action)delegate()
                            {
                                statusLabel.Content = "Fastboot";
                                statusEllipse.Fill = Brushes.Blue;
                                Log.AddLogItem("Connected: Fastboot.", "DEVICE");
                            });
                            break;

                        case "RECOVERY":
                            this.Dispatcher.BeginInvoke((Action)delegate()
                            {
                                statusLabel.Content = "Recovery";
                                statusEllipse.Fill = Brushes.Purple;
                                Log.AddLogItem("Connected: Recovery.", "DEVICE");
                            });
                            break;

                        case "SIDELOAD":
                            this.Dispatcher.BeginInvoke((Action)delegate ()
                            {
                                statusLabel.Content = "Sideload";
                                statusEllipse.Fill = Brushes.Orange;
                                Log.AddLogItem("Connected: Sideload.", "DEVICE");
                            });
                            break;

                        case "UNAUTHORIZED":
                            this.Dispatcher.BeginInvoke((Action)delegate ()
                            {
                                statusLabel.Content = "Unauthorized";
                                statusEllipse.Fill = Brushes.Orange;
                                Log.AddLogItem("Connected: Unauthorized.", "DEVICE");
                            });
                            break;

                        case "UNKNOWN":
                            this.Dispatcher.BeginInvoke((Action)delegate()
                            {
                                statusLabel.Content = "Unknown";
                                statusEllipse.Fill = Brushes.Gray;
                                Log.AddLogItem("Connected: Unknown.", "DEVICE");
                            });
                            break;
                    }
                }
                else
                {
                    this.Dispatcher.BeginInvoke((Action)delegate()
                    {
                        statusLabel.Content = "Offline";
                        statusEllipse.Fill = Brushes.Red;
                        Log.AddLogItem("No Device Found.", "DEVICE");
                    });
                }
                await TaskEx.Run(() => _android.Dispose());
            }
            catch (Exception ex)
            {
                string fileDateTime = DateTime.Now.ToString("MMddyyyy") + "_" + DateTime.Now.ToString("HHmmss");
                var file = new StreamWriter("./Data/Logs/" + fileDateTime + ".txt");
                file.WriteLine(ex);
                file.WriteLine(" ");
                file.WriteLine(logBox.Text);
                file.Close();
            }
        }
 /// <summary>
 /// Releases all resources used by <see cref="AndroidController"/>        
 /// </summary>
 /// <remarks>Needs to be called when application has finished using <see cref="AndroidController"/></remarks>
 public void Dispose()
 {
     if (Adb.ServerRunning)
     {
         Adb.KillServer();
         Thread.Sleep(1000);
     }
     AndroidController.instance = null;
 }
 private void Form1_Load(object sender, EventArgs e)
 {
     //Usually, you want to load this at startup, may take up to 5 seconds to initialize/set up resources/start server
     android = AndroidController.Instance;
 }
        /// <summary>
        /// Releases all resources used by <see cref="AndroidController"/>        
        /// </summary>
        /// <remarks>Needs to be called when application has finished using <see cref="AndroidController"/></remarks>
        public void Dispose()
        {
            if (Adb.ServerRunning)
            {
                Adb.KillServer();
                Thread.Sleep(1000);
            }

            ResourceFolderManager.Unregister(ANDROID_CONTROLLER_TMP_FOLDER);
            AndroidController.instance = null;
        }
 private void installApp_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         _android = AndroidController.Instance;
         _device = _android.GetConnectedDevice(_android.ConnectedDevices[0]);
         if (_device.InstallApk(AndroidLib.InitialCmd).ToString() == "True")
         {
             MessageBox.Show(@"The SuperCID app was successfully installed!", @"Hurray for SuperCID!",
                 MessageBoxButtons.OK, MessageBoxIcon.Information);
             MessageBox.Show(
                 @"The app will be named 'HTC DNA SuperCID' in your app drawer. Please run it and continue on to the next step.",
                 @"SuperCID App",
                 MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show(
                 @"An issue occured while attempting to install the SuperCID app. Please try again in a few moments.",
                 @"Houston, we have a problem!",
                 MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         _android.Dispose();
     }
     catch (Exception ex)
     {
         MessageBox.Show(
             @"An error has occured! A log file has been placed in the Logs folder within the Data folder. Please send the file to WindyCityRockr or post the file in the toolkit thread.",
             @"Houston, we have a problem!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         string fileDateTime = DateTime.Now.ToString("MMddyyyy") + "_" + DateTime.Now.ToString("HHmmss");
         var file = new StreamWriter("./Data/Logs/" + fileDateTime + ".txt");
         file.WriteLine(ex);
         file.Close();
     }
 }
Beispiel #11
0
 private void AutoCheckPoints_Load_1(object sender, EventArgs e)
 {
     android = AndroidController.Instance;       
     
 }
Beispiel #12
0
        private void DeviceInfo_Click(object sender, EventArgs e)
        {
            string serial;
            listBox1.Items.Clear();
            android = AndroidController.Instance;

            //Always call UpdateDeviceList() before using AndroidController on devices to get the most updated list
            android.UpdateDeviceList();

            if (android.HasConnectedDevices)
            {

                for (var i = 0; i < android.ConnectedDevices.Count; i++)
                {

                    serial = android.ConnectedDevices[i];
                    device = android.GetConnectedDevice(serial);
                    GetResolution(device, i);                  

                }
            }
            else
            {
                this.DeviceList.Text = "Error - No Devices Connected";
            }

        }// End Device Info code