bluetooth: Find the device's Bluetooth address
Test: bluetooth_hidl_hal_test
Change-Id: I5353aaef3f8c5db75e424a8e1b242b08d5a96c6e
diff --git a/bluetooth/1.0/default/vendor_interface.cc b/bluetooth/1.0/default/vendor_interface.cc
index 7efd5bd..905e1a6 100644
--- a/bluetooth/1.0/default/vendor_interface.cc
+++ b/bluetooth/1.0/default/vendor_interface.cc
@@ -18,9 +18,13 @@
#define LOG_TAG "android.hardware.bluetooth@1.0-impl"
#include <android-base/logging.h>
+#include <cutils/properties.h>
#include <utils/Log.h>
#include <dlfcn.h>
+#include <fcntl.h>
+
+#include "bluetooth_address.h"
static const char* VENDOR_LIBRARY_NAME = "libbt-vendor.so";
static const char* VENDOR_LIBRARY_SYMBOL_NAME =
@@ -59,7 +63,7 @@
packet->len = data.size();
packet->layer_specific = 0;
packet->event = event;
- // TODO(eisenbach): Avoid copy here; if BT_HDR->data can be enusred to
+ // TODO(eisenbach): Avoid copy here; if BT_HDR->data can be ensured to
// be the only way the data is accessed, a pointer could be passed here...
memcpy(packet->data, data.data(), data.size());
return packet;
@@ -143,9 +147,6 @@
VendorInterface* VendorInterface::get() { return g_vendor_interface; }
bool VendorInterface::Open(PacketReadCallback packet_read_cb) {
- // TODO(eisenbach): P0 - get local BD address somehow
- uint8_t local_bda[] = {0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
-
firmware_configured_ = false;
packet_read_cb_ = packet_read_cb;
@@ -166,6 +167,10 @@
return false;
}
+ // Get the local BD address
+
+ uint8_t local_bda[BluetoothAddress::kBytes];
+ CHECK(BluetoothAddress::get_local_address(local_bda));
int status = lib_interface_->init(&lib_callbacks, (unsigned char*)local_bda);
if (status) {
ALOGE("%s unable to initialize vendor library: %d", __func__, status);