dynamically build and load adapter libs

this is to support bringup efforts. This change will decouple
the dependencies between GPS HAL and proprietary QMI headers,
so that we can build HAL without any proprietary repos.

Change-Id: I7b836d09f4ac6b1a1bdb38f8d6a2bfb90bb5bf01
This commit is contained in:
Kevin Tang 2012-09-11 15:14:48 -07:00
parent b6a9a0d446
commit a389eae611
5 changed files with 32 additions and 14 deletions

View file

@ -13,9 +13,11 @@ GPS_DIR_LIST += $(LOCAL_PATH)/libloc_api/
endif #TARGET_NO_RPC endif #TARGET_NO_RPC
ifeq (exists, $(shell test -d $(TOP)/vendor/qcom/proprietary/qmi-framework && echo exists))
#add QMI libraries for QMI targets #add QMI libraries for QMI targets
QMI_BOARD_PLATFORM_LIST := msm8960 QMI_BOARD_PLATFORM_LIST := msm8960
QMI_BOARD_PLATFORM_LIST += msm8974 QMI_BOARD_PLATFORM_LIST += msm8974
endif
ifeq ($(call is-board-platform-in-list,$(QMI_BOARD_PLATFORM_LIST)),true) ifeq ($(call is-board-platform-in-list,$(QMI_BOARD_PLATFORM_LIST)),true)
GPS_DIR_LIST += $(LOCAL_PATH)/loc_api_v02/ GPS_DIR_LIST += $(LOCAL_PATH)/loc_api_v02/

View file

@ -19,7 +19,8 @@ LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := \ LOCAL_SHARED_LIBRARIES := \
libutils \ libutils \
libcutils \ libcutils \
libgps.utils libgps.utils \
libdl
LOCAL_SRC_FILES += \ LOCAL_SRC_FILES += \
loc_eng_log.cpp \ loc_eng_log.cpp \
@ -79,17 +80,6 @@ LOCAL_SRC_FILES += \
loc_eng_dmn_conn_glue_msg.c \ loc_eng_dmn_conn_glue_msg.c \
loc_eng_dmn_conn_glue_pipe.c loc_eng_dmn_conn_glue_pipe.c
# if QMI is supported then link to loc_api_v02
ifeq ($(call is-board-platform-in-list,$(QMI_BOARD_PLATFORM_LIST)),true)
LOCAL_SHARED_LIBRARIES += libloc_api_v02
else
## Check if RPC is not unsupported
ifneq ($(TARGET_NO_RPC),true)
LOCAL_SHARED_LIBRARIES += libloc_api-rpc-qc
endif #TARGET_NO_RPC
endif #is-board-platform-in-list
LOCAL_CFLAGS += \ LOCAL_CFLAGS += \
-fno-short-enums \ -fno-short-enums \
-D_ANDROID_ -D_ANDROID_

View file

@ -29,6 +29,7 @@
#define LOG_NDDEBUG 0 #define LOG_NDDEBUG 0
#define LOG_TAG "LocSvc_adapter" #define LOG_TAG "LocSvc_adapter"
#include <dlfcn.h>
#include <LocApiAdapter.h> #include <LocApiAdapter.h>
#include "loc_eng_msg.h" #include "loc_eng_msg.h"
#include "loc_log.h" #include "loc_log.h"
@ -67,6 +68,28 @@ LocApiAdapter::~LocApiAdapter()
LOC_LOGV("LocApiAdapter deleted"); LOC_LOGV("LocApiAdapter deleted");
} }
LocApiAdapter* LocApiAdapter::getLocApiAdapter(LocEng &locEng)
{
void* handle;
LocApiAdapter* adapter = NULL;
handle = dlopen ("libloc_api_v02.so", RTLD_NOW);
if (!handle) {
handle = dlopen ("libloc_api-rpc-qc.so", RTLD_NOW);
}
if (!handle) {
adapter = new LocApiAdapter(locEng);
} else {
getLocApiAdapter_t* getHandle = (getLocApiAdapter_t*)dlsym(handle, "getLocApiAdapter");
adapter = (*getHandle)(locEng);
}
return adapter;
}
int LocApiAdapter::hexcode(char *hexstring, int string_size, int LocApiAdapter::hexcode(char *hexstring, int string_size,
const char *data, int data_size) const char *data, int data_size)
{ {

View file

@ -115,6 +115,8 @@ public:
//LocApiAdapter(int q, reportCb_t[LOC_API_ADAPTER_EVENT_MAX] callbackTable); //LocApiAdapter(int q, reportCb_t[LOC_API_ADAPTER_EVENT_MAX] callbackTable);
virtual ~LocApiAdapter(); virtual ~LocApiAdapter();
static LocApiAdapter* getLocApiAdapter(LocEng &locEng);
static int hexcode(char *hexstring, int string_size, static int hexcode(char *hexstring, int string_size,
const char *data, int data_size); const char *data, int data_size);
static int decodeAddress(char *addr_string, int string_size, static int decodeAddress(char *addr_string, int string_size,
@ -221,7 +223,8 @@ public:
inline virtual void setInSession(bool inSession) { navigating = inSession; } inline virtual void setInSession(bool inSession) { navigating = inSession; }
}; };
LocApiAdapter* getLocApiAdapter(LocEng &locEng); extern "C" LocApiAdapter* getLocApiAdapter(LocEng &locEng);
typedef LocApiAdapter* (getLocApiAdapter_t)(LocEng&);
#endif //LOC_API_RPC_ADAPTER_H #endif //LOC_API_RPC_ADAPTER_H

View file

@ -319,7 +319,7 @@ int loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks,
LocEng locEngHandle(&loc_eng_data, event, loc_eng_data.acquire_wakelock_cb, LocEng locEngHandle(&loc_eng_data, event, loc_eng_data.acquire_wakelock_cb,
loc_eng_data.release_wakelock_cb, loc_eng_msg_sender, loc_external_msg_sender, loc_eng_data.release_wakelock_cb, loc_eng_msg_sender, loc_external_msg_sender,
callbacks->location_ext_parser, callbacks->sv_ext_parser); callbacks->location_ext_parser, callbacks->sv_ext_parser);
loc_eng_data.client_handle = getLocApiAdapter(locEngHandle); loc_eng_data.client_handle = LocApiAdapter::getLocApiAdapter(locEngHandle);
int ret_val =-1; int ret_val =-1;
if (NULL == loc_eng_data.client_handle) { if (NULL == loc_eng_data.client_handle) {