Beispiel #1
0
        /// <summary>
        /// Keep reading log messages until cancelled by the listener or closed.
        /// </summary>
        internal void RunLogService(ILogListener listener, IDevice device, string logName)
        {
            // Connect to the given device
            SetDevice(device);

            // Send request
            Write(FormatAdbRequest("log:" + logName));

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

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

            var data     = new byte[16384];
            var receiver = new LogOutputReceiver(listener);

            while (true)
            {
                if (receiver.IsCancelled)
                {
                    break;
                }

                var count = tcpClient.GetStream().Read(data, 0, data.Length);
                if (count == 0)
                {
                    // we're at the end, we flush the output
                    break;
                }
                // send data to receiver
                receiver.AddOutput(data, 0, count);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Keep reading log messages until cancelled by the listener or closed.
        /// </summary>
        internal void RunLogService(ILogListener listener, IDevice device, string logName)
        {
            // Connect to the given device
            SetDevice(device);

            // Send request
            Write(FormatAdbRequest("log:" + logName));

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

            var data = new byte[16384];
            var receiver = new LogOutputReceiver(listener);
            while (true)
            {
                if (receiver.IsCancelled)
                {
                    break;
                }

                var count = tcpClient.GetStream().Read(data, 0, data.Length);
                if (count == 0)
                {
                    // we're at the end, we flush the output
                    break;
                }
                // send data to receiver 
                receiver.AddOutput(data, 0, count);
            }
        }