コード例 #1
0
 private void buttonUntether_Click(object sender, EventArgs e)
 {
     deviceForOperation = (ADBDevice)comboBoxDevices.SelectedItem;
     if (buttonUntether.Text == "Untether")
     {
         untetherWorker.RunWorkerAsync();
     }
     else if (buttonUntether.Text == "Disconnect")
     {
         disconnectWorker.RunWorkerAsync();
     }
 }
コード例 #2
0
        public static void ChangeADBModeToUSB(ADBDevice device)
        {
            //Change the ADB mode to USB
            Process USBOperation = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName               = "cmd",
                    Arguments              = @"/C " + $"{ADB_Path} -s {device.DEVICE_ID} usb",
                    UseShellExecute        = false,
                    RedirectStandardOutput = true,
                    CreateNoWindow         = true
                }
            };

            //Launch process
            USBOperation.Start();
        }
コード例 #3
0
        public static String GatherIPAddress(ADBDevice device)
        {
            //Get IP address of the active interface
            Process IPQuery = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName               = "cmd",
                    Arguments              = $@"/C {ADB_Path} -s {device.DEVICE_ID} shell ip route",
                    UseShellExecute        = false,
                    RedirectStandardOutput = true,
                    CreateNoWindow         = true
                }
            };

            //Launch process
            IPQuery.Start();
            //Return IP address
            return(IPQuery.StandardOutput.ReadLine().Split(' ')[11]);
        }
コード例 #4
0
 private void comboBoxDevices_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboBoxDevices.SelectedItem != null)
     {
         ADBDevice selectedDevice = (ADBDevice)comboBoxDevices.SelectedItem;
         if (selectedDevice.DEVICE_ID.Contains("."))
         {
             buttonUntether.Text = "Disconnect";
             statusLabel.Text    = "This is a remote device connected to this computer.";
         }
         else if (ADBUtility.IsDeviceAlreadyConnected(ADBUtility.GatherIPAddress(selectedDevice)))
         {
             buttonUntether.Text = "Disconnect";
             statusLabel.Text    = "This device is already connected to this computer over WiFi.";
         }
         else
         {
             buttonUntether.Text = "Untether";
             String Network_Interface = ADBUtility.GatherInterface(selectedDevice);
             buttonUntether.Enabled = Network_Interface.Contains("wlan");
             statusLabel.Text       = Network_Interface.Contains("wlan") ? "Ready" : "The selecte device is not connected to a WiFi network.";
         }
     }
 }