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 Signed-off-by: Iliyan Malchev <malchev@google.com>
This commit is contained in:
parent
ac8fa07a02
commit
197fe088f7
7 changed files with 43 additions and 12 deletions
|
@ -12,6 +12,8 @@ LOCAL_PATH := $(call my-dir)
|
|||
|
||||
GPS_DIR_LIST :=
|
||||
|
||||
ifeq (exists, $(shell test -d $(TOP)/vendor/qcom/proprietary/qmi-frameworks && echo exists))
|
||||
|
||||
# add RPC dirs if RPC is available
|
||||
ifneq ($(TARGET_NO_RPC),true)
|
||||
|
||||
|
@ -25,6 +27,8 @@ GPS_DIR_LIST += $(LOCAL_PATH)/loc_api_v02/
|
|||
|
||||
endif #TARGET_NO_RPC
|
||||
|
||||
endif
|
||||
|
||||
GPS_DIR_LIST += $(LOCAL_PATH)/libloc_api_50001/
|
||||
|
||||
#call the subfolders
|
||||
|
|
|
@ -98,7 +98,7 @@ static void loc_rpc_global_cb(void* user, CLIENT* clnt, enum rpc_reset_event eve
|
|||
}
|
||||
|
||||
|
||||
LocApiAdapter* getLocApiAdapter(LocEng &locEng)
|
||||
extern "C" LocApiAdapter* getLocApiAdapter(LocEng &locEng)
|
||||
{
|
||||
return new LocApiRpcAdapter(locEng);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,8 @@ LOCAL_MODULE_TAGS := optional
|
|||
LOCAL_SHARED_LIBRARIES := \
|
||||
libutils \
|
||||
libcutils \
|
||||
libgps.utils
|
||||
libgps.utils \
|
||||
libdl
|
||||
|
||||
LOCAL_SRC_FILES += \
|
||||
loc_eng_log.cpp \
|
||||
|
@ -78,13 +79,6 @@ LOCAL_SRC_FILES += \
|
|||
loc_eng_dmn_conn_glue_msg.c \
|
||||
loc_eng_dmn_conn_glue_pipe.c
|
||||
|
||||
## Check if RPC is not unsupported
|
||||
ifneq ($(TARGET_NO_RPC),true)
|
||||
LOCAL_SHARED_LIBRARIES += libloc_api-rpc-qc
|
||||
else
|
||||
LOCAL_SHARED_LIBRARIES += libloc_api_v02
|
||||
endif #TARGET_NO_RPC
|
||||
|
||||
LOCAL_CFLAGS += \
|
||||
-fno-short-enums \
|
||||
-D_ANDROID_
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#define LOG_NDDEBUG 0
|
||||
#define LOG_TAG "LocSvc_adapter"
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <LocApiAdapter.h>
|
||||
#include "loc_eng_msg.h"
|
||||
#include "loc_log.h"
|
||||
|
@ -66,6 +67,35 @@ LocApiAdapter::~LocApiAdapter()
|
|||
LOC_LOGV("LocApiAdapter deleted");
|
||||
}
|
||||
|
||||
LocApiAdapter* LocApiAdapter::getLocApiAdapter(LocEng &locEng)
|
||||
{
|
||||
void* handle;
|
||||
LocApiAdapter* adapter = NULL;
|
||||
|
||||
handle = dlopen ("libloc_api_v02.so", RTLD_NOW);
|
||||
|
||||
if (!handle) {
|
||||
LOC_LOGI("%s: dlopen(libloc_api_v02.so) failed, trying to load libloc_api-rpc-qc.so", __FUNCTION__);
|
||||
handle = dlopen ("libloc_api-rpc-qc.so", RTLD_NOW);
|
||||
}
|
||||
else
|
||||
LOC_LOGE("%s: dlopen(libloc_api_v02.so) succeeded.", __FUNCTION__);
|
||||
|
||||
if (!handle) {
|
||||
LOC_LOGI("%s: dlopen(libloc_api-rpc-qc.so) failed, constructing LocApiAdapter", __FUNCTION__);
|
||||
adapter = new LocApiAdapter(locEng);
|
||||
} else {
|
||||
getLocApiAdapter_t* getHandle = (getLocApiAdapter_t*)dlsym(handle, "getLocApiAdapter");
|
||||
if (!getHandle) {
|
||||
LOC_LOGE("%s: dlsym(getLocApiAdapter) failed", __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
adapter = (*getHandle)(locEng);
|
||||
}
|
||||
|
||||
return adapter;
|
||||
}
|
||||
|
||||
int LocApiAdapter::hexcode(char *hexstring, int string_size,
|
||||
const char *data, int data_size)
|
||||
{
|
||||
|
|
|
@ -107,6 +107,8 @@ public:
|
|||
//LocApiAdapter(int q, reportCb_t[LOC_API_ADAPTER_EVENT_MAX] callbackTable);
|
||||
virtual ~LocApiAdapter();
|
||||
|
||||
static LocApiAdapter* getLocApiAdapter(LocEng &locEng);
|
||||
|
||||
static int hexcode(char *hexstring, int string_size,
|
||||
const char *data, int data_size);
|
||||
static int decodeAddress(char *addr_string, int string_size,
|
||||
|
@ -199,7 +201,8 @@ public:
|
|||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
};
|
||||
|
||||
LocApiAdapter* getLocApiAdapter(LocEng &locEng);
|
||||
extern "C" LocApiAdapter* getLocApiAdapter(LocEng &locEng);
|
||||
|
||||
typedef LocApiAdapter* (getLocApiAdapter_t)(LocEng&);
|
||||
|
||||
#endif //LOC_API_RPC_ADAPTER_H
|
||||
|
|
|
@ -265,7 +265,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,
|
||||
loc_eng_data.release_wakelock_cb, loc_eng_msg_sender,
|
||||
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;
|
||||
if (NULL == loc_eng_data.client_handle) {
|
||||
|
|
|
@ -2053,7 +2053,7 @@ void LocApiV02Adapter :: errorCb(locClientHandleType handle,
|
|||
}
|
||||
|
||||
/* return a Loc API adapter */
|
||||
LocApiAdapter* getLocApiAdapter(LocEng &locEng)
|
||||
extern "C" LocApiAdapter* getLocApiAdapter(LocEng &locEng)
|
||||
{
|
||||
return(new LocApiV02Adapter(locEng));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue