fix CFI issues
Change-Id: I5b94804c381f1d26196ddf6dee97adbee36dc128 CRs-Fixed: 2353650
This commit is contained in:
parent
a6c61bde6a
commit
313284b9dd
7 changed files with 60 additions and 65 deletions
|
@ -27,7 +27,7 @@
|
||||||
#include "Gnss.h"
|
#include "Gnss.h"
|
||||||
#include <LocationUtil.h>
|
#include <LocationUtil.h>
|
||||||
|
|
||||||
typedef void* (getLocationInterface)();
|
typedef const GnssInterface* (getLocationInterface)();
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
namespace hardware {
|
namespace hardware {
|
||||||
|
@ -84,7 +84,7 @@ GnssAPIClient* Gnss::getApi() {
|
||||||
return mApi;
|
return mApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
GnssInterface* Gnss::getGnssInterface() {
|
const GnssInterface* Gnss::getGnssInterface() {
|
||||||
static bool getGnssInterfaceFailed = false;
|
static bool getGnssInterfaceFailed = false;
|
||||||
if (nullptr == mGnssInterface && !getGnssInterfaceFailed) {
|
if (nullptr == mGnssInterface && !getGnssInterfaceFailed) {
|
||||||
LOC_LOGD("%s]: loading libgnss.so::getGnssInterface ...", __func__);
|
LOC_LOGD("%s]: loading libgnss.so::getGnssInterface ...", __func__);
|
||||||
|
@ -105,7 +105,7 @@ GnssInterface* Gnss::getGnssInterface() {
|
||||||
if (NULL == getter) {
|
if (NULL == getter) {
|
||||||
getGnssInterfaceFailed = true;
|
getGnssInterfaceFailed = true;
|
||||||
} else {
|
} else {
|
||||||
mGnssInterface = (GnssInterface*)(*getter)();
|
mGnssInterface = (const GnssInterface*)(*getter)();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mGnssInterface;
|
return mGnssInterface;
|
||||||
|
@ -238,7 +238,7 @@ Return<bool> Gnss::injectLocation(double latitudeDegrees,
|
||||||
double longitudeDegrees,
|
double longitudeDegrees,
|
||||||
float accuracyMeters) {
|
float accuracyMeters) {
|
||||||
ENTRY_LOG_CALLFLOW();
|
ENTRY_LOG_CALLFLOW();
|
||||||
GnssInterface* gnssInterface = getGnssInterface();
|
const GnssInterface* gnssInterface = getGnssInterface();
|
||||||
if (nullptr != gnssInterface) {
|
if (nullptr != gnssInterface) {
|
||||||
gnssInterface->injectLocation(latitudeDegrees, longitudeDegrees, accuracyMeters);
|
gnssInterface->injectLocation(latitudeDegrees, longitudeDegrees, accuracyMeters);
|
||||||
return true;
|
return true;
|
||||||
|
@ -250,7 +250,7 @@ Return<bool> Gnss::injectLocation(double latitudeDegrees,
|
||||||
Return<bool> Gnss::injectTime(int64_t timeMs, int64_t timeReferenceMs,
|
Return<bool> Gnss::injectTime(int64_t timeMs, int64_t timeReferenceMs,
|
||||||
int32_t uncertaintyMs) {
|
int32_t uncertaintyMs) {
|
||||||
ENTRY_LOG_CALLFLOW();
|
ENTRY_LOG_CALLFLOW();
|
||||||
GnssInterface* gnssInterface = getGnssInterface();
|
const GnssInterface* gnssInterface = getGnssInterface();
|
||||||
if (nullptr != gnssInterface) {
|
if (nullptr != gnssInterface) {
|
||||||
gnssInterface->injectTime(timeMs, timeReferenceMs, uncertaintyMs);
|
gnssInterface->injectTime(timeMs, timeReferenceMs, uncertaintyMs);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -99,7 +99,7 @@ struct Gnss : public IGnss {
|
||||||
GnssAPIClient* getApi();
|
GnssAPIClient* getApi();
|
||||||
Return<bool> setGnssNiCb(const sp<IGnssNiCallback>& niCb);
|
Return<bool> setGnssNiCb(const sp<IGnssNiCallback>& niCb);
|
||||||
Return<bool> updateConfiguration(GnssConfig& gnssConfig);
|
Return<bool> updateConfiguration(GnssConfig& gnssConfig);
|
||||||
GnssInterface* getGnssInterface();
|
const GnssInterface* getGnssInterface();
|
||||||
|
|
||||||
// Callback for ODCPI request
|
// Callback for ODCPI request
|
||||||
void odcpiRequestCb(const OdcpiRequestInfo& request);
|
void odcpiRequestCb(const OdcpiRequestInfo& request);
|
||||||
|
@ -129,7 +129,7 @@ struct Gnss : public IGnss {
|
||||||
sp<V1_0::IGnssCallback> mGnssCbIface = nullptr;
|
sp<V1_0::IGnssCallback> mGnssCbIface = nullptr;
|
||||||
sp<V1_0::IGnssNiCallback> mGnssNiCbIface = nullptr;
|
sp<V1_0::IGnssNiCallback> mGnssNiCbIface = nullptr;
|
||||||
GnssConfig mPendingConfig;
|
GnssConfig mPendingConfig;
|
||||||
GnssInterface* mGnssInterface = nullptr;
|
const GnssInterface* mGnssInterface = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" IGnss* HIDL_FETCH_IGnss(const char* name);
|
extern "C" IGnss* HIDL_FETCH_IGnss(const char* name);
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "Gnss.h"
|
#include "Gnss.h"
|
||||||
#include <LocationUtil.h>
|
#include <LocationUtil.h>
|
||||||
|
|
||||||
typedef void* (getLocationInterface)();
|
typedef const GnssInterface* (getLocationInterface)();
|
||||||
|
|
||||||
#define IMAGES_INFO_FILE "/sys/devices/soc0/images"
|
#define IMAGES_INFO_FILE "/sys/devices/soc0/images"
|
||||||
#define DELIMITER ";"
|
#define DELIMITER ";"
|
||||||
|
@ -124,7 +124,7 @@ GnssAPIClient* Gnss::getApi() {
|
||||||
return mApi;
|
return mApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
GnssInterface* Gnss::getGnssInterface() {
|
const GnssInterface* Gnss::getGnssInterface() {
|
||||||
static bool getGnssInterfaceFailed = false;
|
static bool getGnssInterfaceFailed = false;
|
||||||
if (nullptr == mGnssInterface && !getGnssInterfaceFailed) {
|
if (nullptr == mGnssInterface && !getGnssInterfaceFailed) {
|
||||||
LOC_LOGD("%s]: loading libgnss.so::getGnssInterface ...", __func__);
|
LOC_LOGD("%s]: loading libgnss.so::getGnssInterface ...", __func__);
|
||||||
|
@ -145,7 +145,7 @@ GnssInterface* Gnss::getGnssInterface() {
|
||||||
if (NULL == getter) {
|
if (NULL == getter) {
|
||||||
getGnssInterfaceFailed = true;
|
getGnssInterfaceFailed = true;
|
||||||
} else {
|
} else {
|
||||||
mGnssInterface = (GnssInterface*)(*getter)();
|
mGnssInterface = (const GnssInterface*)(*getter)();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mGnssInterface;
|
return mGnssInterface;
|
||||||
|
@ -278,7 +278,7 @@ Return<bool> Gnss::injectLocation(double latitudeDegrees,
|
||||||
double longitudeDegrees,
|
double longitudeDegrees,
|
||||||
float accuracyMeters) {
|
float accuracyMeters) {
|
||||||
ENTRY_LOG_CALLFLOW();
|
ENTRY_LOG_CALLFLOW();
|
||||||
GnssInterface* gnssInterface = getGnssInterface();
|
const GnssInterface* gnssInterface = getGnssInterface();
|
||||||
if (nullptr != gnssInterface) {
|
if (nullptr != gnssInterface) {
|
||||||
gnssInterface->injectLocation(latitudeDegrees, longitudeDegrees, accuracyMeters);
|
gnssInterface->injectLocation(latitudeDegrees, longitudeDegrees, accuracyMeters);
|
||||||
return true;
|
return true;
|
||||||
|
@ -290,7 +290,7 @@ Return<bool> Gnss::injectLocation(double latitudeDegrees,
|
||||||
Return<bool> Gnss::injectTime(int64_t timeMs, int64_t timeReferenceMs,
|
Return<bool> Gnss::injectTime(int64_t timeMs, int64_t timeReferenceMs,
|
||||||
int32_t uncertaintyMs) {
|
int32_t uncertaintyMs) {
|
||||||
ENTRY_LOG_CALLFLOW();
|
ENTRY_LOG_CALLFLOW();
|
||||||
GnssInterface* gnssInterface = getGnssInterface();
|
const GnssInterface* gnssInterface = getGnssInterface();
|
||||||
if (nullptr != gnssInterface) {
|
if (nullptr != gnssInterface) {
|
||||||
gnssInterface->injectTime(timeMs, timeReferenceMs, uncertaintyMs);
|
gnssInterface->injectTime(timeMs, timeReferenceMs, uncertaintyMs);
|
||||||
return true;
|
return true;
|
||||||
|
@ -375,7 +375,7 @@ Return<bool> Gnss::setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) {
|
||||||
ENTRY_LOG_CALLFLOW();
|
ENTRY_LOG_CALLFLOW();
|
||||||
callback->gnssNameCb(getVersionString());
|
callback->gnssNameCb(getVersionString());
|
||||||
mGnssCbIface_1_1 = callback;
|
mGnssCbIface_1_1 = callback;
|
||||||
GnssInterface* gnssInterface = getGnssInterface();
|
const GnssInterface* gnssInterface = getGnssInterface();
|
||||||
if (nullptr != gnssInterface) {
|
if (nullptr != gnssInterface) {
|
||||||
OdcpiRequestCallback cb = [this](const OdcpiRequestInfo& odcpiRequest) {
|
OdcpiRequestCallback cb = [this](const OdcpiRequestInfo& odcpiRequest) {
|
||||||
odcpiRequestCb(odcpiRequest);
|
odcpiRequestCb(odcpiRequest);
|
||||||
|
@ -419,7 +419,7 @@ Return<sp<V1_1::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration_1_1() {
|
||||||
|
|
||||||
Return<bool> Gnss::injectBestLocation(const GnssLocation& gnssLocation) {
|
Return<bool> Gnss::injectBestLocation(const GnssLocation& gnssLocation) {
|
||||||
ENTRY_LOG_CALLFLOW();
|
ENTRY_LOG_CALLFLOW();
|
||||||
GnssInterface* gnssInterface = getGnssInterface();
|
const GnssInterface* gnssInterface = getGnssInterface();
|
||||||
if (nullptr != gnssInterface) {
|
if (nullptr != gnssInterface) {
|
||||||
Location location = {};
|
Location location = {};
|
||||||
convertGnssLocation(gnssLocation, location);
|
convertGnssLocation(gnssLocation, location);
|
||||||
|
@ -446,9 +446,9 @@ void Gnss::odcpiRequestCb(const OdcpiRequestInfo& request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IGnss* HIDL_FETCH_IGnss(const char* hal) {
|
V1_0::IGnss* HIDL_FETCH_IGnss(const char* hal) {
|
||||||
ENTRY_LOG_CALLFLOW();
|
ENTRY_LOG_CALLFLOW();
|
||||||
IGnss* iface = nullptr;
|
V1_0::IGnss* iface = nullptr;
|
||||||
iface = new Gnss();
|
iface = new Gnss();
|
||||||
if (iface == nullptr) {
|
if (iface == nullptr) {
|
||||||
LOC_LOGE("%s]: failed to get %s", __FUNCTION__, hal);
|
LOC_LOGE("%s]: failed to get %s", __FUNCTION__, hal);
|
||||||
|
|
|
@ -109,7 +109,7 @@ struct Gnss : public IGnss {
|
||||||
GnssAPIClient* getApi();
|
GnssAPIClient* getApi();
|
||||||
Return<bool> setGnssNiCb(const sp<IGnssNiCallback>& niCb);
|
Return<bool> setGnssNiCb(const sp<IGnssNiCallback>& niCb);
|
||||||
Return<bool> updateConfiguration(GnssConfig& gnssConfig);
|
Return<bool> updateConfiguration(GnssConfig& gnssConfig);
|
||||||
GnssInterface* getGnssInterface();
|
const GnssInterface* getGnssInterface();
|
||||||
|
|
||||||
// Callback for ODCPI request
|
// Callback for ODCPI request
|
||||||
void odcpiRequestCb(const OdcpiRequestInfo& request);
|
void odcpiRequestCb(const OdcpiRequestInfo& request);
|
||||||
|
@ -140,10 +140,10 @@ struct Gnss : public IGnss {
|
||||||
sp<V1_1::IGnssCallback> mGnssCbIface_1_1 = nullptr;
|
sp<V1_1::IGnssCallback> mGnssCbIface_1_1 = nullptr;
|
||||||
sp<V1_0::IGnssNiCallback> mGnssNiCbIface = nullptr;
|
sp<V1_0::IGnssNiCallback> mGnssNiCbIface = nullptr;
|
||||||
GnssConfig mPendingConfig;
|
GnssConfig mPendingConfig;
|
||||||
GnssInterface* mGnssInterface = nullptr;
|
const GnssInterface* mGnssInterface = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" IGnss* HIDL_FETCH_IGnss(const char* name);
|
extern "C" V1_0::IGnss* HIDL_FETCH_IGnss(const char* name);
|
||||||
|
|
||||||
} // namespace implementation
|
} // namespace implementation
|
||||||
} // namespace V1_1
|
} // namespace V1_1
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "Gnss.h"
|
#include "Gnss.h"
|
||||||
#include "LocationUtil.h"
|
#include "LocationUtil.h"
|
||||||
|
|
||||||
typedef void* (getLocationInterface)();
|
typedef const GnssInterface* (getLocationInterface)();
|
||||||
|
|
||||||
#define IMAGES_INFO_FILE "/sys/devices/soc0/images"
|
#define IMAGES_INFO_FILE "/sys/devices/soc0/images"
|
||||||
#define DELIMITER ";"
|
#define DELIMITER ";"
|
||||||
|
@ -125,7 +125,7 @@ GnssAPIClient* Gnss::getApi() {
|
||||||
return mApi;
|
return mApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
GnssInterface* Gnss::getGnssInterface() {
|
const GnssInterface* Gnss::getGnssInterface() {
|
||||||
static bool getGnssInterfaceFailed = false;
|
static bool getGnssInterfaceFailed = false;
|
||||||
if (nullptr == mGnssInterface && !getGnssInterfaceFailed) {
|
if (nullptr == mGnssInterface && !getGnssInterfaceFailed) {
|
||||||
LOC_LOGD("%s]: loading libgnss.so::getGnssInterface ...", __func__);
|
LOC_LOGD("%s]: loading libgnss.so::getGnssInterface ...", __func__);
|
||||||
|
@ -146,7 +146,7 @@ GnssInterface* Gnss::getGnssInterface() {
|
||||||
if (NULL == getter) {
|
if (NULL == getter) {
|
||||||
getGnssInterfaceFailed = true;
|
getGnssInterfaceFailed = true;
|
||||||
} else {
|
} else {
|
||||||
mGnssInterface = (GnssInterface*)(*getter)();
|
mGnssInterface = (const GnssInterface*)(*getter)();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mGnssInterface;
|
return mGnssInterface;
|
||||||
|
@ -283,7 +283,7 @@ Return<bool> Gnss::injectLocation(double latitudeDegrees,
|
||||||
double longitudeDegrees,
|
double longitudeDegrees,
|
||||||
float accuracyMeters) {
|
float accuracyMeters) {
|
||||||
ENTRY_LOG_CALLFLOW();
|
ENTRY_LOG_CALLFLOW();
|
||||||
GnssInterface* gnssInterface = getGnssInterface();
|
const GnssInterface* gnssInterface = getGnssInterface();
|
||||||
if (nullptr != gnssInterface) {
|
if (nullptr != gnssInterface) {
|
||||||
gnssInterface->injectLocation(latitudeDegrees, longitudeDegrees, accuracyMeters);
|
gnssInterface->injectLocation(latitudeDegrees, longitudeDegrees, accuracyMeters);
|
||||||
return true;
|
return true;
|
||||||
|
@ -295,7 +295,7 @@ Return<bool> Gnss::injectLocation(double latitudeDegrees,
|
||||||
Return<bool> Gnss::injectTime(int64_t timeMs, int64_t timeReferenceMs,
|
Return<bool> Gnss::injectTime(int64_t timeMs, int64_t timeReferenceMs,
|
||||||
int32_t uncertaintyMs) {
|
int32_t uncertaintyMs) {
|
||||||
ENTRY_LOG_CALLFLOW();
|
ENTRY_LOG_CALLFLOW();
|
||||||
GnssInterface* gnssInterface = getGnssInterface();
|
const GnssInterface* gnssInterface = getGnssInterface();
|
||||||
if (nullptr != gnssInterface) {
|
if (nullptr != gnssInterface) {
|
||||||
gnssInterface->injectTime(timeMs, timeReferenceMs, uncertaintyMs);
|
gnssInterface->injectTime(timeMs, timeReferenceMs, uncertaintyMs);
|
||||||
return true;
|
return true;
|
||||||
|
@ -383,7 +383,7 @@ Return<bool> Gnss::setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) {
|
||||||
ENTRY_LOG_CALLFLOW();
|
ENTRY_LOG_CALLFLOW();
|
||||||
callback->gnssNameCb(getVersionString());
|
callback->gnssNameCb(getVersionString());
|
||||||
mGnssCbIface_1_1 = callback;
|
mGnssCbIface_1_1 = callback;
|
||||||
GnssInterface* gnssInterface = getGnssInterface();
|
const GnssInterface* gnssInterface = getGnssInterface();
|
||||||
if (nullptr != gnssInterface) {
|
if (nullptr != gnssInterface) {
|
||||||
OdcpiRequestCallback cb = [this](const OdcpiRequestInfo& odcpiRequest) {
|
OdcpiRequestCallback cb = [this](const OdcpiRequestInfo& odcpiRequest) {
|
||||||
odcpiRequestCb(odcpiRequest);
|
odcpiRequestCb(odcpiRequest);
|
||||||
|
@ -431,7 +431,7 @@ Return<sp<V1_1::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration_1_1() {
|
||||||
|
|
||||||
Return<bool> Gnss::injectBestLocation(const GnssLocation& gnssLocation) {
|
Return<bool> Gnss::injectBestLocation(const GnssLocation& gnssLocation) {
|
||||||
ENTRY_LOG_CALLFLOW();
|
ENTRY_LOG_CALLFLOW();
|
||||||
GnssInterface* gnssInterface = getGnssInterface();
|
const GnssInterface* gnssInterface = getGnssInterface();
|
||||||
if (nullptr != gnssInterface) {
|
if (nullptr != gnssInterface) {
|
||||||
Location location = {};
|
Location location = {};
|
||||||
convertGnssLocation(gnssLocation, location);
|
convertGnssLocation(gnssLocation, location);
|
||||||
|
@ -521,9 +521,9 @@ Return<sp<V2_0::IGnssDebug>> Gnss::getExtensionGnssDebug_2_0() {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
IGnss* HIDL_FETCH_IGnss(const char* hal) {
|
V1_0::IGnss* HIDL_FETCH_IGnss(const char* hal) {
|
||||||
ENTRY_LOG_CALLFLOW();
|
ENTRY_LOG_CALLFLOW();
|
||||||
IGnss* iface = nullptr;
|
V1_0::IGnss* iface = nullptr;
|
||||||
iface = new Gnss();
|
iface = new Gnss();
|
||||||
if (iface == nullptr) {
|
if (iface == nullptr) {
|
||||||
LOC_LOGE("%s]: failed to get %s", __FUNCTION__, hal);
|
LOC_LOGE("%s]: failed to get %s", __FUNCTION__, hal);
|
||||||
|
|
|
@ -138,7 +138,7 @@ struct Gnss : public IGnss {
|
||||||
GnssAPIClient* getApi();
|
GnssAPIClient* getApi();
|
||||||
Return<bool> setGnssNiCb(const sp<IGnssNiCallback>& niCb);
|
Return<bool> setGnssNiCb(const sp<IGnssNiCallback>& niCb);
|
||||||
Return<bool> updateConfiguration(GnssConfig& gnssConfig);
|
Return<bool> updateConfiguration(GnssConfig& gnssConfig);
|
||||||
GnssInterface* getGnssInterface();
|
const GnssInterface* getGnssInterface();
|
||||||
|
|
||||||
// Callback for ODCPI request
|
// Callback for ODCPI request
|
||||||
void odcpiRequestCb(const OdcpiRequestInfo& request);
|
void odcpiRequestCb(const OdcpiRequestInfo& request);
|
||||||
|
@ -171,10 +171,10 @@ struct Gnss : public IGnss {
|
||||||
|
|
||||||
GnssAPIClient* mApi = nullptr;
|
GnssAPIClient* mApi = nullptr;
|
||||||
GnssConfig mPendingConfig;
|
GnssConfig mPendingConfig;
|
||||||
GnssInterface* mGnssInterface = nullptr;
|
const GnssInterface* mGnssInterface = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" IGnss* HIDL_FETCH_IGnss(const char* name);
|
extern "C" V1_0::IGnss* HIDL_FETCH_IGnss(const char* name);
|
||||||
|
|
||||||
} // namespace implementation
|
} // namespace implementation
|
||||||
} // namespace V2_0
|
} // namespace V2_0
|
||||||
|
|
|
@ -34,8 +34,11 @@
|
||||||
#include <log_util.h>
|
#include <log_util.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <loc_misc_utils.h>
|
||||||
|
|
||||||
typedef void* (getLocationInterface)();
|
typedef const GnssInterface* (getGnssInterface)();
|
||||||
|
typedef const GeofenceInterface* (getGeofenceInterface)();
|
||||||
|
typedef const BatchingInterface* (getBatchingInterface)();
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// bit mask of the adpaters that we need to wait for the removeClientCompleteCallback
|
// bit mask of the adpaters that we need to wait for the removeClientCompleteCallback
|
||||||
|
@ -66,6 +69,17 @@ static bool gGnssLoadFailed = false;
|
||||||
static bool gBatchingLoadFailed = false;
|
static bool gBatchingLoadFailed = false;
|
||||||
static bool gGeofenceLoadFailed = false;
|
static bool gGeofenceLoadFailed = false;
|
||||||
|
|
||||||
|
template <typename T1, typename T2>
|
||||||
|
static const T1* loadLocationInterface(const char* library, const char* name) {
|
||||||
|
void* libhandle = nullptr;
|
||||||
|
T2* getter = (T2*)dlGetSymFromLib(libhandle, library, name);
|
||||||
|
if (nullptr == getter) {
|
||||||
|
return (const T1*) getter;
|
||||||
|
}else {
|
||||||
|
return (*getter)();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool isGnssClient(LocationCallbacks& locationCallbacks)
|
static bool isGnssClient(LocationCallbacks& locationCallbacks)
|
||||||
{
|
{
|
||||||
return (locationCallbacks.gnssNiCb != nullptr ||
|
return (locationCallbacks.gnssNiCb != nullptr ||
|
||||||
|
@ -85,32 +99,6 @@ static bool isGeofenceClient(LocationCallbacks& locationCallbacks)
|
||||||
locationCallbacks.geofenceStatusCb != nullptr);
|
locationCallbacks.geofenceStatusCb != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* loadLocationInterface(const char* library, const char* name)
|
|
||||||
{
|
|
||||||
LOC_LOGD("%s]: loading %s::%s ...", __func__, library, name);
|
|
||||||
if (NULL == library || NULL == name) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
getLocationInterface* getter = NULL;
|
|
||||||
const char *error = NULL;
|
|
||||||
dlerror();
|
|
||||||
void *handle = dlopen(library, RTLD_NOW);
|
|
||||||
if (NULL == handle || (error = dlerror()) != NULL) {
|
|
||||||
LOC_LOGW("dlopen for %s failed, error = %s", library, error);
|
|
||||||
} else {
|
|
||||||
getter = (getLocationInterface*)dlsym(handle, name);
|
|
||||||
if ((error = dlerror()) != NULL) {
|
|
||||||
LOC_LOGW("dlsym for %s::%s failed, error = %s", library, name, error);
|
|
||||||
getter = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NULL == getter) {
|
|
||||||
return (void*)getter;
|
|
||||||
} else {
|
|
||||||
return (*getter)();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LocationAPI::onRemoveClientCompleteCb (LocationAdapterTypeMask adapterType)
|
void LocationAPI::onRemoveClientCompleteCb (LocationAdapterTypeMask adapterType)
|
||||||
{
|
{
|
||||||
|
@ -170,7 +158,8 @@ LocationAPI::createInstance(LocationCallbacks& locationCallbacks)
|
||||||
if (isGnssClient(locationCallbacks)) {
|
if (isGnssClient(locationCallbacks)) {
|
||||||
if (NULL == gData.gnssInterface && !gGnssLoadFailed) {
|
if (NULL == gData.gnssInterface && !gGnssLoadFailed) {
|
||||||
gData.gnssInterface =
|
gData.gnssInterface =
|
||||||
(GnssInterface*)loadLocationInterface("libgnss.so", "getGnssInterface");
|
(GnssInterface*)loadLocationInterface<GnssInterface,
|
||||||
|
getGnssInterface>("libgnss.so", "getGnssInterface");
|
||||||
if (NULL == gData.gnssInterface) {
|
if (NULL == gData.gnssInterface) {
|
||||||
gGnssLoadFailed = true;
|
gGnssLoadFailed = true;
|
||||||
LOC_LOGW("%s:%d]: No gnss interface available", __func__, __LINE__);
|
LOC_LOGW("%s:%d]: No gnss interface available", __func__, __LINE__);
|
||||||
|
@ -190,7 +179,8 @@ LocationAPI::createInstance(LocationCallbacks& locationCallbacks)
|
||||||
if (isBatchingClient(locationCallbacks)) {
|
if (isBatchingClient(locationCallbacks)) {
|
||||||
if (NULL == gData.batchingInterface && !gBatchingLoadFailed) {
|
if (NULL == gData.batchingInterface && !gBatchingLoadFailed) {
|
||||||
gData.batchingInterface =
|
gData.batchingInterface =
|
||||||
(BatchingInterface*)loadLocationInterface("libbatching.so", "getBatchingInterface");
|
(BatchingInterface*)loadLocationInterface<BatchingInterface,
|
||||||
|
getBatchingInterface>("libbatching.so", "getBatchingInterface");
|
||||||
if (NULL == gData.batchingInterface) {
|
if (NULL == gData.batchingInterface) {
|
||||||
gBatchingLoadFailed = true;
|
gBatchingLoadFailed = true;
|
||||||
LOC_LOGW("%s:%d]: No batching interface available", __func__, __LINE__);
|
LOC_LOGW("%s:%d]: No batching interface available", __func__, __LINE__);
|
||||||
|
@ -210,7 +200,8 @@ LocationAPI::createInstance(LocationCallbacks& locationCallbacks)
|
||||||
if (isGeofenceClient(locationCallbacks)) {
|
if (isGeofenceClient(locationCallbacks)) {
|
||||||
if (NULL == gData.geofenceInterface && !gGeofenceLoadFailed) {
|
if (NULL == gData.geofenceInterface && !gGeofenceLoadFailed) {
|
||||||
gData.geofenceInterface =
|
gData.geofenceInterface =
|
||||||
(GeofenceInterface*)loadLocationInterface("libgeofencing.so", "getGeofenceInterface");
|
(GeofenceInterface*)loadLocationInterface<GeofenceInterface,
|
||||||
|
getGeofenceInterface>("libgeofencing.so", "getGeofenceInterface");
|
||||||
if (NULL == gData.geofenceInterface) {
|
if (NULL == gData.geofenceInterface) {
|
||||||
gGeofenceLoadFailed = true;
|
gGeofenceLoadFailed = true;
|
||||||
LOC_LOGW("%s:%d]: No geofence interface available", __func__, __LINE__);
|
LOC_LOGW("%s:%d]: No geofence interface available", __func__, __LINE__);
|
||||||
|
@ -324,7 +315,8 @@ LocationAPI::updateCallbacks(LocationCallbacks& locationCallbacks)
|
||||||
if (isGnssClient(locationCallbacks)) {
|
if (isGnssClient(locationCallbacks)) {
|
||||||
if (NULL == gData.gnssInterface && !gGnssLoadFailed) {
|
if (NULL == gData.gnssInterface && !gGnssLoadFailed) {
|
||||||
gData.gnssInterface =
|
gData.gnssInterface =
|
||||||
(GnssInterface*)loadLocationInterface("libgnss.so", "getGnssInterface");
|
(GnssInterface*)loadLocationInterface<GnssInterface,
|
||||||
|
getGnssInterface>("libgnss.so", "getGnssInterface");
|
||||||
if (NULL == gData.gnssInterface) {
|
if (NULL == gData.gnssInterface) {
|
||||||
gGnssLoadFailed = true;
|
gGnssLoadFailed = true;
|
||||||
LOC_LOGW("%s:%d]: No gnss interface available", __func__, __LINE__);
|
LOC_LOGW("%s:%d]: No gnss interface available", __func__, __LINE__);
|
||||||
|
@ -341,7 +333,8 @@ LocationAPI::updateCallbacks(LocationCallbacks& locationCallbacks)
|
||||||
if (isBatchingClient(locationCallbacks)) {
|
if (isBatchingClient(locationCallbacks)) {
|
||||||
if (NULL == gData.batchingInterface && !gBatchingLoadFailed) {
|
if (NULL == gData.batchingInterface && !gBatchingLoadFailed) {
|
||||||
gData.batchingInterface =
|
gData.batchingInterface =
|
||||||
(BatchingInterface*)loadLocationInterface("libbatching.so", "getBatchingInterface");
|
(BatchingInterface*)loadLocationInterface<BatchingInterface,
|
||||||
|
getBatchingInterface>("libbatching.so", "getBatchingInterface");
|
||||||
if (NULL == gData.batchingInterface) {
|
if (NULL == gData.batchingInterface) {
|
||||||
gBatchingLoadFailed = true;
|
gBatchingLoadFailed = true;
|
||||||
LOC_LOGW("%s:%d]: No batching interface available", __func__, __LINE__);
|
LOC_LOGW("%s:%d]: No batching interface available", __func__, __LINE__);
|
||||||
|
@ -358,7 +351,8 @@ LocationAPI::updateCallbacks(LocationCallbacks& locationCallbacks)
|
||||||
if (isGeofenceClient(locationCallbacks)) {
|
if (isGeofenceClient(locationCallbacks)) {
|
||||||
if (NULL == gData.geofenceInterface && !gGeofenceLoadFailed) {
|
if (NULL == gData.geofenceInterface && !gGeofenceLoadFailed) {
|
||||||
gData.geofenceInterface =
|
gData.geofenceInterface =
|
||||||
(GeofenceInterface*)loadLocationInterface("libgeofencing.so", "getGeofenceInterface");
|
(GeofenceInterface*)loadLocationInterface<GeofenceInterface,
|
||||||
|
getGeofenceInterface>("libgeofencing.so", "getGeofenceInterface");
|
||||||
if (NULL == gData.geofenceInterface) {
|
if (NULL == gData.geofenceInterface) {
|
||||||
gGeofenceLoadFailed = true;
|
gGeofenceLoadFailed = true;
|
||||||
LOC_LOGW("%s:%d]: No geofence interface available", __func__, __LINE__);
|
LOC_LOGW("%s:%d]: No geofence interface available", __func__, __LINE__);
|
||||||
|
@ -606,7 +600,8 @@ LocationControlAPI::createInstance(LocationControlCallbacks& locationControlCall
|
||||||
if (nullptr != locationControlCallbacks.responseCb && NULL == gData.controlAPI) {
|
if (nullptr != locationControlCallbacks.responseCb && NULL == gData.controlAPI) {
|
||||||
if (NULL == gData.gnssInterface && !gGnssLoadFailed) {
|
if (NULL == gData.gnssInterface && !gGnssLoadFailed) {
|
||||||
gData.gnssInterface =
|
gData.gnssInterface =
|
||||||
(GnssInterface*)loadLocationInterface("libgnss.so", "getGnssInterface");
|
(GnssInterface*)loadLocationInterface<GnssInterface,
|
||||||
|
getGnssInterface>("libgnss.so", "getGnssInterface");
|
||||||
if (NULL == gData.gnssInterface) {
|
if (NULL == gData.gnssInterface) {
|
||||||
gGnssLoadFailed = true;
|
gGnssLoadFailed = true;
|
||||||
LOC_LOGW("%s:%d]: No gnss interface available", __func__, __LINE__);
|
LOC_LOGW("%s:%d]: No gnss interface available", __func__, __LINE__);
|
||||||
|
|
Loading…
Reference in a new issue