From 6b69af7c683e1e3edd25891d73eba5914f885d4b Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 17 Jul 2012 19:16:52 -0700 Subject: 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 --- hci/Android.mk | 2 +- hci/src/bt_hw.c | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'hci') 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 #include #include #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); } -- cgit v1.1