Loading system/btcore/include/hal_util.h +2 −2 Original line number Diff line number Diff line Loading @@ -16,8 +16,8 @@ #pragma once struct hw_module_t; #include <hardware/bluetooth.h> // Loads the Bluetooth library. This function looks explicitly for // libbluetooth.default.so and loads it. int hal_util_load_bt_library(const struct hw_module_t** module); int hal_util_load_bt_library(const bt_interface_t** interface); system/btcore/src/hal_util.cc +10 −20 Original line number Diff line number Diff line Loading @@ -37,10 +37,9 @@ using base::StringPrintf; #define BACKUP_PATH "/system/lib/hw/" BLUETOOTH_LIBRARY_NAME #endif int hal_util_load_bt_library(const struct hw_module_t** module) { const char* id = BT_STACK_MODULE_ID; const char* sym = HAL_MODULE_INFO_SYM_AS_STR; struct hw_module_t* hmi = nullptr; int hal_util_load_bt_library(const bt_interface_t** interface) { const char* sym = BLUETOOTH_INTERFACE_STRING; bt_interface_t* itf = nullptr; // Always try to load the default Bluetooth stack on GN builds. const char* path = BLUETOOTH_LIBRARY_NAME; Loading @@ -60,32 +59,23 @@ int hal_util_load_bt_library(const struct hw_module_t** module) { } } // Get the address of the struct hal_module_info. hmi = (struct hw_module_t*)dlsym(handle, sym); if (!hmi) { // Get the address of the bt_interface_t. itf = (bt_interface_t*)dlsym(handle, sym); if (!itf) { LOG(ERROR) << __func__ << ": failed to load symbol from Bluetooth library " << sym; goto error; } // Check that the id matches. if (strcmp(id, hmi->id) != 0) { LOG(ERROR) << StringPrintf("%s: id=%s does not match HAL module ID: %s", __func__, id, hmi->id); goto error; } hmi->dso = handle; // Success. LOG(INFO) << StringPrintf("%s: loaded HAL id=%s path=%s hmi=%p handle=%p", __func__, id, path, hmi, handle); LOG(INFO) << __func__ << " loaded HAL path=" << BLUETOOTH_LIBRARY_NAME << " btinterface=" << itf << " handle=" << handle; *module = hmi; *interface = itf; return 0; error: *module = NULL; *interface = NULL; if (handle) dlclose(handle); return -EINVAL; Loading system/btif/src/bluetooth.cc +1 −38 Original line number Diff line number Diff line Loading @@ -414,7 +414,7 @@ static int config_clear(void) { return btif_config_clear() ? BT_STATUS_SUCCESS : BT_STATUS_FAIL; } static const bt_interface_t bluetoothInterface = { EXPORT_SYMBOL bt_interface_t bluetoothInterface = { sizeof(bluetoothInterface), init, enable, Loading Loading @@ -448,40 +448,3 @@ static const bt_interface_t bluetoothInterface = { interop_database_clear, interop_database_add, }; const bt_interface_t* bluetooth__get_bluetooth_interface() { /* fixme -- add property to disable bt interface ? */ return &bluetoothInterface; } static int close_bluetooth_stack(UNUSED_ATTR struct hw_device_t* device) { cleanup(); return 0; } static int open_bluetooth_stack(const struct hw_module_t* module, UNUSED_ATTR char const* name, struct hw_device_t** abstraction) { static bluetooth_device_t device; device.common.tag = HARDWARE_DEVICE_TAG; device.common.version = 0; device.common.close = close_bluetooth_stack; device.get_bluetooth_interface = bluetooth__get_bluetooth_interface; device.common.module = (struct hw_module_t*)module; *abstraction = (struct hw_device_t*)&device; return 0; } static struct hw_module_methods_t bt_stack_module_methods = { .open = open_bluetooth_stack, }; EXPORT_SYMBOL struct hw_module_t HAL_MODULE_INFO_SYM = { .tag = HARDWARE_MODULE_TAG, .version_major = 1, .version_minor = 0, .id = BT_HARDWARE_MODULE_ID, .name = "Bluetooth Stack", .author = "The Android Open Source Project", .methods = &bt_stack_module_methods}; system/build/BUILD.gn +0 −5 Original line number Diff line number Diff line Loading @@ -55,11 +55,6 @@ config("linux") { "EXPORT_SYMBOL=__attribute__((visibility(\"default\")))", "KERNEL_MISSING_CLOCK_BOOTTIME_ALARM=TRUE", # This is a macro to that can be used by android hardware/libhardware # to not include dependencies on core project. This is a temporary # workaround until we get rid of dependency on hardware. "_HW_DONT_INCLUDE_CORE_=1", # This is a macro to that can be used by source code to detect if the # current build is done by GN or via Android.mk. This is a temporary # workaround until we can remove all Android-specific dependencies. Loading system/service/hal/bluetooth_interface.cc +4 −22 Original line number Diff line number Diff line Loading @@ -209,7 +209,7 @@ bt_os_callouts_t bt_os_callouts = {sizeof(bt_os_callouts_t), // BluetoothInterface implementation for production. class BluetoothInterfaceImpl : public BluetoothInterface { public: BluetoothInterfaceImpl() : hal_iface_(nullptr), hal_adapter_(nullptr) {} BluetoothInterfaceImpl() : hal_iface_(nullptr) {} ~BluetoothInterfaceImpl() override { if (hal_iface_) hal_iface_->cleanup(); Loading @@ -230,31 +230,18 @@ class BluetoothInterfaceImpl : public BluetoothInterface { bt_callbacks_t* GetHALCallbacks() const override { return &bt_callbacks; } const bluetooth_device_t* GetHALAdapter() const override { return hal_adapter_; } // Initialize the interface. This loads the shared Bluetooth library and sets // up the callbacks. bool Initialize() { // Load the Bluetooth shared library module. const hw_module_t* module; int status = hal_util_load_bt_library(&module); if (status) { LOG(ERROR) << "Failed to load Bluetooth library: " << status; return false; } // Open the Bluetooth adapter. hw_device_t* device; status = module->methods->open(module, BT_HARDWARE_MODULE_ID, &device); const bt_interface_t* interface; int status = hal_util_load_bt_library(&interface); if (status) { LOG(ERROR) << "Failed to open the Bluetooth module"; return false; } hal_adapter_ = reinterpret_cast<bluetooth_device_t*>(device); hal_iface_ = hal_adapter_->get_bluetooth_interface(); hal_iface_ = interface; // Initialize the Bluetooth interface. Set up the adapter (Bluetooth DM) API // callbacks. Loading Loading @@ -286,11 +273,6 @@ class BluetoothInterfaceImpl : public BluetoothInterface { // to this since the actual data resides in the shared Bluetooth library. const bt_interface_t* hal_iface_; // The HAL handle that represents the underlying Bluetooth adapter. We hold a // weak reference to this since the actual data resides in the shared // Bluetooth library. const bluetooth_device_t* hal_adapter_; DISALLOW_COPY_AND_ASSIGN(BluetoothInterfaceImpl); }; Loading Loading
system/btcore/include/hal_util.h +2 −2 Original line number Diff line number Diff line Loading @@ -16,8 +16,8 @@ #pragma once struct hw_module_t; #include <hardware/bluetooth.h> // Loads the Bluetooth library. This function looks explicitly for // libbluetooth.default.so and loads it. int hal_util_load_bt_library(const struct hw_module_t** module); int hal_util_load_bt_library(const bt_interface_t** interface);
system/btcore/src/hal_util.cc +10 −20 Original line number Diff line number Diff line Loading @@ -37,10 +37,9 @@ using base::StringPrintf; #define BACKUP_PATH "/system/lib/hw/" BLUETOOTH_LIBRARY_NAME #endif int hal_util_load_bt_library(const struct hw_module_t** module) { const char* id = BT_STACK_MODULE_ID; const char* sym = HAL_MODULE_INFO_SYM_AS_STR; struct hw_module_t* hmi = nullptr; int hal_util_load_bt_library(const bt_interface_t** interface) { const char* sym = BLUETOOTH_INTERFACE_STRING; bt_interface_t* itf = nullptr; // Always try to load the default Bluetooth stack on GN builds. const char* path = BLUETOOTH_LIBRARY_NAME; Loading @@ -60,32 +59,23 @@ int hal_util_load_bt_library(const struct hw_module_t** module) { } } // Get the address of the struct hal_module_info. hmi = (struct hw_module_t*)dlsym(handle, sym); if (!hmi) { // Get the address of the bt_interface_t. itf = (bt_interface_t*)dlsym(handle, sym); if (!itf) { LOG(ERROR) << __func__ << ": failed to load symbol from Bluetooth library " << sym; goto error; } // Check that the id matches. if (strcmp(id, hmi->id) != 0) { LOG(ERROR) << StringPrintf("%s: id=%s does not match HAL module ID: %s", __func__, id, hmi->id); goto error; } hmi->dso = handle; // Success. LOG(INFO) << StringPrintf("%s: loaded HAL id=%s path=%s hmi=%p handle=%p", __func__, id, path, hmi, handle); LOG(INFO) << __func__ << " loaded HAL path=" << BLUETOOTH_LIBRARY_NAME << " btinterface=" << itf << " handle=" << handle; *module = hmi; *interface = itf; return 0; error: *module = NULL; *interface = NULL; if (handle) dlclose(handle); return -EINVAL; Loading
system/btif/src/bluetooth.cc +1 −38 Original line number Diff line number Diff line Loading @@ -414,7 +414,7 @@ static int config_clear(void) { return btif_config_clear() ? BT_STATUS_SUCCESS : BT_STATUS_FAIL; } static const bt_interface_t bluetoothInterface = { EXPORT_SYMBOL bt_interface_t bluetoothInterface = { sizeof(bluetoothInterface), init, enable, Loading Loading @@ -448,40 +448,3 @@ static const bt_interface_t bluetoothInterface = { interop_database_clear, interop_database_add, }; const bt_interface_t* bluetooth__get_bluetooth_interface() { /* fixme -- add property to disable bt interface ? */ return &bluetoothInterface; } static int close_bluetooth_stack(UNUSED_ATTR struct hw_device_t* device) { cleanup(); return 0; } static int open_bluetooth_stack(const struct hw_module_t* module, UNUSED_ATTR char const* name, struct hw_device_t** abstraction) { static bluetooth_device_t device; device.common.tag = HARDWARE_DEVICE_TAG; device.common.version = 0; device.common.close = close_bluetooth_stack; device.get_bluetooth_interface = bluetooth__get_bluetooth_interface; device.common.module = (struct hw_module_t*)module; *abstraction = (struct hw_device_t*)&device; return 0; } static struct hw_module_methods_t bt_stack_module_methods = { .open = open_bluetooth_stack, }; EXPORT_SYMBOL struct hw_module_t HAL_MODULE_INFO_SYM = { .tag = HARDWARE_MODULE_TAG, .version_major = 1, .version_minor = 0, .id = BT_HARDWARE_MODULE_ID, .name = "Bluetooth Stack", .author = "The Android Open Source Project", .methods = &bt_stack_module_methods};
system/build/BUILD.gn +0 −5 Original line number Diff line number Diff line Loading @@ -55,11 +55,6 @@ config("linux") { "EXPORT_SYMBOL=__attribute__((visibility(\"default\")))", "KERNEL_MISSING_CLOCK_BOOTTIME_ALARM=TRUE", # This is a macro to that can be used by android hardware/libhardware # to not include dependencies on core project. This is a temporary # workaround until we get rid of dependency on hardware. "_HW_DONT_INCLUDE_CORE_=1", # This is a macro to that can be used by source code to detect if the # current build is done by GN or via Android.mk. This is a temporary # workaround until we can remove all Android-specific dependencies. Loading
system/service/hal/bluetooth_interface.cc +4 −22 Original line number Diff line number Diff line Loading @@ -209,7 +209,7 @@ bt_os_callouts_t bt_os_callouts = {sizeof(bt_os_callouts_t), // BluetoothInterface implementation for production. class BluetoothInterfaceImpl : public BluetoothInterface { public: BluetoothInterfaceImpl() : hal_iface_(nullptr), hal_adapter_(nullptr) {} BluetoothInterfaceImpl() : hal_iface_(nullptr) {} ~BluetoothInterfaceImpl() override { if (hal_iface_) hal_iface_->cleanup(); Loading @@ -230,31 +230,18 @@ class BluetoothInterfaceImpl : public BluetoothInterface { bt_callbacks_t* GetHALCallbacks() const override { return &bt_callbacks; } const bluetooth_device_t* GetHALAdapter() const override { return hal_adapter_; } // Initialize the interface. This loads the shared Bluetooth library and sets // up the callbacks. bool Initialize() { // Load the Bluetooth shared library module. const hw_module_t* module; int status = hal_util_load_bt_library(&module); if (status) { LOG(ERROR) << "Failed to load Bluetooth library: " << status; return false; } // Open the Bluetooth adapter. hw_device_t* device; status = module->methods->open(module, BT_HARDWARE_MODULE_ID, &device); const bt_interface_t* interface; int status = hal_util_load_bt_library(&interface); if (status) { LOG(ERROR) << "Failed to open the Bluetooth module"; return false; } hal_adapter_ = reinterpret_cast<bluetooth_device_t*>(device); hal_iface_ = hal_adapter_->get_bluetooth_interface(); hal_iface_ = interface; // Initialize the Bluetooth interface. Set up the adapter (Bluetooth DM) API // callbacks. Loading Loading @@ -286,11 +273,6 @@ class BluetoothInterfaceImpl : public BluetoothInterface { // to this since the actual data resides in the shared Bluetooth library. const bt_interface_t* hal_iface_; // The HAL handle that represents the underlying Bluetooth adapter. We hold a // weak reference to this since the actual data resides in the shared // Bluetooth library. const bluetooth_device_t* hal_adapter_; DISALLOW_COPY_AND_ASSIGN(BluetoothInterfaceImpl); }; Loading