Bluetooth: Change CHECK() to LOG_ALWAYS_FATAL()
Bug: 62641184
Test: Compilation
Change-Id: I21192c7a5c15def379d040b586a66ee1534c7c15
(cherry picked from commit 3e272a70763ff6191ac96d8560724e0a02f827ac)
diff --git a/bluetooth/1.0/default/bluetooth_address.cc b/bluetooth/1.0/default/bluetooth_address.cc
index 656d78d..65dc6a6 100644
--- a/bluetooth/1.0/default/bluetooth_address.cc
+++ b/bluetooth/1.0/default/bluetooth_address.cc
@@ -16,8 +16,8 @@
#include "bluetooth_address.h"
-#include <android-base/logging.h>
#include <cutils/properties.h>
+#include <errno.h>
#include <fcntl.h>
#include <utils/Log.h>
@@ -54,19 +54,25 @@
addr_fd = open(property, O_RDONLY);
if (addr_fd != -1) {
- int bytes_read = read(addr_fd, property, kStringLength);
- CHECK(bytes_read == kStringLength);
+ char address[kStringLength + 1] = {0};
+ int bytes_read = read(addr_fd, address, kStringLength);
+ if (bytes_read == -1) {
+ ALOGE("%s: Error reading address from %s: %s", __func__, property,
+ strerror(errno));
+ }
close(addr_fd);
// Null terminate the string.
- property[kStringLength] = '\0';
+ address[kStringLength] = '\0';
// If the address is not all zeros, then use it.
const uint8_t zero_bdaddr[kBytes] = {0, 0, 0, 0, 0, 0};
- if ((string_to_bytes(property, local_addr)) &&
+ if ((string_to_bytes(address, local_addr)) &&
(memcmp(local_addr, zero_bdaddr, kBytes) != 0)) {
valid_bda = true;
- ALOGD("%s: Got Factory BDA %s", __func__, property);
+ ALOGD("%s: Got Factory BDA %s", __func__, address);
+ } else {
+ ALOGE("%s: Got Invalid BDA '%s' from %s", __func__, address, property);
}
}
}