sanders: gps: switch to LA.UM.6.6.r1-04300-89xx.0 branch

This commit is contained in:
Vachounet
2017-11-22 20:38:49 +01:00
committed by therootlord
parent 3ffdc23017
commit 1f8198a460
162 changed files with 22237 additions and 11732 deletions

View File

@@ -1,3 +1,4 @@
ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
ifneq ($(BUILD_TINY_ANDROID),true)
LOCAL_PATH := $(call my-dir)
@@ -5,8 +6,8 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libloc_core
LOCAL_MODULE_OWNER := qcom
LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib
LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64
LOCAL_MODULE_TAGS := optional
ifeq ($(TARGET_DEVICE),apq8026_lw)
@@ -21,6 +22,7 @@ LOCAL_SHARED_LIBRARIES := \
libcutils \
libgps.utils \
libdl \
liblog \
libloc_pla
LOCAL_SRC_FILES += \
@@ -28,32 +30,40 @@ LOCAL_SRC_FILES += \
LocAdapterBase.cpp \
ContextBase.cpp \
LocDualContext.cpp \
loc_core_log.cpp
loc_core_log.cpp \
data-items/DataItemsFactoryProxy.cpp \
data-items/common/ClientIndex.cpp \
data-items/common/DataItemIndex.cpp \
data-items/common/IndexFactory.cpp \
SystemStatusOsObserver.cpp \
SystemStatus.cpp
LOCAL_CFLAGS += \
-fno-short-enums \
-D_ANDROID_
LOCAL_C_INCLUDES:= \
$(TARGET_OUT_HEADERS)/gps.utils \
$(TARGET_OUT_HEADERS)/libflp \
$(TARGET_OUT_HEADERS)/libloc_pla
$(LOCAL_PATH)/data-items \
$(LOCAL_PATH)/data-items/common \
$(LOCAL_PATH)/observer \
LOCAL_COPY_HEADERS_TO:= libloc_core/
LOCAL_COPY_HEADERS:= \
LocApiBase.h \
LocAdapterBase.h \
ContextBase.h \
LocDualContext.h \
LBSProxyBase.h \
UlpProxyBase.h \
gps_extended_c.h \
gps_extended.h \
loc_core_log.h \
LocAdapterProxyBase.h
LOCAL_HEADER_LIBRARIES := \
libgps.utils_headers \
libloc_pla_headers \
liblocation_api_headers
LOCAL_PRELINK_MODULE := false
LOCAL_CFLAGS += $(GNSS_CFLAGS)
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libloc_core_headers
LOCAL_EXPORT_C_INCLUDE_DIRS := \
$(LOCAL_PATH) \
$(LOCAL_PATH)/data-items \
$(LOCAL_PATH)/data-items/common \
$(LOCAL_PATH)/observer
include $(BUILD_HEADER_LIBRARY)
endif # not BUILD_TINY_ANDROID
endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014,2016-2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -26,7 +26,7 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#define LOG_NDDEBUG 0
#define LOG_NDEBUG 0
#define LOG_TAG "LocSvc_CtxBase"
#include <dlfcn.h>
@@ -40,8 +40,114 @@
namespace loc_core {
loc_gps_cfg_s_type ContextBase::mGps_conf {0};
loc_sap_cfg_s_type ContextBase::mSap_conf {0};
loc_gps_cfg_s_type ContextBase::mGps_conf {};
loc_sap_cfg_s_type ContextBase::mSap_conf {};
const loc_param_s_type ContextBase::mGps_conf_table[] =
{
{"GPS_LOCK", &mGps_conf.GPS_LOCK, NULL, 'n'},
{"SUPL_VER", &mGps_conf.SUPL_VER, NULL, 'n'},
{"LPP_PROFILE", &mGps_conf.LPP_PROFILE, NULL, 'n'},
{"A_GLONASS_POS_PROTOCOL_SELECT", &mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT, NULL, 'n'},
{"LPPE_CP_TECHNOLOGY", &mGps_conf.LPPE_CP_TECHNOLOGY, NULL, 'n'},
{"LPPE_UP_TECHNOLOGY", &mGps_conf.LPPE_UP_TECHNOLOGY, NULL, 'n'},
{"AGPS_CERT_WRITABLE_MASK", &mGps_conf.AGPS_CERT_WRITABLE_MASK, NULL, 'n'},
{"SUPL_MODE", &mGps_conf.SUPL_MODE, NULL, 'n'},
{"SUPL_ES", &mGps_conf.SUPL_ES, NULL, 'n'},
{"INTERMEDIATE_POS", &mGps_conf.INTERMEDIATE_POS, NULL, 'n'},
{"ACCURACY_THRES", &mGps_conf.ACCURACY_THRES, NULL, 'n'},
{"NMEA_PROVIDER", &mGps_conf.NMEA_PROVIDER, NULL, 'n'},
{"CAPABILITIES", &mGps_conf.CAPABILITIES, NULL, 'n'},
{"XTRA_VERSION_CHECK", &mGps_conf.XTRA_VERSION_CHECK, NULL, 'n'},
{"XTRA_SERVER_1", &mGps_conf.XTRA_SERVER_1, NULL, 's'},
{"XTRA_SERVER_2", &mGps_conf.XTRA_SERVER_2, NULL, 's'},
{"XTRA_SERVER_3", &mGps_conf.XTRA_SERVER_3, NULL, 's'},
{"USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL", &mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL, NULL, 'n'},
{"AGPS_CONFIG_INJECT", &mGps_conf.AGPS_CONFIG_INJECT, NULL, 'n'},
{"EXTERNAL_DR_ENABLED", &mGps_conf.EXTERNAL_DR_ENABLED, NULL, 'n'},
};
const loc_param_s_type ContextBase::mSap_conf_table[] =
{
{"GYRO_BIAS_RANDOM_WALK", &mSap_conf.GYRO_BIAS_RANDOM_WALK, &mSap_conf.GYRO_BIAS_RANDOM_WALK_VALID, 'f'},
{"ACCEL_RANDOM_WALK_SPECTRAL_DENSITY", &mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY, &mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
{"ANGLE_RANDOM_WALK_SPECTRAL_DENSITY", &mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY, &mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
{"RATE_RANDOM_WALK_SPECTRAL_DENSITY", &mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY, &mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
{"VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY", &mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY, &mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
{"SENSOR_ACCEL_BATCHES_PER_SEC", &mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC, NULL, 'n'},
{"SENSOR_ACCEL_SAMPLES_PER_BATCH", &mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH, NULL, 'n'},
{"SENSOR_GYRO_BATCHES_PER_SEC", &mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC, NULL, 'n'},
{"SENSOR_GYRO_SAMPLES_PER_BATCH", &mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH, NULL, 'n'},
{"SENSOR_ACCEL_BATCHES_PER_SEC_HIGH", &mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH, NULL, 'n'},
{"SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH", &mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH, NULL, 'n'},
{"SENSOR_GYRO_BATCHES_PER_SEC_HIGH", &mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH, NULL, 'n'},
{"SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH", &mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH, NULL, 'n'},
{"SENSOR_CONTROL_MODE", &mSap_conf.SENSOR_CONTROL_MODE, NULL, 'n'},
{"SENSOR_USAGE", &mSap_conf.SENSOR_USAGE, NULL, 'n'},
{"SENSOR_ALGORITHM_CONFIG_MASK", &mSap_conf.SENSOR_ALGORITHM_CONFIG_MASK, NULL, 'n'},
{"SENSOR_PROVIDER", &mSap_conf.SENSOR_PROVIDER, NULL, 'n'}
};
void ContextBase::readConfig()
{
/*Defaults for gps.conf*/
mGps_conf.INTERMEDIATE_POS = 0;
mGps_conf.ACCURACY_THRES = 0;
mGps_conf.NMEA_PROVIDER = 0;
mGps_conf.GPS_LOCK = 0;
mGps_conf.SUPL_VER = 0x10000;
mGps_conf.SUPL_MODE = 0x1;
mGps_conf.SUPL_ES = 0;
mGps_conf.CAPABILITIES = 0x7;
/* LTE Positioning Profile configuration is disable by default*/
mGps_conf.LPP_PROFILE = 0;
/*By default no positioning protocol is selected on A-GLONASS system*/
mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT = 0;
/*XTRA version check is disabled by default*/
mGps_conf.XTRA_VERSION_CHECK=0;
/*Use emergency PDN by default*/
mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL = 1;
/* By default no LPPe CP technology is enabled*/
mGps_conf.LPPE_CP_TECHNOLOGY = 0;
/* By default no LPPe UP technology is enabled*/
mGps_conf.LPPE_UP_TECHNOLOGY = 0;
/*Defaults for sap.conf*/
mSap_conf.GYRO_BIAS_RANDOM_WALK = 0;
mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC = 2;
mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH = 5;
mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC = 2;
mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH = 5;
mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH = 4;
mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH = 25;
mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH = 4;
mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH = 25;
mSap_conf.SENSOR_CONTROL_MODE = 0; /* AUTO */
mSap_conf.SENSOR_USAGE = 0; /* Enabled */
mSap_conf.SENSOR_ALGORITHM_CONFIG_MASK = 0; /* INS Disabled = FALSE*/
/* Values MUST be set by OEMs in configuration for sensor-assisted
navigation to work. There are NO default values */
mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY = 0;
mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY = 0;
mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY = 0;
mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY = 0;
mSap_conf.GYRO_BIAS_RANDOM_WALK_VALID = 0;
mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
/* default provider is SSC */
mSap_conf.SENSOR_PROVIDER = 1;
/* None of the 10 slots for agps certificates are writable by default */
mGps_conf.AGPS_CERT_WRITABLE_MASK = 0;
/* inject supl config to modem with config values from config.xml or gps.conf, default 1 */
mGps_conf.AGPS_CONFIG_INJECT = 1;
UTIL_READ_CONF(LOC_PATH_GPS_CONF, mGps_conf_table);
UTIL_READ_CONF(LOC_PATH_SAP_CONF, mSap_conf_table);
}
uint32_t ContextBase::getCarrierCapabilities() {
#define carrierMSA (uint32_t)0x2
@@ -88,31 +194,35 @@ LocApiBase* ContextBase::createLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask)
{
LocApiBase* locApi = NULL;
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
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) {
// Check the target
if (TARGET_NO_GNSS != loc_get_target()){
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 (NULL != getter) {
LOC_LOGD("%s:%d]: getter is not NULL in RPC", __func__,
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
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) {
getLocApi_t* getter = (getLocApi_t*) dlsym(handle, "getLocApi");
if (NULL != getter) {
LOC_LOGD("%s:%d]: getter is not NULL in RPC", __func__,
__LINE__);
locApi = (*getter)(mMsgTask, exMask, this);
}
}
}
}
}

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -34,6 +34,7 @@
#include <MsgTask.h>
#include <LocApiBase.h>
#include <LBSProxyBase.h>
#include <loc_cfg.h>
#define MAX_XTRA_SERVER_URL_LENGTH 256
@@ -105,6 +106,8 @@ class LocAdapterBase;
class ContextBase {
static LBSProxyBase* getLBSProxy(const char* libName);
LocApiBase* createLocApi(LOC_API_ADAPTER_EVENT_MASK_T excludedMask);
static const loc_param_s_type mGps_conf_table[];
static const loc_param_s_type mSap_conf_table[];
protected:
const LBSProxyBase* mLBSProxy;
const MsgTask* mMsgTask;
@@ -135,6 +138,7 @@ public:
static loc_gps_cfg_s_type mGps_conf;
static loc_sap_cfg_s_type mSap_conf;
void readConfig();
static uint32_t getCarrierCapabilities();
};

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014, 2016-2017The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -26,7 +26,7 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#define LOG_NDDEBUG 0
#define LOG_NDEBUG 0
#define LOG_TAG "LocSvc_LocAdapterBase"
#include <dlfcn.h>
@@ -50,6 +50,16 @@ LocAdapterBase::LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
mLocApi->addAdapter(this);
}
uint32_t LocAdapterBase::mSessionIdCounter(1);
uint32_t LocAdapterBase::generateSessionId()
{
if (++mSessionIdCounter == 0xFFFFFFFF)
mSessionIdCounter = 1;
return mSessionIdCounter;
}
void LocAdapterBase::handleEngineUpEvent()
{
if (mLocAdapterProxyBase) {
@@ -65,46 +75,45 @@ void LocAdapterBase::handleEngineDownEvent()
}
void LocAdapterBase::
reportPosition(UlpLocation &location,
GpsLocationExtended &locationExtended,
void* locationExt,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask) {
if (mLocAdapterProxyBase == NULL ||
!mLocAdapterProxyBase->reportPosition(location,
locationExtended,
status,
loc_technology_mask)) {
reportPositionEvent(const UlpLocation& location,
const GpsLocationExtended& locationExtended,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask,
bool /*fromUlp*/) {
if (mLocAdapterProxyBase != NULL) {
mLocAdapterProxyBase->reportPositionEvent((UlpLocation&)location,
(GpsLocationExtended&)locationExtended,
status,
loc_technology_mask);
} else {
DEFAULT_IMPL()
}
}
void LocAdapterBase::
reportSv(GnssSvStatus &svStatus,
GpsLocationExtended &locationExtended,
void* svExt)
reportSvEvent(const GnssSvNotification& /*svNotify*/, bool /*fromUlp*/)
DEFAULT_IMPL()
void LocAdapterBase::
reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet)
reportSvMeasurementEvent(GnssSvMeasurementSet &/*svMeasurementSet*/)
DEFAULT_IMPL()
void LocAdapterBase::
reportSvPolynomial(GnssSvPolynomial &svPolynomial)
reportSvPolynomialEvent(GnssSvPolynomial &/*svPolynomial*/)
DEFAULT_IMPL()
void LocAdapterBase::
reportStatus(GpsStatusValue status)
reportStatus(LocGpsStatusValue /*status*/)
DEFAULT_IMPL()
void LocAdapterBase::
reportNmea(const char* nmea, int length)
reportNmeaEvent(const char* /*nmea*/, size_t /*length*/, bool /*fromUlp*/)
DEFAULT_IMPL()
bool LocAdapterBase::
reportXtraServer(const char* url1, const char* url2,
const char* url3, const int maxlength)
reportXtraServer(const char* /*url1*/, const char* /*url2*/,
const char* /*url3*/, const int /*maxlength*/)
DEFAULT_IMPL(false)
bool LocAdapterBase::
@@ -120,15 +129,15 @@ bool LocAdapterBase::
DEFAULT_IMPL(false)
bool LocAdapterBase::
requestATL(int connHandle, AGpsType agps_type)
requestATL(int /*connHandle*/, LocAGpsType /*agps_type*/)
DEFAULT_IMPL(false)
bool LocAdapterBase::
releaseATL(int connHandle)
releaseATL(int /*connHandle*/)
DEFAULT_IMPL(false)
bool LocAdapterBase::
requestSuplES(int connHandle)
requestSuplES(int /*connHandle*/)
DEFAULT_IMPL(false)
bool LocAdapterBase::
@@ -140,10 +149,16 @@ bool LocAdapterBase::
DEFAULT_IMPL(false)
bool LocAdapterBase::
requestNiNotify(GpsNiNotification &notify, const void* data)
requestNiNotifyEvent(const GnssNiNotification &/*notify*/, const void* /*data*/)
DEFAULT_IMPL(false)
void LocAdapterBase::
reportGnssMeasurementData(GnssData &gnssMeasurementData)
reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& /*measurements*/,
int /*msInWeek*/)
DEFAULT_IMPL()
bool LocAdapterBase::
reportWwanZppFix(LocGpsLocation &/*zppLoc*/)
DEFAULT_IMPL(false)
} // namespace loc_core

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2011-2014,2016 The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014, 2016-2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -32,19 +32,39 @@
#include <gps_extended.h>
#include <UlpProxyBase.h>
#include <ContextBase.h>
#include <LocationAPI.h>
#include <map>
typedef struct LocationSessionKey {
LocationAPI* client;
uint32_t id;
inline LocationSessionKey(LocationAPI* _client, uint32_t _id) :
client(_client), id(_id) {}
} LocationSessionKey;
inline bool operator <(LocationSessionKey const& left, LocationSessionKey const& right) {
return left.id < right.id || (left.id == right.id && left.client < right.client);
}
inline bool operator ==(LocationSessionKey const& left, LocationSessionKey const& right) {
return left.id == right.id && left.client == right.client;
}
inline bool operator !=(LocationSessionKey const& left, LocationSessionKey const& right) {
return left.id != right.id || left.client != right.client;
}
typedef std::map<LocationSessionKey, LocationOptions> LocationSessionMap;
namespace loc_core {
class LocAdapterProxyBase;
class LocAdapterBase {
private:
static uint32_t mSessionIdCounter;
protected:
LOC_API_ADAPTER_EVENT_MASK_T mEvtMask;
ContextBase* mContext;
LocApiBase* mLocApi;
LocAdapterProxyBase* mLocAdapterProxyBase;
const MsgTask* mMsgTask;
inline LocAdapterBase(const MsgTask* msgTask) :
mEvtMask(0), mContext(NULL), mLocApi(NULL),
mLocAdapterProxyBase(NULL), mMsgTask(msgTask) {}
@@ -70,11 +90,19 @@ public:
}
inline void updateEvtMask(LOC_API_ADAPTER_EVENT_MASK_T event,
loc_registration_mask_status isEnabled)
loc_registration_mask_status status)
{
mEvtMask =
isEnabled == LOC_REGISTRATION_MASK_ENABLED ? (mEvtMask|event):(mEvtMask&~event);
switch(status) {
case (LOC_REGISTRATION_MASK_ENABLED):
mEvtMask = mEvtMask | event;
break;
case (LOC_REGISTRATION_MASK_DISABLED):
mEvtMask = mEvtMask &~ event;
break;
case (LOC_REGISTRATION_MASK_SET):
mEvtMask = event;
break;
}
mLocApi->updateEvtMask();
}
@@ -82,48 +110,49 @@ public:
return mLocApi->isFeatureSupported(featureVal);
}
uint32_t generateSessionId();
// This will be overridden by the individual adapters
// if necessary.
inline virtual void setUlpProxy(UlpProxyBase* ulp) {
inline virtual void setUlpProxyCommand(UlpProxyBase* ulp) {
(void)ulp;
}
virtual void handleEngineUpEvent();
virtual void handleEngineDownEvent();
inline virtual void setPositionModeInt(LocPosMode& posMode) {
inline virtual void setPositionModeCommand(LocPosMode& posMode) {
(void)posMode;
}
virtual void startFixInt() {}
virtual void stopFixInt() {}
virtual void getZppInt() {}
virtual void reportPosition(UlpLocation &location,
GpsLocationExtended &locationExtended,
void* locationExt,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask);
virtual void reportSv(GnssSvStatus &svStatus,
GpsLocationExtended &locationExtended,
void* svExt);
virtual void reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet);
virtual void reportSvPolynomial(GnssSvPolynomial &svPolynomial);
virtual void reportStatus(GpsStatusValue status);
virtual void reportNmea(const char* nmea, int length);
virtual void startTrackingCommand() {}
virtual void stopTrackingCommand() {}
virtual void getZppCommand() {}
virtual void reportPositionEvent(const UlpLocation& location,
const GpsLocationExtended& locationExtended,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask,
bool fromUlp=false);
virtual void reportSvEvent(const GnssSvNotification& svNotify, bool fromUlp=false);
virtual void reportNmeaEvent(const char* nmea, size_t length, bool fromUlp=false);
virtual void reportSvMeasurementEvent(GnssSvMeasurementSet &svMeasurementSet);
virtual void reportSvPolynomialEvent(GnssSvPolynomial &svPolynomial);
virtual void reportStatus(LocGpsStatusValue status);
virtual bool reportXtraServer(const char* url1, const char* url2,
const char* url3, const int maxlength);
virtual bool requestXtraData();
virtual bool requestTime();
virtual bool requestLocation();
virtual bool requestATL(int connHandle, AGpsType agps_type);
virtual bool requestATL(int connHandle, LocAGpsType agps_type);
virtual bool releaseATL(int connHandle);
virtual bool requestSuplES(int connHandle);
virtual bool reportDataCallOpened();
virtual bool reportDataCallClosed();
virtual bool requestNiNotify(GpsNiNotification &notify,
const void* data);
virtual bool requestNiNotifyEvent(const GnssNiNotification &notify, const void* data);
inline virtual bool isInSession() { return false; }
ContextBase* getContext() const { return mContext; }
virtual void reportGnssMeasurementData(GnssData &gnssMeasurementData);
virtual void reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& measurements,
int msInWeek);
virtual bool reportWwanZppFix(LocGpsLocation &zppLoc);
};
} // namespace loc_core

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2014 The Linux Foundation. All rights reserved.
/* Copyright (c) 2014, 2016-2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -51,22 +51,25 @@ protected:
mLocAdapterBase->updateEvtMask(event,isEnabled);
}
inline uint32_t generateSessionId() {
return mLocAdapterBase->generateSessionId();
}
public:
inline ContextBase* getContext() const {
return mLocAdapterBase->getContext();
}
inline virtual void handleEngineUpEvent() {};
inline virtual void handleEngineDownEvent() {};
inline virtual bool reportPosition(UlpLocation &location,
GpsLocationExtended &locationExtended,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask) {
inline virtual void reportPositionEvent(UlpLocation &location,
GpsLocationExtended &locationExtended,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask) {
(void)location;
(void)locationExtended;
(void)status;
(void)loc_technology_mask;
return false;
}
};

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2011-2014,2016 The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014, 2016-2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -26,10 +26,11 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#define LOG_NDDEBUG 0
#define LOG_NDEBUG 0 //Define to enable LOGV
#define LOG_TAG "LocSvc_LocApiBase"
#include <dlfcn.h>
#include <inttypes.h>
#include <LocApiBase.h>
#include <LocAdapterBase.h>
#include <platform_lib_log_util.h>
@@ -96,10 +97,10 @@ struct LocSsrMsg : public LocMsg {
mLocApi->close();
mLocApi->open(mLocApi->getEvtMask());
}
inline void locallog() {
inline void locallog() const {
LOC_LOGV("LocSsrMsg");
}
inline virtual void log() {
inline virtual void log() const {
locallog();
}
};
@@ -116,11 +117,11 @@ struct LocOpenMsg : public LocMsg {
inline virtual void proc() const {
mLocApi->open(mMask);
}
inline void locallog() {
inline void locallog() const {
LOC_LOGV("%s:%d]: LocOpen Mask: %x\n",
__func__, __LINE__, mMask);
}
inline virtual void log() {
inline virtual void log() const {
locallog();
}
};
@@ -128,8 +129,8 @@ struct LocOpenMsg : public LocMsg {
LocApiBase::LocApiBase(const MsgTask* msgTask,
LOC_API_ADAPTER_EVENT_MASK_T excludedMask,
ContextBase* context) :
mExcludedMask(excludedMask), mMsgTask(msgTask),
mMask(0), mSupportedMsg(0), mContext(context)
mMsgTask(msgTask), mContext(context), mSupportedMsg(0),
mMask(0), mExcludedMask(excludedMask)
{
memset(mLocAdapters, 0, sizeof(mLocAdapters));
memset(mFeaturesSupported, 0, sizeof(mFeaturesSupported));
@@ -227,65 +228,70 @@ void LocApiBase::handleEngineDownEvent()
TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineDownEvent());
}
void LocApiBase::reportPosition(UlpLocation &location,
GpsLocationExtended &locationExtended,
void* locationExt,
void LocApiBase::reportPosition(UlpLocation& location,
GpsLocationExtended& locationExtended,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask)
{
// print the location info before delivering
LOC_LOGV("flags: %d\n source: %d\n latitude: %f\n longitude: %f\n "
LOC_LOGD("flags: %d\n source: %d\n latitude: %f\n longitude: %f\n "
"altitude: %f\n speed: %f\n bearing: %f\n accuracy: %f\n "
"timestamp: %lld\n rawDataSize: %d\n rawData: %p\n "
"Session status: %d\n Technology mask: %u",
"timestamp: %" PRId64 "\n rawDataSize: %d\n rawData: %p\n "
"Session status: %d\n Technology mask: %u\n "
"SV used in fix (gps/glo/bds/gal/qzss) : \
(%" PRIx64 "/%" PRIx64 "/%" PRIx64 "/%" PRIx64 "/%" PRIx64 ")",
location.gpsLocation.flags, location.position_source,
location.gpsLocation.latitude, location.gpsLocation.longitude,
location.gpsLocation.altitude, location.gpsLocation.speed,
location.gpsLocation.bearing, location.gpsLocation.accuracy,
location.gpsLocation.timestamp, location.rawDataSize,
location.rawData, status, loc_technology_mask);
location.rawData, status, loc_technology_mask,
locationExtended.gnss_sv_used_ids.gps_sv_used_ids_mask,
locationExtended.gnss_sv_used_ids.glo_sv_used_ids_mask,
locationExtended.gnss_sv_used_ids.bds_sv_used_ids_mask,
locationExtended.gnss_sv_used_ids.gal_sv_used_ids_mask,
locationExtended.gnss_sv_used_ids.qzss_sv_used_ids_mask);
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(
mLocAdapters[i]->reportPosition(location,
locationExtended,
locationExt,
status,
loc_technology_mask)
mLocAdapters[i]->reportPositionEvent(location, locationExtended,
status, loc_technology_mask)
);
}
void LocApiBase::reportSv(GnssSvStatus &svStatus,
GpsLocationExtended &locationExtended,
void* svExt)
void LocApiBase::reportWwanZppFix(LocGpsLocation &zppLoc)
{
// loop through adapters, and deliver to the first handling adapter.
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportWwanZppFix(zppLoc));
}
void LocApiBase::reportSv(GnssSvNotification& svNotify)
{
const char* constellationString[] = { "Unknown", "GPS", "SBAS", "GLONASS",
"QZSS", "BEIDOU", "GALILEO" };
// print the SV info before delivering
LOC_LOGV("num sv: %d\n"
LOC_LOGV("num sv: %zu\n"
" sv: constellation svid cN0"
" elevation azimuth flags",
svStatus.num_svs);
for (int i = 0; i < svStatus.num_svs && i < GNSS_MAX_SVS; i++) {
if (svStatus.gnss_sv_list[i].constellation >
svNotify.count);
for (size_t i = 0; i < svNotify.count && i < LOC_GNSS_MAX_SVS; i++) {
if (svNotify.gnssSvs[i].type >
sizeof(constellationString) / sizeof(constellationString[0]) - 1) {
svStatus.gnss_sv_list[i].constellation = 0;
svNotify.gnssSvs[i].type = GNSS_SV_TYPE_UNKNOWN;
}
LOC_LOGV(" %03d: %*s %02d %f %f %f 0x%02X",
LOC_LOGV(" %03zu: %*s %02d %f %f %f 0x%02X",
i,
13,
constellationString[svStatus.gnss_sv_list[i].constellation],
svStatus.gnss_sv_list[i].svid,
svStatus.gnss_sv_list[i].c_n0_dbhz,
svStatus.gnss_sv_list[i].elevation,
svStatus.gnss_sv_list[i].azimuth,
svStatus.gnss_sv_list[i].flags);
constellationString[svNotify.gnssSvs[i].type],
svNotify.gnssSvs[i].svId,
svNotify.gnssSvs[i].cN0Dbhz,
svNotify.gnssSvs[i].elevation,
svNotify.gnssSvs[i].azimuth,
svNotify.gnssSvs[i].gnssSvOptionsMask);
}
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(
mLocAdapters[i]->reportSv(svStatus,
locationExtended,
svExt)
mLocAdapters[i]->reportSvEvent(svNotify)
);
}
@@ -293,7 +299,7 @@ void LocApiBase::reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet)
{
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(
mLocAdapters[i]->reportSvMeasurement(svMeasurementSet)
mLocAdapters[i]->reportSvMeasurementEvent(svMeasurementSet)
);
}
@@ -301,11 +307,11 @@ void LocApiBase::reportSvPolynomial(GnssSvPolynomial &svPolynomial)
{
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(
mLocAdapters[i]->reportSvPolynomial(svPolynomial)
mLocAdapters[i]->reportSvPolynomialEvent(svPolynomial)
);
}
void LocApiBase::reportStatus(GpsStatusValue status)
void LocApiBase::reportStatus(LocGpsStatusValue status)
{
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportStatus(status));
@@ -314,7 +320,7 @@ void LocApiBase::reportStatus(GpsStatusValue status)
void LocApiBase::reportNmea(const char* nmea, int length)
{
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportNmea(nmea, length));
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportNmeaEvent(nmea, length));
}
void LocApiBase::reportXtraServer(const char* url1, const char* url2,
@@ -343,7 +349,7 @@ void LocApiBase::requestLocation()
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestLocation());
}
void LocApiBase::requestATL(int connHandle, AGpsType agps_type)
void LocApiBase::requestATL(int connHandle, LocAGpsType agps_type)
{
// loop through adapters, and deliver to the first handling adapter.
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestATL(connHandle, agps_type));
@@ -373,10 +379,10 @@ void LocApiBase::reportDataCallClosed()
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportDataCallClosed());
}
void LocApiBase::requestNiNotify(GpsNiNotification &notify, const void* data)
void LocApiBase::requestNiNotify(GnssNiNotification &notify, const void* data)
{
// loop through adapters, and deliver to the first handling adapter.
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestNiNotify(notify, data));
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestNiNotifyEvent(notify, data));
}
void LocApiBase::saveSupportedMsgList(uint64_t supportedMsgList)
@@ -395,14 +401,15 @@ void* LocApiBase :: getSibling()
LocApiProxyBase* LocApiBase :: getLocApiProxy()
DEFAULT_IMPL(NULL)
void LocApiBase::reportGnssMeasurementData(GnssData &gnssMeasurementData)
void LocApiBase::reportGnssMeasurementData(GnssMeasurementsNotification& measurements,
int msInWeek)
{
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssMeasurementData(gnssMeasurementData));
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssMeasurementDataEvent(measurements, msInWeek));
}
enum loc_api_adapter_err LocApiBase::
open(LOC_API_ADAPTER_EVENT_MASK_T mask)
open(LOC_API_ADAPTER_EVENT_MASK_T /*mask*/)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
@@ -410,35 +417,35 @@ enum loc_api_adapter_err LocApiBase::
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
startFix(const LocPosMode& posMode)
startFix(const LocPosMode& /*posMode*/)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
stopFix()
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
LocationError LocApiBase::
deleteAidingData(const GnssAidingData& /*data*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
deleteAidingData(GpsAidingData f)
enableData(int /*enable*/)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
enableData(int enable)
setAPN(char* /*apn*/, int /*len*/)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setAPN(char* apn, int len)
injectPosition(double /*latitude*/, double /*longitude*/, float /*accuracy*/)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
injectPosition(double latitude, double longitude, float accuracy)
setTime(LocGpsUtcTime /*time*/, int64_t /*timeReference*/, int /*uncertainty*/)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setTime(GpsUtcTime time, int64_t timeReference, int uncertainty)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setXtraData(char* data, int length)
setXtraData(char* /*data*/, int /*length*/)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
@@ -446,104 +453,108 @@ enum loc_api_adapter_err LocApiBase::
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
atlOpenStatus(int handle, int is_succ, char* apn,
AGpsBearerType bear, AGpsType agpsType)
atlOpenStatus(int /*handle*/, int /*is_succ*/, char* /*apn*/,
AGpsBearerType /*bear*/, LocAGpsType /*agpsType*/)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
atlCloseStatus(int handle, int is_succ)
atlCloseStatus(int /*handle*/, int /*is_succ*/)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setPositionMode(const LocPosMode& posMode)
setPositionMode(const LocPosMode& /*posMode*/)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
LocationError LocApiBase::
setServer(const char* /*url*/, int /*len*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
LocationError LocApiBase::
setServer(unsigned int /*ip*/, int /*port*/, LocServerType /*type*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
LocationError LocApiBase::
informNiResponse(GnssNiResponse /*userResponse*/, const void* /*passThroughData*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
LocationError LocApiBase::
setSUPLVersion(GnssConfigSuplVersion /*version*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setNMEATypes (uint32_t /*typesMask*/)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
LocationError LocApiBase::
setLPPConfig(GnssConfigLppProfile /*profile*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setSensorControlConfig(int /*sensorUsage*/,
int /*sensorProvider*/)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setServer(const char* url, int len)
setSensorProperties(bool /*gyroBiasVarianceRandomWalk_valid*/,
float /*gyroBiasVarianceRandomWalk*/,
bool /*accelBiasVarianceRandomWalk_valid*/,
float /*accelBiasVarianceRandomWalk*/,
bool /*angleBiasVarianceRandomWalk_valid*/,
float /*angleBiasVarianceRandomWalk*/,
bool /*rateBiasVarianceRandomWalk_valid*/,
float /*rateBiasVarianceRandomWalk*/,
bool /*velocityBiasVarianceRandomWalk_valid*/,
float /*velocityBiasVarianceRandomWalk*/)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setServer(unsigned int ip, int port,
LocServerType type)
setSensorPerfControlConfig(int /*controlMode*/,
int /*accelSamplesPerBatch*/,
int /*accelBatchesPerSec*/,
int /*gyroSamplesPerBatch*/,
int /*gyroBatchesPerSec*/,
int /*accelSamplesPerBatchHigh*/,
int /*accelBatchesPerSecHigh*/,
int /*gyroSamplesPerBatchHigh*/,
int /*gyroBatchesPerSecHigh*/,
int /*algorithmConfig*/)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
LocationError LocApiBase::
setAGLONASSProtocol(GnssConfigAGlonassPositionProtocolMask /*aGlonassProtocol*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
LocationError LocApiBase::
setLPPeProtocolCp(GnssConfigLppeControlPlaneMask /*lppeCP*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
LocationError LocApiBase::
setLPPeProtocolUp(GnssConfigLppeUserPlaneMask /*lppeUP*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
getWwanZppFix()
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
informNiResponse(GpsUserResponseType userResponse,
const void* passThroughData)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setSUPLVersion(uint32_t version)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setNMEATypes (uint32_t typesMask)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setLPPConfig(uint32_t profile)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setSensorControlConfig(int sensorUsage,
int sensorProvider)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setSensorProperties(bool gyroBiasVarianceRandomWalk_valid,
float gyroBiasVarianceRandomWalk,
bool accelBiasVarianceRandomWalk_valid,
float accelBiasVarianceRandomWalk,
bool angleBiasVarianceRandomWalk_valid,
float angleBiasVarianceRandomWalk,
bool rateBiasVarianceRandomWalk_valid,
float rateBiasVarianceRandomWalk,
bool velocityBiasVarianceRandomWalk_valid,
float velocityBiasVarianceRandomWalk)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setSensorPerfControlConfig(int controlMode,
int accelSamplesPerBatch,
int accelBatchesPerSec,
int gyroSamplesPerBatch,
int gyroBatchesPerSec,
int accelSamplesPerBatchHigh,
int accelBatchesPerSecHigh,
int gyroSamplesPerBatchHigh,
int gyroBatchesPerSecHigh,
int algorithmConfig)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setAGLONASSProtocol(unsigned long aGlonassProtocol)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setLPPeProtocol(unsigned long lppeCP, unsigned long lppeUP)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
getWwanZppFix(GpsLocation& zppLoc)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
getBestAvailableZppFix(GpsLocation& zppLoc)
getBestAvailableZppFix(LocGpsLocation& zppLoc)
{
memset(&zppLoc, 0, sizeof(zppLoc));
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
}
enum loc_api_adapter_err LocApiBase::
getBestAvailableZppFix(GpsLocation & zppLoc, LocPosTechMask & tech_mask)
getBestAvailableZppFix(LocGpsLocation & zppLoc, GpsLocationExtended & locationExtended,
LocPosTechMask & tech_mask)
{
memset(&zppLoc, 0, sizeof(zppLoc));
memset(&tech_mask, 0, sizeof(tech_mask));
memset(&locationExtended, 0, sizeof (locationExtended));
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
}
int LocApiBase::
initDataServiceClient()
initDataServiceClient(bool /*isDueToSsr*/)
DEFAULT_IMPL(-1)
int LocApiBase::
@@ -558,23 +569,27 @@ void LocApiBase::
closeDataCall()
DEFAULT_IMPL()
int LocApiBase::
setGpsLock(LOC_GPS_LOCK_MASK lock)
DEFAULT_IMPL(-1)
void LocApiBase::
releaseDataServiceClient()
DEFAULT_IMPL()
LocationError LocApiBase::
setGpsLock(GnssConfigGpsLock /*lock*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
void LocApiBase::
installAGpsCert(const DerEncodedCertificate* pData,
size_t length,
uint32_t slotBitMask)
installAGpsCert(const LocDerEncodedCertificate* /*pData*/,
size_t /*length*/,
uint32_t /*slotBitMask*/)
DEFAULT_IMPL()
int LocApiBase::
getGpsLock()
DEFAULT_IMPL(-1)
enum loc_api_adapter_err LocApiBase::
setXtraVersionCheck(enum xtra_version_check check)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
LocationError LocApiBase::
setXtraVersionCheck(uint32_t /*check*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
bool LocApiBase::
gnssConstellationConfig()

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2011-2014, 2016 The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014, 2016-2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -32,6 +32,7 @@
#include <stddef.h>
#include <ctype.h>
#include <gps_extended.h>
#include <LocationAPI.h>
#include <MsgTask.h>
#include <platform_lib_log_util.h>
@@ -102,40 +103,37 @@ public:
inline void sendMsg(const LocMsg* msg) const {
mMsgTask->sendMsg(msg);
}
void addAdapter(LocAdapterBase* adapter);
void removeAdapter(LocAdapterBase* adapter);
// upward calls
void handleEngineUpEvent();
void handleEngineDownEvent();
void reportPosition(UlpLocation &location,
GpsLocationExtended &locationExtended,
void* locationExt,
void reportPosition(UlpLocation& location,
GpsLocationExtended& locationExtended,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask =
LOC_POS_TECH_MASK_DEFAULT);
void reportSv(GnssSvStatus &svStatus,
GpsLocationExtended &locationExtended,
void* svExt);
void reportSv(GnssSvNotification& svNotify);
void reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet);
void reportSvPolynomial(GnssSvPolynomial &svPolynomial);
void reportStatus(GpsStatusValue status);
void reportStatus(LocGpsStatusValue status);
void reportNmea(const char* nmea, int length);
void reportXtraServer(const char* url1, const char* url2,
const char* url3, const int maxlength);
void requestXtraData();
void requestTime();
void requestLocation();
void requestATL(int connHandle, AGpsType agps_type);
void requestATL(int connHandle, LocAGpsType agps_type);
void releaseATL(int connHandle);
void requestSuplES(int connHandle);
void reportDataCallOpened();
void reportDataCallClosed();
void requestNiNotify(GpsNiNotification &notify, const void* data);
void requestNiNotify(GnssNiNotification &notify, const void* data);
void saveSupportedMsgList(uint64_t supportedMsgList);
void reportGnssMeasurementData(GnssData &gnssMeasurementData);
void reportGnssMeasurementData(GnssMeasurementsNotification& measurements, int msInWeek);
void saveSupportedFeatureList(uint8_t *featureList);
void reportWwanZppFix(LocGpsLocation &zppLoc);
// downward calls
// All below functions are to be defined by adapter specific modules:
@@ -147,8 +145,8 @@ public:
startFix(const LocPosMode& posMode);
virtual enum loc_api_adapter_err
stopFix();
virtual enum loc_api_adapter_err
deleteAidingData(GpsAidingData f);
virtual LocationError
deleteAidingData(const GnssAidingData& data);
virtual enum loc_api_adapter_err
enableData(int enable);
virtual enum loc_api_adapter_err
@@ -156,30 +154,28 @@ public:
virtual enum loc_api_adapter_err
injectPosition(double latitude, double longitude, float accuracy);
virtual enum loc_api_adapter_err
setTime(GpsUtcTime time, int64_t timeReference, int uncertainty);
setTime(LocGpsUtcTime time, int64_t timeReference, int uncertainty);
virtual enum loc_api_adapter_err
setXtraData(char* data, int length);
virtual enum loc_api_adapter_err
requestXtraServer();
virtual enum loc_api_adapter_err
atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bear, AGpsType agpsType);
atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bear, LocAGpsType agpsType);
virtual enum loc_api_adapter_err
atlCloseStatus(int handle, int is_succ);
virtual enum loc_api_adapter_err
setPositionMode(const LocPosMode& posMode);
virtual enum loc_api_adapter_err
virtual LocationError
setServer(const char* url, int len);
virtual enum loc_api_adapter_err
virtual LocationError
setServer(unsigned int ip, int port,
LocServerType type);
virtual enum loc_api_adapter_err
informNiResponse(GpsUserResponseType userResponse, const void* passThroughData);
virtual enum loc_api_adapter_err
setSUPLVersion(uint32_t version);
virtual LocationError
informNiResponse(GnssNiResponse userResponse, const void* passThroughData);
virtual LocationError setSUPLVersion(GnssConfigSuplVersion version);
virtual enum loc_api_adapter_err
setNMEATypes (uint32_t typesMask);
virtual enum loc_api_adapter_err
setLPPConfig(uint32_t profile);
virtual LocationError setLPPConfig(GnssConfigLppProfile profile);
virtual enum loc_api_adapter_err
setSensorControlConfig(int sensorUsage, int sensorProvider);
virtual enum loc_api_adapter_err
@@ -204,21 +200,23 @@ public:
int gyroSamplesPerBatchHigh,
int gyroBatchesPerSecHigh,
int algorithmConfig);
virtual LocationError
setAGLONASSProtocol(GnssConfigAGlonassPositionProtocolMask aGlonassProtocol);
virtual LocationError setLPPeProtocolCp(GnssConfigLppeControlPlaneMask lppeCP);
virtual LocationError setLPPeProtocolUp(GnssConfigLppeUserPlaneMask lppeUP);
virtual enum loc_api_adapter_err
setAGLONASSProtocol(unsigned long aGlonassProtocol);
getWwanZppFix();
virtual enum loc_api_adapter_err
setLPPeProtocol(unsigned long lppeCP, unsigned long lppeUP);
getBestAvailableZppFix(LocGpsLocation & zppLoc);
virtual enum loc_api_adapter_err
getWwanZppFix(GpsLocation & zppLoc);
virtual enum loc_api_adapter_err
getBestAvailableZppFix(GpsLocation & zppLoc);
virtual enum loc_api_adapter_err
getBestAvailableZppFix(GpsLocation & zppLoc, LocPosTechMask & tech_mask);
virtual int initDataServiceClient();
getBestAvailableZppFix(LocGpsLocation & zppLoc, GpsLocationExtended & locationExtended,
LocPosTechMask & tech_mask);
virtual int initDataServiceClient(bool isDueToSsr);
virtual int openAndStartDataCall();
virtual void stopDataCall();
virtual void closeDataCall();
virtual void installAGpsCert(const DerEncodedCertificate* pData,
virtual void releaseDataServiceClient();
virtual void installAGpsCert(const LocDerEncodedCertificate* pData,
size_t length,
uint32_t slotBitMask);
inline virtual void setInSession(bool inSession) {
@@ -236,15 +234,10 @@ public:
return (messageChecker & mSupportedMsg) == messageChecker;
}
}
void updateEvtMask();
/*Values for lock
1 = Do not lock any position sessions
2 = Lock MI position sessions
3 = Lock MT position sessions
4 = Lock all position sessions
*/
virtual int setGpsLock(LOC_GPS_LOCK_MASK lock);
virtual LocationError setGpsLock(GnssConfigGpsLock lock);
/*
Returns
Current value of GPS Lock on success
@@ -252,8 +245,7 @@ public:
*/
virtual int getGpsLock(void);
virtual enum loc_api_adapter_err setXtraVersionCheck(enum xtra_version_check check);
virtual LocationError setXtraVersionCheck(uint32_t check);
/*
Check if the modem support the service
*/

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014, 2016-2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -26,7 +26,7 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#define LOG_NDDEBUG 0
#define LOG_NDEBUG 0
#define LOG_TAG "LocSvc_DualCtx"
#include <cutils/sched_policy.h>
@@ -44,8 +44,7 @@ LocDualContext::mFgExclMask = 0;
// excluded events for background clients
const LOC_API_ADAPTER_EVENT_MASK_T
LocDualContext::mBgExclMask =
(LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT |
LOC_API_ADAPTER_BIT_SATELLITE_REPORT |
(LOC_API_ADAPTER_BIT_SATELLITE_REPORT |
LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT |
LOC_API_ADAPTER_BIT_NMEA_POSITION_REPORT |
LOC_API_ADAPTER_BIT_IOCTL_REPORT |

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014, 2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are

61
gps/core/Makefile.am Normal file
View File

@@ -0,0 +1,61 @@
AM_CFLAGS = -I./ \
-I../utils \
-I../location \
$(LOCPLA_CFLAGS) \
$(GPSUTILS_CFLAGS) \
-I$(WORKSPACE)/gps-noship/flp \
-D__func__=__PRETTY_FUNCTION__ \
-fno-short-enums \
-std=c++11
libloc_core_la_h_sources = \
LocApiBase.h \
LocAdapterBase.h \
ContextBase.h \
LocDualContext.h \
LBSProxyBase.h \
UlpProxyBase.h \
loc_core_log.h \
LocAdapterProxyBase.h \
data-items/DataItemId.h \
data-items/IDataItemCore.h \
observer/IDataItemObserver.h \
observer/IDataItemSubscription.h \
observer/IFrameworkActionReq.h \
observer/IOsObserver.h \
SystemStatusOsObserver.h \
SystemStatus.h
libloc_core_la_c_sources = \
LocApiBase.cpp \
LocAdapterBase.cpp \
ContextBase.cpp \
LocDualContext.cpp \
loc_core_log.cpp \
data-items/DataItemsFactoryProxy.cpp \
data-items/common/ClientIndex.cpp \
data-items/common/DataItemIndex.cpp \
data-items/common/IndexFactory.cpp \
SystemStatusOsObserver.cpp \
SystemStatus.cpp
library_includedir = $(pkgincludedir)/core
library_include_HEADERS = $(libloc_core_la_h_sources)
libloc_core_la_SOURCES = $(libloc_core_la_c_sources)
if USE_GLIB
libloc_core_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
libloc_core_la_LDFLAGS = -lstdc++ -Wl,-z,defs -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
libloc_core_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libloc_core_la_CFLAGS = $(AM_CFLAGS)
libloc_core_la_LDFLAGS = -Wl,-z,defs -lpthread -shared -version-info 1:0:0
libloc_core_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
libloc_core_la_LIBADD = -lstdc++ -ldl $(LOCPLA_LIBS) $(GPSUTILS_LIBS)
#Create and Install libraries
lib_LTLIBRARIES = libloc_core.la

1788
gps/core/SystemStatus.cpp Normal file

File diff suppressed because it is too large Load Diff

644
gps/core/SystemStatus.h Normal file
View File

@@ -0,0 +1,644 @@
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __SYSTEM_STATUS__
#define __SYSTEM_STATUS__
#include <stdint.h>
#include <string>
#include <vector>
#include <platform_lib_log_util.h>
#include <MsgTask.h>
#include <IDataItemCore.h>
#include <IOsObserver.h>
#include <SystemStatusOsObserver.h>
#include <gps_extended_c.h>
#define GPS_MIN (1) //1-32
#define SBAS_MIN (33)
#define GLO_MIN (65) //65-88
#define QZSS_MIN (193) //193-197
#define BDS_MIN (201) //201-237
#define GAL_MIN (301) //301-336
#define GPS_NUM (32)
#define SBAS_NUM (32)
#define GLO_NUM (24)
#define QZSS_NUM (5)
#define BDS_NUM (37)
#define GAL_NUM (36)
#define SV_ALL_NUM (GPS_NUM+GLO_NUM+QZSS_NUM+BDS_NUM+GAL_NUM) //=134
namespace loc_core
{
/******************************************************************************
SystemStatus report data structure
******************************************************************************/
class SystemStatusItemBase
{
public:
timespec mUtcTime; // UTC timestamp when this info was last updated
timespec mUtcReported; // UTC timestamp when this info was reported
SystemStatusItemBase() {
timeval tv;
gettimeofday(&tv, NULL);
mUtcTime.tv_sec = tv.tv_sec;
mUtcTime.tv_nsec = tv.tv_usec *1000ULL;
mUtcReported = mUtcTime;
};
virtual ~SystemStatusItemBase() { };
virtual void dump(void) { };
};
class SystemStatusLocation : public SystemStatusItemBase
{
public:
bool mValid;
UlpLocation mLocation;
GpsLocationExtended mLocationEx;
inline SystemStatusLocation() :
mValid(false) {}
inline SystemStatusLocation(const UlpLocation& location,
const GpsLocationExtended& locationEx) :
mValid(true),
mLocation(location),
mLocationEx(locationEx) { }
bool equals(SystemStatusLocation& peer);
void dump(void);
};
class SystemStatusPQWM1;
class SystemStatusTimeAndClock : public SystemStatusItemBase
{
public:
uint16_t mGpsWeek;
uint32_t mGpsTowMs;
uint8_t mTimeValid;
uint8_t mTimeSource;
int32_t mTimeUnc;
int32_t mClockFreqBias;
int32_t mClockFreqBiasUnc;
int32_t mLeapSeconds;
int32_t mLeapSecUnc;
inline SystemStatusTimeAndClock() :
mGpsWeek(0),
mGpsTowMs(0),
mTimeValid(0),
mTimeSource(0),
mTimeUnc(0),
mClockFreqBias(0),
mClockFreqBiasUnc(0),
mLeapSeconds(0),
mLeapSecUnc(0) {}
inline SystemStatusTimeAndClock(const SystemStatusPQWM1& nmea);
bool equals(SystemStatusTimeAndClock& peer);
void dump(void);
};
class SystemStatusXoState : public SystemStatusItemBase
{
public:
uint8_t mXoState;
inline SystemStatusXoState() :
mXoState(0) {}
inline SystemStatusXoState(const SystemStatusPQWM1& nmea);
bool equals(SystemStatusXoState& peer);
void dump(void);
};
class SystemStatusRfAndParams : public SystemStatusItemBase
{
public:
int32_t mPgaGain;
uint32_t mGpsBpAmpI;
uint32_t mGpsBpAmpQ;
uint32_t mAdcI;
uint32_t mAdcQ;
uint32_t mJammerGps;
uint32_t mJammerGlo;
uint32_t mJammerBds;
uint32_t mJammerGal;
double mAgcGps;
double mAgcGlo;
double mAgcBds;
double mAgcGal;
inline SystemStatusRfAndParams() :
mPgaGain(0),
mGpsBpAmpI(0),
mGpsBpAmpQ(0),
mAdcI(0),
mAdcQ(0),
mJammerGps(0),
mJammerGlo(0),
mJammerBds(0),
mJammerGal(0),
mAgcGps(0),
mAgcGlo(0),
mAgcBds(0),
mAgcGal(0) {}
inline SystemStatusRfAndParams(const SystemStatusPQWM1& nmea);
bool equals(SystemStatusRfAndParams& peer);
void dump(void);
};
class SystemStatusErrRecovery : public SystemStatusItemBase
{
public:
uint32_t mRecErrorRecovery;
inline SystemStatusErrRecovery() :
mRecErrorRecovery(0) {};
inline SystemStatusErrRecovery(const SystemStatusPQWM1& nmea);
bool equals(SystemStatusErrRecovery& peer);
void dump(void);
};
class SystemStatusPQWP1;
class SystemStatusInjectedPosition : public SystemStatusItemBase
{
public:
uint8_t mEpiValidity;
float mEpiLat;
float mEpiLon;
float mEpiAlt;
float mEpiHepe;
float mEpiAltUnc;
uint8_t mEpiSrc;
inline SystemStatusInjectedPosition() :
mEpiValidity(0),
mEpiLat(0),
mEpiLon(0),
mEpiAlt(0),
mEpiHepe(0),
mEpiAltUnc(0),
mEpiSrc(0) {}
inline SystemStatusInjectedPosition(const SystemStatusPQWP1& nmea);
bool equals(SystemStatusInjectedPosition& peer);
void dump(void);
};
class SystemStatusPQWP2;
class SystemStatusBestPosition : public SystemStatusItemBase
{
public:
bool mValid;
float mBestLat;
float mBestLon;
float mBestAlt;
float mBestHepe;
float mBestAltUnc;
inline SystemStatusBestPosition() :
mValid(false),
mBestLat(0),
mBestLon(0),
mBestAlt(0),
mBestHepe(0),
mBestAltUnc(0) {}
inline SystemStatusBestPosition(const SystemStatusPQWP2& nmea);
bool equals(SystemStatusBestPosition& peer);
void dump(void);
};
class SystemStatusPQWP3;
class SystemStatusXtra : public SystemStatusItemBase
{
public:
uint8_t mXtraValidMask;
uint32_t mGpsXtraAge;
uint32_t mGloXtraAge;
uint32_t mBdsXtraAge;
uint32_t mGalXtraAge;
uint32_t mQzssXtraAge;
uint32_t mGpsXtraValid;
uint32_t mGloXtraValid;
uint64_t mBdsXtraValid;
uint64_t mGalXtraValid;
uint8_t mQzssXtraValid;
inline SystemStatusXtra() :
mXtraValidMask(0),
mGpsXtraAge(0),
mGloXtraAge(0),
mBdsXtraAge(0),
mGalXtraAge(0),
mQzssXtraAge(0),
mGpsXtraValid(0),
mGloXtraValid(0),
mBdsXtraValid(0ULL),
mGalXtraValid(0ULL),
mQzssXtraValid(0) {}
inline SystemStatusXtra(const SystemStatusPQWP3& nmea);
bool equals(SystemStatusXtra& peer);
void dump(void);
};
class SystemStatusPQWP4;
class SystemStatusEphemeris : public SystemStatusItemBase
{
public:
uint32_t mGpsEpheValid;
uint32_t mGloEpheValid;
uint64_t mBdsEpheValid;
uint64_t mGalEpheValid;
uint8_t mQzssEpheValid;
inline SystemStatusEphemeris() :
mGpsEpheValid(0),
mGloEpheValid(0),
mBdsEpheValid(0ULL),
mGalEpheValid(0ULL),
mQzssEpheValid(0) {}
inline SystemStatusEphemeris(const SystemStatusPQWP4& nmea);
bool equals(SystemStatusEphemeris& peer);
void dump(void);
};
class SystemStatusPQWP5;
class SystemStatusSvHealth : public SystemStatusItemBase
{
public:
uint32_t mGpsUnknownMask;
uint32_t mGloUnknownMask;
uint64_t mBdsUnknownMask;
uint64_t mGalUnknownMask;
uint8_t mQzssUnknownMask;
uint32_t mGpsGoodMask;
uint32_t mGloGoodMask;
uint64_t mBdsGoodMask;
uint64_t mGalGoodMask;
uint8_t mQzssGoodMask;
uint32_t mGpsBadMask;
uint32_t mGloBadMask;
uint64_t mBdsBadMask;
uint64_t mGalBadMask;
uint8_t mQzssBadMask;
inline SystemStatusSvHealth() :
mGpsUnknownMask(0),
mGloUnknownMask(0),
mBdsUnknownMask(0ULL),
mGalUnknownMask(0ULL),
mQzssUnknownMask(0),
mGpsGoodMask(0),
mGloGoodMask(0),
mBdsGoodMask(0ULL),
mGalGoodMask(0ULL),
mQzssGoodMask(0),
mGpsBadMask(0),
mGloBadMask(0),
mBdsBadMask(0ULL),
mGalBadMask(0ULL),
mQzssBadMask(0) {}
inline SystemStatusSvHealth(const SystemStatusPQWP5& nmea);
bool equals(SystemStatusSvHealth& peer);
void dump(void);
};
class SystemStatusPQWP6;
class SystemStatusPdr : public SystemStatusItemBase
{
public:
uint32_t mFixInfoMask;
inline SystemStatusPdr() :
mFixInfoMask(0) {}
inline SystemStatusPdr(const SystemStatusPQWP6& nmea);
bool equals(SystemStatusPdr& peer);
void dump(void);
};
class SystemStatusPQWP7;
struct SystemStatusNav
{
GnssEphemerisType mType;
GnssEphemerisSource mSource;
int32_t mAgeSec;
};
class SystemStatusNavData : public SystemStatusItemBase
{
public:
SystemStatusNav mNav[SV_ALL_NUM];
inline SystemStatusNavData() {
for (uint32_t i=0; i<SV_ALL_NUM; i++) {
mNav[i].mType = GNSS_EPH_TYPE_UNKNOWN;
mNav[i].mSource = GNSS_EPH_SOURCE_UNKNOWN;
mNav[i].mAgeSec = 0;
}
}
inline SystemStatusNavData(const SystemStatusPQWP7& nmea);
bool equals(SystemStatusNavData& peer);
void dump(void);
};
class SystemStatusPQWS1;
class SystemStatusPositionFailure : public SystemStatusItemBase
{
public:
uint32_t mFixInfoMask;
uint32_t mHepeLimit;
inline SystemStatusPositionFailure() :
mFixInfoMask(0),
mHepeLimit(0) {}
inline SystemStatusPositionFailure(const SystemStatusPQWS1& nmea);
bool equals(SystemStatusPositionFailure& peer);
void dump(void);
};
/******************************************************************************
SystemStatus report data structure - from DataItem observer
******************************************************************************/
class SystemStatusGpsState : public SystemStatusItemBase, public IDataItemCore
{
public:
inline SystemStatusGpsState() :
mEnabled(false) {}
inline SystemStatusGpsState(bool enabled) :
mEnabled(enabled) {}
bool mEnabled;
inline bool equals(SystemStatusGpsState& peer) {
return (mEnabled == peer.mEnabled);
}
inline void dump(void) {
LOC_LOGD("GpsState: state=%u", mEnabled);
}
inline DataItemId getId() {
return GPSSTATE_DATA_ITEM_ID;
}
inline void stringify(string& valueStr) {
valueStr.clear();
valueStr += "GpsState: enabled=";
valueStr += to_string(mEnabled);
}
inline int32_t copy(IDataItemCore* src, bool* dataItemCopied = nullptr) {
SystemStatusGpsState* gpsstate = static_cast<SystemStatusGpsState*>(src);
mEnabled = gpsstate->mEnabled;
if (dataItemCopied) {
*dataItemCopied = true;
}
return 1;
}
};
class SystemStatusNetworkInfo : public SystemStatusItemBase, public IDataItemCore
{
public:
inline SystemStatusNetworkInfo() :
mType(0),
mTypeName(""),
mSubTypeName(""),
mAvailable(false),
mConnected(false),
mRoaming(false) {}
inline SystemStatusNetworkInfo(
uint32_t type,
std::string typeName,
std::string subTypeName,
bool available,
bool connected,
bool roaming) :
mType(type),
mTypeName(typeName),
mSubTypeName(subTypeName),
mAvailable(available),
mConnected(connected),
mRoaming(roaming) {}
uint32_t mType;
std::string mTypeName;
std::string mSubTypeName;
bool mAvailable;
bool mConnected;
bool mRoaming;
inline bool equals(SystemStatusNetworkInfo& peer) {
if ((mType != peer.mType) ||
(mTypeName != peer.mTypeName) ||
(mSubTypeName != peer.mSubTypeName) ||
(mAvailable != peer.mAvailable) ||
(mConnected != peer.mConnected) ||
(mRoaming != peer.mRoaming)) {
return false;
}
return true;
}
inline void dump(void) {
LOC_LOGD("NetworkInfo: type=%u connected=%u", mType, mConnected);
}
inline DataItemId getId() {
return NETWORKINFO_DATA_ITEM_ID;
}
inline void stringify(string& /*valueStr*/) { }
inline int32_t copy(IDataItemCore* src, bool* dataItemCopied = nullptr) {
SystemStatusNetworkInfo* networkinfo = static_cast<SystemStatusNetworkInfo*>(src);
mType = networkinfo->mType;
mTypeName = networkinfo->mTypeName;
mSubTypeName = networkinfo->mSubTypeName;
mAvailable = networkinfo->mAvailable;
mConnected = networkinfo->mConnected;
mRoaming = networkinfo->mRoaming;
if (dataItemCopied) {
*dataItemCopied = true;
}
return 1;
}
};
class SystemStatusTac : public SystemStatusItemBase, public IDataItemCore
{
public:
inline SystemStatusTac() :
mValue("") {}
inline SystemStatusTac(std::string value) :
mValue(value) {}
std::string mValue;
inline bool equals(SystemStatusTac& peer) {
return (mValue == peer.mValue);
}
inline void dump(void) {
LOC_LOGD("Tac: value=%s", mValue.c_str());
}
inline DataItemId getId() {
return TAC_DATA_ITEM_ID;
}
inline void stringify(string& /*valueStr*/) { }
inline int32_t copy(IDataItemCore* src, bool* dataItemCopied = nullptr) {
SystemStatusTac* tac = static_cast<SystemStatusTac*>(src);
mValue = tac->mValue;
if (dataItemCopied) {
*dataItemCopied = true;
}
return 1;
}
};
class SystemStatusMccMnc : public SystemStatusItemBase, public IDataItemCore
{
public:
inline SystemStatusMccMnc() :
mValue("") {}
inline SystemStatusMccMnc(std::string value) :
mValue(value) {}
std::string mValue;
inline bool equals(SystemStatusMccMnc& peer) {
return (mValue == peer.mValue);
}
inline void dump(void) {
LOC_LOGD("TacMccMnc value=%s", mValue.c_str());
}
inline DataItemId getId() {
return MCCMNC_DATA_ITEM_ID;
}
inline void stringify(string& /*valueStr*/) { }
inline int32_t copy(IDataItemCore* src, bool* dataItemCopied = nullptr) {
SystemStatusMccMnc* mccmnc = static_cast<SystemStatusMccMnc*>(src);
mValue = mccmnc->mValue;
if (dataItemCopied) {
*dataItemCopied = true;
}
return 1;
}
};
/******************************************************************************
SystemStatusReports
******************************************************************************/
class SystemStatusReports
{
public:
// from QMI_LOC indication
std::vector<SystemStatusLocation> mLocation;
// from ME debug NMEA
std::vector<SystemStatusTimeAndClock> mTimeAndClock;
std::vector<SystemStatusXoState> mXoState;
std::vector<SystemStatusRfAndParams> mRfAndParams;
std::vector<SystemStatusErrRecovery> mErrRecovery;
// from PE debug NMEA
std::vector<SystemStatusInjectedPosition> mInjectedPosition;
std::vector<SystemStatusBestPosition> mBestPosition;
std::vector<SystemStatusXtra> mXtra;
std::vector<SystemStatusEphemeris> mEphemeris;
std::vector<SystemStatusSvHealth> mSvHealth;
std::vector<SystemStatusPdr> mPdr;
std::vector<SystemStatusNavData> mNavData;
// from SM debug NMEA
std::vector<SystemStatusPositionFailure> mPositionFailure;
// from dataitems observer
std::vector<SystemStatusGpsState> mGpsState;
std::vector<SystemStatusNetworkInfo> mNetworkInfo;
std::vector<SystemStatusTac> mTac;
std::vector<SystemStatusMccMnc> mMccMnc;
};
/******************************************************************************
SystemStatus
******************************************************************************/
class SystemStatus
{
private:
static SystemStatus *mInstance;
SystemStatusOsObserver mSysStatusObsvr;
// ctor
SystemStatus(const MsgTask* msgTask);
// dtor
inline ~SystemStatus() {}
// Data members
static pthread_mutex_t mMutexSystemStatus;
static const uint32_t maxLocation = 5;
static const uint32_t maxTimeAndClock = 5;
static const uint32_t maxXoState = 5;
static const uint32_t maxRfAndParams = 5;
static const uint32_t maxErrRecovery = 5;
static const uint32_t maxInjectedPosition = 5;
static const uint32_t maxBestPosition = 5;
static const uint32_t maxXtra = 5;
static const uint32_t maxEphemeris = 5;
static const uint32_t maxSvHealth = 5;
static const uint32_t maxPdr = 5;
static const uint32_t maxNavData = 5;
static const uint32_t maxPositionFailure = 5;
static const uint32_t maxGpsState = 5;
static const uint32_t maxNetworkInfo = 5;
static const uint32_t maxTac = 5;
static const uint32_t maxMccMnc = 5;
SystemStatusReports mCache;
bool mConnected;
bool setLocation(const UlpLocation& location);
bool setTimeAndCLock(const SystemStatusPQWM1& nmea);
bool setXoState(const SystemStatusPQWM1& nmea);
bool setRfAndParams(const SystemStatusPQWM1& nmea);
bool setErrRecovery(const SystemStatusPQWM1& nmea);
bool setInjectedPosition(const SystemStatusPQWP1& nmea);
bool setBestPosition(const SystemStatusPQWP2& nmea);
bool setXtra(const SystemStatusPQWP3& nmea);
bool setEphemeris(const SystemStatusPQWP4& nmea);
bool setSvHealth(const SystemStatusPQWP5& nmea);
bool setPdr(const SystemStatusPQWP6& nmea);
bool setNavData(const SystemStatusPQWP7& nmea);
bool setPositionFailure(const SystemStatusPQWS1& nmea);
bool setNetworkInfo(IDataItemCore* dataitem);
public:
// Static methods
static SystemStatus* getInstance(const MsgTask* msgTask);
static void destroyInstance();
IOsObserver* getOsObserver();
// Helpers
bool eventPosition(const UlpLocation& location,const GpsLocationExtended& locationEx);
bool eventDataItemNotify(IDataItemCore* dataitem);
bool setNmeaString(const char *data, uint32_t len);
bool getReport(SystemStatusReports& reports, bool isLatestonly = false) const;
bool setDefaultReport(void);
bool eventConnectionStatus(bool connected, uint8_t type);
};
} // namespace loc_core
#endif //__SYSTEM_STATUS__

View File

@@ -0,0 +1,593 @@
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#define LOG_TAG "LocSvc_SystemStatusOsObserver"
#include <algorithm>
#include <SystemStatus.h>
#include <SystemStatusOsObserver.h>
#include <IDataItemCore.h>
#include <IClientIndex.h>
#include <IDataItemIndex.h>
#include <IndexFactory.h>
#include <DataItemsFactoryProxy.h>
namespace loc_core
{
SystemStatusOsObserver::SystemStatusOsObserver(const MsgTask* msgTask) :
mAddress("SystemStatusOsObserver"),
mClientIndex(IndexFactory<IDataItemObserver*, DataItemId> :: createClientIndex()),
mDataItemIndex(IndexFactory<IDataItemObserver*, DataItemId> :: createDataItemIndex())
{
mContext.mMsgTask = msgTask;
}
SystemStatusOsObserver::~SystemStatusOsObserver()
{
// Close data-item library handle
DataItemsFactoryProxy::closeDataItemLibraryHandle();
// Destroy cache
for (auto each : mDataItemCache) {
if (nullptr != each.second) {
delete each.second;
}
}
mDataItemCache.clear();
delete mClientIndex;
delete mDataItemIndex;
}
void SystemStatusOsObserver::setSubscriptionObj(IDataItemSubscription* subscriptionObj)
{
mContext.mSubscriptionObj = subscriptionObj;
LOC_LOGD("Request cache size - Subscribe:%zu RequestData:%zu",
mSubscribeReqCache.size(), mReqDataCache.size());
// we have received the subscription object. process cached requests
// process - subscribe request cache
for (auto each : mSubscribeReqCache) {
subscribe(each.second, each.first);
}
// process - requestData request cache
for (auto each : mReqDataCache) {
requestData(each.second, each.first);
}
}
// Helper to cache requests subscribe and requestData till subscription obj is obtained
void SystemStatusOsObserver::cacheObserverRequest(ObserverReqCache& reqCache,
const list<DataItemId>& l, IDataItemObserver* client)
{
ObserverReqCache::iterator dicIter = reqCache.find(client);
if (dicIter != reqCache.end()) {
// found
list<DataItemId> difference(0);
set_difference(l.begin(), l.end(),
dicIter->second.begin(), dicIter->second.end(),
inserter(difference, difference.begin()));
if (!difference.empty()) {
difference.sort();
dicIter->second.merge(difference);
dicIter->second.unique();
}
}
else {
// not found
reqCache[client] = l;
}
}
/******************************************************************************
IDataItemSubscription Overrides
******************************************************************************/
void SystemStatusOsObserver::subscribe(
const list<DataItemId>& l, IDataItemObserver* client)
{
if (nullptr == mContext.mSubscriptionObj) {
LOC_LOGD("%s]: Subscription object is NULL. Caching requests", __func__);
cacheObserverRequest(mSubscribeReqCache, l, client);
return;
}
struct HandleSubscribeReq : public LocMsg {
HandleSubscribeReq(SystemStatusOsObserver* parent,
const list<DataItemId>& l, IDataItemObserver* client) :
mParent(parent), mClient(client), mDataItemList(l) {}
virtual ~HandleSubscribeReq() {}
void proc() const {
if (mDataItemList.empty()) {
LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting");
return;
}
// Handle First Response
list<DataItemId> pendingFirstResponseList(0);
mParent->mClientIndex->add(mClient, mDataItemList, pendingFirstResponseList);
// Do not send first response for only pendingFirstResponseList,
// instead send for all the data items (present in the cache) that
// have been subscribed for each time.
mParent->sendFirstResponse(mDataItemList, mClient);
list<DataItemId> yetToSubscribeDataItemsList(0);
mParent->mDataItemIndex->add(mClient, mDataItemList, yetToSubscribeDataItemsList);
// Send subscription list to framework
if (!yetToSubscribeDataItemsList.empty()) {
mParent->mContext.mSubscriptionObj->subscribe(yetToSubscribeDataItemsList, mParent);
LOC_LOGD("Subscribe Request sent to framework for the following");
mParent->logMe(yetToSubscribeDataItemsList);
}
}
SystemStatusOsObserver* mParent;
IDataItemObserver* mClient;
const list<DataItemId> mDataItemList;
};
mContext.mMsgTask->sendMsg(new (nothrow) HandleSubscribeReq(this, l, client));
}
void SystemStatusOsObserver::updateSubscription(
const list<DataItemId>& l, IDataItemObserver* client)
{
if (nullptr == mContext.mSubscriptionObj) {
LOC_LOGE("%s:%d]: Subscription object is NULL", __func__, __LINE__);
return;
}
struct HandleUpdateSubscriptionReq : public LocMsg {
HandleUpdateSubscriptionReq(SystemStatusOsObserver* parent,
const list<DataItemId>& l, IDataItemObserver* client) :
mParent(parent), mClient(client), mDataItemList(l) {}
virtual ~HandleUpdateSubscriptionReq() {}
void proc() const {
if (mDataItemList.empty()) {
LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting");
return;
}
list<DataItemId> currentlySubscribedList(0);
mParent->mClientIndex->getSubscribedList(mClient, currentlySubscribedList);
list<DataItemId> removeDataItemList(0);
set_difference(currentlySubscribedList.begin(), currentlySubscribedList.end(),
mDataItemList.begin(), mDataItemList.end(),
inserter(removeDataItemList,removeDataItemList.begin()));
// Handle First Response
list<DataItemId> pendingFirstResponseList(0);
mParent->mClientIndex->add(mClient, mDataItemList, pendingFirstResponseList);
// Send First Response
mParent->sendFirstResponse(pendingFirstResponseList, mClient);
list<DataItemId> yetToSubscribeDataItemsList(0);
mParent->mDataItemIndex->add(
mClient, mDataItemList, yetToSubscribeDataItemsList);
// Send subscription list to framework
if (!yetToSubscribeDataItemsList.empty()) {
mParent->mContext.mSubscriptionObj->subscribe(
yetToSubscribeDataItemsList, mParent);
LOC_LOGD("Subscribe Request sent to framework for the following");
mParent->logMe(yetToSubscribeDataItemsList);
}
list<DataItemId> unsubscribeList(0);
list<DataItemId> unused(0);
mParent->mClientIndex->remove(mClient, removeDataItemList, unused);
if (!mParent->mClientIndex->isSubscribedClient(mClient)) {
mParent->mDataItemIndex->remove(
list<IDataItemObserver*> (1,mClient), unsubscribeList);
}
if (!unsubscribeList.empty()) {
// Send unsubscribe to framework
mParent->mContext.mSubscriptionObj->unsubscribe(unsubscribeList, mParent);
LOC_LOGD("Unsubscribe Request sent to framework for the following");
mParent->logMe(unsubscribeList);
}
}
SystemStatusOsObserver* mParent;
IDataItemObserver* mClient;
const list<DataItemId> mDataItemList;
};
mContext.mMsgTask->sendMsg(new (nothrow) HandleUpdateSubscriptionReq(this, l, client));
}
void SystemStatusOsObserver::requestData(
const list<DataItemId>& l, IDataItemObserver* client)
{
if (nullptr == mContext.mSubscriptionObj) {
LOC_LOGD("%s]: Subscription object is NULL. Caching requests", __func__);
cacheObserverRequest(mReqDataCache, l, client);
return;
}
struct HandleRequestData : public LocMsg {
HandleRequestData(SystemStatusOsObserver* parent,
const list<DataItemId>& l, IDataItemObserver* client) :
mParent(parent), mClient(client), mDataItemList(l) {}
virtual ~HandleRequestData() {}
void proc() const {
if (mDataItemList.empty()) {
LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting");
return;
}
list<DataItemId> yetToSubscribeDataItemsList(0);
mParent->mClientIndex->add(
mClient, mDataItemList, yetToSubscribeDataItemsList);
mParent->mDataItemIndex->add(
mClient, mDataItemList, yetToSubscribeDataItemsList);
// Send subscription list to framework
if (!mDataItemList.empty()) {
mParent->mContext.mSubscriptionObj->requestData(mDataItemList, mParent);
LOC_LOGD("Subscribe Request sent to framework for the following");
mParent->logMe(yetToSubscribeDataItemsList);
}
}
SystemStatusOsObserver* mParent;
IDataItemObserver* mClient;
const list<DataItemId> mDataItemList;
};
mContext.mMsgTask->sendMsg(new (nothrow) HandleRequestData(this, l, client));
}
void SystemStatusOsObserver::unsubscribe(
const list<DataItemId>& l, IDataItemObserver* client)
{
if (nullptr == mContext.mSubscriptionObj) {
LOC_LOGE("%s:%d]: Subscription object is NULL", __func__, __LINE__);
return;
}
struct HandleUnsubscribeReq : public LocMsg {
HandleUnsubscribeReq(SystemStatusOsObserver* parent,
const list<DataItemId>& l, IDataItemObserver* client) :
mParent(parent), mClient(client), mDataItemList(l) {}
virtual ~HandleUnsubscribeReq() {}
void proc() const {
if (mDataItemList.empty()) {
LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting");
return;
}
list<DataItemId> unsubscribeList(0);
list<DataItemId> unused(0);
mParent->mClientIndex->remove(mClient, mDataItemList, unused);
for (auto each : mDataItemList) {
list<IDataItemObserver*> clientListSubs(0);
list<IDataItemObserver*> clientListOut(0);
mParent->mDataItemIndex->remove(
each, list<IDataItemObserver*> (1,mClient), clientListOut);
// check if there are any other subscribed client for this data item id
mParent->mDataItemIndex->getListOfSubscribedClients(each, clientListSubs);
if (clientListSubs.empty())
{
LOC_LOGD("Client list subscribed is empty for dataitem - %d", each);
unsubscribeList.push_back(each);
}
}
if (!unsubscribeList.empty()) {
// Send unsubscribe to framework
mParent->mContext.mSubscriptionObj->unsubscribe(unsubscribeList, mParent);
LOC_LOGD("Unsubscribe Request sent to framework for the following data items");
mParent->logMe(unsubscribeList);
}
}
SystemStatusOsObserver* mParent;
IDataItemObserver* mClient;
const list<DataItemId> mDataItemList;
};
mContext.mMsgTask->sendMsg(new (nothrow) HandleUnsubscribeReq(this, l, client));
}
void SystemStatusOsObserver::unsubscribeAll(IDataItemObserver* client)
{
if (nullptr == mContext.mSubscriptionObj) {
LOC_LOGE("%s:%d]: Subscription object is NULL", __func__, __LINE__);
return;
}
struct HandleUnsubscribeAllReq : public LocMsg {
HandleUnsubscribeAllReq(SystemStatusOsObserver* parent,
IDataItemObserver* client) :
mParent(parent), mClient(client) {}
virtual ~HandleUnsubscribeAllReq() {}
void proc() const {
list<IDataItemObserver*> clients(1, mClient);
list<DataItemId> unsubscribeList(0);
if(0 == mParent->mClientIndex->remove(mClient)) {
return;
}
mParent->mDataItemIndex->remove(clients, unsubscribeList);
if (!unsubscribeList.empty()) {
// Send unsubscribe to framework
mParent->mContext.mSubscriptionObj->unsubscribe(unsubscribeList, mParent);
LOC_LOGD("Unsubscribe Request sent to framework for the following data items");
mParent->logMe(unsubscribeList);
}
}
SystemStatusOsObserver* mParent;
IDataItemObserver* mClient;
};
mContext.mMsgTask->sendMsg(new (nothrow) HandleUnsubscribeAllReq(this, client));
}
/******************************************************************************
IDataItemObserver Overrides
******************************************************************************/
void SystemStatusOsObserver::notify(const list<IDataItemCore*>& dlist)
{
list<IDataItemCore*> dataItemList(0);
for (auto each : dlist) {
string dv;
each->stringify(dv);
LOC_LOGD("notify: DataItem In Value:%s", dv.c_str());
IDataItemCore* di = DataItemsFactoryProxy::createNewDataItem(each->getId());
if (nullptr == di) {
LOC_LOGE("Unable to create dataitem:%d", each->getId());
return;
}
// Copy contents into the newly created data item
di->copy(each);
dataItemList.push_back(di);
// Request systemstatus to record this dataitem in its cache
SystemStatus* systemstatus = SystemStatus::getInstance(mContext.mMsgTask);
if(nullptr != systemstatus) {
systemstatus->eventDataItemNotify(di);
}
}
struct HandleNotify : public LocMsg {
HandleNotify(SystemStatusOsObserver* parent, const list<IDataItemCore*>& l) :
mParent(parent), mDList(l) {}
virtual ~HandleNotify() {
for (auto each : mDList) {
delete each;
}
}
void proc() const {
// Update Cache with received data items and prepare
// list of data items to be sent.
list<DataItemId> dataItemIdsToBeSent(0);
for (auto item : mDList) {
bool dataItemUpdated = false;
mParent->updateCache(item, dataItemUpdated);
if (dataItemUpdated) {
dataItemIdsToBeSent.push_back(item->getId());
}
}
// Send data item to all subscribed clients
list<IDataItemObserver*> clientList(0);
for (auto each : dataItemIdsToBeSent) {
list<IDataItemObserver*> clients(0);
mParent->mDataItemIndex->getListOfSubscribedClients(each, clients);
for (auto each_cient: clients) {
clientList.push_back(each_cient);
}
}
clientList.unique();
for (auto client : clientList) {
list<DataItemId> dataItemIdsSubscribedByThisClient(0);
list<DataItemId> dataItemIdsToBeSentForThisClient(0);
mParent->mClientIndex->getSubscribedList(
client, dataItemIdsSubscribedByThisClient);
dataItemIdsSubscribedByThisClient.sort();
dataItemIdsToBeSent.sort();
set_intersection(dataItemIdsToBeSent.begin(),
dataItemIdsToBeSent.end(),
dataItemIdsSubscribedByThisClient.begin(),
dataItemIdsSubscribedByThisClient.end(),
inserter(dataItemIdsToBeSentForThisClient,
dataItemIdsToBeSentForThisClient.begin()));
mParent->sendCachedDataItems(dataItemIdsToBeSentForThisClient, client);
dataItemIdsSubscribedByThisClient.clear();
dataItemIdsToBeSentForThisClient.clear();
}
}
SystemStatusOsObserver* mParent;
const list<IDataItemCore*> mDList;
};
mContext.mMsgTask->sendMsg(new (nothrow) HandleNotify(this, dataItemList));
}
/******************************************************************************
IFrameworkActionReq Overrides
******************************************************************************/
void SystemStatusOsObserver::turnOn(DataItemId dit, int timeOut)
{
if (nullptr == mContext.mFrameworkActionReqObj) {
LOC_LOGE("%s:%d]: Framework action request object is NULL", __func__, __LINE__);
return;
}
// Check if data item exists in mActiveRequestCount
map<DataItemId, int>::iterator citer = mActiveRequestCount.find(dit);
if (citer == mActiveRequestCount.end()) {
// Data item not found in map
// Add reference count as 1 and add dataitem to map
pair<DataItemId, int> cpair(dit, 1);
mActiveRequestCount.insert(cpair);
LOC_LOGD("Sending turnOn request");
// Send action turn on to framework
struct HandleTurnOnMsg : public LocMsg {
HandleTurnOnMsg(IFrameworkActionReq* framework,
DataItemId dit, int timeOut) :
mFrameworkActionReqObj(framework), mDataItemId(dit), mTimeOut(timeOut) {}
virtual ~HandleTurnOnMsg() {}
void proc() const {
mFrameworkActionReqObj->turnOn(mDataItemId, mTimeOut);
}
IFrameworkActionReq* mFrameworkActionReqObj;
DataItemId mDataItemId;
int mTimeOut;
};
mContext.mMsgTask->sendMsg(new (nothrow) HandleTurnOnMsg(this, dit, timeOut));
}
else {
// Found in map, update reference count
citer->second++;
LOC_LOGD("turnOn - Data item:%d Num_refs:%d", dit, citer->second);
}
}
void SystemStatusOsObserver::turnOff(DataItemId dit)
{
if (nullptr == mContext.mFrameworkActionReqObj) {
LOC_LOGE("%s:%d]: Framework action request object is NULL", __func__, __LINE__);
return;
}
// Check if data item exists in mActiveRequestCount
map<DataItemId, int>::iterator citer = mActiveRequestCount.find(dit);
if (citer != mActiveRequestCount.end()) {
// found
citer->second--;
LOC_LOGD("turnOff - Data item:%d Remaining:%d", dit, citer->second);
if(citer->second == 0) {
// if this was last reference, remove item from map and turn off module
mActiveRequestCount.erase(citer);
// Send action turn off to framework
struct HandleTurnOffMsg : public LocMsg {
HandleTurnOffMsg(IFrameworkActionReq* framework, DataItemId dit) :
mFrameworkActionReqObj(framework), mDataItemId(dit) {}
virtual ~HandleTurnOffMsg() {}
void proc() const {
mFrameworkActionReqObj->turnOff(mDataItemId);
}
IFrameworkActionReq* mFrameworkActionReqObj;
DataItemId mDataItemId;
};
mContext.mMsgTask->sendMsg(
new (nothrow) HandleTurnOffMsg(mContext.mFrameworkActionReqObj, dit));
}
}
}
/******************************************************************************
Helpers
******************************************************************************/
void SystemStatusOsObserver::sendFirstResponse(
const list<DataItemId>& l, IDataItemObserver* to)
{
if (l.empty()) {
LOC_LOGV("list is empty. Nothing to do. Exiting");
return;
}
string clientName;
to->getName(clientName);
list<IDataItemCore*> dataItems(0);
for (auto each : l) {
map<DataItemId, IDataItemCore*>::const_iterator citer = mDataItemCache.find(each);
if (citer != mDataItemCache.end()) {
string dv;
citer->second->stringify(dv);
LOC_LOGI("DataItem: %s >> %s", dv.c_str(), clientName.c_str());
dataItems.push_back(citer->second);
}
}
if (dataItems.empty()) {
LOC_LOGV("No items to notify. Nothing to do. Exiting");
return;
}
to->notify(dataItems);
}
void SystemStatusOsObserver::sendCachedDataItems(
const list<DataItemId>& l, IDataItemObserver* to)
{
string clientName;
to->getName(clientName);
list<IDataItemCore*> dataItems(0);
for (auto each : l) {
string dv;
IDataItemCore* di = mDataItemCache[each];
di->stringify(dv);
LOC_LOGI("DataItem: %s >> %s", dv.c_str(), clientName.c_str());
dataItems.push_back(di);
}
to->notify(dataItems);
}
void SystemStatusOsObserver::updateCache(IDataItemCore* d, bool& dataItemUpdated)
{
if (nullptr == d) {
return;
}
// Check if data item exists in cache
map<DataItemId, IDataItemCore*>::iterator citer =
mDataItemCache.find(d->getId());
if (citer == mDataItemCache.end()) {
// New data item; not found in cache
IDataItemCore* dataitem = DataItemsFactoryProxy::createNewDataItem(d->getId());
if (nullptr == dataitem) {
return;
}
// Copy the contents of the data item
dataitem->copy(d);
pair<DataItemId, IDataItemCore*> cpair(d->getId(), dataitem);
// Insert in mDataItemCache
mDataItemCache.insert(cpair);
dataItemUpdated = true;
}
else {
// Found in cache; Update cache if necessary
if(0 == citer->second->copy(d, &dataItemUpdated)) {
return;
}
}
if (dataItemUpdated) {
LOC_LOGV("DataItem:%d updated:%d", d->getId(), dataItemUpdated);
}
}
} // namespace loc_core

View File

@@ -0,0 +1,135 @@
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __SYSTEM_STATUS_OSOBSERVER__
#define __SYSTEM_STATUS_OSOBSERVER__
#include <cinttypes>
#include <string>
#include <list>
#include <map>
#include <new>
#include <vector>
#include <MsgTask.h>
#include <DataItemId.h>
#include <IOsObserver.h>
#include <platform_lib_log_util.h>
namespace loc_core
{
/******************************************************************************
SystemStatusOsObserver
******************************************************************************/
using namespace std;
// Forward Declarations
class IDataItemCore;
template<typename CT, typename DIT> class IClientIndex;
template<typename CT, typename DIT> class IDataItemIndex;
struct SystemContext {
IDataItemSubscription* mSubscriptionObj;
IFrameworkActionReq* mFrameworkActionReqObj;
const MsgTask* mMsgTask;
inline SystemContext() :
mSubscriptionObj(NULL),
mFrameworkActionReqObj(NULL),
mMsgTask(NULL) {}
};
typedef map<IDataItemObserver*, list<DataItemId>> ObserverReqCache;
// Clients wanting to get data from OS/Framework would need to
// subscribe with OSObserver using IDataItemSubscription interface.
// Such clients would need to implement IDataItemObserver interface
// to receive data when it becomes available.
class SystemStatusOsObserver : public IOsObserver {
public:
// ctor
SystemStatusOsObserver(const MsgTask* msgTask);
// dtor
~SystemStatusOsObserver();
// To set the subscription object
virtual void setSubscriptionObj(IDataItemSubscription* subscriptionObj);
// To set the framework action request object
inline void setFrameworkActionReqObj(IFrameworkActionReq* frameworkActionReqObj) {
mContext.mFrameworkActionReqObj = frameworkActionReqObj;
}
// IDataItemSubscription Overrides
virtual void subscribe(const list<DataItemId>& l, IDataItemObserver* client);
virtual void updateSubscription(const list<DataItemId>& l, IDataItemObserver* client);
virtual void requestData(const list<DataItemId>& l, IDataItemObserver* client);
virtual void unsubscribe(const list<DataItemId>& l, IDataItemObserver* client);
virtual void unsubscribeAll(IDataItemObserver* client);
// IDataItemObserver Overrides
virtual void notify(const list<IDataItemCore*>& dlist);
inline virtual void getName(string& name) {
name = mAddress;
}
// IFrameworkActionReq Overrides
virtual void turnOn(DataItemId dit, int timeOut = 0);
virtual void turnOff(DataItemId dit);
private:
SystemContext mContext;
const string mAddress;
IClientIndex<IDataItemObserver*, DataItemId>* mClientIndex;
IDataItemIndex<IDataItemObserver*, DataItemId>* mDataItemIndex;
map<DataItemId, IDataItemCore*> mDataItemCache;
map<DataItemId, int> mActiveRequestCount;
// Cache the subscribe and requestData till subscription obj is obtained
ObserverReqCache mSubscribeReqCache;
ObserverReqCache mReqDataCache;
void cacheObserverRequest(ObserverReqCache& reqCache,
const list<DataItemId>& l, IDataItemObserver* client);
// Helpers
void sendFirstResponse(const list<DataItemId>& l, IDataItemObserver* to);
void sendCachedDataItems(const list<DataItemId>& l, IDataItemObserver* to);
void updateCache(IDataItemCore* d, bool& dataItemUpdated);
inline void logMe(const list<DataItemId>& l) {
for (auto id : l) {
LOC_LOGD("DataItem %d", id);
}
}
};
} // namespace loc_core
#endif //__SYSTEM_STATUS__

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -30,9 +30,7 @@
#define ULP_PROXY_BASE_H
#include <gps_extended.h>
struct FlpExtLocation_s;
struct FlpExtBatchOptions;
#include <LocationAPI.h>
namespace loc_core {
@@ -54,24 +52,18 @@ public:
return false;
}
inline virtual bool reportPosition(UlpLocation &location,
GpsLocationExtended &locationExtended,
void* locationExt,
inline virtual bool reportPosition(const UlpLocation &location,
const GpsLocationExtended &locationExtended,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask) {
(void)location;
(void)locationExtended;
(void)locationExt;
(void)status;
(void)loc_technology_mask;
return false;
}
inline virtual bool reportSv(GnssSvStatus &svStatus,
GpsLocationExtended &locationExtended,
void* svExt) {
(void)svStatus;
(void)locationExtended;
(void)svExt;
inline virtual bool reportSv(const GnssSvNotification& svNotify) {
(void)svNotify;
return false;
}
inline virtual bool reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet) {
@@ -84,7 +76,7 @@ public:
(void)svPolynomial;
return false;
}
inline virtual bool reportStatus(GpsStatusValue status) {
inline virtual bool reportStatus(LocGpsStatusValue status) {
(void)status;
return false;
@@ -97,24 +89,34 @@ public:
(void)capabilities;
}
inline virtual bool reportBatchingSession(FlpExtBatchOptions &options,
bool active) {
(void)options;
(void)active;
inline virtual bool reportBatchingSession(const LocationOptions& options, bool active)
{
(void)options;
(void)active;
return false;
}
inline virtual bool reportPositions(const UlpLocation* ulpLocations,
const GpsLocationExtended* extendedLocations,
const uint32_t* techMasks,
const size_t count)
{
(void)ulpLocations;
(void)extendedLocations;
(void)techMasks;
(void)count;
return false;
}
inline virtual bool reportPositions(const struct FlpExtLocation_s* locations,
int32_t number_of_locations) {
(void)locations;
(void)number_of_locations;
return false;
}
inline virtual bool reportDeleteAidingData(GpsAidingData aidingData)
inline virtual bool reportDeleteAidingData(LocGpsAidingData aidingData)
{
(void)aidingData;
return false;
}
inline virtual bool reportNmea(const char* nmea, int length)
{
(void)nmea;
(void)length;
return false;
}
};
} // namespace loc_core

View File

@@ -0,0 +1,73 @@
/* Copyright (c) 2015-2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __DATAITEMID_H__
#define __DATAITEMID_H__
/**
* Enumeration of Data Item types
* When add/remove/update changes are made to Data Items, this file needs to be updated
* accordingly
*/
typedef enum e_DataItemId {
INVALID_DATA_ITEM_ID = -1,
// 0 - 4
AIRPLANEMODE_DATA_ITEM_ID,
ENH_DATA_ITEM_ID,
GPSSTATE_DATA_ITEM_ID,
NLPSTATUS_DATA_ITEM_ID,
WIFIHARDWARESTATE_DATA_ITEM_ID,
// 5 - 9
NETWORKINFO_DATA_ITEM_ID,
RILVERSION_DATA_ITEM_ID,
RILSERVICEINFO_DATA_ITEM_ID,
RILCELLINFO_DATA_ITEM_ID,
SERVICESTATUS_DATA_ITEM_ID,
// 10 - 14
MODEL_DATA_ITEM_ID,
MANUFACTURER_DATA_ITEM_ID,
VOICECALL_DATA_ITEM,
ASSISTED_GPS_DATA_ITEM_ID,
SCREEN_STATE_DATA_ITEM_ID,
// 15 - 19
POWER_CONNECTED_STATE_DATA_ITEM_ID,
TIMEZONE_CHANGE_DATA_ITEM_ID,
TIME_CHANGE_DATA_ITEM_ID,
WIFI_SUPPLICANT_STATUS_DATA_ITEM_ID,
SHUTDOWN_STATE_DATA_ITEM_ID,
// 20 - 24
TAC_DATA_ITEM_ID,
MCCMNC_DATA_ITEM_ID,
BTLE_SCAN_DATA_ITEM_ID,
BT_SCAN_DATA_ITEM_ID,
OEM_GTP_UPLOAD_TRIGGER_READY_ITEM_ID,
MAX_DATA_ITEM_ID
} DataItemId;
#endif // #ifndef __DATAITEMID_H__

View File

@@ -0,0 +1,99 @@
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#define LOG_TAG "DataItemsFactoryProxy"
#include <dlfcn.h>
#include <DataItemId.h>
#include <IDataItemCore.h>
#include <DataItemsFactoryProxy.h>
#include <platform_lib_log_util.h>
namespace loc_core
{
void* DataItemsFactoryProxy::dataItemLibHandle = NULL;
get_concrete_data_item_fn* DataItemsFactoryProxy::getConcreteDIFunc = NULL;
IDataItemCore* DataItemsFactoryProxy::createNewDataItem(DataItemId id)
{
IDataItemCore *mydi = nullptr;
if (NULL != getConcreteDIFunc) {
mydi = (*getConcreteDIFunc)(id);
}
else {
// first call to this function, symbol not yet loaded
if (NULL == dataItemLibHandle) {
LOC_LOGD("Loaded library %s",DATA_ITEMS_LIB_NAME);
dataItemLibHandle = dlopen(DATA_ITEMS_LIB_NAME, RTLD_NOW);
if (NULL == dataItemLibHandle) {
// dlopen failed.
const char * err = dlerror();
if (NULL == err)
{
err = "Unknown";
}
LOC_LOGE("%s:%d]: failed to load library %s; error=%s",
__func__, __LINE__, DATA_ITEMS_LIB_NAME, err);
}
}
// load sym - if dlopen handle is obtained and symbol is not yet obtained
if (NULL != dataItemLibHandle) {
getConcreteDIFunc = (get_concrete_data_item_fn * )
dlsym(dataItemLibHandle, DATA_ITEMS_GET_CONCRETE_DI);
if (NULL != getConcreteDIFunc) {
LOC_LOGD("Loaded function %s : %x",DATA_ITEMS_GET_CONCRETE_DI,getConcreteDIFunc);
mydi = (*getConcreteDIFunc)(id);
}
else {
// dlysm failed.
const char * err = dlerror();
if (NULL == err)
{
err = "Unknown";
}
LOC_LOGE("%s:%d]: failed to find symbol %s; error=%s",
__func__, __LINE__, DATA_ITEMS_GET_CONCRETE_DI, err);
}
}
}
return mydi;
}
void DataItemsFactoryProxy::closeDataItemLibraryHandle()
{
if (NULL != dataItemLibHandle) {
dlclose(dataItemLibHandle);
dataItemLibHandle = NULL;
}
}
} // namespace loc_core

View File

@@ -0,0 +1,55 @@
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __DATAITEMFACTORYBASE__
#define __DATAITEMFACTORYBASE__
#include <DataItemId.h>
#include <IDataItemCore.h>
namespace loc_core
{
#define DATA_ITEMS_LIB_NAME "libdataitems.so"
#define DATA_ITEMS_GET_CONCRETE_DI "getConcreteDataItem"
typedef IDataItemCore * (get_concrete_data_item_fn)(DataItemId);
class DataItemsFactoryProxy {
public:
static IDataItemCore* createNewDataItem(DataItemId id);
static void closeDataItemLibraryHandle();
static void *dataItemLibHandle;
static get_concrete_data_item_fn *getConcreteDIFunc;
};
} // namespace loc_core
#endif //__DATAITEMFACTORYBASE__

View File

@@ -0,0 +1,82 @@
/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __IDATAITEMCORE_H__
#define __IDATAITEMCORE_H__
#include <string>
#include <DataItemId.h>
namespace loc_core {
using namespace std;
/**
* @brief IDataItemCore interface.
* @details IDataItemCore interface.
*
*/
class IDataItemCore {
public:
/**
* @brief Gets Data item id.
* @details Gets Data item id.
* @return Data item id.
*/
virtual DataItemId getId () = 0;
/**
* @brief Stringify.
* @details Stringify.
*
* @param valueStr Reference to string.
*/
virtual void stringify (string & valueStr) = 0;
/**
* @brief copy.
* @details copy.
*
* @param src Where to copy from.
* @param dataItemCopied Boolean flag indicated whether or not copied.
*
* @return Zero for success or non zero for failure.
*/
virtual int32_t copy (IDataItemCore * src, bool *dataItemCopied = nullptr) = 0;
/**
* @brief Destructor.
* @details Destructor.
*/
virtual ~IDataItemCore () {}
};
} // namespace loc_core
#endif // __IDATAITEMCORE_H__

View File

@@ -0,0 +1,171 @@
/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <algorithm>
#include <iterator>
#include <string>
#include <platform_lib_log_util.h>
#include <ClientIndex.h>
#include <IDataItemObserver.h>
#include <DataItemId.h>
using namespace std;
using namespace loc_core;
template <typename CT, typename DIT>
inline ClientIndex <CT,DIT> :: ClientIndex () {}
template <typename CT, typename DIT>
inline ClientIndex <CT,DIT> :: ~ClientIndex () {}
template <typename CT, typename DIT>
bool ClientIndex <CT,DIT> :: isSubscribedClient (CT client) {
bool result = false;
ENTRY_LOG ();
typename map < CT, list <DIT> > :: iterator it =
mDataItemsPerClientMap.find (client);
if (it != mDataItemsPerClientMap.end ()) {
result = true;
}
EXIT_LOG_WITH_ERROR ("%d",result);
return result;
}
template <typename CT, typename DIT>
void ClientIndex <CT,DIT> :: getSubscribedList (CT client, list <DIT> & out) {
ENTRY_LOG ();
typename map < CT, list <DIT> > :: iterator it =
mDataItemsPerClientMap.find (client);
if (it != mDataItemsPerClientMap.end ()) {
out = it->second;
}
EXIT_LOG_WITH_ERROR ("%d",0);
}
template <typename CT, typename DIT>
int ClientIndex <CT,DIT> :: remove (CT client) {
int result = 0;
ENTRY_LOG ();
mDataItemsPerClientMap.erase (client);
EXIT_LOG_WITH_ERROR ("%d",result);
return result;
}
template <typename CT, typename DIT>
void ClientIndex <CT,DIT> :: remove (const list <DIT> & r, list <CT> & out) {
ENTRY_LOG ();
typename map < CT, list <DIT> > :: iterator dicIter =
mDataItemsPerClientMap.begin ();
while (dicIter != mDataItemsPerClientMap.end()) {
typename list <DIT> :: const_iterator it = r.begin ();
for (; it != r.end (); ++it) {
typename list <DIT> :: iterator iter =
find (dicIter->second.begin (), dicIter->second.end (), *it);
if (iter != dicIter->second.end ()) {
dicIter->second.erase (iter);
}
}
if (dicIter->second.empty ()) {
out.push_back (dicIter->first);
// Post-increment operator increases the iterator but returns the
// prevous one that will be invalidated by erase()
mDataItemsPerClientMap.erase (dicIter++);
} else {
++dicIter;
}
}
EXIT_LOG_WITH_ERROR ("%d",0);
}
template <typename CT, typename DIT>
void ClientIndex <CT,DIT> :: remove
(
CT client,
const list <DIT> & r,
list <DIT> & out
)
{
ENTRY_LOG ();
typename map < CT, list <DIT> > :: iterator dicIter =
mDataItemsPerClientMap.find (client);
if (dicIter != mDataItemsPerClientMap.end ()) {
set_intersection (dicIter->second.begin (), dicIter->second.end (),
r.begin (), r.end (),
inserter (out,out.begin ()));
if (!out.empty ()) {
typename list <DIT> :: iterator it = out.begin ();
for (; it != out.end (); ++it) {
dicIter->second.erase (find (dicIter->second.begin (),
dicIter->second.end (),
*it));
}
}
if (dicIter->second.empty ()) {
mDataItemsPerClientMap.erase (dicIter);
EXIT_LOG_WITH_ERROR ("%d",0);
}
}
EXIT_LOG_WITH_ERROR ("%d",0);
}
template <typename CT, typename DIT>
void ClientIndex <CT,DIT> :: add
(
CT client,
const list <DIT> & l,
list <DIT> & out
)
{
ENTRY_LOG ();
list <DIT> difference;
typename map < CT, list <DIT> > :: iterator dicIter =
mDataItemsPerClientMap.find (client);
if (dicIter != mDataItemsPerClientMap.end ()) {
set_difference (l.begin (), l.end (),
dicIter->second.begin (), dicIter->second.end (),
inserter (difference,difference.begin ()));
if (!difference.empty ()) {
difference.sort ();
out = difference;
dicIter->second.merge (difference);
dicIter->second.unique ();
}
} else {
out = l;
pair < CT, list <DIT> > dicnpair (client, out);
mDataItemsPerClientMap.insert (dicnpair);
}
EXIT_LOG_WITH_ERROR ("%d",0);
}
// Explicit instantiation must occur in same namespace where class is defined
namespace loc_core
{
template class ClientIndex <IDataItemObserver *, DataItemId>;
template class ClientIndex <string, DataItemId>;
}

View File

@@ -0,0 +1,70 @@
/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __CLIENTINDEX_H__
#define __CLIENTINDEX_H__
#include <list>
#include <map>
#include <IClientIndex.h>
using loc_core::IClientIndex;
namespace loc_core
{
template <typename CT, typename DIT>
class ClientIndex : public IClientIndex <CT, DIT> {
public:
ClientIndex ();
~ClientIndex ();
bool isSubscribedClient (CT client);
void getSubscribedList (CT client, std :: list <DIT> & out);
int remove (CT client);
void remove (const std :: list <DIT> & r, std :: list <CT> & out);
void remove (CT client, const std :: list <DIT> & r, std :: list <DIT> & out);
void add (CT client, const std :: list <DIT> & l, std :: list <DIT> & out);
private:
//Data members
std :: map < CT , std :: list <DIT> > mDataItemsPerClientMap;
};
} // namespace loc_core
#endif // #ifndef __CLIENTINDEX_H__

View File

@@ -0,0 +1,202 @@
/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <string>
#include <algorithm>
#include <iterator>
#include <DataItemIndex.h>
#include <platform_lib_log_util.h>
#include <IDataItemObserver.h>
#include <DataItemId.h>
using namespace std;
using namespace loc_core;
template <typename CT, typename DIT>
inline DataItemIndex <CT,DIT> :: DataItemIndex () {}
template <typename CT, typename DIT>
inline DataItemIndex <CT,DIT> :: ~DataItemIndex () {}
template <typename CT, typename DIT>
void DataItemIndex <CT,DIT> :: getListOfSubscribedClients
(
DIT id,
list <CT> & out
)
{
typename map < DIT, list <CT> > :: iterator cdiIter =
mClientsPerDataItemMap.find (id);
if (cdiIter != mClientsPerDataItemMap.end ()) {
out = cdiIter->second;
}
}
template <typename CT, typename DIT>
int DataItemIndex <CT,DIT> :: remove (DIT id) {
int result = 0;
ENTRY_LOG ();
mClientsPerDataItemMap.erase (id);
EXIT_LOG_WITH_ERROR ("%d",result);
return result;
}
template <typename CT, typename DIT>
void DataItemIndex <CT,DIT> :: remove (const list <CT> & r, list <DIT> & out) {
ENTRY_LOG ();
typename map < DIT, list <CT> > :: iterator cdiIter =
mClientsPerDataItemMap.begin ();
while (cdiIter != mClientsPerDataItemMap.end()) {
typename list <CT> :: const_iterator it = r.begin ();
for (; it != r.end (); ++it) {
typename list <CT> :: iterator iter =
find
(
cdiIter->second.begin (),
cdiIter->second.end (),
*it
);
if (iter != cdiIter->second.end ()) {
cdiIter->second.erase (iter);
}
}
if (cdiIter->second.empty ()) {
out.push_back (cdiIter->first);
// Post-increment operator increases the iterator but returns the
// prevous one that will be invalidated by erase()
mClientsPerDataItemMap.erase (cdiIter++);
} else {
++cdiIter;
}
}
EXIT_LOG_WITH_ERROR ("%d",0);
}
template <typename CT, typename DIT>
void DataItemIndex <CT,DIT> :: remove
(
DIT id,
const list <CT> & r,
list <CT> & out
)
{
ENTRY_LOG ();
typename map < DIT, list <CT> > :: iterator cdiIter =
mClientsPerDataItemMap.find (id);
if (cdiIter != mClientsPerDataItemMap.end ()) {
set_intersection (cdiIter->second.begin (), cdiIter->second.end (),
r.begin (), r.end (),
inserter (out, out.begin ()));
if (!out.empty ()) {
typename list <CT> :: iterator it = out.begin ();
for (; it != out.end (); ++it) {
cdiIter->second.erase (find (cdiIter->second.begin (),
cdiIter->second.end (),
*it));
}
}
if (cdiIter->second.empty ()) {
mClientsPerDataItemMap.erase (cdiIter);
EXIT_LOG_WITH_ERROR ("%d",0);
}
}
EXIT_LOG_WITH_ERROR ("%d",0);
}
template <typename CT, typename DIT>
void DataItemIndex <CT,DIT> :: add
(
DIT id,
const list <CT> & l,
list <CT> & out
)
{
ENTRY_LOG ();
list <CT> difference;
typename map < DIT, list <CT> > :: iterator cdiIter =
mClientsPerDataItemMap.find (id);
if (cdiIter != mClientsPerDataItemMap.end ()) {
set_difference (l.begin (), l.end (),
cdiIter->second.begin (), cdiIter->second.end (),
inserter (difference, difference.begin ()));
if (!difference.empty ()) {
difference.sort ();
out = difference;
cdiIter->second.merge (difference);
}
} else {
out = l;
pair < DIT, list <CT> > cndipair (id, out);
mClientsPerDataItemMap.insert (cndipair);
}
EXIT_LOG_WITH_ERROR ("%d",0);
}
template <typename CT, typename DIT>
void DataItemIndex <CT,DIT> :: add
(
CT client,
const list <DIT> & l,
list <DIT> & out
)
{
ENTRY_LOG ();
typename map < DIT, list <CT> > :: iterator cdiIter;
typename list <DIT> :: const_iterator it = l.begin ();
for (; it != l.end (); ++it) {
cdiIter = mClientsPerDataItemMap.find (*it);
if (cdiIter == mClientsPerDataItemMap.end ()) {
out.push_back (*it);
pair < DIT, list <CT> > cndiPair (*it, list <CT> (1, client));
mClientsPerDataItemMap.insert (cndiPair);
} else {
typename list<CT> :: iterator clientIter =
find
(
cdiIter->second.begin (),
cdiIter->second.end (),
client
);
if (clientIter == cdiIter->second.end()) {
cdiIter->second.push_back (client);
}
}
}
EXIT_LOG_WITH_ERROR ("%d",0);
}
// Explicit instantiation must occur in same namespace where class is defined
namespace loc_core
{
template class DataItemIndex <IDataItemObserver *, DataItemId>;
template class DataItemIndex <string, DataItemId>;
}

View File

@@ -0,0 +1,70 @@
/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __DATAITEMINDEX_H__
#define __DATAITEMINDEX_H__
#include <list>
#include <map>
#include <IDataItemIndex.h>
using loc_core::IDataItemIndex;
namespace loc_core
{
template <typename CT, typename DIT>
class DataItemIndex : public IDataItemIndex <CT, DIT> {
public:
DataItemIndex ();
~DataItemIndex ();
void getListOfSubscribedClients (DIT id, std :: list <CT> & out);
int remove (DIT id);
void remove (const std :: list <CT> & r, std :: list <DIT> & out);
void remove (DIT id, const std :: list <CT> & r, std :: list <CT> & out);
void add (DIT id, const std :: list <CT> & l, std :: list <CT> & out);
void add (CT client, const std :: list <DIT> & l, std :: list <DIT> & out);
private:
std :: map < DIT, std :: list <CT> > mClientsPerDataItemMap;
};
} // namespace loc_core
#endif // #ifndef __DATAITEMINDEX_H__

View File

@@ -0,0 +1,83 @@
/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __ICLIENTINDEX_H__
#define __ICLIENTINDEX_H__
#include <list>
namespace loc_core
{
template <typename CT, typename DIT>
class IClientIndex {
public:
// Checks if client is subscribed
virtual bool isSubscribedClient (CT client) = 0;
// gets subscription list
virtual void getSubscribedList (CT client, std :: list <DIT> & out) = 0;
// removes an entry
virtual int remove (CT client) = 0;
// removes std :: list of data items and returns a list of clients
// removed if any.
virtual void remove
(
const std :: list <DIT> & r,
std :: list <CT> & out
) = 0;
// removes list of data items indexed by client and returns list
// of data items removed if any.
virtual void remove
(
CT client,
const std :: list <DIT> & r,
std :: list <DIT> & out
) = 0;
// adds/modifies entry in map and returns new data items added.
virtual void add
(
CT client,
const std :: list <DIT> & l,
std :: list <DIT> & out
) = 0;
// dtor
virtual ~IClientIndex () {}
};
} // namespace loc_core
#endif // #ifndef __ICLIENTINDEX_H__

View File

@@ -0,0 +1,94 @@
/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __IDATAITEMINDEX_H__
#define __IDATAITEMINDEX_H__
#include <list>
namespace loc_core
{
template <typename CT, typename DIT>
class IDataItemIndex {
public:
// gets std :: list of subscribed clients
virtual void getListOfSubscribedClients
(
DIT id,
std :: list <CT> & out
) = 0;
// removes an entry from
virtual int remove (DIT id) = 0;
// removes list of clients and returns a list of data items
// removed if any.
virtual void remove
(
const std :: list <CT> & r,
std :: list <DIT> & out
) = 0;
// removes list of clients indexed by data item and returns list of
// clients removed if any.
virtual void remove
(
DIT id,
const std :: list <CT> & r,
std :: list <CT> & out
) = 0;
// adds/modifies entry and returns new clients added
virtual void add
(
DIT id,
const std :: list <CT> & l,
std :: list <CT> & out
) = 0;
// adds/modifies entry and returns yet to subscribe list of data items
virtual void add
(
CT client,
const std :: list <DIT> & l,
std :: list <DIT> & out
) = 0;
// dtor
virtual ~IDataItemIndex () {}
};
} // namespace loc_core
#endif // #ifndef __IDATAITEMINDEX_H__

View File

@@ -0,0 +1,64 @@
/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <string>
#include <IndexFactory.h>
#include <IClientIndex.h>
#include <ClientIndex.h>
#include <IDataItemIndex.h>
#include <DataItemIndex.h>
#include <IDataItemObserver.h>
#include <DataItemId.h>
using namespace std;
using loc_core::IClientIndex;
using loc_core::IDataItemIndex;
using loc_core::IDataItemObserver;
using namespace loc_core;
template <typename CT, typename DIT>
inline IClientIndex <CT, DIT> * IndexFactory <CT, DIT> :: createClientIndex
()
{
return new (nothrow) ClientIndex <CT, DIT> ();
}
template <typename CT, typename DIT>
inline IDataItemIndex <CT, DIT> * IndexFactory <CT, DIT> :: createDataItemIndex
()
{
return new (nothrow) DataItemIndex <CT, DIT> ();
}
// Explicit instantiation must occur in same namespace where class is defined
namespace loc_core
{
template class IndexFactory <IDataItemObserver *, DataItemId>;
template class IndexFactory <string, DataItemId>;
}

View File

@@ -0,0 +1,48 @@
/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __INDEXFACTORY_H__
#define __INDEXFACTORY_H__
#include <IClientIndex.h>
#include <IDataItemIndex.h>
namespace loc_core
{
template <typename CT, typename DIT>
class IndexFactory {
public:
static IClientIndex <CT, DIT> * createClientIndex ();
static IDataItemIndex <CT, DIT> * createDataItemIndex ();
};
} // namespace loc_core
#endif // #ifndef __INDEXFACTORY_H__

View File

@@ -1,104 +0,0 @@
/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef GPS_EXTENDED_H
#define GPS_EXTENDED_H
#include <gps_extended_c.h>
/**
* @file
* @brief C++ declarations for GPS types
*/
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#if defined(USE_GLIB) || defined(OFF_TARGET)
#include <string.h>
#endif
struct LocPosMode
{
LocPositionMode mode;
GpsPositionRecurrence recurrence;
uint32_t min_interval;
uint32_t preferred_accuracy;
uint32_t preferred_time;
bool share_position;
char credentials[14];
char provider[8];
LocPosMode(LocPositionMode m, GpsPositionRecurrence recr,
uint32_t gap, uint32_t accu, uint32_t time,
bool sp, const char* cred, const char* prov) :
mode(m), recurrence(recr),
min_interval(gap < GPS_MIN_POSSIBLE_FIX_INTERVAL_MS ?
GPS_MIN_POSSIBLE_FIX_INTERVAL_MS : gap),
preferred_accuracy(accu), preferred_time(time),
share_position(sp) {
memset(credentials, 0, sizeof(credentials));
memset(provider, 0, sizeof(provider));
if (NULL != cred) {
memcpy(credentials, cred, sizeof(credentials)-1);
}
if (NULL != prov) {
memcpy(provider, prov, sizeof(provider)-1);
}
}
inline LocPosMode() :
mode(LOC_POSITION_MODE_MS_BASED),
recurrence(GPS_POSITION_RECURRENCE_PERIODIC),
min_interval(GPS_DEFAULT_FIX_INTERVAL_MS),
preferred_accuracy(50), preferred_time(120000),
share_position(true) {
memset(credentials, 0, sizeof(credentials));
memset(provider, 0, sizeof(provider));
}
inline bool equals(const LocPosMode &anotherMode) const
{
return anotherMode.mode == mode &&
anotherMode.recurrence == recurrence &&
anotherMode.min_interval == min_interval &&
anotherMode.preferred_accuracy == preferred_accuracy &&
anotherMode.preferred_time == preferred_time &&
!strncmp(anotherMode.credentials, credentials, sizeof(credentials)-1) &&
!strncmp(anotherMode.provider, provider, sizeof(provider)-1);
}
void logv() const;
};
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* GPS_EXTENDED_H */

File diff suppressed because it is too large Load Diff

View File

@@ -27,7 +27,7 @@
*
*/
#define LOG_NDDEBUG 0
#define LOG_NDEBUG 0
#define LOG_TAG "LocSvc_core_log"
#include <loc_log.h>
@@ -51,16 +51,16 @@ void LocPosMode::logv() const
/* GPS status names */
static const loc_name_val_s_type gps_status_name[] =
{
NAME_VAL( GPS_STATUS_NONE ),
NAME_VAL( GPS_STATUS_SESSION_BEGIN ),
NAME_VAL( GPS_STATUS_SESSION_END ),
NAME_VAL( GPS_STATUS_ENGINE_ON ),
NAME_VAL( GPS_STATUS_ENGINE_OFF ),
NAME_VAL( LOC_GPS_STATUS_NONE ),
NAME_VAL( LOC_GPS_STATUS_SESSION_BEGIN ),
NAME_VAL( LOC_GPS_STATUS_SESSION_END ),
NAME_VAL( LOC_GPS_STATUS_ENGINE_ON ),
NAME_VAL( LOC_GPS_STATUS_ENGINE_OFF ),
};
static const int gps_status_num = sizeof(gps_status_name) / sizeof(loc_name_val_s_type);
/* Find Android GPS status name */
const char* loc_get_gps_status_name(GpsStatusValue gps_status)
const char* loc_get_gps_status_name(LocGpsStatusValue gps_status)
{
return loc_get_name_from_val(gps_status_name, gps_status_num,
(long) gps_status);
@@ -81,7 +81,7 @@ static const loc_name_val_s_type loc_eng_position_modes[] =
};
static const int loc_eng_position_mode_num = sizeof(loc_eng_position_modes) / sizeof(loc_name_val_s_type);
const char* loc_get_position_mode_name(GpsPositionMode mode)
const char* loc_get_position_mode_name(LocGpsPositionMode mode)
{
return loc_get_name_from_val(loc_eng_position_modes, loc_eng_position_mode_num, (long) mode);
}
@@ -90,12 +90,12 @@ const char* loc_get_position_mode_name(GpsPositionMode mode)
static const loc_name_val_s_type loc_eng_position_recurrences[] =
{
NAME_VAL( GPS_POSITION_RECURRENCE_PERIODIC ),
NAME_VAL( GPS_POSITION_RECURRENCE_SINGLE )
NAME_VAL( LOC_GPS_POSITION_RECURRENCE_PERIODIC ),
NAME_VAL( LOC_GPS_POSITION_RECURRENCE_SINGLE )
};
static const int loc_eng_position_recurrence_num = sizeof(loc_eng_position_recurrences) / sizeof(loc_name_val_s_type);
const char* loc_get_position_recurrence_name(GpsPositionRecurrence recur)
const char* loc_get_position_recurrence_name(LocGpsPositionRecurrence recur)
{
return loc_get_name_from_val(loc_eng_position_recurrences, loc_eng_position_recurrence_num, (long) recur);
}
@@ -104,23 +104,23 @@ const char* loc_get_position_recurrence_name(GpsPositionRecurrence recur)
static const loc_name_val_s_type loc_eng_aiding_data_bits[] =
{
NAME_VAL( GPS_DELETE_EPHEMERIS ),
NAME_VAL( GPS_DELETE_ALMANAC ),
NAME_VAL( GPS_DELETE_POSITION ),
NAME_VAL( GPS_DELETE_TIME ),
NAME_VAL( GPS_DELETE_IONO ),
NAME_VAL( GPS_DELETE_UTC ),
NAME_VAL( GPS_DELETE_HEALTH ),
NAME_VAL( GPS_DELETE_SVDIR ),
NAME_VAL( GPS_DELETE_SVSTEER ),
NAME_VAL( GPS_DELETE_SADATA ),
NAME_VAL( GPS_DELETE_RTI ),
NAME_VAL( GPS_DELETE_CELLDB_INFO ),
NAME_VAL( GPS_DELETE_ALL)
NAME_VAL( LOC_GPS_DELETE_EPHEMERIS ),
NAME_VAL( LOC_GPS_DELETE_ALMANAC ),
NAME_VAL( LOC_GPS_DELETE_POSITION ),
NAME_VAL( LOC_GPS_DELETE_TIME ),
NAME_VAL( LOC_GPS_DELETE_IONO ),
NAME_VAL( LOC_GPS_DELETE_UTC ),
NAME_VAL( LOC_GPS_DELETE_HEALTH ),
NAME_VAL( LOC_GPS_DELETE_SVDIR ),
NAME_VAL( LOC_GPS_DELETE_SVSTEER ),
NAME_VAL( LOC_GPS_DELETE_SADATA ),
NAME_VAL( LOC_GPS_DELETE_RTI ),
NAME_VAL( LOC_GPS_DELETE_CELLDB_INFO ),
NAME_VAL( LOC_GPS_DELETE_ALL)
};
static const int loc_eng_aiding_data_bit_num = sizeof(loc_eng_aiding_data_bits) / sizeof(loc_name_val_s_type);
const char* loc_get_aiding_data_mask_names(GpsAidingData data)
const char* loc_get_aiding_data_mask_names(LocGpsAidingData /*data*/)
{
return NULL;
}
@@ -128,15 +128,15 @@ const char* loc_get_aiding_data_mask_names(GpsAidingData data)
static const loc_name_val_s_type loc_eng_agps_types[] =
{
NAME_VAL( AGPS_TYPE_INVALID ),
NAME_VAL( AGPS_TYPE_ANY ),
NAME_VAL( AGPS_TYPE_SUPL ),
NAME_VAL( AGPS_TYPE_C2K ),
NAME_VAL( AGPS_TYPE_WWAN_ANY )
NAME_VAL( LOC_AGPS_TYPE_INVALID ),
NAME_VAL( LOC_AGPS_TYPE_ANY ),
NAME_VAL( LOC_AGPS_TYPE_SUPL ),
NAME_VAL( LOC_AGPS_TYPE_C2K ),
NAME_VAL( LOC_AGPS_TYPE_WWAN_ANY )
};
static const int loc_eng_agps_type_num = sizeof(loc_eng_agps_types) / sizeof(loc_name_val_s_type);
const char* loc_get_agps_type_name(AGpsType type)
const char* loc_get_agps_type_name(LocAGpsType type)
{
return loc_get_name_from_val(loc_eng_agps_types, loc_eng_agps_type_num, (long) type);
}
@@ -144,14 +144,14 @@ const char* loc_get_agps_type_name(AGpsType type)
static const loc_name_val_s_type loc_eng_ni_types[] =
{
NAME_VAL( GPS_NI_TYPE_VOICE ),
NAME_VAL( GPS_NI_TYPE_UMTS_SUPL ),
NAME_VAL( GPS_NI_TYPE_UMTS_CTRL_PLANE ),
NAME_VAL( GPS_NI_TYPE_EMERGENCY_SUPL )
NAME_VAL( LOC_GPS_NI_TYPE_VOICE ),
NAME_VAL( LOC_GPS_NI_TYPE_UMTS_SUPL ),
NAME_VAL( LOC_GPS_NI_TYPE_UMTS_CTRL_PLANE ),
NAME_VAL( LOC_GPS_NI_TYPE_EMERGENCY_SUPL )
};
static const int loc_eng_ni_type_num = sizeof(loc_eng_ni_types) / sizeof(loc_name_val_s_type);
const char* loc_get_ni_type_name(GpsNiType type)
const char* loc_get_ni_type_name(LocGpsNiType type)
{
return loc_get_name_from_val(loc_eng_ni_types, loc_eng_ni_type_num, (long) type);
}
@@ -159,13 +159,13 @@ const char* loc_get_ni_type_name(GpsNiType type)
static const loc_name_val_s_type loc_eng_ni_responses[] =
{
NAME_VAL( GPS_NI_RESPONSE_ACCEPT ),
NAME_VAL( GPS_NI_RESPONSE_DENY ),
NAME_VAL( GPS_NI_RESPONSE_DENY )
NAME_VAL( LOC_GPS_NI_RESPONSE_ACCEPT ),
NAME_VAL( LOC_GPS_NI_RESPONSE_DENY ),
NAME_VAL( LOC_GPS_NI_RESPONSE_DENY )
};
static const int loc_eng_ni_reponse_num = sizeof(loc_eng_ni_responses) / sizeof(loc_name_val_s_type);
const char* loc_get_ni_response_name(GpsUserResponseType response)
const char* loc_get_ni_response_name(LocGpsUserResponseType response)
{
return loc_get_name_from_val(loc_eng_ni_responses, loc_eng_ni_reponse_num, (long) response);
}
@@ -173,15 +173,15 @@ const char* loc_get_ni_response_name(GpsUserResponseType response)
static const loc_name_val_s_type loc_eng_ni_encodings[] =
{
NAME_VAL( GPS_ENC_NONE ),
NAME_VAL( GPS_ENC_SUPL_GSM_DEFAULT ),
NAME_VAL( GPS_ENC_SUPL_UTF8 ),
NAME_VAL( GPS_ENC_SUPL_UCS2 ),
NAME_VAL( GPS_ENC_UNKNOWN )
NAME_VAL( LOC_GPS_ENC_NONE ),
NAME_VAL( LOC_GPS_ENC_SUPL_GSM_DEFAULT ),
NAME_VAL( LOC_GPS_ENC_SUPL_UTF8 ),
NAME_VAL( LOC_GPS_ENC_SUPL_UCS2 ),
NAME_VAL( LOC_GPS_ENC_UNKNOWN )
};
static const int loc_eng_ni_encoding_num = sizeof(loc_eng_ni_encodings) / sizeof(loc_name_val_s_type);
const char* loc_get_ni_encoding_name(GpsNiEncodingType encoding)
const char* loc_get_ni_encoding_name(LocGpsNiEncodingType encoding)
{
return loc_get_name_from_val(loc_eng_ni_encodings, loc_eng_ni_encoding_num, (long) encoding);
}
@@ -229,15 +229,15 @@ const char* loc_get_position_sess_status_name(enum loc_sess_status status)
static const loc_name_val_s_type loc_eng_agps_status_names[] =
{
NAME_VAL( GPS_REQUEST_AGPS_DATA_CONN ),
NAME_VAL( GPS_RELEASE_AGPS_DATA_CONN ),
NAME_VAL( GPS_AGPS_DATA_CONNECTED ),
NAME_VAL( GPS_AGPS_DATA_CONN_DONE ),
NAME_VAL( GPS_AGPS_DATA_CONN_FAILED )
NAME_VAL( LOC_GPS_REQUEST_AGPS_DATA_CONN ),
NAME_VAL( LOC_GPS_RELEASE_AGPS_DATA_CONN ),
NAME_VAL( LOC_GPS_AGPS_DATA_CONNECTED ),
NAME_VAL( LOC_GPS_AGPS_DATA_CONN_DONE ),
NAME_VAL( LOC_GPS_AGPS_DATA_CONN_FAILED )
};
static const int loc_eng_agps_status_num = sizeof(loc_eng_agps_status_names) / sizeof(loc_name_val_s_type);
const char* loc_get_agps_status_name(AGpsStatusValue status)
const char* loc_get_agps_status_name(LocAGpsStatusValue status)
{
return loc_get_name_from_val(loc_eng_agps_status_names, loc_eng_agps_status_num, (long) status);
}

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2013, 2016-2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -30,26 +30,26 @@
#ifndef LOC_CORE_LOG_H
#define LOC_CORE_LOG_H
#include <ctype.h>
#include <gps_extended.h>
#ifdef __cplusplus
extern "C"
{
#endif
#include <ctype.h>
#include <gps_extended.h>
const char* loc_get_gps_status_name(GpsStatusValue gps_status);
const char* loc_get_position_mode_name(GpsPositionMode mode);
const char* loc_get_position_recurrence_name(GpsPositionRecurrence recur);
const char* loc_get_aiding_data_mask_names(GpsAidingData data);
const char* loc_get_agps_type_name(AGpsType type);
const char* loc_get_ni_type_name(GpsNiType type);
const char* loc_get_ni_response_name(GpsUserResponseType response);
const char* loc_get_ni_encoding_name(GpsNiEncodingType encoding);
const char* loc_get_gps_status_name(LocGpsStatusValue gps_status);
const char* loc_get_position_mode_name(LocGpsPositionMode mode);
const char* loc_get_position_recurrence_name(LocGpsPositionRecurrence recur);
const char* loc_get_aiding_data_mask_names(LocGpsAidingData data);
const char* loc_get_agps_type_name(LocAGpsType type);
const char* loc_get_ni_type_name(LocGpsNiType type);
const char* loc_get_ni_response_name(LocGpsUserResponseType response);
const char* loc_get_ni_encoding_name(LocGpsNiEncodingType encoding);
const char* loc_get_agps_bear_name(AGpsBearerType bear);
const char* loc_get_server_type_name(LocServerType type);
const char* loc_get_position_sess_status_name(enum loc_sess_status status);
const char* loc_get_agps_status_name(AGpsStatusValue status);
const char* loc_get_agps_status_name(LocAGpsStatusValue status);
#ifdef __cplusplus
}

View File

@@ -0,0 +1,76 @@
/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __IDATAITEMOBSERVER_H__
#define __IDATAITEMOBSERVER_H__
#include <list>
#include <string>
using namespace std;
namespace loc_core
{
class IDataItemCore;
/**
* @brief IDataItemObserver interface
* @details IDataItemObserver interface;
* In OS dependent code this type serves as a handle to an OS independent instance of this interface.
*/
class IDataItemObserver {
public:
/**
* @brief Gets name of Data Item Observer
* @details Gets name of Data Item Observer
*
* @param name reference to name of Data Item Observer
*/
virtual void getName (string & name) = 0;
/**
* @brief Notify updated values of Data Items
* @details Notifys updated values of Data items
*
* @param dlist List of updated data items
*/
virtual void notify (const std :: list <IDataItemCore *> & dlist) = 0;
/**
* @brief Destructor
* @details Destructor
*/
virtual ~IDataItemObserver () {}
};
} // namespace loc_core
#endif // #ifndef __IDATAITEMOBSERVER_H__

View File

@@ -0,0 +1,129 @@
/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __IDATAITEMSUBSCRIPTION_H__
#define __IDATAITEMSUBSCRIPTION_H__
#include <list>
#include <DataItemId.h>
namespace loc_core
{
class IDataItemObserver;
/**
* @brief IDataItemSubscription interface
* @details IDataItemSubscription interface;
* Defines an interface for operations such as subscribe,
* unsubscribe data items by their IDs.
* Must be implemented by OS dependent code.
*/
class IDataItemSubscription {
public:
/**
* @brief Subscribe for data items by their IDs
* @details Subscribe for data items by their IDs;
* An IDataItemObserver implementer invokes this method to subscribe
* for a list of DataItems by passing in their Ids.
* A symbolic invocation of this method in the following order
* subscribe ( {1,2,3}, &obj), subscribe ( {2,3,4,5}, &obj)
* where the numbers enclosed in braces indicate a list of data item Ids
* will cause this class implementer to update its subscription list for
* &obj to only contain the following Data Item Ids 1,2,3,4,5.
*
* @param l List of DataItemId
* @param o Pointer to an instance of IDataItemObserver
*/
virtual void subscribe (const std :: list <DataItemId> & l, IDataItemObserver * o = NULL) = 0;
/**
* @brief Update subscription for Data items
* @details Update subscription for Data items;
* An IDataItemObserver implementer invokes this method to update their
* subscription for a list of DataItems by passing in their Ids
* A symbolic invocation of this method in the following order
* updateSubscription ( {1,2,3}, &obj),updateSubscription ( {2,3,4,5}, &obj)
* where the numbers enclosed in braces indicate a list of data item Ids
* will cause this class implementer to update its subscription list for
* &obj to only contain the following Data Item Ids 2,3,4,5.
* Note that this method may or may not be called.
*
* @param l List of DataItemId
* @param o Pointer to an instance of IDataItemObserver
*/
virtual void updateSubscription (const std :: list <DataItemId> & l, IDataItemObserver * o = NULL) = 0;
/**
* @brief Request Data
* @details Request Data
*
* @param l List of DataItemId
* @param o Pointer to an instance of IDataItemObserver
*/
virtual void requestData (const std :: list <DataItemId> & l, IDataItemObserver * o = NULL) = 0;
/**
* @brief Unsubscribe Data items
* @details Unsubscrbe Data items;
* An IDataItemObserver implementer invokes this method to unsubscribe their
* subscription for a list of DataItems by passing in their Ids
* Suppose this class implementor has a currently active subscription list
* containing 1,2,3,4,5,6,7 for &obj then a symbolic invocation of this
* method in the following order
* unsubscribe ( {1,2,3}, &obj), unsubscribe ( {1,2,3,4}, &obj),
* unsubscribe ( {7}, &obj)
* where the numbers enclosed in braces indicate a list of data item Ids
* will cause this class implementer to update its subscription list for
* &obj to only contain the following data item id 5,6.
*
* @param l List of DataItemId
* @param o Pointer to an instance of IDataItemObserver
*/
virtual void unsubscribe (const std :: list <DataItemId> & l, IDataItemObserver * o = NULL) = 0;
/**
* @brief Unsubscribe all data items
* @details Unsubscribe all data items
*
* @param o Pointer to an instance of IDataItemObserver
*/
virtual void unsubscribeAll (IDataItemObserver * o = NULL) = 0;
/**
* @brief Destructor
* @details Destructor
*/
virtual ~IDataItemSubscription () {}
};
} // namespace loc_core
#endif // #ifndef __IDATAITEMSUBSCRIPTION_H__

View File

@@ -0,0 +1,83 @@
/* Copyright (c) 2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __IFRAMEWORKACTIONREQ_H__
#define __IFRAMEWORKACTIONREQ_H__
#include <DataItemId.h>
namespace loc_core
{
/**
* @brief IFrameworkActionReq interface
* @details IFrameworkActionReq interface;
* Defines an interface for operations such as turnOn, turnOff a
* framework module described by the data item. Framework module
* could be bluetooth, wifi etc.
* Must be implemented by OS dependent code.
*
*/
class IFrameworkActionReq {
public:
/**
* @brief Turn on the framework module described by the data item.
* @details Turn on the framework module described by the data item;
* An IFrameworkActionReq implementer invokes this method to
* turn on the framework module described by the data item.
* Framework module could be bluetooth, wifi etc.
*
* @param dit DataItemId
* @param timeout Timeout after which to turn off the framework module.
*/
virtual void turnOn (DataItemId dit, int timeOut = 0) = 0;
/**
* @brief Turn off the framework module described by the data item.
* @details Turn off the framework module described by the data item;
* An IFrameworkActionReq implementer invokes this method to
* turn off the framework module described by the data item.
* Framework module could be bluetooth, wifi etc.
*
* @param dit DataItemId
*/
virtual void turnOff (DataItemId dit) = 0;
/**
* @brief Destructor
* @details Destructor
*/
virtual ~IFrameworkActionReq () {}
};
} // namespace loc_core
#endif // #ifndef __IFRAMEWORKACTIONREQ_H__

View File

@@ -0,0 +1,103 @@
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __IOSOBSERVER_H__
#define __IOSOBSERVER_H__
#include <list>
#include <string>
#include <IDataItemObserver.h>
#include <IDataItemSubscription.h>
#include <IFrameworkActionReq.h>
using namespace std;
namespace loc_core
{
/**
* @brief IOsObserver interface
* @details IOsObserver interface;
* In OS dependent code this type serves as a handle to
* an OS independent instance of this interface.
*/
class IOsObserver :
public IDataItemObserver,
public IDataItemSubscription,
public IFrameworkActionReq {
public:
// To set the subscription object
virtual void setSubscriptionObj(IDataItemSubscription *subscriptionObj) = 0;
// To set the framework action request object
virtual void setFrameworkActionReqObj(IFrameworkActionReq *frameworkActionReqObj) = 0;
// IDataItemObserver Overrides
inline virtual void getName (string & /*name*/) {}
inline virtual void notify (const std::list <IDataItemCore *> & /*dlist*/) {}
// IDataItemSubscription Overrides
inline virtual void subscribe
(
const std :: list <DataItemId> & /*l*/,
IDataItemObserver * /*client*/
){}
inline virtual void updateSubscription
(
const std :: list <DataItemId> & /*l*/,
IDataItemObserver * /*client*/
){}
inline virtual void requestData
(
const std :: list <DataItemId> & /*l*/,
IDataItemObserver * /*client*/
){}
inline virtual void unsubscribe
(
const std :: list <DataItemId> & /*l*/,
IDataItemObserver * /*client*/
){}
inline virtual void unsubscribeAll (IDataItemObserver * /*client*/){}
// IFrameworkActionReq Overrides
inline virtual void turnOn (DataItemId /*dit*/, int /*timeOut*/){}
inline virtual void turnOff (DataItemId /*dit*/) {}
/**
* @brief Destructor
* @details Destructor
*/
virtual ~IOsObserver () {}
};
} // namespace loc_core
#endif // #ifndef __IOSOBSERVER_H__