Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

An error occurred while reading data from the ADB stream #160

Open
ghost opened this issue Jan 6, 2020 · 5 comments
Open

An error occurred while reading data from the ADB stream #160

ghost opened this issue Jan 6, 2020 · 5 comments

Comments

@ghost
Copy link

ghost commented Jan 6, 2020

An error occurred while reading data from the ADB stream. Although the header size was expected to be 0x18, a header size of 0x696F was sent by the device

See picture

@qmfrederik
Copy link
Contributor

Are you reading adb logs?

@ghost
Copy link
Author

ghost commented Jan 7, 2020

Are you reading adb logs?

Yes! I'm calling method RunLogServiceAsync(). This is my code

public async Task StartListenToDeviceAsync()
{
    _adbServer.StartServer(AdbPath, false);
    var devicesList    = _adbClient.GetDevices();
    var sb             = new StringBuilder();
    var i              = 0;

    foreach (var deviceData in devicesList)
    {
        i++;
        sb.AppendLine($"#{i}\tname {deviceData.Name} / model {deviceData.Model} / product {deviceData.Product}");
    }
    _logger.WithCaller().Information($"Devices connected:\r\n{sb}");
    
    var device = _adbClient.GetDevices().FirstOrDefault();

    if (device == null)
    {
        _logger.WithCaller().Error("No devices");

        return;
    }

    // Local function
    void MessageCallback(LogEntry logEntry)
    {
        try
        {
            var androidLogEntry = logEntry as AndroidLogEntry;

            if (androidLogEntry?.Tag == "Ruby")
            {
                var message = androidLogEntry.Message;

                // Filter message contain OTP string
                if (message.Contains("title=otp"))
                {
                    var otp = FilterMessage(message, "body=", ", title=otp");
                    _logger.WithCaller().Information($"OTP logged: {otp}");
                    return;
                }
            }
        }
        catch (Exception e)
        {
            _logger.WithCaller().Error(e, "An error occurred while reading callback");
        }
    }

    await _adbClient.RunLogServiceAsync(device, MessageCallback, CancellationToken.None).ConfigureAwait(false);
}

@ghost
Copy link
Author

ghost commented Jan 8, 2020

@quamotion @qmfrederik Can you help me!

@ductai230894
Copy link

Anyone can fix it, I have same problem

@qmfrederik
Copy link
Contributor

It's a known problem. I haven't had time to investigate this yet. PRs are welcome.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants