diff options
author | Hongguang Chen <hgchen@google.com> | 2020-04-22 14:25:45 -0700 |
---|---|---|
committer | Hongguang Chen <hgchen@google.com> | 2020-05-19 19:11:25 +0000 |
commit | 7516ebe63ba6ec9224ed65885c4c8eb5bf8575d9 (patch) | |
tree | c369880168517fcffbe979b37edd670e8a3e90e4 /fastboot/socket.cpp | |
parent | 8de46ae39dbc5a9a4cebabfeeaa392a9f6e64c7d (diff) |
fastbootd: Support TCP protocol.
The current fastbootd only supports USB protocol. But some Android TV
devices are built without USB port. The fastbootd cannot be used on
those ATV devices due to it.
This change adds TCP protocol for such devices and fastbootd.protocol
property is added to control which protocol to use.
BUG: 152544169
BUG: 155198345
Test: manual test.
Change-Id: Idc391e677eb6a1880036419ba5f6c4160e8dbcbc
Merged-In: Idc391e677eb6a1880036419ba5f6c4160e8dbcbc
Diffstat (limited to 'fastboot/socket.cpp')
-rw-r--r-- | fastboot/socket.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/fastboot/socket.cpp b/fastboot/socket.cpp index e56ffcf4b..5a14b6377 100644 --- a/fastboot/socket.cpp +++ b/fastboot/socket.cpp @@ -54,7 +54,9 @@ ssize_t Socket::ReceiveAll(void* data, size_t length, int timeout_ms) { while (total < length) { ssize_t bytes = Receive(reinterpret_cast<char*>(data) + total, length - total, timeout_ms); - if (bytes == -1) { + // Returns 0 only when the peer has disconnected because our requested length is not 0. So + // we return immediately to avoid dead loop here. + if (bytes <= 0) { if (total == 0) { return -1; } |