Implements the IAdbClient interface, and allows you to interact with the adb server and devices that are connected to that adb server.

For example, to fetch a list of all devices that are currently connected to this PC, you can call the GetDevices method.

To run a command on a device, you can use the ExecuteRemoteCommand(string, DeviceData, IShellOutputReceiver, CancellationToken, int) method.

Inheritance: IAdbClient
Exemple #1
0
        public frmSend(string filename)
        {
            InitializeComponent();
            _filename = filename;
            server    = new SharpAdbClient.AdbServer();
            var adbPath = @"C:\android - sdk\platform - tools\adb.exe";
            StartServerResult result;

            if (!System.IO.File.Exists(adbPath))
            {
                adbPath = @"C:\ProgramData\Microsoft\AndroidSDK\25\platform-tools\adb.exe";
            }
            if (!System.IO.File.Exists(adbPath))
            {
                MessageBox.Show("Unable to find adb.exe", "Error");
                return;
            }
            result = server.StartServer(adbPath, restartServerIfNewer: false);
            client = new SharpAdbClient.AdbClient();
            List <SharpAdbClient.DeviceData> devices = client.GetDevices();

            foreach (SharpAdbClient.DeviceData device in devices)
            {
                cboListDevices.Items.Add(device);
            }
            if (cboListDevices.Items.Count > 0)
            {
                cboListDevices.SelectedIndex = 0;
            }
        }
        internal AdbClient()
        {
            AdbServer.Instance.StartServer("adb.exe", false);
            if (!AdbServer.Instance.GetStatus().IsRunning)
            {
                throw new Exception("No ADB server running!");
            }

            this.client  = (ExtAdbClient)ExtAdbClient.Instance;
            this.monitor = new DeviceMonitor(new AdbSocket(client.EndPoint));

            monitor.DeviceChanged      += OnDeviceChanged;
            monitor.DeviceConnected    += OnDeviceConnected;
            monitor.DeviceDisconnected += OnDeviceDisconnected;
            monitor.Start();
        }
Exemple #3
0
        static void Main()
        {
            RestoreConfig();
            SetScrPath();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var menu = new ContextMenu();

            menu.Popup += (sender, args) =>
            {
                var client  = new SharpAdbClient.AdbClient();
                var devices = client.GetDevices();

                menu.MenuItems.Clear();

                menu.MenuItems.Add(new MenuItem("Set srccpy path", (o, eventArgs) => { ChooseScrPath(); }));

                if (CanViewDevices())
                {
                    var viewMenu = devices.Select(device =>
                                                  new MenuItem(device.Model, (o, eventArgs) => { ViewDevice(device); }))
                                   .ToArray();

                    menu.MenuItems.Add(new MenuItem("View", viewMenu));
                }

                var restartMenu = devices.Select(device => new MenuItem(device.Model,
                                                                        (o, eventArgs) => { RestartAction(client, device); })).ToArray();

                menu.MenuItems.Add(new MenuItem("Restart", restartMenu));

                menu.MenuItems.Add(new MenuItem("Exit", (o, eventArgs) => { Application.Exit(); }));
            };
            // Show the system tray icon.
            using (var pi = new ProcessIcon(menu))
            {
                pi.Display();

                // Make sure the application runs!
                Application.Run();
            }
        }
Exemple #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Framebuffer"/> class.
        /// </summary>
        /// <param name="device">
        /// The device for which to fetch the frame buffer.
        /// </param>
        /// <param name="client">
        /// A <see cref="AdbClient"/> which manages the connection with adb.
        /// </param>
        public Framebuffer(DeviceData device, AdbClient client)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }

            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            this.Device = device;

            this.client = client;

            // Initialize the headerData buffer
            var size = Marshal.SizeOf <FramebufferHeader>();

            this.headerData = new byte[size];
        }
 internal AdbDevice(ExtAdbClient client, DeviceData deviceData)
 {
     this.client     = client;
     this.deviceData = deviceData;
 }