Bluetooth: Sleep instead of dying on EOF
When a device is restarted, the UART may go away before the
packetizer. Print an error and sleep in case it isn't really
a restart.
Bug: 70855323
Test: Repeated restarts, check for Bluetooth tombstones
Change-Id: I2b4e677451e826d40dcc9d063d80dc0e17fc9aca
diff --git a/bluetooth/1.0/default/h4_protocol.cc b/bluetooth/1.0/default/h4_protocol.cc
index 163cc33..df40507 100644
--- a/bluetooth/1.0/default/h4_protocol.cc
+++ b/bluetooth/1.0/default/h4_protocol.cc
@@ -71,8 +71,10 @@
ssize_t bytes_read = TEMP_FAILURE_RETRY(read(fd, buffer, 1));
if (bytes_read != 1) {
if (bytes_read == 0) {
- LOG_ALWAYS_FATAL("%s: Unexpected EOF reading the packet type!",
- __func__);
+ // This is only expected if the UART got closed when shutting down.
+ ALOGE("%s: Unexpected EOF reading the packet type!", __func__);
+ sleep(5); // Expect to be shut down within 5 seconds.
+ return;
} else if (bytes_read < 0) {
LOG_ALWAYS_FATAL("%s: Read packet type error: %s", __func__,
strerror(errno));