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; } }
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(); } }
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 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(); } }