Merge "Add option to fallback to LocApiV02"

This commit is contained in:
Linux Build Service Account 2014-07-16 04:01:15 -07:00 committed by Gerrit - the friendly Code Review server
commit db2dcf2cff

View file

@ -66,16 +66,31 @@ LocApiBase* ContextBase::createLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask)
// first if can not be MPQ // first if can not be MPQ
if (TARGET_MPQ != loc_get_target()) { if (TARGET_MPQ != loc_get_target()) {
if (NULL == (locApi = mLBSProxy->getLocApi(mMsgTask, exMask, this))) { if (NULL == (locApi = mLBSProxy->getLocApi(mMsgTask, exMask, this))) {
void *handle = NULL;
//try to see if LocApiV02 is present
if((handle = dlopen("libloc_api_v02.so", RTLD_NOW)) != NULL) {
LOC_LOGD("%s:%d]: libloc_api_v02.so is present", __func__, __LINE__);
getLocApi_t* getter = (getLocApi_t*)dlsym(handle, "getLocApi");
if(getter != NULL) {
LOC_LOGD("%s:%d]: getter is not NULL for LocApiV02", __func__, __LINE__);
locApi = (*getter)(mMsgTask, exMask, this);
}
}
// only RPC is the option now // only RPC is the option now
void* handle = dlopen("libloc_api-rpc-qc.so", RTLD_NOW); else {
LOC_LOGD("%s:%d]: libloc_api_v02.so is NOT present. Trying RPC",
__func__, __LINE__);
handle = dlopen("libloc_api-rpc-qc.so", RTLD_NOW);
if (NULL != handle) { if (NULL != handle) {
getLocApi_t* getter = (getLocApi_t*)dlsym(handle, "getLocApi"); getLocApi_t* getter = (getLocApi_t*)dlsym(handle, "getLocApi");
if (NULL != getter) { if (NULL != getter) {
LOC_LOGD("%s:%d]: getter is not NULL in RPC", __func__, __LINE__);
locApi = (*getter)(mMsgTask, exMask, this); locApi = (*getter)(mMsgTask, exMask, this);
} }
} }
} }
} }
}
// locApi could still be NULL at this time // locApi could still be NULL at this time
// we would then create a dummy one // we would then create a dummy one