コード例 #1
0
        public Task ExecuteRemoteCommandAsync(string command, DeviceData device, IShellOutputReceiver receiver, CancellationToken cancellationToken, int maxTimeToOutputResponse)
        {
            this.ReceivedCommands.Add(command);

            if (this.Commands.ContainsKey(command))
            {
                if (receiver != null)
                {
                    StringReader reader = new StringReader(this.Commands[command]);

                    while (reader.Peek() != -1)
                    {
                        receiver.AddOutput(reader.ReadLine());
                    }

                    receiver.Flush();
                }
            }
            else
            {
                throw new ArgumentOutOfRangeException(nameof(command), $"The command '{command}' was unexpected");
            }

            return(Task.FromResult(true));
        }
コード例 #2
0
ファイル: DummyAdbClient.cs プロジェクト: vebin/madb
        public Task ExecuteRemoteCommand(string command, DeviceData device, IShellOutputReceiver rcvr, CancellationToken cancellationToken, int maxTimeToOutputResponse)
        {
            this.ReceivedCommands.Add(command);

            if (this.Commands.ContainsKey(command))
            {
                if (rcvr != null)
                {
                    StringReader reader = new StringReader(this.Commands[command]);

                    while (reader.Peek() != -1)
                    {
                        rcvr.AddOutput(reader.ReadLine());
                    }

                    rcvr.Flush();
                }
            }
            else
            {
                throw new ArgumentOutOfRangeException(nameof(command));
            }

            return Task.FromResult(true);
        }
コード例 #3
0
ファイル: BusyBox.cs プロジェクト: vebin/madb
 /// <include file='.\BusyBox.xml' path='/BusyBox/ExecuteRootShellCommand/*'/>
 public void ExecuteRootShellCommand( String command, IShellOutputReceiver receiver, params object[] commandArgs )
 {
     command.ThrowIfNullOrWhiteSpace ( "command" );
     var cmd = String.Format ( "{0} {1}", BUSYBOX_COMMAND, String.Format ( command, commandArgs ) );
     Log.d ( "executing (su): {0}", cmd );
     Device.ExecuteRootShellCommand(cmd, receiver );
 }
コード例 #4
0
ファイル: BusyBox.cs プロジェクト: phaufe/madb
 /// <include file='.\BusyBox.xml' path='/BusyBox/ExecuteRootShellCommand/*'/>
 public void ExecuteRootShellCommand( String command, IShellOutputReceiver receiver, params object[] commandArgs )
 {
     command.ThrowIfNullOrWhiteSpace ( "command" );
     var cmd = String.Format ( "{0} {1}", BUSYBOX_COMMAND, String.Format ( command, commandArgs ) );
     Log.d ( "executing (su): {0}", cmd );
     AdbHelper.Instance.ExecuteRemoteRootCommand ( AndroidDebugBridge.SocketAddress, cmd, this.Device, receiver );
 }
コード例 #5
0
ファイル: BusyBox.cs プロジェクト: rbergen/CherryUpdater
        /// <summary>
        /// Executes a busybox command on the device as root
        /// </summary>
        /// <param name="command">The command.</param>
        /// <param name="receiver">The receiver.</param>
        /// <param name="commandArgs">The command args.</param>
        public void ExecuteRootShellCommand(string command, IShellOutputReceiver receiver, params object[] commandArgs)
        {
            var cmd = string.Format("{0} {1}", BUSYBOX_COMMAND, string.Format(command, commandArgs));

            Log.D(LOG_TAG, "executing as root: {0}", cmd);
            AdbHelper.Instance.ExecuteRemoteRootCommand(AndroidDebugBridge.SocketAddress, cmd, this.Device, receiver);
        }
コード例 #6
0
ファイル: BusyBox.cs プロジェクト: sttt/madb
        /// <include file='.\BusyBox.xml' path='/BusyBox/ExecuteRootShellCommand/*'/>
        public void ExecuteRootShellCommand(String command, IShellOutputReceiver receiver, params object[] commandArgs)
        {
            command.ThrowIfNullOrWhiteSpace("command");
            var cmd = String.Format("{0} {1}", BUSYBOX_COMMAND, String.Format(command, commandArgs));

            Log.d("executing (su): {0}", cmd);
            AdbHelper.Instance.ExecuteRemoteRootCommand(AndroidDebugBridge.SocketAddress, cmd, this.Device, receiver);
        }
コード例 #7
0
        /// <include file='.\BusyBox.xml' path='/BusyBox/ExecuteRootShellCommand/*'/>
        public void ExecuteRootShellCommand(String command, IShellOutputReceiver receiver, params object[] commandArgs)
        {
            command.ThrowIfNullOrWhiteSpace("command");
            var cmd = String.Format("{0} {1}", BUSYBOX_COMMAND, String.Format(command, commandArgs));

            Log.d("executing (su): {0}", cmd);
            Device.ExecuteRootShellCommand(cmd, receiver);
        }
コード例 #8
0
        /// <include file='.\BusyBox.xml' path='/BusyBox/ExecuteShellCommand/*'/>
        public void ExecuteShellCommand(String command, IShellOutputReceiver receiver, params object[] commandArgs)
        {
            command.ThrowIfNullOrWhiteSpace("command");
            var cmd = String.Format("{0} {1}", BUSYBOX_COMMAND, String.Format(command, commandArgs));

            Log.d("executing: {0}", cmd);
            AdbClient.Instance.ExecuteRemoteCommand(cmd, this.Device.DeviceData, receiver);
        }
コード例 #9
0
        /// <summary>
        /// Sends a tap event to the connected device with the given coordenates
        /// </summary>
        /// <param name="coordenates">Coordenates Tuple (X, Y)</param>
        public void Tap(Tuple <int, int> coordenates)
        {
            //TODO Check if device is null
            string command = "input tap " + coordenates.Item1 + " " + coordenates.Item2;

            IShellOutputReceiver receiver = null;

            AdbClient.Instance.ExecuteRemoteCommand(command, _device, receiver);
        }
コード例 #10
0
        /// <inheritdoc/>
        public void ExecuteRemoteCommand(string command, DeviceData device, IShellOutputReceiver receiver, CancellationToken cancellationToken, int maxTimeToOutputResponse)
        {
            this.EnsureDevice(device);

            using (IAdbSocket socket = Factories.AdbSocketFactory(this.EndPoint))
            {
                cancellationToken.Register(() => socket.Close());

                this.SetDevice(socket, device);
                socket.SendAdbRequest($"shell:{command}");
                var response = socket.ReadAdbResponse();

                try
                {
                    using (StreamReader reader = new StreamReader(socket.GetShellStream(), Encoding))
                    {
                        // Previously, we would loop while reader.Peek() >= 0. Turns out that this would
                        // break too soon in certain cases (about every 10 loops, so it appears to be a timing
                        // issue). Checking for reader.ReadLine() to return null appears to be much more robust
                        // -- one of the integration test fetches output 1000 times and found no truncations.
                        while (!cancellationToken.IsCancellationRequested)
                        {
                            var line = reader.ReadLine();

                            if (line == null)
                            {
                                break;
                            }

                            if (receiver != null)
                            {
                                receiver.AddOutput(line);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    // If a cancellation was requested, this main loop is interrupted with an exception
                    // because the socket is closed. In that case, we don't need to throw a ShellCommandUnresponsiveException.
                    // In all other cases, something went wrong, and we want to report it to the user.
                    if (!cancellationToken.IsCancellationRequested)
                    {
                        throw new ShellCommandUnresponsiveException(e);
                    }
                }
                finally
                {
                    if (receiver != null)
                    {
                        receiver.Flush();
                    }
                }
            }
        }
コード例 #11
0
ファイル: DummyDevice.cs プロジェクト: xuan2261/madb
 public void ExecuteShellCommand(string command, IShellOutputReceiver receiver, int maxTimeToOutputResponse, params object[] commandArgs)
 {
     if (command == "busybox")
     {
         throw new FileNotFoundException();
     }
     else
     {
         throw new NotImplementedException();
     }
 }
コード例 #12
0
ファイル: AdbRequest.cs プロジェクト: yuva2achieve/dot42
        /// <summary>
        /// Execute a shell command.
        /// </summary>
        internal void ExecuteShellCommand(IShellOutputReceiver receiver, IDevice device, int timeout, string command, params string[] args)
        {
            // Connect to the given device
            SetDevice(device);

            // Send request
            var req = new StringBuilder();

            req.Append("shell:");
            req.Append(Quote(command));
            foreach (var arg in args)
            {
                req.Append(' ');
                req.Append(Quote(arg));
            }
            Write(FormatAdbRequest(req.ToString()));

            // Read response
            var resp = ReadAdbResponse(false);

            if (!resp.Okay)
            {
                throw new AdbCommandRejectedException(resp.Message);
            }

            var data  = new byte[16384];
            var start = DateTime.Now;

            while (true)
            {
                if (receiver != null && receiver.IsCancelled)
                {
                    break;
                }

                var count = tcpClient.GetStream().Read(data, 0, data.Length);
                if (count == 0)
                {
                    // we're at the end, we flush the output
                    if (receiver != null)
                    {
                        receiver.Completed();
                    }
                    break;
                }
                // send data to receiver if present
                if (receiver != null)
                {
                    receiver.AddOutput(data, 0, count);
                }
            }
        }
コード例 #13
0
ファイル: AdbRequest.cs プロジェクト: Xtremrules/dot42
        /// <summary>
        /// Execute a shell command.
        /// </summary>
        internal void ExecuteShellCommand(IShellOutputReceiver receiver, IDevice device, int timeout, string command, params string[] args)
        {
            // Connect to the given device
            SetDevice(device);

            // Send request
            var req = new StringBuilder();
            req.Append("shell:");
            req.Append(Quote(command));
            foreach (var arg in args)
            {
                req.Append(' ');
                req.Append(Quote(arg));
            }
            Write(FormatAdbRequest(req.ToString()));

            // Read response
            var resp = ReadAdbResponse(false);
            if (!resp.Okay)
            {
                throw new AdbCommandRejectedException(resp.Message);
            }

            var data = new byte[16384];
            var start = DateTime.Now;
            while (true)
            {
                if (receiver != null && receiver.IsCancelled)
                {
                    break;
                }

                var count = tcpClient.GetStream().Read(data, 0, data.Length);
                if (count == 0)
                {
                    // we're at the end, we flush the output
                    if (receiver != null) 
                        receiver.Completed();
                    break;
                }
                // send data to receiver if present
                if (receiver != null)
                {
                    receiver.AddOutput(data, 0, count);
                }
            }
        }
コード例 #14
0
ファイル: Device.cs プロジェクト: sp0x/ApkLoader
        public async Task Uninstall(string pkgname, IShellOutputReceiver receiver)
        {
            var ar = new AsyncReceiver((lines) =>
            {
                string data    = string.Join("\n", lines);
                bool isUnknown = data.ToLower().Contains("unknown package");
                if (isUnknown)
                {
                    return(true);
                }
                Console.WriteLine(data);
                return(true);
            });

            this.ExecuteShellCommand($"pm uninstall {pkgname}", ar);
            await ar.WaitAsync();
        }
コード例 #15
0
 /// <summary>
 /// Executes a shell command on the remote device
 /// </summary>
 /// <param name="client">
 /// An instance of a class that implements the <see cref="IAdbClient"/> interface.
 /// </param>
 /// <param name="command">The command to execute</param>
 /// <param name="device">The device to execute on</param>
 /// <param name="rcvr">The shell output receiver</param>
 public static void ExecuteRemoteCommand(this IAdbClient client, string command, DeviceData device, IShellOutputReceiver rcvr)
 {
     try
     {
         client.ExecuteRemoteCommand(command, device, rcvr, CancellationToken.None, int.MaxValue);
     }
     catch (AggregateException ex)
     {
         if (ex.InnerExceptions.Count == 1)
         {
             throw ex.InnerException;
         }
         else
         {
             throw;
         }
     }
 }
コード例 #16
0
ファイル: Device.cs プロジェクト: xuan2261/madb
 /// <summary>
 /// Executes a shell command on the device, and sends the result to a receiver.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="receiver">The receiver.</param>
 /// <param name="commandArgs">The command args.</param>
 public void ExecuteShellCommand(string command, IShellOutputReceiver receiver, params object[] commandArgs)
 {
     AdbClient.Instance.ExecuteRemoteCommand(string.Format(command, commandArgs), this.DeviceData, receiver);
 }
コード例 #17
0
ファイル: DummyDevice.cs プロジェクト: phaufe/madb
 public void ExecuteShellCommand(string command, IShellOutputReceiver receiver, int maxTimeToOutputResponse)
 {
     this.ExecuteShellCommand(command, receiver, -1, null);
 }
コード例 #18
0
 /// <summary>
 /// Executes a shell command on the device.
 /// </summary>
 /// <param name="device">
 /// The device on which to run the command.
 /// </param>
 /// <param name="command">
 /// The command to execute.
 /// </param>
 /// <param name="receiver">
 /// Optionally, a <see cref="IShellOutputReceiver"/> that processes the command output.
 /// </param>
 public static void ExecuteShellCommand(this DeviceData device, string command, IShellOutputReceiver receiver)
 {
     AdbClient.Instance.ExecuteRemoteCommand(command, device, receiver);
 }
コード例 #19
0
ファイル: AdbClient.cs プロジェクト: xuan2261/madb
 /// <inheritdoc/>
 public Task ExecuteRemoteCommandAsync(string command, DeviceData device, IShellOutputReceiver receiver, CancellationToken cancellationToken, int maxTimeToOutputResponse)
 {
     return(this.ExecuteRemoteCommandAsync(command, device, receiver, cancellationToken, maxTimeToOutputResponse, Encoding));
 }
コード例 #20
0
        /// <summary>
        /// Executes a shell command on the device and retrieve the output. The output is
        /// handed to <var>rcvr</var> as it arrives.
        /// </summary>
        /// <param name="adbSockAddr"> the <seealso cref="InetSocketAddress"/> to adb. </param>
        /// <param name="command"> the shell command to execute </param>
        /// <param name="device"> the <seealso cref="IDevice"/> on which to execute the command. </param>
        /// <param name="rcvr"> the <seealso cref="IShellOutputReceiver"/> that will receives the output of the shell
        ///            command </param>
        /// <param name="maxTimeToOutputResponse"> max time between command output. If more time passes
        ///            between command output, the method will throw
        ///            <seealso cref="ShellCommandUnresponsiveException"/>. A value of 0 means the method will
        ///            wait forever for command output and never throw. </param>
        /// <exception cref="TimeoutException"> in case of timeout on the connection when sending the command. </exception>
        /// <exception cref="AdbCommandRejectedException"> if adb rejects the command </exception>
        /// <exception cref="ShellCommandUnresponsiveException"> in case the shell command doesn't send any output
        ///            for a period longer than <var>maxTimeToOutputResponse</var>. </exception>
        /// <exception cref="IOException"> in case of I/O error on the connection.
        /// </exception>
        /// <seealso cref= DdmPreferences#getTimeOut() </seealso>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: static void executeRemoteCommand(java.net.InetSocketAddress adbSockAddr, String command, IDevice device, IShellOutputReceiver rcvr, int maxTimeToOutputResponse) throws TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException, java.io.IOException
        internal static void executeRemoteCommand(EndPoint adbSockAddr, string command, IDevice device, IShellOutputReceiver rcvr, int maxTimeToOutputResponse)
        {
            Log.v("ddms", "execute: running " + command);

            SocketChannel adbChan = null;

            try
            {
                adbChan = SocketChannel.open(adbSockAddr);
                adbChan.configureBlocking(false);

                // if the device is not -1, then we first tell adb we're looking to
                // talk
                // to a specific device
                setDevice(adbChan, device);

                var request = formAdbRequest("shell:" + command);                 //$NON-NLS-1$
                write(adbChan, request);

                AdbResponse resp = readAdbResponse(adbChan, false);                 // readDiagString
                if (resp.okay == false)
                {
                    Log.e("ddms", "ADB rejected shell command (" + command + "): " + resp.message);
                    throw new AdbCommandRejectedException(resp.message);
                }

                var        data = new byte[16384];
                ByteBuffer buf  = ByteBuffer.wrap(data);
                int        timeToResponseCount = 0;
                while (true)
                {
                    int count;

                    if (rcvr != null && rcvr.cancelled)
                    {
                        Log.v("ddms", "execute: cancelled");
                        break;
                    }

                    count = adbChan.read(buf);
                    if (count < 0)
                    {
                        // we're at the end, we flush the output
                        rcvr.flush();
                        Log.v("ddms", "execute '" + command + "' on '" + device + "' : EOF hit. Read: " + count);
                        break;
                    }
                    else if (count == 0)
                    {
                        int wait = WAIT_TIME * 5;
                        timeToResponseCount += wait;
                        if (maxTimeToOutputResponse > 0 && timeToResponseCount > maxTimeToOutputResponse)
                        {
                            throw new ShellCommandUnresponsiveException();
                        }
                        Thread.Sleep(wait);
                    }
                    else
                    {
                        // reset timeout
                        timeToResponseCount = 0;

                        // send data to receiver if present
                        if (rcvr != null)
                        {
                            rcvr.addOutput(buf.array(), buf.arrayOffset(), buf.position);
                        }
                        buf.rewind();
                    }
                }
            }
            finally
            {
                if (adbChan != null)
                {
                    adbChan.close();
                }
                Log.v("ddms", "execute: returning");
            }
        }
コード例 #21
0
ファイル: Device.cs プロジェクト: sp0x/ApkLoader
 /// <summary>
 /// Executes a shell command on the device, and sends the result to a receiver.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="receiver">The receiver.</param>
 /// <param name="timeout">The timeout.</param>
 /// <param name="commandArgs">The command args.</param>
 public void ExecuteShellCommand(string command, IShellOutputReceiver receiver, int timeout, params object[] commandArgs)
 {
     AdbClient.Instance.ExecuteRemoteCommand(string.Format(command, commandArgs), this.DeviceData, receiver, CancellationToken.None);
 }
コード例 #22
0
ファイル: DummyDevice.cs プロジェクト: phaufe/madb
 public void ExecuteRootShellCommand(string command, IShellOutputReceiver receiver)
 {
     throw new NotImplementedException();
 }
コード例 #23
0
ファイル: Device.cs プロジェクト: vebin/madb
 /// <summary>
 /// Executes a shell command on the device, and sends the result to a receiver.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="receiver">The receiver.</param>
 /// <param name="timeout">The timeout.</param>
 public void ExecuteShellCommand(string command, IShellOutputReceiver receiver, int timeout)
 {
     this.ExecuteShellCommand(command, receiver, new object[] { });
 }
コード例 #24
0
ファイル: Device.cs プロジェクト: SwerveRobotics/tools
 public void ExecuteShellCommand(string command, IShellOutputReceiver receiver, params object[] commandArgs)
 {
     AdbHelper.Instance.ExecuteRemoteCommand(AndroidDebugBridge.AdbServerSocketAddress, string.Format(command, commandArgs), this.SerialNumber, receiver);
 }
コード例 #25
0
ファイル: DummyDevice.cs プロジェクト: phaufe/madb
 public void ExecuteRootShellCommand(string command, IShellOutputReceiver receiver, int maxTimeToOutputResponse)
 {
     throw new NotImplementedException();
 }
コード例 #26
0
ファイル: Device.cs プロジェクト: camalot/droidexplorer
 public void ExecuteShellCommand( String command, IShellOutputReceiver receiver )
 {
     AdbHelper.Instance.ExecuteRemoteCommand ( AndroidDebugBridge.SocketAddress, command, this,
                     receiver );
 }
コード例 #27
0
ファイル: DummyDevice.cs プロジェクト: phaufe/madb
 public void ExecuteShellCommand(string command, IShellOutputReceiver receiver, int maxTimeToOutputResponse, params object[] commandArgs)
 {
     if (command == "busybox")
     {
         throw new FileNotFoundException();
     }
     else
     {
         throw new NotImplementedException();
     }
 }
コード例 #28
0
ファイル: DummyDevice.cs プロジェクト: phaufe/madb
 public void ExecuteShellCommand(string command, IShellOutputReceiver receiver, params object[] commandArgs)
 {
     this.ExecuteShellCommand(command, receiver, -1, command);
 }
コード例 #29
0
ファイル: DummyDevice.cs プロジェクト: phaufe/madb
 public void ExecuteRootShellCommand(string command, IShellOutputReceiver receiver, params object[] commandArgs)
 {
     throw new NotImplementedException();
 }
コード例 #30
0
ファイル: Device.cs プロジェクト: NasC0/Side_Stuff
 /// <summary>
 /// Executes a shell command on the device as root, and sends the result to a receiver.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="receiver">The receiver.</param>
 public void ExecuteRootShellCommand(String command, IShellOutputReceiver receiver, int timeout)
 {
     ExecuteRootShellCommand(command, receiver, timeout, new object[] { });
 }
コード例 #31
0
ファイル: Device.cs プロジェクト: vebin/madb
 /// <summary>
 /// Executes a root shell command on the device, and sends the result to a receiver.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="receiver">The receiver.</param>
 /// <param name="commandArgs">The command args.</param>
 public void ExecuteRootShellCommand(string command, IShellOutputReceiver receiver, params object[] commandArgs)
 {
     this.ExecuteRootShellCommand(command, receiver, int.MaxValue, commandArgs);
 }
コード例 #32
0
ファイル: Device.cs プロジェクト: NasC0/Side_Stuff
 /// <summary>
 /// Executes a root shell command on the device, and sends the result to a receiver.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="receiver">The receiver.</param>
 /// <param name="commandArgs">The command args.</param>
 public void ExecuteRootShellCommand(String command, IShellOutputReceiver receiver, params object[] commandArgs)
 {
     ExecuteRootShellCommand(command, receiver, int.MaxValue, commandArgs);
 }
コード例 #33
0
ファイル: Device.cs プロジェクト: vebin/madb
 /// <summary>
 /// Executes a shell command on the device, and sends the result to a receiver.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="receiver">The receiver.</param>
 /// <param name="timeout">The timeout.</param>
 /// <param name="commandArgs">The command args.</param>
 public void ExecuteShellCommand(string command, IShellOutputReceiver receiver, int timeout, params object[] commandArgs)
 {
     AdbClient.Instance.ExecuteRemoteCommand(string.Format(command, commandArgs), this.DeviceData, receiver);
 }
コード例 #34
0
ファイル: AdbHelper.cs プロジェクト: ngzero/madb
        /// <summary>
        /// Executes the remote command.
        /// </summary>
        /// <param name="endPoint">The end point.</param>
        /// <param name="command">The command.</param>
        /// <param name="device">The device.</param>
        /// <param name="rcvr">The RCVR.</param>
        /// <param name="maxTimeToOutputResponse">The max time to output response.</param>
        /// <exception cref="System.OperationCanceledException"></exception>
        /// <exception cref="System.IO.FileNotFoundException">
        /// </exception>
        /// <exception cref="Managed.Adb.Exceptions.UnknownOptionException"></exception>
        /// <exception cref="Managed.Adb.Exceptions.CommandAbortingException"></exception>
        /// <exception cref="Managed.Adb.Exceptions.PermissionDeniedException"></exception>
        /// <exception cref="Managed.Adb.Exceptions.ShellCommandUnresponsiveException"></exception>
        /// <exception cref="AdbException">failed submitting shell command</exception>
        /// <exception cref="UnknownOptionException"></exception>
        /// <exception cref="CommandAbortingException"></exception>
        /// <exception cref="PermissionDeniedException"></exception>
        public void ExecuteRemoteCommand(IPEndPoint endPoint, String command, Device device, IShellOutputReceiver rcvr, int maxTimeToOutputResponse)
        {
            using(var socket = ExecuteRawSocketCommand(endPoint, device, "shell:{0}".With(command))) {
                socket.ReceiveTimeout = maxTimeToOutputResponse;
                socket.SendTimeout = maxTimeToOutputResponse;

                try {
                    byte[] data = new byte[16384];
                    int count = -1;
                    while(count != 0) {

                        if(rcvr != null && rcvr.IsCancelled) {
                            Log.w(TAG, "execute: cancelled");
                            throw new OperationCanceledException();
                        }

                        count = socket.Receive(data);
                        if(count == 0) {
                            // we're at the end, we flush the output
                            rcvr.Flush();
                            Log.w(TAG, "execute '" + command + "' on '" + device + "' : EOF hit. Read: " + count);
                        } else {
                            string[] cmd = command.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                            string sdata = data.GetString(0, count, AdbHelper.DEFAULT_ENCODING);

                            var sdataTrimmed = sdata.Trim();
                            if(sdataTrimmed.EndsWith(String.Format("{0}: not found", cmd[0]))) {
                                Log.w(TAG, "The remote execution returned: '{0}: not found'", cmd[0]);
                                throw new FileNotFoundException(string.Format("The remote execution returned: '{0}: not found'", cmd[0]));
                            }

                            if(sdataTrimmed.EndsWith("No such file or directory")) {
                                Log.w(TAG, "The remote execution returned: {0}", sdataTrimmed);
                                throw new FileNotFoundException(String.Format("The remote execution returned: {0}", sdataTrimmed));
                            }

                            // for "unknown options"
                            if(sdataTrimmed.Contains("Unknown option")) {
                                Log.w(TAG, "The remote execution returned: {0}", sdataTrimmed);
                                throw new UnknownOptionException(sdataTrimmed);
                            }

                            // for "aborting" commands
                            if(sdataTrimmed.IsMatch("Aborting.$")) {
                                Log.w(TAG, "The remote execution returned: {0}", sdataTrimmed);
                                throw new CommandAbortingException(sdataTrimmed);
                            }

                            // for busybox applets
                            // cmd: applet not found
                            if(sdataTrimmed.IsMatch("applet not found$") && cmd.Length > 1) {
                                Log.w(TAG, "The remote execution returned: '{0}'", sdataTrimmed);
                                throw new FileNotFoundException(string.Format("The remote execution returned: '{0}'", sdataTrimmed));
                            }

                            // checks if the permission to execute the command was denied.
                            // workitem: 16822
                            if(sdataTrimmed.IsMatch("(permission|access) denied$")) {
                                Log.w(TAG, "The remote execution returned: '{0}'", sdataTrimmed);
                                throw new PermissionDeniedException(String.Format("The remote execution returned: '{0}'", sdataTrimmed));
                            }

                            // Add the data to the receiver
                            if(rcvr != null) {
                                rcvr.AddOutput(data, 0, count);
                            }

                        }
                    }
                } catch(SocketException) {
                    throw new ShellCommandUnresponsiveException();
                } finally {
                    rcvr.Flush();
                }
            }
        }
コード例 #35
0
ファイル: Device.cs プロジェクト: sp0x/ApkLoader
 /// <summary>
 /// Executes a shell command on the device, and sends the result to a receiver.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="receiver">The receiver.</param>
 /// <param name="commandArgs">The command args.</param>
 public void ExecuteShellCommand(string command, IShellOutputReceiver receiver, CancellationToken ct)
 {
     AdbClient.Instance.ExecuteRemoteCommand(command, this.DeviceData, receiver, ct);
 }
コード例 #36
0
ファイル: AdbClientExtensions.cs プロジェクト: xuan2261/madb
 /// <summary>
 /// Executes a shell command on the remote device
 /// </summary>
 /// <param name="client">
 /// An instance of a class that implements the <see cref="IAdbClient"/> interface.
 /// </param>
 /// <param name="command">The command to execute</param>
 /// <param name="device">The device to execute on</param>
 /// <param name="rcvr">The shell output receiver</param>
 /// <param name="encoding">The encoding to use.</param>
 public static void ExecuteRemoteCommand(this IAdbClient client, string command, DeviceData device, IShellOutputReceiver rcvr, Encoding encoding)
 {
     try
     {
         client.ExecuteRemoteCommandAsync(command, device, rcvr, CancellationToken.None, int.MaxValue).Wait();
     }
     catch (AggregateException ex)
     {
         if (ex.InnerExceptions.Count == 1)
         {
             throw ex.InnerException;
         }
         else
         {
             throw;
         }
     }
 }
コード例 #37
0
ファイル: BusyBox.cs プロジェクト: vebin/madb
 /// <include file='.\BusyBox.xml' path='/BusyBox/ExecuteShellCommand/*'/>
 public void ExecuteShellCommand( String command, IShellOutputReceiver receiver, params object[] commandArgs )
 {
     command.ThrowIfNullOrWhiteSpace ( "command" );
     var cmd = String.Format ( "{0} {1}", BUSYBOX_COMMAND, String.Format ( command, commandArgs ) );
     Log.d ( "executing: {0}", cmd );
     AdbClient.Instance.ExecuteRemoteCommand(cmd, this.Device.DeviceData, receiver);
 }
コード例 #38
0
ファイル: AdbHelper.cs プロジェクト: camalot/droidexplorer
 /// <summary>
 /// Executes a shell command on the remote device
 /// </summary>
 /// <param name="endPoint">The socket end point</param>
 /// <param name="command">The command to execute</param>
 /// <param name="device">The device to execute on</param>
 /// <param name="rcvr">The shell output receiver</param>
 /// <exception cref="FileNotFoundException">Throws if the result is 'command': not found</exception>
 /// <exception cref="IOException">Throws if there is a problem reading / writing to the socket</exception>
 /// <exception cref="OperationCanceledException">Throws if the execution was canceled</exception>
 /// <exception cref="EndOfStreamException">Throws if the Socket.Receice ever returns -1</exception>
 public void ExecuteRemoteCommand( IPEndPoint endPoint, String command, Device device, IShellOutputReceiver rcvr )
 {
     ExecuteRemoteCommand ( endPoint, command, device, rcvr, int.MaxValue );
 }
コード例 #39
0
ファイル: AdbClient.cs プロジェクト: ArduPilot/MissionPlanner
        /// <inheritdoc/>
        public void ExecuteRemoteCommand(string command, DeviceData device, IShellOutputReceiver receiver, CancellationToken cancellationToken, int maxTimeToOutputResponse)
        {
            this.EnsureDevice(device);

            using (IAdbSocket socket = Factories.AdbSocketFactory(this.EndPoint))
            {
                cancellationToken.Register(() => socket.Close());

                this.SetDevice(socket, device);
                socket.SendAdbRequest($"shell:{command}");
                var response = socket.ReadAdbResponse();

                try
                {
                    using (StreamReader reader = new StreamReader(socket.GetShellStream(), Encoding))
                    {
                        // Previously, we would loop while reader.Peek() >= 0. Turns out that this would
                        // break too soon in certain cases (about every 10 loops, so it appears to be a timing
                        // issue). Checking for reader.ReadLine() to return null appears to be much more robust
                        // -- one of the integration test fetches output 1000 times and found no truncations.
                        while (!cancellationToken.IsCancellationRequested)
                        {
                            var line = reader.ReadLine();

                            if (line == null)
                            {
                                break;
                            }

                            if (receiver != null)
                            {
                                receiver.AddOutput(line);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    // If a cancellation was requested, this main loop is interrupted with an exception
                    // because the socket is closed. In that case, we don't need to throw a ShellCommandUnresponsiveException.
                    // In all other cases, something went wrong, and we want to report it to the user.
                    if (!cancellationToken.IsCancellationRequested)
                    {
                        throw new ShellCommandUnresponsiveException(e);
                    }
                }
                finally
                {
                    if (receiver != null)
                    {
                        receiver.Flush();
                    }
                }
            }
        }
コード例 #40
0
ファイル: AdbHelper.cs プロジェクト: camalot/droidexplorer
 /// <summary>
 /// Executes a shell command on the remote device
 /// </summary>
 /// <param name="endPoint">The end point.</param>
 /// <param name="command">The command.</param>
 /// <param name="device">The device.</param>
 /// <param name="rcvr">The RCVR.</param>
 /// <param name="maxTimeToOutputResponse">The max time to output response.</param>
 public void ExecuteRemoteRootCommand( IPEndPoint endPoint, String command, Device device, IShellOutputReceiver rcvr, int maxTimeToOutputResponse )
 {
     ExecuteRemoteCommand ( endPoint, String.Format ( "su -c \"{0}\"", command ), device, rcvr );
 }
コード例 #41
0
ファイル: Device.cs プロジェクト: xuan2261/madb
 /// <summary>
 /// Executes a shell command on the device, and sends the result to a receiver.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="receiver">The receiver.</param>
 /// <param name="timeout">The timeout.</param>
 public void ExecuteShellCommand(string command, IShellOutputReceiver receiver, int timeout)
 {
     this.ExecuteShellCommand(command, receiver, new object[] { });
 }
コード例 #42
0
ファイル: DeviceExtensions.cs プロジェクト: xuan2261/madb
 /// <summary>
 /// Executes a shell command on the device.
 /// </summary>
 /// <param name="device">
 /// The device on which to run the command.
 /// </param>
 /// <param name="command">
 /// The command to execute.
 /// </param>
 /// <param name="receiver">
 /// Optionally, a <see cref="IShellOutputReceiver"/> that processes the command output.
 /// </param>
 public static void ExecuteShellCommand(this DeviceData device, string command, IShellOutputReceiver receiver)
 {
     device.ExecuteShellCommand(AdbClient.Instance, command, receiver);
 }
コード例 #43
0
ファイル: Device.cs プロジェクト: xuan2261/madb
 /// <summary>
 /// Executes a root shell command on the device, and sends the result to a receiver.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="receiver">The receiver.</param>
 /// <param name="timeout">The timeout.</param>
 /// <param name="commandArgs">The command args.</param>
 public void ExecuteRootShellCommand(string command, IShellOutputReceiver receiver, int timeout, params object[] commandArgs)
 {
     AdbClient.Instance.ExecuteRemoteCommand(string.Format("su -c \"{0}\"", command), this.DeviceData, receiver);
 }
コード例 #44
0
ファイル: DummyDevice.cs プロジェクト: phaufe/madb
 public void ExecuteShellCommand(string command, IShellOutputReceiver receiver)
 {
     this.ExecuteShellCommand(command, receiver, -1);
 }
コード例 #45
0
ファイル: Device.cs プロジェクト: NasC0/Side_Stuff
 /// <summary>
 /// Executes a shell command on the device, and sends the result to a receiver.
 /// </summary>
 /// <param name="command">The command to execute</param>
 /// <param name="receiver">The receiver object getting the result from the command.</param>
 public void ExecuteShellCommand(String command, IShellOutputReceiver receiver)
 {
     ExecuteShellCommand(command, receiver, new object[] { });
 }
コード例 #46
0
 /// <summary>
 /// Executes a shell command on the remote device
 /// </summary>
 /// <param name="endPoint">The end point.</param>
 /// <param name="command">The command.</param>
 /// <param name="device">The device.</param>
 /// <param name="rcvr">The RCVR.</param>
 /// <param name="maxTimeToOutputResponse">The max time to output response.</param>
 public void ExecuteRemoteRootCommand(IPEndPoint endPoint, String command, Device device, IShellOutputReceiver rcvr, int maxTimeToOutputResponse)
 {
     ExecuteRemoteCommand(endPoint, String.Format("su -c \"{0}\"", command), device, rcvr);
 }
コード例 #47
0
ファイル: Device.cs プロジェクト: NasC0/Side_Stuff
 /// <summary>
 /// Executes a shell command on the device as root, and sends the result to a receiver.
 /// </summary>
 /// <param name="command">The command to execute</param>
 /// <param name="receiver">The receiver object getting the result from the command.</param>
 public void ExecuteRootShellCommand(String command, IShellOutputReceiver receiver)
 {
     ExecuteRootShellCommand(command, receiver, int.MaxValue);
 }
コード例 #48
0
        /// <summary>
        /// Executes the remote command.
        /// </summary>
        /// <param name="endPoint">The end point.</param>
        /// <param name="command">The command.</param>
        /// <param name="device">The device.</param>
        /// <param name="rcvr">The RCVR.</param>
        /// <param name="maxTimeToOutputResponse">The max time to output response.</param>
        /// <exception cref="AdbException">failed submitting shell command</exception>
        /// <exception cref="System.OperationCanceledException"></exception>
        /// <exception cref="Managed.Adb.Exceptions.ShellCommandUnresponsiveException"></exception>
        /// <exception cref="System.IO.FileNotFoundException"></exception>
        /// <exception cref="UnknownOptionException"></exception>
        /// <exception cref="CommandAbortingException"></exception>
        /// <exception cref="PermissionDeniedException"></exception>
        public void ExecuteRemoteCommand(IPEndPoint endPoint, String command, Device device, IShellOutputReceiver rcvr, int maxTimeToOutputResponse)
        {
            Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            if (!device.IsOnline)
            {
                return;
            }

            try {
                socket.Connect(endPoint);
                socket.ReceiveTimeout = maxTimeToOutputResponse;
                socket.SendTimeout    = maxTimeToOutputResponse;
                socket.Blocking       = true;

                SetDevice(socket, device);

                byte[] request = FormAdbRequest("shell:" + command);
                if (!Write(socket, request))
                {
                    throw new AdbException("failed submitting shell command");
                }

                AdbResponse resp = ReadAdbResponse(socket, false /* readDiagString */);
                if (!resp.IOSuccess || !resp.Okay)
                {
                    throw new AdbException("sad result from adb: " + resp.Message);
                }

                byte[] data  = new byte[16384];
                int    count = -1;
                while (count != 0)
                {
                    if (rcvr != null && rcvr.IsCancelled)
                    {
                        Log.w(TAG, "execute: cancelled");
                        throw new OperationCanceledException( );
                    }

                    count = socket.Receive(data);
                    if (count == 0)
                    {
                        // we're at the end, we flush the output
                        rcvr.Flush( );
                        Log.w(TAG, "execute '" + command + "' on '" + device + "' : EOF hit. Read: " + count);
                    }
                    else
                    {
                        string[] cmd   = command.Trim( ).Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        string   sdata = data.GetString(0, count, AdbHelper.DEFAULT_ENCODING);

                        var sdataTrimmed = sdata.Trim( );
                        if (sdataTrimmed.EndsWith(String.Format("{0}: not found", cmd[0])))
                        {
                            Log.w(TAG, "The remote execution returned: '{0}: not found'", cmd[0]);
                            throw new FileNotFoundException(string.Format("The remote execution returned: '{0}: not found'", cmd[0]));
                        }

                        if (sdataTrimmed.EndsWith("No such file or directory"))
                        {
                            Log.w(TAG, "The remote execution returned: {0}", sdataTrimmed);
                            throw new FileNotFoundException(String.Format("The remote execution returned: {0}", sdataTrimmed));
                        }

                        // for "unknown options"
                        if (sdataTrimmed.Contains("Unknown option"))
                        {
                            Log.w(TAG, "The remote execution returned: {0}", sdataTrimmed);
                            throw new UnknownOptionException(sdataTrimmed);
                        }

                        // for "aborting" commands
                        if (sdataTrimmed.IsMatch("Aborting.$"))
                        {
                            Log.w(TAG, "The remote execution returned: {0}", sdataTrimmed);
                            throw new CommandAbortingException(sdataTrimmed);
                        }

                        // for busybox applets
                        // cmd: applet not found
                        if (sdataTrimmed.IsMatch("applet not found$") && cmd.Length > 1)
                        {
                            Log.w(TAG, "The remote execution returned: '{0}'", sdataTrimmed);
                            throw new FileNotFoundException(string.Format("The remote execution returned: '{0}'", sdataTrimmed));
                        }

                        // checks if the permission to execute the command was denied.
                        // workitem: 16822
                        if (sdataTrimmed.IsMatch("(permission|access) denied$"))
                        {
                            Log.w(TAG, "The remote execution returned: '{0}'", sdataTrimmed);
                            throw new PermissionDeniedException(String.Format("The remote execution returned: '{0}'", sdataTrimmed));
                        }

                        // Add the data to the receiver
                        if (rcvr != null)
                        {
                            rcvr.AddOutput(data, 0, count);
                        }
                    }
                }
            } catch (SocketException s) {
                throw new ShellCommandUnresponsiveException( );
            } finally {
                if (socket != null)
                {
                    socket.Close( );
                }
                rcvr.Flush( );
            }
        }
コード例 #49
0
ファイル: Device.cs プロジェクト: NasC0/Side_Stuff
 /// <summary>
 /// Executes a root shell command on the device, and sends the result to a receiver.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="receiver">The receiver.</param>
 /// <param name="timeout">The timeout.</param>
 /// <param name="commandArgs">The command args.</param>
 public void ExecuteRootShellCommand(String command, IShellOutputReceiver receiver, int timeout, params object[] commandArgs)
 {
     AdbHelper.Instance.ExecuteRemoteRootCommand(AndroidDebugBridge.SocketAddress, string.Format(command, commandArgs), this, receiver, timeout);
 }
コード例 #50
0
 /// <summary>
 /// Executes a shell command on the remote device
 /// </summary>
 /// <param name="endPoint">The socket end point</param>
 /// <param name="command">The command to execute</param>
 /// <param name="device">The device to execute on</param>
 /// <param name="rcvr">The shell output receiver</param>
 /// <exception cref="FileNotFoundException">Throws if the result is 'command': not found</exception>
 /// <exception cref="IOException">Throws if there is a problem reading / writing to the socket</exception>
 /// <exception cref="OperationCanceledException">Throws if the execution was canceled</exception>
 /// <exception cref="EndOfStreamException">Throws if the Socket.Receice ever returns -1</exception>
 public void ExecuteRemoteCommand(IPEndPoint endPoint, String command, Device device, IShellOutputReceiver rcvr)
 {
     ExecuteRemoteCommand(endPoint, command, device, rcvr, int.MaxValue);
 }
コード例 #51
0
ファイル: AdbClientExtensions.cs プロジェクト: xuan2261/madb
 /// <summary>
 /// Executes a shell command on the remote device
 /// </summary>
 /// <param name="client">
 /// An instance of a class that implements the <see cref="IAdbClient"/> interface.
 /// </param>
 /// <param name="command">The command to execute</param>
 /// <param name="device">The device to execute on</param>
 /// <param name="rcvr">The shell output receiver</param>
 public static void ExecuteRemoteCommand(this IAdbClient client, string command, DeviceData device, IShellOutputReceiver rcvr)
 {
     ExecuteRemoteCommand(client, command, device, rcvr, AdbClient.Encoding);
 }
コード例 #52
0
ファイル: AdbClientExtensions.cs プロジェクト: vebin/madb
 /// <summary>
 /// Executes a shell command on the remote device
 /// </summary>
 /// <param name="client">
 /// An instance of a class that implements the <see cref="IAdbClient"/> interface.
 /// </param>
 /// <param name="command">The command to execute</param>
 /// <param name="device">The device to execute on</param>
 /// <param name="rcvr">The shell output receiver</param>
 public static void ExecuteRemoteCommand(this IAdbClient client, string command, DeviceData device, IShellOutputReceiver rcvr)
 {
     client.ExecuteRemoteCommand(command, device, rcvr, CancellationToken.None, int.MaxValue).Wait();
 }
コード例 #53
0
ファイル: AdbHelper.cs プロジェクト: camalot/droidexplorer
        /// <summary>
        /// Executes the remote command.
        /// </summary>
        /// <param name="endPoint">The end point.</param>
        /// <param name="command">The command.</param>
        /// <param name="device">The device.</param>
        /// <param name="rcvr">The RCVR.</param>
        /// <param name="maxTimeToOutputResponse">The max time to output response.</param>
        /// <exception cref="AdbException">failed submitting shell command</exception>
        /// <exception cref="System.OperationCanceledException"></exception>
        /// <exception cref="Managed.Adb.Exceptions.ShellCommandUnresponsiveException"></exception>
        /// <exception cref="System.IO.FileNotFoundException"></exception>
        /// <exception cref="UnknownOptionException"></exception>
        /// <exception cref="CommandAbortingException"></exception>
        /// <exception cref="PermissionDeniedException"></exception>
        public void ExecuteRemoteCommand( IPEndPoint endPoint, String command, Device device, IShellOutputReceiver rcvr, int maxTimeToOutputResponse )
        {
            Socket socket = new Socket ( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp );

            if ( !device.IsOnline ) {
                return;
            }

            try {
                socket.Connect ( endPoint );
                socket.Blocking = true;

                SetDevice ( socket, device );

                byte[] request = FormAdbRequest ( "shell:" + command );
                if ( !Write ( socket, request ) ) {
                    throw new AdbException ( "failed submitting shell command" );
                }

                AdbResponse resp = ReadAdbResponse ( socket, false /* readDiagString */);
                if ( !resp.IOSuccess || !resp.Okay ) {
                    throw new AdbException ( "sad result from adb: " + resp.Message );
                }

                byte[] data = new byte[16384];
                int timeToResponseCount = 0;

                while ( true ) {
                    int count;

                    if ( rcvr != null && rcvr.IsCancelled ) {
                        this.LogWarn("execute: cancelled" );
                        throw new OperationCanceledException ( );
                    }

                    count = socket.Receive ( data );
                    if ( count < 0 ) {
                        // we're at the end, we flush the output
                        rcvr.Flush ( );
                        this.LogInfo("execute '" + command + "' on '" + device + "' : EOF hit. Read: " + count );
                        break;
                    } else if ( count == 0 ) {
                        try {
                            int wait = WAIT_TIME * 5;
                            timeToResponseCount += wait;
                            if ( maxTimeToOutputResponse > 0 && timeToResponseCount > maxTimeToOutputResponse ) {
                                throw new AdbException ( );
                            }
                            Thread.Sleep ( wait );
                        } catch ( ThreadInterruptedException ) { }
                    } else {
                        timeToResponseCount = 0;

                        string[] cmd = command.Trim ( ).Split ( new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries );
                        string sdata = data.GetString ( 0, count, AdbHelper.DEFAULT_ENCODING );

                        var sdataTrimmed = sdata.Trim ( );
                        if ( sdataTrimmed.EndsWith ( String.Format ( "{0}: not found", cmd[0] ) ) ) {
                            this.LogWarn( "The remote execution returned: '{0}: not found'", cmd[0] );
                            throw new FileNotFoundException ( string.Format ( "The remote execution returned: '{0}: not found'", cmd[0] ) );
                        }

                        if ( sdataTrimmed.EndsWith ( "No such file or directory" ) ) {
                            this.LogWarn ( "The remote execution returned: {0}", sdataTrimmed );
                            throw new FileNotFoundException ( String.Format ( "The remote execution returned: {0}", sdataTrimmed ) );
                        }

                        // for "unknown options"
                        if ( sdataTrimmed.Contains ( "Unknown option" ) ) {
                            this.LogWarn ( "The remote execution returned: {0}", sdataTrimmed );
                            throw new UnknownOptionException ( sdataTrimmed );
                        }

                        // for "aborting" commands
                        if ( sdataTrimmed.IsMatch ( "Aborting.$" ) ) {
                            this.LogWarn ( "The remote execution returned: {0}", sdataTrimmed );
                            throw new CommandAbortingException ( sdataTrimmed );
                        }

                        // for busybox applets
                        // cmd: applet not found
                        if ( sdataTrimmed.IsMatch ( "applet not found$" ) && cmd.Length > 1 ) {
                            this.LogWarn ( "The remote execution returned: '{0}'", sdataTrimmed );
                            throw new FileNotFoundException ( string.Format ( "The remote execution returned: '{0}'", sdataTrimmed ) );
                        }

                        // checks if the permission to execute the command was denied.
                        // workitem: 16822
                        if ( sdataTrimmed.IsMatch ( "(permission|access) denied$" ) ) {
                            this.LogWarn ( "The remote execution returned: '{0}'", sdataTrimmed );
                            throw new PermissionDeniedException ( String.Format ( "The remote execution returned: '{0}'", sdataTrimmed ) );
                        }

                        // Add the data to the receiver
                        if ( rcvr != null ) {
                            rcvr.AddOutput ( data, 0, count );
                        }
                    }
                }
            } /*catch ( Exception e ) {
                Log.e ( TAG, e );
                Console.Error.WriteLine ( e.ToString ( ) );
                throw;
            }*/ finally {
                if ( socket != null ) {
                    socket.Close ( );
                }
                rcvr.Flush ( );
            }
        }
コード例 #54
0
ファイル: Device.cs プロジェクト: otugi/SmartArrow-Windows
 /// <summary>
 /// Executes a shell command on the device as root, and sends the result to a receiver.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="receiver">The receiver.</param>
 public void ExecuteRootShellCommand(String command, IShellOutputReceiver receiver, int timeout)
 {
     ExecuteRootShellCommand(command, receiver, timeout, new object[] { });
 }
コード例 #55
0
ファイル: AdbHelper.cs プロジェクト: camalot/droidexplorer
 /// <summary>
 /// Executes a shell command on the remote device
 /// </summary>
 /// <param name="endPoint">The end point.</param>
 /// <param name="command">The command.</param>
 /// <param name="device">The device.</param>
 /// <param name="rcvr">The RCVR.</param>
 /// <remarks>Should check if you CanSU before calling this.</remarks>
 public void ExecuteRemoteRootCommand( IPEndPoint endPoint, String command, Device device, IShellOutputReceiver rcvr )
 {
     ExecuteRemoteRootCommand ( endPoint, String.Format ( "su -c \"{0}\"", command ), device, rcvr, int.MaxValue );
 }
コード例 #56
0
ファイル: Device.cs プロジェクト: otugi/SmartArrow-Windows
 /// <summary>
 /// Executes a shell command on the device, and sends the result to a receiver.
 /// </summary>
 /// <param name="command">The command to execute</param>
 /// <param name="receiver">The receiver object getting the result from the command.</param>
 public void ExecuteShellCommand(String command, IShellOutputReceiver receiver)
 {
     ExecuteShellCommand(command, receiver, new object[] { });
 }
コード例 #57
0
ファイル: ADBUtils.cs プロジェクト: hejiheji001/Frida.Net
 public DeviceInfo(DeviceData deviceData, IShellOutputReceiver receiver = null)
 {
     this.deviceData = deviceData;
     this.receiver   = receiver;
 }
コード例 #58
0
ファイル: Device.cs プロジェクト: otugi/SmartArrow-Windows
 /// <summary>
 /// Executes a shell command on the device, and sends the result to a receiver.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="receiver">The receiver.</param>
 /// <param name="timeout">The timeout.</param>
 /// <param name="commandArgs">The command args.</param>
 public void ExecuteShellCommand(String command, IShellOutputReceiver receiver, int timeout, params object[] commandArgs)
 {
     AdbHelper.Instance.ExecuteRemoteCommand(AndroidDebugBridge.SocketAddress, string.Format(command, commandArgs), this, receiver);
 }
コード例 #59
0
ファイル: DeviceExtensions.cs プロジェクト: xuan2261/madb
 /// <summary>
 /// Executes a shell command on the device.
 /// </summary>
 /// <param name="device">
 /// The device on which to run the command.
 /// </param>
 /// <param name="client">
 /// The <see cref="IAdbClient"/> to use when executing the command.
 /// </param>
 /// <param name="command">
 /// The command to execute.
 /// </param>
 /// <param name="receiver">
 /// Optionally, a <see cref="IShellOutputReceiver"/> that processes the command output.
 /// </param>
 public static void ExecuteShellCommand(this DeviceData device, IAdbClient client, string command, IShellOutputReceiver receiver)
 {
     client.ExecuteRemoteCommand(command, device, receiver);
 }
コード例 #60
0
ファイル: Device.cs プロジェクト: vebin/madb
 /// <summary>
 /// Executes a shell command on the device as root, and sends the result to a receiver.
 /// </summary>
 /// <param name="command">The command to execute</param>
 /// <param name="receiver">The receiver object getting the result from the command.</param>
 public void ExecuteRootShellCommand(string command, IShellOutputReceiver receiver)
 {
     this.ExecuteRootShellCommand(command, receiver, int.MaxValue);
 }