diff --git a/loc_api/Android.mk b/loc_api/Android.mk index 20ff0727..82aa08bb 100644 --- a/loc_api/Android.mk +++ b/loc_api/Android.mk @@ -13,9 +13,11 @@ GPS_DIR_LIST += $(LOCAL_PATH)/libloc_api/ endif #TARGET_NO_RPC +ifeq (exists, $(shell test -d $(TOP)/vendor/qcom/proprietary/qmi-framework && echo exists)) #add QMI libraries for QMI targets QMI_BOARD_PLATFORM_LIST := msm8960 QMI_BOARD_PLATFORM_LIST += msm8974 +endif ifeq ($(call is-board-platform-in-list,$(QMI_BOARD_PLATFORM_LIST)),true) GPS_DIR_LIST += $(LOCAL_PATH)/loc_api_v02/ diff --git a/loc_api/libloc_api_50001/Android.mk b/loc_api/libloc_api_50001/Android.mk index 0bf889ef..d492120b 100644 --- a/loc_api/libloc_api_50001/Android.mk +++ b/loc_api/libloc_api_50001/Android.mk @@ -19,7 +19,8 @@ LOCAL_MODULE_TAGS := optional LOCAL_SHARED_LIBRARIES := \ libutils \ libcutils \ - libgps.utils + libgps.utils \ + libdl LOCAL_SRC_FILES += \ loc_eng_log.cpp \ @@ -79,17 +80,6 @@ LOCAL_SRC_FILES += \ loc_eng_dmn_conn_glue_msg.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 += \ -fno-short-enums \ -D_ANDROID_ diff --git a/loc_api/libloc_api_50001/LocApiAdapter.cpp b/loc_api/libloc_api_50001/LocApiAdapter.cpp index 6bd79bbe..950c6438 100755 --- a/loc_api/libloc_api_50001/LocApiAdapter.cpp +++ b/loc_api/libloc_api_50001/LocApiAdapter.cpp @@ -29,6 +29,7 @@ #define LOG_NDDEBUG 0 #define LOG_TAG "LocSvc_adapter" +#include #include #include "loc_eng_msg.h" #include "loc_log.h" @@ -67,6 +68,28 @@ 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) { + 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, const char *data, int data_size) { diff --git a/loc_api/libloc_api_50001/LocApiAdapter.h b/loc_api/libloc_api_50001/LocApiAdapter.h index 80a675d8..ec53805e 100755 --- a/loc_api/libloc_api_50001/LocApiAdapter.h +++ b/loc_api/libloc_api_50001/LocApiAdapter.h @@ -115,6 +115,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, @@ -221,7 +223,8 @@ public: 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 diff --git a/loc_api/libloc_api_50001/loc_eng.cpp b/loc_api/libloc_api_50001/loc_eng.cpp index aa9298d5..89a77292 100755 --- a/loc_api/libloc_api_50001/loc_eng.cpp +++ b/loc_api/libloc_api_50001/loc_eng.cpp @@ -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, loc_eng_data.release_wakelock_cb, loc_eng_msg_sender, loc_external_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) {