コード例 #1
1
ファイル: AutoCheckPoints.cs プロジェクト: dave4086/AutoChkPt
        private void button1_Click(object sender, EventArgs e)
        {
            this.DeviceList.Text = "";
            string serial;

            //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);
                    this.DeviceList.AppendText(device.SerialNumber);
                    this.DeviceList.AppendText("\r\n");
                }
            }
            else
            {
                this.DeviceList.Text = "Error - No Devices Connected";
            }


        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string serial;

            android.UpdateDeviceList();

            listBox1.Items.Clear();
            label2.Text = "-null-";

            if (android.HasConnectedDevices)
            {
                serial = android.ConnectedDevices[0];
                device = android.GetConnectedDevice(serial);

                //Adds all of the build.prop keys to the listbox
                foreach (string key in device.BuildProp.Keys)
                {
                    listBox1.Items.Add(key);
                }

                // OR you could do
                // listBox1.Items.AddRange(device.BuildProp.Keys.ToArray());

                //So no items are selected right away
                listBox1.SelectedIndex = -1;
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: Oblongmana/MMS-Puller
        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;
            }
        }
コード例 #4
0
ファイル: BusyBox.cs プロジェクト: DanielKng/AndroidLib
        /// <summary>
        /// Initializes a new instance of the <see cref="BusyBox"/> class.
        /// </summary>
        /// <param name="device">The device.</param>
        internal BusyBox(Device device)
        {
            this.device = device;

            this.commands = new List<string>();

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

            }
        }
コード例 #6
0
        private void Button1_Click(object sender, EventArgs e)
        {
            string serial;

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

            if (android.HasConnectedDevices)
            {
                serial = android.ConnectedDevices[0];
                device = android.GetConnectedDevice(serial);
                this.TextBox1.Text = device.SerialNumber;
            }
            else
            {
                this.TextBox1.Text = "Error - No Devices Connected";
            }
        }
コード例 #7
0
        public bool IsConnected()
        {
            AndroidController android = null;

            android = AndroidController.Instance;
            if (android.HasConnectedDevices)
            {
                ArrayList devicelist = new ArrayList();
                serial = android.ConnectedDevices[0];
                device = android.GetConnectedDevice(serial);
                decimal   temp        = device.Battery.Temperature;
                ArrayList devicecheck = new ArrayList();
                devicecheck.Add(" Device: Online! ");
                devicecheck.Add(" Mode: USB debugging ");
                devicecheck.Add(" Serial Number: " + serial);
                devicecheck.Add(" -------------------------");
                devicecheck.Add(" Battery: " + device.Battery.Status.ToString() + " " + device.Battery.Level.ToString() + System.Environment.NewLine + "%");
                devicecheck.Add(" Battery Temperature: " + temp + System.Environment.NewLine + " �C");
                devicecheck.Add(" Battery Health: " + device.Battery.Health.ToString() + System.Environment.NewLine);
                listBox2.DataSource = devicecheck;
                return(true);
            }
            else
            {
                ArrayList devicecheck = new ArrayList();
                devicecheck.Add(" Remember to always have enable USB DEBUGGING! ");
                devicecheck.Add(" Device: Offline! ");
                devicecheck.Add(" Mode: --- ");
                devicecheck.Add(" Serial Number: --- ");
                devicecheck.Add(" -------------------------");
                devicecheck.Add(" Battery: --- ");
                devicecheck.Add(" Battery Temperature: --- ");
                devicecheck.Add(" Battery Health: --- ");
                listBox2.DataSource = devicecheck;
                return(false);
            }
        }
コード例 #8
0
ファイル: Adb.cs プロジェクト: OmarBizreh/AndroidLib
        /// <summary>
        /// Forms an <see cref="AdbCommand"/> that is passed to <c>Adb.ExecuteAdbCommand()</c>
        /// </summary>
        /// <param name="device">Specific <see cref="Device"/> to run the command on</param>
        /// <param name="rootShell">Specifies if you need <paramref name="executable"/> to run in a root shell</param>
        /// <param name="executable">Executable file on <paramref name="device"/> to execute</param>
        /// <param name="args">Any arguments that need to be sent to <paramref name="executable"/></param>
        /// <returns><see cref="AdbCommand"/> that contains formatted command information</returns>
        /// <remarks>This should only be used for Adb Shell commands, such as <c>adb shell getprop</c> or <c>adb shell dumpsys</c>.</remarks>
        /// <exception cref="DeviceHasNoRootException"> if <paramref name="device"/> does not have root</exception>
        /// <example>This example demonstrates how to create an <see cref="AdbCommand"/>
        /// <code>
        /// //This example shows how to create an AdbCommand object to execute on the running server.
        /// //The command we will create is "adb shell input keyevent KeyEventCode.HOME".
        /// //Notice how in the formation, you don't supply the prefix "adb", because the method takes care of it for you.
        /// //This example also assumes you have a Device instance named device.
        /// 
        /// AdbCommand adbCmd = Adb.FormAdbCommand(device, true, "input", "keyevent", (int)KeyEventCode.HOME);
        /// 
        /// </code>
        /// </example>
        public static AdbCommand FormAdbShellCommand(Device device, bool rootShell, string executable, params object[] args)
        {
            if (rootShell && !device.HasRoot)
                throw new DeviceHasNoRootException();

            string shellCommand = string.Format("-s {0} shell \"", device.SerialNumber);

            if (rootShell)
                shellCommand += "su -c \"";

            shellCommand += executable;

            for (int i = 0; i < args.Length; i++)
                shellCommand += " " + args[i];

            if (rootShell)
                shellCommand += "\"";

            shellCommand += "\"";

            return new AdbCommand(shellCommand);
        }
コード例 #9
0
ファイル: Adb.cs プロジェクト: OmarBizreh/AndroidLib
        /// <summary>
        /// Forwards a port that remains until the current <see cref="AndroidController"/> instance is Disposed, or the device is unplugged
        /// </summary>
        /// <remarks>Only supports tcp: forward spec for now</remarks>
        /// <param name="device">Instance of <see cref="Device"/> to apply port forwarding to</param>
        /// <param name="localPort">Local port number</param>
        /// <param name="remotePort">Remote port number</param>
        /// <returns>True if successful, false if unsuccessful</returns>
        public static bool PortForward(Device device, int localPort, int remotePort)
        {
            bool success = false;

            AdbCommand adbCmd = Adb.FormAdbCommand(device, "forward", "tcp:" + localPort, "tcp:" + remotePort);
            using (StringReader r = new StringReader(ExecuteAdbCommand(adbCmd)))
            {
                if (r.ReadToEnd().Trim() == "")
                    success = true;
            }

            return success;
        }
コード例 #10
0
ファイル: AutoCheckPoints.cs プロジェクト: dave4086/AutoChkPt
        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
コード例 #11
0
ファイル: EventArgs.cs プロジェクト: DanielKng/AndroidLib
 /// <summary>
 /// Initializes a new instance of the <see cref="OnBatteryInfoChangedEventArgs"/> class.
 /// Created by: Beatsleigher
 /// At:               08.06.2015, 11:07
 /// On:              BEATSLEIGHER-PC
 /// </summary>
 /// <param name="m_message">The m_message.</param>
 /// <param name="m_device">The m_device.</param>
 /// <param name="m_batteryLevel">The m_battery level.</param>
 public OnBatteryInfoChangedEventArgs(string m_message, Device m_device)
 {
     this.Message = m_message;
     this.Device = m_device;
 }
コード例 #12
0
        /// <summary>
        /// Determines if the Android device tied to <paramref name="device"/> is currently connected
        /// </summary>
        /// <param name="device">Instance of <see cref="Device"/></param>
        /// <returns>A value indicating if the Android device indicated in <paramref name="device"/> is connected</returns>
        public bool IsDeviceConnected(Device device)
        {
            this.UpdateDeviceList();

            foreach (string d in this.connectedDevices)
                if (d == device.SerialNumber)
                    return true;

            return false;
        }
コード例 #13
0
        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();
            }
        }
コード例 #14
0
ファイル: BatteryInfo.cs プロジェクト: DanielKng/AndroidLib
 /// <summary>
 /// Initializes a new instance of the BatteryInfo class
 /// </summary>
 /// <param name="device">Serial number of Android device</param>
 internal BatteryInfo(Device device, bool monitorBattery = true) {
     this.device = device;
     this.MonitorBattery = monitorBattery;
     Update();
 }
コード例 #15
0
 internal Su(Device device)
 {
     this.device = device;
     GetSuData();
 }
コード例 #16
0
ファイル: Adb.cs プロジェクト: DanielKng/AndroidLib
 /// <summary>
 /// Forms an <see cref="AdbCommand"/> that is passed to <c>Adb.ExecuteAdbCommand()</c>
 /// </summary>
 /// <remarks>This should only be used for device-specific Adb commands, such as <c>adb push</c> or <c>adb pull</c>.</remarks>
 /// <param name="device">Specific <see cref="Device"/> to run the command on</param>
 /// <param name="command">The command to run on the Adb Server</param>
 /// <param name="args">Any arguments that need to be sent to <paramref name="command"/></param>
 /// <returns><see cref="AdbCommand"/> that contains formatted command information</returns>
 /// <example>This example demonstrates how to create an <see cref="AdbCommand"/>
 /// <code>//This example shows how to create an AdbCommand object to execute on the running server.
 /// //The command we will create is "adb pull /system/app C:\".  
 /// //Notice how in the formation, you don't supply the prefix "adb", because the method takes care of it for you.
 /// //This example also assumes you have a Device instance named device.
 /// 
 /// AdbCommand adbCmd = Adb.FormAdbCommand(device, "pull", "/system/app", @"C:\");
 /// 
 /// </code>
 /// </example>
 public static AdbCommand FormAdbCommand(Device device, string command, params object[] args) {
     //return FormAdbCommand("-s " + device.SerialNumber + " " + command, args);
     return FormAdbCommand(string.Format("-s {0} {1}", device.SerialNumber, command), args);
 }
コード例 #17
0
ファイル: Adb.cs プロジェクト: Dynogic/AndroidLib
 public static void ExecuteAdbShellCommandInputString(Device device, params string[] inputLines)
 {
     lock (_lock)
     {
         Command.RunProcessWriteInput(GetAdb(), "shell", inputLines);
     }
 }
コード例 #18
0
 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();
     }
 }
コード例 #19
0
 private void doAdbBackupMethod(Device device, String packageName)
 {
 }
コード例 #20
0
        private void doPullMethod(Device device, String packageName)
        {
            String targetFolder = Path.Combine(Classes.Application.Info.getApplicationPath(), "imports", device.SerialNumber);

            Adb.ExecuteAdbCommandNoReturn(Adb.FormAdbCommand("root"));

            //writeToLogBox("Checking if package is installed... ");
            //string shellOutput = Adb.ExecuteAdbCommand(Adb.FormAdbShellCommand(device, false, "pm list packages " + packageName));
            //if (shellOutput.Contains(packageName))
            //    writeToLogBox("OK!", true);
            //else
            //{
            //    writeToLogBox("Failed!");
            //    return;
            //}

            writeToLogBox("Creating output folder... ");
            Classes.Files.Directory.createFolder(targetFolder);
            writeToLogBox("OK!", true);

            writeToLogBox("Pulling msgstore.db... ");
            if (device.PullFile("/data/data/" + packageName + "/databases/msgstore.db", targetFolder))
                writeToLogBox("OK!", true);
            else
                writeToLogBox("Failed!", true);

            writeToLogBox("Pulling wa.db... ");
            if (device.PullFile("/data/data/" + packageName + "/databases/wa.db", targetFolder))
                writeToLogBox("OK!", true);
            else
                writeToLogBox("Failed!", true);

            writeToLogBox("Finished!");
        }
コード例 #21
0
ファイル: Adb.cs プロジェクト: OmarBizreh/AndroidLib
 /// <summary>
 /// Opens Adb Shell and allows input to be typed directly to the shell.  Experimental!
 /// </summary>
 /// <remarks>Added specifically for RegawMOD CDMA Hero Rooter.  Always remember to pass "exit" as the last command or it will not return!</remarks>
 /// <param name="device">Specific <see cref="Device"/> to run the command on</param>
 /// <param name="inputLines">Lines of commands to send to shell</param>
 public static void ExecuteAdbShellCommandInputString(Device device, params string[] inputLines)
 {
     lock (_lock)
     {
         Command.RunProcessWriteInput(AndroidController.Instance.ResourceDirectory + ADB_EXE, "shell", inputLines);
     }
 }
コード例 #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ActivityManager"/> class.
 /// </summary>
 /// <param name="m_device">The <see cref="RegawMOD.Android.Device"/> to associate with this object.</param>
 internal ActivityManager(Device m_device)
 {
     this.m_device = m_device;
 }
コード例 #23
0
ファイル: AutoCheckPoints.cs プロジェクト: dave4086/AutoChkPt
        private void timer2_Tick(object sender, EventArgs e)
        {
            string serial;

            if (android.HasConnectedDevices)
            {

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

                    serial = android.ConnectedDevices[i];
                    device = android.GetConnectedDevice(serial);
                    try { 
                    CheckRoutine(device, i);
                    }
                    catch
                    {
                        device.Reboot();
                        continue;
                    }

                }
            }
            else
            {
                this.DeviceList.Text = "Error - No Devices Connected";
            }
            //code that runs every x
        }
コード例 #24
0
ファイル: AutoCheckPoints.cs プロジェクト: dave4086/AutoChkPt
        }//end button 3 code

        private void GetResolution(Device device, int i)
        {
            string adbString1 = "shell dumpsys window displays";
            AdbCommand adbCmd = Adb.FormAdbCommand(device, adbString1);
            string dumpString = Adb.ExecuteAdbCommand(adbCmd, false);

            //Should have probably used RegEx for this, but this was faster and less complex.
            int index1 = dumpString.IndexOf("app=");
            int index2 = dumpString.IndexOf(" ", index1);
            //this is sloppy, but it works... revisit later
            string resString = dumpString.Substring(index1 + 4, index2 - index1 - 4);
            
            listBox1.Items.Add(resString);
        }
コード例 #25
0
 /// <summary>
 /// Initializes a new instance of the BatteryInfo class
 /// </summary>
 /// <param name="device">Serial number of Android device</param>
 internal BatteryInfo(Device device)
 {
     this.device = device;
     Update();
 }
コード例 #26
0
        public bool IsConnected()
        {
            AndroidController android = null;

            android = AndroidController.Instance;

            if (android.HasConnectedDevices)
            {
                ArrayList devicelist = new ArrayList();
                serial = android.ConnectedDevices[0];
                device = android.GetConnectedDevice(serial);
                decimal temp = device.Battery.Temperature;

                devicelist.Add(" Device: Xiaomi Redmi Note 7");
                devicelist.Add(" Codename: Lavender");
                devicelist.Add(" SoC: SDM660 Snapdragon 660");
                devicelist.Add(" CPU: 8x Qualcomm® Kryo™ 260 up to 2.2GHz");
                devicelist.Add(" GPU: Adreno 512");
                devicelist.Add(" Memory: 3GB / 4GB / 6GB RAM (LPDDR4X)");
                devicelist.Add(" Storage: 32GB / 64GB eMMC 5.1 flash storage");
                devicelist.Add(" Battery: Non-removable Li-Po 4000 mAh");
                devicelist.Add(" Dimensions: 159.21 x 75.21 x 8.1 mm");
                devicelist.Add(" Display: 2340 x 1080 (19.5:9), 6.3 inch");
                devicelist.Add(" Rear camera 1: 48MP, 1.6-micron pixels, f/1.8 Dual LED flash");
                devicelist.Add(" Rear camera 2: 5MP, 1.6-micron pixels, f/1.8");
                devicelist.Add(" Front camera: 13MP");
                listBox1.DataSource = devicelist;

                ArrayList devicecheck = new ArrayList();
                devicecheck.Add(" Device: Online! ");
                devicecheck.Add(" Mode: USB debugging ");
                devicecheck.Add(" Serial Number: " + serial);
                devicecheck.Add(" -------------------------");
                devicecheck.Add(" Battery: " + device.Battery.Status.ToString() + " " + device.Battery.Level.ToString() + System.Environment.NewLine + "%");
                devicecheck.Add(" Battery Temperature: " + temp + System.Environment.NewLine + " °C");
                devicecheck.Add(" Battery Health: " + device.Battery.Health.ToString() + System.Environment.NewLine);
                listBox2.DataSource = devicecheck;
                return(true);
            }
            else
            {
                ArrayList devicelist = new ArrayList();
                devicelist.Add(" Device: ---");
                devicelist.Add(" Codename: ---");
                devicelist.Add(" SoC: ---");
                devicelist.Add(" CPU: ---");
                devicelist.Add(" GPU: ---");
                devicelist.Add(" Memory: ---");
                devicelist.Add(" Storage: ---");
                devicelist.Add(" Battery: ---");
                devicelist.Add(" Dimensions: ---");
                devicelist.Add(" Display: ---");
                devicelist.Add(" Rear camera 1: ---");
                devicelist.Add(" Rear camera 2: ---");
                devicelist.Add(" Front camera: ---");
                listBox1.DataSource = devicelist;

                ArrayList devicecheck = new ArrayList();
                devicecheck.Add(" Remember to always have enable USB DEBUGGING! ");
                devicecheck.Add(" Device: Offline! ");
                devicecheck.Add(" Mode: --- ");
                devicecheck.Add(" Serial Number: --- ");
                devicecheck.Add(" -------------------------");
                devicecheck.Add(" Battery: --- ");
                devicecheck.Add(" Battery Temperature: --- ");
                devicecheck.Add(" Battery Health: --- ");
                listBox2.DataSource = devicecheck;
                return(false);
            }
        }
        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();
            }
        }
コード例 #28
0
ファイル: AutoCheckPoints.cs プロジェクト: dave4086/AutoChkPt
        private void button2_Click(object sender, EventArgs e)
        {
            resetFlag = true;
            this.StatusBox.Text = "";
            this.StatusBox.Text = "Reboot Command Issued";
            listBox1.Items.Clear();
            string serial;
            android.UpdateDeviceList();

            if (android.HasConnectedDevices)
            {

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

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

                }
            }
            else
            {
                this.DeviceList.Text = "Error - No Devices Connected";
            }
            android.Dispose();

        }
コード例 #29
0
ファイル: BuildProp.cs プロジェクト: Drarig29/AndroidLib
 internal BuildProp(Device device)
 {
     this.prop = new Dictionary<string, string>();
     this.device = device;
 }
コード例 #30
0
ファイル: Adb.cs プロジェクト: OmarBizreh/AndroidLib
 /// <summary>
 /// Forms an <see cref="AdbCommand"/> that is passed to <c>Adb.ExecuteAdbCommand()</c>
 /// </summary>
 /// <remarks>This should only be used for device-specific Adb commands, such as <c>adb push</c> or <c>adb pull</c>.</remarks>
 /// <param name="device">Specific <see cref="Device"/> to run the command on</param>
 /// <param name="command">The command to run on the Adb Server</param>
 /// <param name="args">Any arguments that need to be sent to <paramref name="command"/></param>
 /// <returns><see cref="AdbCommand"/> that contains formatted command information</returns>
 /// <example>This example demonstrates how to create an <see cref="AdbCommand"/>
 /// <code>//This example shows how to create an AdbCommand object to execute on the running server.
 /// //The command we will create is "adb pull /system/app C:\".  
 /// //Notice how in the formation, you don't supply the prefix "adb", because the method takes care of it for you.
 /// //This example also assumes you have a Device instance named device.
 /// 
 /// AdbCommand adbCmd = Adb.FormAdbCommand(device, "pull", "/system/app", @"C:\");
 /// 
 /// </code>
 /// </example>
 public static AdbCommand FormAdbCommand(Device device, string command, params object[] args)
 {
     return FormAdbCommand("-s " + device.SerialNumber + " " + command, args);
 }
コード例 #31
0
 internal FileSystem(Device device)
 {
     this.device = device;
     UpdateMountPoints();
 }
コード例 #32
0
ファイル: EventArgs.cs プロジェクト: DanielKng/AndroidLib
 /// <summary>
 /// Initializes a new instance of the <see cref="OnDeviceAddedEventArgs"/> class.
 /// </summary>
 /// <param name="m_message">The m_message.</param>
 /// <param name="m_device">The m_device.</param>
 public OnDeviceAddedEventArgs(string m_message, Device m_device)
 {
     this.Message = m_message;
     this.Device = m_device;
 }