summaryrefslogtreecommitdiffstats
path: root/hci
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2012-07-17 19:16:52 -0700
committerColin Cross <ccross@android.com>2012-07-17 19:16:52 -0700
commit6b69af7c683e1e3edd25891d73eba5914f885d4b (patch)
tree7f8de1c567e6e39d610614f795b06cfd6c8051dd /hci
parentdff2b120f73b1a2d12ef33de55cb553c86135b92 (diff)
downloadexternal_bluetooth_bluedroid-6b69af7c683e1e3edd25891d73eba5914f885d4b.zip
external_bluetooth_bluedroid-6b69af7c683e1e3edd25891d73eba5914f885d4b.tar.gz
external_bluetooth_bluedroid-6b69af7c683e1e3edd25891d73eba5914f885d4b.tar.bz2
Use dlopen to avoid compile time linking against libbt-vendor.so
libbt-vendor.so is in vendor/, and shouldn't be compile-time linked against from external/. Use dlopen instead. Change-Id: Iefc2d5232506ce8e60a6e5dd93328332549daa1e
Diffstat (limited to 'hci')
-rw-r--r--hci/Android.mk2
-rw-r--r--hci/src/bt_hw.c21
2 files changed, 20 insertions, 3 deletions
diff --git a/hci/Android.mk b/hci/Android.mk
index a500538..b21793b 100644
--- a/hci/Android.mk
+++ b/hci/Android.mk
@@ -16,7 +16,7 @@ LOCAL_C_INCLUDES += \
LOCAL_SHARED_LIBRARIES := \
libcutils \
- libbt-vendor
+ libdl
LOCAL_MODULE := libbt-hci
LOCAL_MODULE_TAGS := optional
diff --git a/hci/src/bt_hw.c b/hci/src/bt_hw.c
index 89afa51..4878260 100644
--- a/hci/src/bt_hw.c
+++ b/hci/src/bt_hw.c
@@ -55,6 +55,7 @@
#define LOG_TAG "bt_hw"
+#include <dlfcn.h>
#include <utils/Log.h>
#include <pthread.h>
#include "bt_vendor_lib.h"
@@ -226,7 +227,6 @@ static const bt_vendor_callbacks_t vnd_callbacks = {
usrl_ctrl_cb
};
-
/******************************************************************************
**
** Function init_vnd_if
@@ -238,7 +238,24 @@ static const bt_vendor_callbacks_t vnd_callbacks = {
******************************************************************************/
void init_vnd_if(unsigned char *local_bdaddr)
{
- if ((bt_vnd_if=(bt_vendor_interface_t *) bt_vendor_get_interface())!=NULL)
+ bt_vendor_interface_t (*bt_vendor_get_interface_func)(void);
+ void *dlhandle;
+
+ dlhandle = dlopen("libbt-vendor.so", RTLD_NOW);
+ if (!dlhandle)
+ {
+ ALOGE("!!! Failed to load libbt-vendor.so !!!");
+ return;
+ }
+
+ bt_vendor_get_interface_func = dlsym(dlhandle, "bt_vendor_get_interface");
+ if (!bt_vendor_get_interface_func)
+ {
+ ALOGE("!!! Failed to get bt_vendor_get_interface !!!");
+ return;
+ }
+
+ if ((bt_vnd_if=(bt_vendor_interface_t *) bt_vendor_get_interface_func)!=NULL)
{
bt_vnd_if->init(&vnd_callbacks, local_bdaddr);
}