aboutsummaryrefslogtreecommitdiff
path: root/gps/core
diff options
context:
space:
mode:
Diffstat (limited to 'gps/core')
-rw-r--r--gps/core/Android.mk69
-rw-r--r--gps/core/ContextBase.cpp248
-rw-r--r--gps/core/ContextBase.h148
-rw-r--r--gps/core/LBSProxyBase.h80
-rw-r--r--gps/core/LocAdapterBase.cpp164
-rw-r--r--gps/core/LocAdapterBase.h160
-rw-r--r--gps/core/LocAdapterProxyBase.h78
-rw-r--r--gps/core/LocApiBase.cpp608
-rw-r--r--gps/core/LocApiBase.h266
-rw-r--r--gps/core/LocDualContext.cpp150
-rw-r--r--gps/core/LocDualContext.h76
-rw-r--r--gps/core/Makefile.am61
-rw-r--r--gps/core/SystemStatus.cpp1716
-rw-r--r--gps/core/SystemStatus.h462
-rw-r--r--gps/core/SystemStatusOsObserver.cpp646
-rw-r--r--gps/core/SystemStatusOsObserver.h333
-rw-r--r--gps/core/UlpProxyBase.h124
-rw-r--r--gps/core/data-items/DataItemId.h73
-rw-r--r--gps/core/data-items/DataItemsFactoryProxy.cpp99
-rw-r--r--gps/core/data-items/DataItemsFactoryProxy.h55
-rw-r--r--gps/core/data-items/IDataItemCore.h82
-rw-r--r--gps/core/data-items/common/ClientIndex.cpp171
-rw-r--r--gps/core/data-items/common/ClientIndex.h70
-rw-r--r--gps/core/data-items/common/DataItemIndex.cpp202
-rw-r--r--gps/core/data-items/common/DataItemIndex.h70
-rw-r--r--gps/core/data-items/common/IClientIndex.h83
-rw-r--r--gps/core/data-items/common/IDataItemIndex.h94
-rw-r--r--gps/core/data-items/common/IndexFactory.cpp64
-rw-r--r--gps/core/data-items/common/IndexFactory.h48
-rw-r--r--gps/core/loc_core_log.cpp243
-rw-r--r--gps/core/loc_core_log.h58
-rw-r--r--gps/core/observer/IDataItemObserver.h76
-rw-r--r--gps/core/observer/IDataItemSubscription.h129
-rw-r--r--gps/core/observer/IFrameworkActionReq.h83
-rw-r--r--gps/core/observer/IOsObserver.h103
35 files changed, 7192 insertions, 0 deletions
diff --git a/gps/core/Android.mk b/gps/core/Android.mk
new file mode 100644
index 0000000..dba0b0a
--- /dev/null
+++ b/gps/core/Android.mk
@@ -0,0 +1,69 @@
+ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
+ifneq ($(BUILD_TINY_ANDROID),true)
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libloc_core
+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)
+LOCAL_CFLAGS += -DPDK_FEATURE_SET
+else ifeq ($(BOARD_VENDOR_QCOM_LOC_PDK_FEATURE_SET),true)
+LOCAL_CFLAGS += -DPDK_FEATURE_SET
+endif
+
+LOCAL_SHARED_LIBRARIES := \
+ liblog \
+ libutils \
+ libcutils \
+ libgps.utils \
+ libdl \
+ liblog \
+ libloc_pla
+
+LOCAL_SRC_FILES += \
+ 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
+
+LOCAL_CFLAGS += \
+ -fno-short-enums \
+ -D_ANDROID_
+
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/data-items \
+ $(LOCAL_PATH)/data-items/common \
+ $(LOCAL_PATH)/observer \
+
+LOCAL_HEADER_LIBRARIES := \
+ libgps.utils_headers \
+ libloc_pla_headers \
+ liblocation_api_headers
+
+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
diff --git a/gps/core/ContextBase.cpp b/gps/core/ContextBase.cpp
new file mode 100644
index 0000000..8af48fc
--- /dev/null
+++ b/gps/core/ContextBase.cpp
@@ -0,0 +1,248 @@
+/* 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
+ * 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_NDEBUG 0
+#define LOG_TAG "LocSvc_CtxBase"
+
+#include <dlfcn.h>
+#include <cutils/sched_policy.h>
+#include <unistd.h>
+#include <ContextBase.h>
+#include <msg_q.h>
+#include <loc_target.h>
+#include <platform_lib_includes.h>
+#include <loc_log.h>
+
+namespace loc_core {
+
+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
+ #define carrierMSB (uint32_t)0x1
+ #define gpsConfMSA (uint32_t)0x4
+ #define gpsConfMSB (uint32_t)0x2
+ uint32_t capabilities = mGps_conf.CAPABILITIES;
+ if ((mGps_conf.SUPL_MODE & carrierMSA) != carrierMSA) {
+ capabilities &= ~gpsConfMSA;
+ }
+ if ((mGps_conf.SUPL_MODE & carrierMSB) != carrierMSB) {
+ capabilities &= ~gpsConfMSB;
+ }
+
+ LOC_LOGV("getCarrierCapabilities: CAPABILITIES %x, SUPL_MODE %x, carrier capabilities %x",
+ mGps_conf.CAPABILITIES, mGps_conf.SUPL_MODE, capabilities);
+ return capabilities;
+}
+
+LBSProxyBase* ContextBase::getLBSProxy(const char* libName)
+{
+ LBSProxyBase* proxy = NULL;
+ LOC_LOGD("%s:%d]: getLBSProxy libname: %s\n", __func__, __LINE__, libName);
+ void* lib = dlopen(libName, RTLD_NOW);
+
+ if ((void*)NULL != lib) {
+ getLBSProxy_t* getter = (getLBSProxy_t*)dlsym(lib, "getLBSProxy");
+ if (NULL != getter) {
+ proxy = (*getter)();
+ }
+ }
+ else
+ {
+ LOC_LOGW("%s:%d]: FAILED TO LOAD libname: %s\n", __func__, __LINE__, libName);
+ }
+ if (NULL == proxy) {
+ proxy = new LBSProxyBase();
+ }
+ LOC_LOGD("%s:%d]: Exiting\n", __func__, __LINE__);
+ return proxy;
+}
+
+LocApiBase* ContextBase::createLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask)
+{
+ LocApiBase* locApi = NULL;
+
+ // 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 (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);
+ }
+ }
+ }
+ }
+ }
+
+ // locApi could still be NULL at this time
+ // we would then create a dummy one
+ if (NULL == locApi) {
+ locApi = new LocApiBase(mMsgTask, exMask, this);
+ }
+
+ return locApi;
+}
+
+ContextBase::ContextBase(const MsgTask* msgTask,
+ LOC_API_ADAPTER_EVENT_MASK_T exMask,
+ const char* libName) :
+ mLBSProxy(getLBSProxy(libName)),
+ mMsgTask(msgTask),
+ mLocApi(createLocApi(exMask)),
+ mLocApiProxy(mLocApi->getLocApiProxy())
+{
+}
+
+}
diff --git a/gps/core/ContextBase.h b/gps/core/ContextBase.h
new file mode 100644
index 0000000..83de999
--- /dev/null
+++ b/gps/core/ContextBase.h
@@ -0,0 +1,148 @@
+/* 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
+ * 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 __LOC_CONTEXT_BASE__
+#define __LOC_CONTEXT_BASE__
+
+#include <stdbool.h>
+#include <ctype.h>
+#include <MsgTask.h>
+#include <LocApiBase.h>
+#include <LBSProxyBase.h>
+#include <loc_cfg.h>
+
+#define MAX_XTRA_SERVER_URL_LENGTH 256
+
+/* GPS.conf support */
+/* NOTE: the implementaiton of the parser casts number
+ fields to 32 bit. To ensure all 'n' fields working,
+ they must all be 32 bit fields. */
+typedef struct loc_gps_cfg_s
+{
+ uint32_t INTERMEDIATE_POS;
+ uint32_t ACCURACY_THRES;
+ uint32_t SUPL_VER;
+ uint32_t SUPL_MODE;
+ uint32_t SUPL_ES;
+ uint32_t CAPABILITIES;
+ uint32_t LPP_PROFILE;
+ uint32_t XTRA_VERSION_CHECK;
+ char XTRA_SERVER_1[MAX_XTRA_SERVER_URL_LENGTH];
+ char XTRA_SERVER_2[MAX_XTRA_SERVER_URL_LENGTH];
+ char XTRA_SERVER_3[MAX_XTRA_SERVER_URL_LENGTH];
+ uint32_t USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL;
+ uint32_t NMEA_PROVIDER;
+ uint32_t GPS_LOCK;
+ uint32_t A_GLONASS_POS_PROTOCOL_SELECT;
+ uint32_t AGPS_CERT_WRITABLE_MASK;
+ uint32_t AGPS_CONFIG_INJECT;
+ uint32_t LPPE_CP_TECHNOLOGY;
+ uint32_t LPPE_UP_TECHNOLOGY;
+ uint32_t EXTERNAL_DR_ENABLED;
+} loc_gps_cfg_s_type;
+
+/* NOTE: the implementaiton of the parser casts number
+ fields to 32 bit. To ensure all 'n' fields working,
+ they must all be 32 bit fields. */
+/* Meanwhile, *_valid fields are 8 bit fields, and 'f'
+ fields are double. Rigid as they are, it is the
+ the status quo, until the parsing mechanism is
+ change, that is. */
+typedef struct
+{
+ uint8_t GYRO_BIAS_RANDOM_WALK_VALID;
+ double GYRO_BIAS_RANDOM_WALK;
+ uint32_t SENSOR_ACCEL_BATCHES_PER_SEC;
+ uint32_t SENSOR_ACCEL_SAMPLES_PER_BATCH;
+ uint32_t SENSOR_GYRO_BATCHES_PER_SEC;
+ uint32_t SENSOR_GYRO_SAMPLES_PER_BATCH;
+ uint32_t SENSOR_ACCEL_BATCHES_PER_SEC_HIGH;
+ uint32_t SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH;
+ uint32_t SENSOR_GYRO_BATCHES_PER_SEC_HIGH;
+ uint32_t SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH;
+ uint32_t SENSOR_CONTROL_MODE;
+ uint32_t SENSOR_USAGE;
+ uint32_t SENSOR_ALGORITHM_CONFIG_MASK;
+ uint8_t ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
+ double ACCEL_RANDOM_WALK_SPECTRAL_DENSITY;
+ uint8_t ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
+ double ANGLE_RANDOM_WALK_SPECTRAL_DENSITY;
+ uint8_t RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
+ double RATE_RANDOM_WALK_SPECTRAL_DENSITY;
+ uint8_t VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
+ double VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY;
+ uint32_t SENSOR_PROVIDER;
+} loc_sap_cfg_s_type;
+
+namespace loc_core {
+
+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;
+ LocApiBase* mLocApi;
+ LocApiProxyBase *mLocApiProxy;
+public:
+ ContextBase(const MsgTask* msgTask,
+ LOC_API_ADAPTER_EVENT_MASK_T exMask,
+ const char* libName);
+ inline virtual ~ContextBase() { delete mLocApi; delete mLBSProxy; }
+
+ inline const MsgTask* getMsgTask() { return mMsgTask; }
+ inline LocApiBase* getLocApi() { return mLocApi; }
+ inline LocApiProxyBase* getLocApiProxy() { return mLocApiProxy; }
+ inline bool hasAgpsExtendedCapabilities() { return mLBSProxy->hasAgpsExtendedCapabilities(); }
+ inline bool hasCPIExtendedCapabilities() { return mLBSProxy->hasCPIExtendedCapabilities(); }
+ inline bool hasNativeXtraClient() { return mLBSProxy->hasNativeXtraClient(); }
+ inline void modemPowerVote(bool power) const { return mLBSProxy->modemPowerVote(power); }
+ inline void requestUlp(LocAdapterBase* adapter,
+ unsigned long capabilities) {
+ mLBSProxy->requestUlp(adapter, capabilities);
+ }
+ inline IzatDevId_t getIzatDevId() const {
+ return mLBSProxy->getIzatDevId();
+ }
+ inline void sendMsg(const LocMsg *msg) { getMsgTask()->sendMsg(msg); }
+
+ static loc_gps_cfg_s_type mGps_conf;
+ static loc_sap_cfg_s_type mSap_conf;
+
+ void readConfig();
+ static uint32_t getCarrierCapabilities();
+
+};
+
+} // namespace loc_core
+
+#endif //__LOC_CONTEXT_BASE__
diff --git a/gps/core/LBSProxyBase.h b/gps/core/LBSProxyBase.h
new file mode 100644
index 0000000..94ddd0f
--- /dev/null
+++ b/gps/core/LBSProxyBase.h
@@ -0,0 +1,80 @@
+/* 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 IZAT_PROXY_BASE_H
+#define IZAT_PROXY_BASE_H
+#include <gps_extended.h>
+#include <MsgTask.h>
+
+namespace loc_core {
+
+class LocApiBase;
+class LocAdapterBase;
+class ContextBase;
+
+class LBSProxyBase {
+ friend class ContextBase;
+ inline virtual LocApiBase*
+ getLocApi(const MsgTask* msgTask,
+ LOC_API_ADAPTER_EVENT_MASK_T exMask,
+ ContextBase* context) const {
+
+ (void)msgTask;
+ (void)exMask;
+ (void)context;
+ return NULL;
+ }
+protected:
+ inline LBSProxyBase() {}
+public:
+ inline virtual ~LBSProxyBase() {}
+ inline virtual void requestUlp(LocAdapterBase* adapter,
+ unsigned long capabilities) const {
+
+ (void)adapter;
+ (void)capabilities;
+ }
+ inline virtual bool hasAgpsExtendedCapabilities() const { return false; }
+ inline virtual bool hasCPIExtendedCapabilities() const { return false; }
+ inline virtual void modemPowerVote(bool power) const {
+
+ (void)power;
+ }
+ virtual void injectFeatureConfig(ContextBase* context) const {
+
+ (void)context;
+ }
+ inline virtual bool hasNativeXtraClient() const { return false; }
+ inline virtual IzatDevId_t getIzatDevId() const { return 0; }
+};
+
+typedef LBSProxyBase* (getLBSProxy_t)();
+
+} // namespace loc_core
+
+#endif // IZAT_PROXY_BASE_H
diff --git a/gps/core/LocAdapterBase.cpp b/gps/core/LocAdapterBase.cpp
new file mode 100644
index 0000000..3943819
--- /dev/null
+++ b/gps/core/LocAdapterBase.cpp
@@ -0,0 +1,164 @@
+/* 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
+ * 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_NDEBUG 0
+#define LOG_TAG "LocSvc_LocAdapterBase"
+
+#include <dlfcn.h>
+#include <LocAdapterBase.h>
+#include <loc_target.h>
+#include <platform_lib_log_util.h>
+#include <LocAdapterProxyBase.h>
+
+namespace loc_core {
+
+// This is the top level class, so the constructor will
+// always gets called. Here we prepare for the default.
+// But if getLocApi(targetEnumType target) is overriden,
+// the right locApi should get created.
+LocAdapterBase::LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
+ ContextBase* context, LocAdapterProxyBase *adapterProxyBase) :
+ mEvtMask(mask), mContext(context),
+ mLocApi(context->getLocApi()), mLocAdapterProxyBase(adapterProxyBase),
+ mMsgTask(context->getMsgTask())
+{
+ mLocApi->addAdapter(this);
+}
+
+uint32_t LocAdapterBase::mSessionIdCounter(1);
+
+uint32_t LocAdapterBase::generateSessionId()
+{
+ if (++mSessionIdCounter == 0xFFFFFFFF)
+ mSessionIdCounter = 1;
+
+ return mSessionIdCounter;
+}
+
+void LocAdapterBase::handleEngineUpEvent()
+{
+ if (mLocAdapterProxyBase) {
+ mLocAdapterProxyBase->handleEngineUpEvent();
+ }
+}
+
+void LocAdapterBase::handleEngineDownEvent()
+{
+ if (mLocAdapterProxyBase) {
+ mLocAdapterProxyBase->handleEngineDownEvent();
+ }
+}
+
+void LocAdapterBase::
+ 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::
+ reportSvEvent(const GnssSvNotification& /*svNotify*/, bool /*fromUlp*/)
+DEFAULT_IMPL()
+
+void LocAdapterBase::
+ reportSvMeasurementEvent(GnssSvMeasurementSet &/*svMeasurementSet*/)
+DEFAULT_IMPL()
+
+void LocAdapterBase::
+ reportSvPolynomialEvent(GnssSvPolynomial &/*svPolynomial*/)
+DEFAULT_IMPL()
+
+void LocAdapterBase::
+ reportStatus(LocGpsStatusValue /*status*/)
+DEFAULT_IMPL()
+
+
+void LocAdapterBase::
+ 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*/)
+DEFAULT_IMPL(false)
+
+bool LocAdapterBase::
+ requestXtraData()
+DEFAULT_IMPL(false)
+
+bool LocAdapterBase::
+ requestTime()
+DEFAULT_IMPL(false)
+
+bool LocAdapterBase::
+ requestLocation()
+DEFAULT_IMPL(false)
+
+bool LocAdapterBase::
+ requestATL(int /*connHandle*/, LocAGpsType /*agps_type*/)
+DEFAULT_IMPL(false)
+
+bool LocAdapterBase::
+ releaseATL(int /*connHandle*/)
+DEFAULT_IMPL(false)
+
+bool LocAdapterBase::
+ requestSuplES(int /*connHandle*/)
+DEFAULT_IMPL(false)
+
+bool LocAdapterBase::
+ reportDataCallOpened()
+DEFAULT_IMPL(false)
+
+bool LocAdapterBase::
+ reportDataCallClosed()
+DEFAULT_IMPL(false)
+
+bool LocAdapterBase::
+ requestNiNotifyEvent(const GnssNiNotification &/*notify*/, const void* /*data*/)
+DEFAULT_IMPL(false)
+
+void LocAdapterBase::
+ reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& /*measurements*/,
+ int /*msInWeek*/)
+DEFAULT_IMPL()
+
+bool LocAdapterBase::
+ reportWwanZppFix(LocGpsLocation &/*zppLoc*/)
+DEFAULT_IMPL(false)
+
+} // namespace loc_core
diff --git a/gps/core/LocAdapterBase.h b/gps/core/LocAdapterBase.h
new file mode 100644
index 0000000..e7beca8
--- /dev/null
+++ b/gps/core/LocAdapterBase.h
@@ -0,0 +1,160 @@
+/* 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
+ * 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 LOC_API_ADAPTER_BASE_H
+#define LOC_API_ADAPTER_BASE_H
+
+#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) {}
+public:
+ inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); }
+ LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
+ ContextBase* context, LocAdapterProxyBase *adapterProxyBase = NULL);
+ inline LOC_API_ADAPTER_EVENT_MASK_T
+ checkMask(LOC_API_ADAPTER_EVENT_MASK_T mask) const {
+ return mEvtMask & mask;
+ }
+
+ inline LOC_API_ADAPTER_EVENT_MASK_T getEvtMask() const {
+ return mEvtMask;
+ }
+
+ inline void sendMsg(const LocMsg* msg) const {
+ mMsgTask->sendMsg(msg);
+ }
+
+ inline void sendMsg(const LocMsg* msg) {
+ mMsgTask->sendMsg(msg);
+ }
+
+ inline void updateEvtMask(LOC_API_ADAPTER_EVENT_MASK_T event,
+ loc_registration_mask_status status)
+ {
+ 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();
+ }
+
+ inline bool isFeatureSupported(uint8_t featureVal) {
+ return mLocApi->isFeatureSupported(featureVal);
+ }
+
+ uint32_t generateSessionId();
+
+ // This will be overridden by the individual adapters
+ // if necessary.
+ inline virtual void setUlpProxyCommand(UlpProxyBase* ulp) {
+
+ (void)ulp;
+ }
+ virtual void handleEngineUpEvent();
+ virtual void handleEngineDownEvent();
+ inline virtual void setPositionModeCommand(LocPosMode& posMode) {
+
+ (void)posMode;
+ }
+ 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, LocAGpsType agps_type);
+ virtual bool releaseATL(int connHandle);
+ virtual bool requestSuplES(int connHandle);
+ virtual bool reportDataCallOpened();
+ virtual bool reportDataCallClosed();
+ virtual bool requestNiNotifyEvent(const GnssNiNotification &notify, const void* data);
+ inline virtual bool isInSession() { return false; }
+ ContextBase* getContext() const { return mContext; }
+ virtual void reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& measurements,
+ int msInWeek);
+ virtual bool reportWwanZppFix(LocGpsLocation &zppLoc);
+};
+
+} // namespace loc_core
+
+#endif //LOC_API_ADAPTER_BASE_H
diff --git a/gps/core/LocAdapterProxyBase.h b/gps/core/LocAdapterProxyBase.h
new file mode 100644
index 0000000..044f59b
--- /dev/null
+++ b/gps/core/LocAdapterProxyBase.h
@@ -0,0 +1,78 @@
+/* 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
+ * 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 LOC_ADAPTER_PROXY_BASE_H
+#define LOC_ADAPTER_PROXY_BASE_H
+
+#include <ContextBase.h>
+#include <gps_extended.h>
+
+namespace loc_core {
+
+class LocAdapterProxyBase {
+private:
+ LocAdapterBase *mLocAdapterBase;
+protected:
+ inline LocAdapterProxyBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
+ ContextBase* context):
+ mLocAdapterBase(new LocAdapterBase(mask, context, this)) {
+ }
+ inline virtual ~LocAdapterProxyBase() {
+ delete mLocAdapterBase;
+ }
+ inline void updateEvtMask(LOC_API_ADAPTER_EVENT_MASK_T event,
+ loc_registration_mask_status isEnabled) {
+ 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 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;
+ }
+};
+
+} // namespace loc_core
+
+#endif //LOC_ADAPTER_PROXY_BASE_H
diff --git a/gps/core/LocApiBase.cpp b/gps/core/LocApiBase.cpp
new file mode 100644
index 0000000..e0845de
--- /dev/null
+++ b/gps/core/LocApiBase.cpp
@@ -0,0 +1,608 @@
+/* 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
+ * 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_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>
+#include <LocDualContext.h>
+
+namespace loc_core {
+
+#define TO_ALL_LOCADAPTERS(call) TO_ALL_ADAPTERS(mLocAdapters, (call))
+#define TO_1ST_HANDLING_LOCADAPTERS(call) TO_1ST_HANDLING_ADAPTER(mLocAdapters, (call))
+
+int hexcode(char *hexstring, int string_size,
+ const char *data, int data_size)
+{
+ int i;
+ for (i = 0; i < data_size; i++)
+ {
+ char ch = data[i];
+ if (i*2 + 3 <= string_size)
+ {
+ snprintf(&hexstring[i*2], 3, "%02X", ch);
+ }
+ else {
+ break;
+ }
+ }
+ return i;
+}
+
+int decodeAddress(char *addr_string, int string_size,
+ const char *data, int data_size)
+{
+ const char addr_prefix = 0x91;
+ int i, idxOutput = 0;
+
+ if (!data || !addr_string) { return 0; }
+
+ if (data[0] != addr_prefix)
+ {
+ LOC_LOGW("decodeAddress: address prefix is not 0x%x but 0x%x", addr_prefix, data[0]);
+ addr_string[0] = '\0';
+ return 0; // prefix not correct
+ }
+
+ for (i = 1; i < data_size; i++)
+ {
+ unsigned char ch = data[i], low = ch & 0x0F, hi = ch >> 4;
+ if (low <= 9 && idxOutput < string_size - 1) { addr_string[idxOutput++] = low + '0'; }
+ if (hi <= 9 && idxOutput < string_size - 1) { addr_string[idxOutput++] = hi + '0'; }
+ }
+
+ addr_string[idxOutput] = '\0'; // Terminates the string
+
+ return idxOutput;
+}
+
+struct LocSsrMsg : public LocMsg {
+ LocApiBase* mLocApi;
+ inline LocSsrMsg(LocApiBase* locApi) :
+ LocMsg(), mLocApi(locApi)
+ {
+ locallog();
+ }
+ inline virtual void proc() const {
+ mLocApi->close();
+ mLocApi->open(mLocApi->getEvtMask());
+ }
+ inline void locallog() const {
+ LOC_LOGV("LocSsrMsg");
+ }
+ inline virtual void log() const {
+ locallog();
+ }
+};
+
+struct LocOpenMsg : public LocMsg {
+ LocApiBase* mLocApi;
+ LOC_API_ADAPTER_EVENT_MASK_T mMask;
+ inline LocOpenMsg(LocApiBase* locApi,
+ LOC_API_ADAPTER_EVENT_MASK_T mask) :
+ LocMsg(), mLocApi(locApi), mMask(mask)
+ {
+ locallog();
+ }
+ inline virtual void proc() const {
+ mLocApi->open(mMask);
+ }
+ inline void locallog() const {
+ LOC_LOGV("%s:%d]: LocOpen Mask: %x\n",
+ __func__, __LINE__, mMask);
+ }
+ inline virtual void log() const {
+ locallog();
+ }
+};
+
+LocApiBase::LocApiBase(const MsgTask* msgTask,
+ LOC_API_ADAPTER_EVENT_MASK_T excludedMask,
+ ContextBase* context) :
+ mMsgTask(msgTask), mContext(context), mSupportedMsg(0),
+ mMask(0), mExcludedMask(excludedMask)
+{
+ memset(mLocAdapters, 0, sizeof(mLocAdapters));
+ memset(mFeaturesSupported, 0, sizeof(mFeaturesSupported));
+}
+
+LOC_API_ADAPTER_EVENT_MASK_T LocApiBase::getEvtMask()
+{
+ LOC_API_ADAPTER_EVENT_MASK_T mask = 0;
+
+ TO_ALL_LOCADAPTERS(mask |= mLocAdapters[i]->getEvtMask());
+
+ return mask & ~mExcludedMask;
+}
+
+bool LocApiBase::isInSession()
+{
+ bool inSession = false;
+
+ for (int i = 0;
+ !inSession && i < MAX_ADAPTERS && NULL != mLocAdapters[i];
+ i++) {
+ inSession = mLocAdapters[i]->isInSession();
+ }
+
+ return inSession;
+}
+
+void LocApiBase::addAdapter(LocAdapterBase* adapter)
+{
+ for (int i = 0; i < MAX_ADAPTERS && mLocAdapters[i] != adapter; i++) {
+ if (mLocAdapters[i] == NULL) {
+ mLocAdapters[i] = adapter;
+ mMsgTask->sendMsg(new LocOpenMsg(this,
+ (adapter->getEvtMask())));
+ break;
+ }
+ }
+}
+
+void LocApiBase::removeAdapter(LocAdapterBase* adapter)
+{
+ for (int i = 0;
+ i < MAX_ADAPTERS && NULL != mLocAdapters[i];
+ i++) {
+ if (mLocAdapters[i] == adapter) {
+ mLocAdapters[i] = NULL;
+
+ // shift the rest of the adapters up so that the pointers
+ // in the array do not have holes. This should be more
+ // performant, because the array maintenance is much much
+ // less frequent than event handlings, which need to linear
+ // search all the adapters
+ int j = i;
+ while (++i < MAX_ADAPTERS && mLocAdapters[i] != NULL);
+
+ // i would be MAX_ADAPTERS or point to a NULL
+ i--;
+ // i now should point to a none NULL adapter within valid
+ // range although i could be equal to j, but it won't hurt.
+ // No need to check it, as it gains nothing.
+ mLocAdapters[j] = mLocAdapters[i];
+ // this makes sure that we exit the for loop
+ mLocAdapters[i] = NULL;
+
+ // if we have an empty list of adapters
+ if (0 == i) {
+ close();
+ } else {
+ // else we need to remove the bit
+ mMsgTask->sendMsg(new LocOpenMsg(this, getEvtMask()));
+ }
+ }
+ }
+}
+
+void LocApiBase::updateEvtMask()
+{
+ mMsgTask->sendMsg(new LocOpenMsg(this, getEvtMask()));
+}
+
+void LocApiBase::handleEngineUpEvent()
+{
+ // This will take care of renegotiating the loc handle
+ mMsgTask->sendMsg(new LocSsrMsg(this));
+
+ LocDualContext::injectFeatureConfig(mContext);
+
+ // loop through adapters, and deliver to all adapters.
+ TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineUpEvent());
+}
+
+void LocApiBase::handleEngineDownEvent()
+{
+ // loop through adapters, and deliver to all adapters.
+ TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineDownEvent());
+}
+
+void LocApiBase::reportPosition(UlpLocation& location,
+ GpsLocationExtended& locationExtended,
+ enum loc_sess_status status,
+ LocPosTechMask loc_technology_mask)
+{
+ // print the location info before delivering
+ 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: %" 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,
+ 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]->reportPositionEvent(location, locationExtended,
+ status, loc_technology_mask)
+ );
+}
+
+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: %zu\n"
+ " sv: constellation svid cN0"
+ " elevation azimuth flags",
+ 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) {
+ svNotify.gnssSvs[i].type = GNSS_SV_TYPE_UNKNOWN;
+ }
+ LOC_LOGV(" %03zu: %*s %02d %f %f %f 0x%02X",
+ i,
+ 13,
+ 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]->reportSvEvent(svNotify)
+ );
+}
+
+void LocApiBase::reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet)
+{
+ // loop through adapters, and deliver to all adapters.
+ TO_ALL_LOCADAPTERS(
+ mLocAdapters[i]->reportSvMeasurementEvent(svMeasurementSet)
+ );
+}
+
+void LocApiBase::reportSvPolynomial(GnssSvPolynomial &svPolynomial)
+{
+ // loop through adapters, and deliver to all adapters.
+ TO_ALL_LOCADAPTERS(
+ mLocAdapters[i]->reportSvPolynomialEvent(svPolynomial)
+ );
+}
+
+void LocApiBase::reportStatus(LocGpsStatusValue status)
+{
+ // loop through adapters, and deliver to all adapters.
+ TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportStatus(status));
+}
+
+void LocApiBase::reportNmea(const char* nmea, int length)
+{
+ // loop through adapters, and deliver to all adapters.
+ TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportNmeaEvent(nmea, length));
+}
+
+void LocApiBase::reportXtraServer(const char* url1, const char* url2,
+ const char* url3, const int maxlength)
+{
+ // loop through adapters, and deliver to the first handling adapter.
+ TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportXtraServer(url1, url2, url3, maxlength));
+
+}
+
+void LocApiBase::requestXtraData()
+{
+ // loop through adapters, and deliver to the first handling adapter.
+ TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestXtraData());
+}
+
+void LocApiBase::requestTime()
+{
+ // loop through adapters, and deliver to the first handling adapter.
+ TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestTime());
+}
+
+void LocApiBase::requestLocation()
+{
+ // loop through adapters, and deliver to the first handling adapter.
+ TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestLocation());
+}
+
+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));
+}
+
+void LocApiBase::releaseATL(int connHandle)
+{
+ // loop through adapters, and deliver to the first handling adapter.
+ TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->releaseATL(connHandle));
+}
+
+void LocApiBase::requestSuplES(int connHandle)
+{
+ // loop through adapters, and deliver to the first handling adapter.
+ TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestSuplES(connHandle));
+}
+
+void LocApiBase::reportDataCallOpened()
+{
+ // loop through adapters, and deliver to the first handling adapter.
+ TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportDataCallOpened());
+}
+
+void LocApiBase::reportDataCallClosed()
+{
+ // loop through adapters, and deliver to the first handling adapter.
+ TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportDataCallClosed());
+}
+
+void LocApiBase::requestNiNotify(GnssNiNotification &notify, const void* data)
+{
+ // loop through adapters, and deliver to the first handling adapter.
+ TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestNiNotifyEvent(notify, data));
+}
+
+void LocApiBase::saveSupportedMsgList(uint64_t supportedMsgList)
+{
+ mSupportedMsg = supportedMsgList;
+}
+
+void LocApiBase::saveSupportedFeatureList(uint8_t *featureList)
+{
+ memcpy((void *)mFeaturesSupported, (void *)featureList, sizeof(mFeaturesSupported));
+}
+
+void* LocApiBase :: getSibling()
+ DEFAULT_IMPL(NULL)
+
+LocApiProxyBase* LocApiBase :: getLocApiProxy()
+ DEFAULT_IMPL(NULL)
+
+void LocApiBase::reportGnssMeasurementData(GnssMeasurementsNotification& measurements,
+ int msInWeek)
+{
+ // loop through adapters, and deliver to all adapters.
+ TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssMeasurementDataEvent(measurements, msInWeek));
+}
+
+enum loc_api_adapter_err LocApiBase::
+ open(LOC_API_ADAPTER_EVENT_MASK_T /*mask*/)
+DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
+
+enum loc_api_adapter_err LocApiBase::
+ close()
+DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
+
+enum loc_api_adapter_err LocApiBase::
+ 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::
+ enableData(int /*enable*/)
+DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
+
+enum loc_api_adapter_err LocApiBase::
+ setAPN(char* /*apn*/, int /*len*/)
+DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
+
+enum loc_api_adapter_err LocApiBase::
+ injectPosition(double /*latitude*/, double /*longitude*/, float /*accuracy*/)
+DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
+
+enum loc_api_adapter_err LocApiBase::
+ setTime(LocGpsUtcTime /*time*/, int64_t /*timeReference*/, int /*uncertainty*/)
+DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
+
+enum loc_api_adapter_err LocApiBase::
+ setXtraData(char* /*data*/, int /*length*/)
+DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
+
+enum loc_api_adapter_err LocApiBase::
+ requestXtraServer()
+DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
+
+enum loc_api_adapter_err LocApiBase::
+ 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*/)
+DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
+
+enum loc_api_adapter_err LocApiBase::
+ 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::
+ 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)
+
+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::
+ getBestAvailableZppFix(LocGpsLocation& zppLoc)
+{
+ memset(&zppLoc, 0, sizeof(zppLoc));
+ DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
+}
+
+enum loc_api_adapter_err LocApiBase::
+ 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(bool /*isDueToSsr*/)
+DEFAULT_IMPL(-1)
+
+int LocApiBase::
+ openAndStartDataCall()
+DEFAULT_IMPL(-1)
+
+void LocApiBase::
+ stopDataCall()
+DEFAULT_IMPL()
+
+void LocApiBase::
+ closeDataCall()
+DEFAULT_IMPL()
+
+void LocApiBase::
+ releaseDataServiceClient()
+DEFAULT_IMPL()
+
+LocationError LocApiBase::
+ setGpsLock(GnssConfigGpsLock /*lock*/)
+DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
+
+void LocApiBase::
+ installAGpsCert(const LocDerEncodedCertificate* /*pData*/,
+ size_t /*length*/,
+ uint32_t /*slotBitMask*/)
+DEFAULT_IMPL()
+
+int LocApiBase::
+ getGpsLock()
+DEFAULT_IMPL(-1)
+
+LocationError LocApiBase::
+ setXtraVersionCheck(uint32_t /*check*/)
+DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
+
+bool LocApiBase::
+ gnssConstellationConfig()
+DEFAULT_IMPL(false)
+
+bool LocApiBase::
+ isFeatureSupported(uint8_t featureVal)
+{
+ uint8_t arrayIndex = featureVal >> 3;
+ uint8_t bitPos = featureVal & 7;
+
+ if (arrayIndex >= MAX_FEATURE_LENGTH) return false;
+ return ((mFeaturesSupported[arrayIndex] >> bitPos ) & 0x1);
+}
+
+} // namespace loc_core
diff --git a/gps/core/LocApiBase.h b/gps/core/LocApiBase.h
new file mode 100644
index 0000000..f66bfe1
--- /dev/null
+++ b/gps/core/LocApiBase.h
@@ -0,0 +1,266 @@
+/* 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
+ * 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 LOC_API_BASE_H
+#define LOC_API_BASE_H
+
+#include <stddef.h>
+#include <ctype.h>
+#include <gps_extended.h>
+#include <LocationAPI.h>
+#include <MsgTask.h>
+#include <platform_lib_log_util.h>
+
+namespace loc_core {
+class ContextBase;
+
+int hexcode(char *hexstring, int string_size,
+ const char *data, int data_size);
+int decodeAddress(char *addr_string, int string_size,
+ const char *data, int data_size);
+
+#define MAX_ADAPTERS 10
+#define MAX_FEATURE_LENGTH 100
+
+#define TO_ALL_ADAPTERS(adapters, call) \
+ for (int i = 0; i < MAX_ADAPTERS && NULL != (adapters)[i]; i++) { \
+ call; \
+ }
+
+#define TO_1ST_HANDLING_ADAPTER(adapters, call) \
+ for (int i = 0; i <MAX_ADAPTERS && NULL != (adapters)[i] && !(call); i++);
+
+enum xtra_version_check {
+ DISABLED,
+ AUTO,
+ XTRA2,
+ XTRA3
+};
+
+class LocAdapterBase;
+struct LocSsrMsg;
+struct LocOpenMsg;
+
+class LocApiProxyBase {
+public:
+ inline LocApiProxyBase() {}
+ inline virtual ~LocApiProxyBase() {}
+ inline virtual void* getSibling2() { return NULL; }
+};
+
+class LocApiBase {
+ friend struct LocSsrMsg;
+ //LocOpenMsg calls open() which makes it necessary to declare
+ //it as a friend
+ friend struct LocOpenMsg;
+ friend class ContextBase;
+ const MsgTask* mMsgTask;
+ ContextBase *mContext;
+ LocAdapterBase* mLocAdapters[MAX_ADAPTERS];
+ uint64_t mSupportedMsg;
+ uint8_t mFeaturesSupported[MAX_FEATURE_LENGTH];
+
+protected:
+ virtual enum loc_api_adapter_err
+ open(LOC_API_ADAPTER_EVENT_MASK_T mask);
+ virtual enum loc_api_adapter_err
+ close();
+ LOC_API_ADAPTER_EVENT_MASK_T getEvtMask();
+ LOC_API_ADAPTER_EVENT_MASK_T mMask;
+ LocApiBase(const MsgTask* msgTask,
+ LOC_API_ADAPTER_EVENT_MASK_T excludedMask,
+ ContextBase* context = NULL);
+ inline virtual ~LocApiBase() { close(); }
+ bool isInSession();
+ const LOC_API_ADAPTER_EVENT_MASK_T mExcludedMask;
+
+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,
+ enum loc_sess_status status,
+ LocPosTechMask loc_technology_mask =
+ LOC_POS_TECH_MASK_DEFAULT);
+ void reportSv(GnssSvNotification& svNotify);
+ void reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet);
+ void reportSvPolynomial(GnssSvPolynomial &svPolynomial);
+ 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, LocAGpsType agps_type);
+ void releaseATL(int connHandle);
+ void requestSuplES(int connHandle);
+ void reportDataCallOpened();
+ void reportDataCallClosed();
+ void requestNiNotify(GnssNiNotification &notify, const void* data);
+ void saveSupportedMsgList(uint64_t supportedMsgList);
+ 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:
+ // RPC, QMI, etc. The default implementation is empty.
+
+ virtual void* getSibling();
+ virtual LocApiProxyBase* getLocApiProxy();
+ virtual enum loc_api_adapter_err
+ startFix(const LocPosMode& posMode);
+ virtual enum loc_api_adapter_err
+ stopFix();
+ virtual LocationError
+ deleteAidingData(const GnssAidingData& data);
+ virtual enum loc_api_adapter_err
+ enableData(int enable);
+ virtual enum loc_api_adapter_err
+ setAPN(char* apn, int len);
+ virtual enum loc_api_adapter_err
+ injectPosition(double latitude, double longitude, float accuracy);
+ virtual enum loc_api_adapter_err
+ 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, 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 LocationError
+ setServer(const char* url, int len);
+ virtual LocationError
+ setServer(unsigned int ip, int port,
+ LocServerType type);
+ virtual LocationError
+ informNiResponse(GnssNiResponse userResponse, const void* passThroughData);
+ virtual LocationError setSUPLVersion(GnssConfigSuplVersion version);
+ virtual enum loc_api_adapter_err
+ setNMEATypes (uint32_t typesMask);
+ virtual LocationError setLPPConfig(GnssConfigLppProfile profile);
+ virtual enum loc_api_adapter_err
+ setSensorControlConfig(int sensorUsage, int sensorProvider);
+ virtual enum loc_api_adapter_err
+ 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);
+ virtual enum loc_api_adapter_err
+ setSensorPerfControlConfig(int controlMode,
+ int accelSamplesPerBatch,
+ int accelBatchesPerSec,
+ int gyroSamplesPerBatch,
+ int gyroBatchesPerSec,
+ int accelSamplesPerBatchHigh,
+ int accelBatchesPerSecHigh,
+ 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
+ getWwanZppFix();
+ virtual enum loc_api_adapter_err
+ getBestAvailableZppFix(LocGpsLocation & zppLoc);
+ virtual enum loc_api_adapter_err
+ getBestAvailableZppFix(LocGpsLocation & zppLoc, GpsLocationExtended & locationExtended,
+ LocPosTechMask & tech_mask);
+ virtual int initDataServiceClient(bool isDueToSsr);
+ virtual int openAndStartDataCall();
+ virtual void stopDataCall();
+ virtual void closeDataCall();
+ virtual void releaseDataServiceClient();
+ virtual void installAGpsCert(const LocDerEncodedCertificate* pData,
+ size_t length,
+ uint32_t slotBitMask);
+ inline virtual void setInSession(bool inSession) {
+
+ (void)inSession;
+ }
+ inline bool isMessageSupported (LocCheckingMessagesID msgID) const {
+
+ // confirm if msgID is not larger than the number of bits in
+ // mSupportedMsg
+ if ((uint64_t)msgID > (sizeof(mSupportedMsg) << 3)) {
+ return false;
+ } else {
+ uint32_t messageChecker = 1 << msgID;
+ return (messageChecker & mSupportedMsg) == messageChecker;
+ }
+ }
+
+ void updateEvtMask();
+
+ virtual LocationError setGpsLock(GnssConfigGpsLock lock);
+ /*
+ Returns
+ Current value of GPS Lock on success
+ -1 on failure
+ */
+ virtual int getGpsLock(void);
+
+ virtual LocationError setXtraVersionCheck(uint32_t check);
+ /*
+ Check if the modem support the service
+ */
+ virtual bool gnssConstellationConfig();
+
+ /*
+ Check if a feature is supported
+ */
+ bool isFeatureSupported(uint8_t featureVal);
+};
+
+typedef LocApiBase* (getLocApi_t)(const MsgTask* msgTask,
+ LOC_API_ADAPTER_EVENT_MASK_T exMask,
+ ContextBase *context);
+
+} // namespace loc_core
+
+#endif //LOC_API_BASE_H
diff --git a/gps/core/LocDualContext.cpp b/gps/core/LocDualContext.cpp
new file mode 100644
index 0000000..fd3450d
--- /dev/null
+++ b/gps/core/LocDualContext.cpp
@@ -0,0 +1,150 @@
+/* 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
+ * 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_NDEBUG 0
+#define LOG_TAG "LocSvc_DualCtx"
+
+#include <cutils/sched_policy.h>
+#include <unistd.h>
+#include <LocDualContext.h>
+#include <msg_q.h>
+#include <platform_lib_log_util.h>
+#include <loc_log.h>
+
+namespace loc_core {
+
+// nothing exclude for foreground
+const LOC_API_ADAPTER_EVENT_MASK_T
+LocDualContext::mFgExclMask = 0;
+// excluded events for background clients
+const LOC_API_ADAPTER_EVENT_MASK_T
+LocDualContext::mBgExclMask =
+ (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 |
+ LOC_API_ADAPTER_BIT_STATUS_REPORT |
+ LOC_API_ADAPTER_BIT_GEOFENCE_GEN_ALERT |
+ LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT);
+
+const MsgTask* LocDualContext::mMsgTask = NULL;
+ContextBase* LocDualContext::mFgContext = NULL;
+ContextBase* LocDualContext::mBgContext = NULL;
+ContextBase* LocDualContext::mInjectContext = NULL;
+// the name must be shorter than 15 chars
+const char* LocDualContext::mLocationHalName = "Loc_hal_worker";
+#ifndef USE_GLIB
+const char* LocDualContext::mLBSLibName = "liblbs_core.so";
+#else
+const char* LocDualContext::mLBSLibName = "liblbs_core.so.1";
+#endif
+
+pthread_mutex_t LocDualContext::mGetLocContextMutex = PTHREAD_MUTEX_INITIALIZER;
+
+const MsgTask* LocDualContext::getMsgTask(LocThread::tCreate tCreator,
+ const char* name, bool joinable)
+{
+ if (NULL == mMsgTask) {
+ mMsgTask = new MsgTask(tCreator, name, joinable);
+ }
+ return mMsgTask;
+}
+
+inline
+const MsgTask* LocDualContext::getMsgTask(const char* name, bool joinable) {
+ return getMsgTask((LocThread::tCreate)NULL, name, joinable);
+}
+
+ContextBase* LocDualContext::getLocFgContext(LocThread::tCreate tCreator,
+ LocMsg* firstMsg, const char* name, bool joinable)
+{
+ pthread_mutex_lock(&LocDualContext::mGetLocContextMutex);
+ LOC_LOGD("%s:%d]: querying ContextBase with tCreator", __func__, __LINE__);
+ if (NULL == mFgContext) {
+ LOC_LOGD("%s:%d]: creating msgTask with tCreator", __func__, __LINE__);
+ const MsgTask* msgTask = getMsgTask(tCreator, name, joinable);
+ mFgContext = new LocDualContext(msgTask,
+ mFgExclMask);
+ }
+ if(NULL == mInjectContext) {
+ LOC_LOGD("%s:%d]: mInjectContext is FgContext", __func__, __LINE__);
+ mInjectContext = mFgContext;
+ injectFeatureConfig(mInjectContext);
+ }
+ pthread_mutex_unlock(&LocDualContext::mGetLocContextMutex);
+
+ if (firstMsg) {
+ mFgContext->sendMsg(firstMsg);
+ }
+
+ return mFgContext;
+}
+
+ContextBase* LocDualContext::getLocBgContext(LocThread::tCreate tCreator,
+ LocMsg* firstMsg, const char* name, bool joinable)
+{
+ pthread_mutex_lock(&LocDualContext::mGetLocContextMutex);
+ LOC_LOGD("%s:%d]: querying ContextBase with tCreator", __func__, __LINE__);
+ if (NULL == mBgContext) {
+ LOC_LOGD("%s:%d]: creating msgTask with tCreator", __func__, __LINE__);
+ const MsgTask* msgTask = getMsgTask(tCreator, name, joinable);
+ mBgContext = new LocDualContext(msgTask,
+ mBgExclMask);
+ }
+ if(NULL == mInjectContext) {
+ LOC_LOGD("%s:%d]: mInjectContext is BgContext", __func__, __LINE__);
+ mInjectContext = mBgContext;
+ injectFeatureConfig(mInjectContext);
+ }
+ pthread_mutex_unlock(&LocDualContext::mGetLocContextMutex);
+
+ if (firstMsg) {
+ mBgContext->sendMsg(firstMsg);
+ }
+
+ return mBgContext;
+}
+
+void LocDualContext :: injectFeatureConfig(ContextBase *curContext)
+{
+ LOC_LOGD("%s:%d]: Enter", __func__, __LINE__);
+ if(curContext == mInjectContext) {
+ LOC_LOGD("%s:%d]: Calling LBSProxy (%p) to inject feature config",
+ __func__, __LINE__, ((LocDualContext *)mInjectContext)->mLBSProxy);
+ ((LocDualContext *)mInjectContext)->mLBSProxy->injectFeatureConfig(curContext);
+ }
+ LOC_LOGD("%s:%d]: Exit", __func__, __LINE__);
+}
+
+LocDualContext::LocDualContext(const MsgTask* msgTask,
+ LOC_API_ADAPTER_EVENT_MASK_T exMask) :
+ ContextBase(msgTask, exMask, mLBSLibName)
+{
+}
+
+}
diff --git a/gps/core/LocDualContext.h b/gps/core/LocDualContext.h
new file mode 100644
index 0000000..3b3ce2c
--- /dev/null
+++ b/gps/core/LocDualContext.h
@@ -0,0 +1,76 @@
+/* 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
+ * 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 __LOC_ENG_CONTEXT__
+#define __LOC_ENG_CONTEXT__
+
+#include <stdbool.h>
+#include <ctype.h>
+#include <dlfcn.h>
+#include <ContextBase.h>
+
+namespace loc_core {
+
+class LocDualContext : public ContextBase {
+ static const MsgTask* mMsgTask;
+ static ContextBase* mFgContext;
+ static ContextBase* mBgContext;
+ static ContextBase* mInjectContext;
+ static const MsgTask* getMsgTask(LocThread::tCreate tCreator,
+ const char* name, bool joinable = true);
+ static const MsgTask* getMsgTask(const char* name, bool joinable = true);
+ static pthread_mutex_t mGetLocContextMutex;
+
+protected:
+ LocDualContext(const MsgTask* msgTask,
+ LOC_API_ADAPTER_EVENT_MASK_T exMask);
+ inline virtual ~LocDualContext() {}
+
+public:
+ static const char* mLBSLibName;
+ static const LOC_API_ADAPTER_EVENT_MASK_T mFgExclMask;
+ static const LOC_API_ADAPTER_EVENT_MASK_T mBgExclMask;
+ static const char* mLocationHalName;
+
+ static ContextBase* getLocFgContext(LocThread::tCreate tCreator, LocMsg* firstMsg,
+ const char* name, bool joinable = true);
+ inline static ContextBase* getLocFgContext(const char* name, bool joinable = true) {
+ return getLocFgContext(NULL, NULL, name, joinable);
+ }
+ static ContextBase* getLocBgContext(LocThread::tCreate tCreator, LocMsg* firstMsg,
+ const char* name, bool joinable = true);
+ inline static ContextBase* getLocBgContext(const char* name, bool joinable = true) {
+ return getLocBgContext(NULL, NULL, name, joinable);
+ }
+
+ static void injectFeatureConfig(ContextBase *context);
+};
+
+}
+
+#endif //__LOC_ENG_CONTEXT__
diff --git a/gps/core/Makefile.am b/gps/core/Makefile.am
new file mode 100644
index 0000000..568880c
--- /dev/null
+++ b/gps/core/Makefile.am
@@ -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
diff --git a/gps/core/SystemStatus.cpp b/gps/core/SystemStatus.cpp
new file mode 100644
index 0000000..dc03604
--- /dev/null
+++ b/gps/core/SystemStatus.cpp
@@ -0,0 +1,1716 @@
+/* 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 "LocSvc_SystemStatus"
+
+#include <inttypes.h>
+#include <string>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+#include <pthread.h>
+#include <platform_lib_log_util.h>
+#include <MsgTask.h>
+#include <loc_nmea.h>
+#include <SystemStatus.h>
+#include <SystemStatusOsObserver.h>
+
+namespace loc_core
+{
+
+/******************************************************************************
+ SystemStatusNmeaBase - base class for all NMEA parsers
+******************************************************************************/
+class SystemStatusNmeaBase
+{
+protected:
+ std::vector<std::string> mField;
+
+ SystemStatusNmeaBase(const char *str_in, uint32_t len_in)
+ {
+ // check size and talker
+ if (!loc_nmea_is_debug(str_in, len_in)) {
+ return;
+ }
+
+ std::string parser(str_in);
+ std::string::size_type index = 0;
+
+ // verify checksum field
+ index = parser.find("*");
+ if (index == std::string::npos) {
+ return;
+ }
+ parser[index] = ',';
+
+ // tokenize parser
+ while (1) {
+ std::string str;
+ index = parser.find(",");
+ if (index == std::string::npos) {
+ break;
+ }
+ str = parser.substr(0, index);
+ parser = parser.substr(index + 1);
+ mField.push_back(str);
+ }
+ }
+
+ virtual ~SystemStatusNmeaBase() { }
+
+public:
+ static const uint32_t NMEA_MINSIZE = DEBUG_NMEA_MINSIZE;
+ static const uint32_t NMEA_MAXSIZE = DEBUG_NMEA_MAXSIZE;
+};
+
+/******************************************************************************
+ SystemStatusPQWM1
+******************************************************************************/
+class SystemStatusPQWM1
+{
+public:
+ uint16_t mGpsWeek; // x1
+ uint32_t mGpsTowMs; // x2
+ uint8_t mTimeValid; // x3
+ uint8_t mTimeSource; // x4
+ int32_t mTimeUnc; // x5
+ int32_t mClockFreqBias; // x6
+ int32_t mClockFreqBiasUnc; // x7
+ uint8_t mXoState; // x8
+ int32_t mPgaGain; // x9
+ uint32_t mGpsBpAmpI; // xA
+ uint32_t mGpsBpAmpQ; // xB
+ uint32_t mAdcI; // xC
+ uint32_t mAdcQ; // xD
+ uint32_t mJammerGps; // xE
+ uint32_t mJammerGlo; // xF
+ uint32_t mJammerBds; // x10
+ uint32_t mJammerGal; // x11
+ uint32_t mRecErrorRecovery; // x12
+ double mAgcGps; // x13
+ double mAgcGlo; // x14
+ double mAgcBds; // x15
+ double mAgcGal; // x16
+ int32_t mLeapSeconds;// x17
+ int32_t mLeapSecUnc; // x18
+};
+
+// parser
+class SystemStatusPQWM1parser : public SystemStatusNmeaBase
+{
+private:
+ enum
+ {
+ eTalker = 0,
+ eGpsWeek = 1,
+ eGpsTowMs = 2,
+ eTimeValid = 3,
+ eTimeSource = 4,
+ eTimeUnc = 5,
+ eClockFreqBias = 6,
+ eClockFreqBiasUnc = 7,
+ eXoState = 8,
+ ePgaGain = 9,
+ eGpsBpAmpI = 10,
+ eGpsBpAmpQ = 11,
+ eAdcI = 12,
+ eAdcQ = 13,
+ eJammerGps = 14,
+ eJammerGlo = 15,
+ eJammerBds = 16,
+ eJammerGal = 17,
+ eRecErrorRecovery = 18,
+ eAgcGps = 19,
+ eAgcGlo = 20,
+ eAgcBds = 21,
+ eAgcGal = 22,
+ eLeapSeconds = 23,
+ eLeapSecUnc = 24,
+ eMax
+ };
+ SystemStatusPQWM1 mM1;
+
+public:
+ inline uint16_t getGpsWeek() { return mM1.mGpsWeek; }
+ inline uint32_t getGpsTowMs() { return mM1.mGpsTowMs; }
+ inline uint8_t getTimeValid() { return mM1.mTimeValid; }
+ inline uint8_t getTimeSource() { return mM1.mTimeSource; }
+ inline int32_t getTimeUnc() { return mM1.mTimeUnc; }
+ inline int32_t getClockFreqBias() { return mM1.mClockFreqBias; }
+ inline int32_t getClockFreqBiasUnc() { return mM1.mClockFreqBiasUnc; }
+ inline uint8_t getXoState() { return mM1.mXoState;}
+ inline int32_t getPgaGain() { return mM1.mPgaGain; }
+ inline uint32_t getGpsBpAmpI() { return mM1.mGpsBpAmpI; }
+ inline uint32_t getGpsBpAmpQ() { return mM1.mGpsBpAmpQ; }
+ inline uint32_t getAdcI() { return mM1.mAdcI; }
+ inline uint32_t getAdcQ() { return mM1.mAdcQ; }
+ inline uint32_t getJammerGps() { return mM1.mJammerGps; }
+ inline uint32_t getJammerGlo() { return mM1.mJammerGlo; }
+ inline uint32_t getJammerBds() { return mM1.mJammerBds; }
+ inline uint32_t getJammerGal() { return mM1.mJammerGal; }
+ inline uint32_t getAgcGps() { return mM1.mAgcGps; }
+ inline uint32_t getAgcGlo() { return mM1.mAgcGlo; }
+ inline uint32_t getAgcBds() { return mM1.mAgcBds; }
+ inline uint32_t getAgcGal() { return mM1.mAgcGal; }
+ inline uint32_t getRecErrorRecovery() { return mM1.mRecErrorRecovery; }
+ inline int32_t getLeapSeconds(){ return mM1.mLeapSeconds; }
+ inline int32_t getLeapSecUnc() { return mM1.mLeapSecUnc; }
+
+ SystemStatusPQWM1parser(const char *str_in, uint32_t len_in)
+ : SystemStatusNmeaBase(str_in, len_in)
+ {
+ memset(&mM1, 0, sizeof(mM1));
+ if (mField.size() < eMax) {
+ LOC_LOGE("PQWM1parser - invalid size=%zu", mField.size());
+ mM1.mTimeValid = 0;
+ return;
+ }
+ mM1.mGpsWeek = atoi(mField[eGpsWeek].c_str());
+ mM1.mGpsTowMs = atoi(mField[eGpsTowMs].c_str());
+ mM1.mTimeValid = atoi(mField[eTimeValid].c_str());
+ mM1.mTimeSource = atoi(mField[eTimeSource].c_str());
+ mM1.mTimeUnc = atoi(mField[eTimeUnc].c_str());
+ mM1.mClockFreqBias = atoi(mField[eClockFreqBias].c_str());
+ mM1.mClockFreqBiasUnc = atoi(mField[eClockFreqBiasUnc].c_str());
+ mM1.mXoState = atoi(mField[eXoState].c_str());
+ mM1.mPgaGain = atoi(mField[ePgaGain].c_str());
+ mM1.mGpsBpAmpI = atoi(mField[eGpsBpAmpI].c_str());
+ mM1.mGpsBpAmpQ = atoi(mField[eGpsBpAmpQ].c_str());
+ mM1.mAdcI = atoi(mField[eAdcI].c_str());
+ mM1.mAdcQ = atoi(mField[eAdcQ].c_str());
+ mM1.mJammerGps = atoi(mField[eJammerGps].c_str());
+ mM1.mJammerGlo = atoi(mField[eJammerGlo].c_str());
+ mM1.mJammerBds = atoi(mField[eJammerBds].c_str());
+ mM1.mJammerGal = atoi(mField[eJammerGal].c_str());
+ mM1.mRecErrorRecovery = atoi(mField[eRecErrorRecovery].c_str());
+ mM1.mAgcGps = atof(mField[eAgcGps].c_str());
+ mM1.mAgcGlo = atof(mField[eAgcGlo].c_str());
+ mM1.mAgcBds = atof(mField[eAgcBds].c_str());
+ mM1.mAgcGal = atof(mField[eAgcGal].c_str());
+ mM1.mLeapSeconds = atoi(mField[eLeapSeconds].c_str());
+ mM1.mLeapSecUnc = atoi(mField[eLeapSecUnc].c_str());
+ }
+
+ inline SystemStatusPQWM1& get() { return mM1;} //getparser
+};
+
+/******************************************************************************
+ SystemStatusPQWP1
+******************************************************************************/
+class SystemStatusPQWP1
+{
+public:
+ uint8_t mEpiValidity; // x4
+ float mEpiLat; // x5
+ float mEpiLon; // x6
+ float mEpiAlt; // x7
+ float mEpiHepe; // x8
+ float mEpiAltUnc; // x9
+ uint8_t mEpiSrc; // x10
+};
+
+class SystemStatusPQWP1parser : public SystemStatusNmeaBase
+{
+private:
+ enum
+ {
+ eTalker = 0,
+ eUtcTime = 1,
+ eEpiValidity = 2,
+ eEpiLat = 3,
+ eEpiLon = 4,
+ eEpiAlt = 5,
+ eEpiHepe = 6,
+ eEpiAltUnc = 7,
+ eEpiSrc = 8,
+ eMax
+ };
+ SystemStatusPQWP1 mP1;
+
+public:
+ inline uint8_t getEpiValidity() { return mP1.mEpiValidity; }
+ inline float getEpiLat() { return mP1.mEpiLat; }
+ inline float getEpiLon() { return mP1.mEpiLon; }
+ inline float getEpiAlt() { return mP1.mEpiAlt; }
+ inline float getEpiHepe() { return mP1.mEpiHepe; }
+ inline float getEpiAltUnc() { return mP1.mEpiAltUnc; }
+ inline uint8_t getEpiSrc() { return mP1.mEpiSrc; }
+
+ SystemStatusPQWP1parser(const char *str_in, uint32_t len_in)
+ : SystemStatusNmeaBase(str_in, len_in)
+ {
+ if (mField.size() < eMax) {
+ return;
+ }
+ memset(&mP1, 0, sizeof(mP1));
+ mP1.mEpiValidity = strtol(mField[eEpiValidity].c_str(), NULL, 16);
+ mP1.mEpiLat = atof(mField[eEpiLat].c_str());
+ mP1.mEpiLon = atof(mField[eEpiLon].c_str());
+ mP1.mEpiAlt = atof(mField[eEpiAlt].c_str());
+ mP1.mEpiHepe = atoi(mField[eEpiHepe].c_str());
+ mP1.mEpiAltUnc = atof(mField[eEpiAltUnc].c_str());
+ mP1.mEpiSrc = atoi(mField[eEpiSrc].c_str());
+ }
+
+ inline SystemStatusPQWP1& get() { return mP1;}
+};
+
+/******************************************************************************
+ SystemStatusPQWP2
+******************************************************************************/
+class SystemStatusPQWP2
+{
+public:
+ float mBestLat; // x4
+ float mBestLon; // x5
+ float mBestAlt; // x6
+ float mBestHepe; // x7
+ float mBestAltUnc; // x8
+};
+
+class SystemStatusPQWP2parser : public SystemStatusNmeaBase
+{
+private:
+ enum
+ {
+ eTalker = 0,
+ eUtcTime = 1,
+ eBestLat = 2,
+ eBestLon = 3,
+ eBestAlt = 4,
+ eBestHepe = 5,
+ eBestAltUnc = 6,
+ eMax
+ };
+ SystemStatusPQWP2 mP2;
+
+public:
+ inline float getBestLat() { return mP2.mBestLat; }
+ inline float getBestLon() { return mP2.mBestLon; }
+ inline float getBestAlt() { return mP2.mBestAlt; }
+ inline float getBestHepe() { return mP2.mBestHepe; }
+ inline float getBestAltUnc() { return mP2.mBestAltUnc; }
+
+ SystemStatusPQWP2parser(const char *str_in, uint32_t len_in)
+ : SystemStatusNmeaBase(str_in, len_in)
+ {
+ if (mField.size() < eMax) {
+ return;
+ }
+ memset(&mP2, 0, sizeof(mP2));
+ mP2.mBestLat = atof(mField[eBestLat].c_str());
+ mP2.mBestLon = atof(mField[eBestLon].c_str());
+ mP2.mBestAlt = atof(mField[eBestAlt].c_str());
+ mP2.mBestHepe = atof(mField[eBestHepe].c_str());
+ mP2.mBestAltUnc = atof(mField[eBestAltUnc].c_str());
+ }
+
+ inline SystemStatusPQWP2& get() { return mP2;}
+};
+
+/******************************************************************************
+ SystemStatusPQWP3
+******************************************************************************/
+class SystemStatusPQWP3
+{
+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;
+};
+
+class SystemStatusPQWP3parser : public SystemStatusNmeaBase
+{
+private:
+ enum
+ {
+ eTalker = 0,
+ eUtcTime = 1,
+ eXtraValidMask = 2,
+ eGpsXtraAge = 3,
+ eGloXtraAge = 4,
+ eBdsXtraAge = 5,
+ eGalXtraAge = 6,
+ eQzssXtraAge = 7,
+ eGpsXtraValid = 8,
+ eGloXtraValid = 9,
+ eBdsXtraValid = 10,
+ eGalXtraValid = 11,
+ eQzssXtraValid = 12,
+ eMax
+ };
+ SystemStatusPQWP3 mP3;
+
+public:
+ inline uint8_t getXtraValid() { return mP3.mXtraValidMask; }
+ inline uint32_t getGpsXtraAge() { return mP3.mGpsXtraAge; }
+ inline uint32_t getGloXtraAge() { return mP3.mGloXtraAge; }
+ inline uint32_t getBdsXtraAge() { return mP3.mBdsXtraAge; }
+ inline uint32_t getGalXtraAge() { return mP3.mGalXtraAge; }
+ inline uint32_t getQzssXtraAge() { return mP3.mQzssXtraAge; }
+ inline uint32_t getGpsXtraValid() { return mP3.mGpsXtraValid; }
+ inline uint32_t getGloXtraValid() { return mP3.mGloXtraValid; }
+ inline uint64_t getBdsXtraValid() { return mP3.mBdsXtraValid; }
+ inline uint64_t getGalXtraValid() { return mP3.mGalXtraValid; }
+ inline uint8_t getQzssXtraValid() { return mP3.mQzssXtraValid; }
+
+ SystemStatusPQWP3parser(const char *str_in, uint32_t len_in)
+ : SystemStatusNmeaBase(str_in, len_in)
+ {
+ if (mField.size() < eMax) {
+ return;
+ }
+ memset(&mP3, 0, sizeof(mP3));
+ mP3.mXtraValidMask = strtol(mField[eXtraValidMask].c_str(), NULL, 16);
+ mP3.mGpsXtraAge = atoi(mField[eGpsXtraAge].c_str());
+ mP3.mGloXtraAge = atoi(mField[eGloXtraAge].c_str());
+ mP3.mBdsXtraAge = atoi(mField[eBdsXtraAge].c_str());
+ mP3.mGalXtraAge = atoi(mField[eGalXtraAge].c_str());
+ mP3.mQzssXtraAge = atoi(mField[eQzssXtraAge].c_str());
+ mP3.mGpsXtraValid = strtol(mField[eGpsXtraValid].c_str(), NULL, 16);
+ mP3.mGloXtraValid = strtol(mField[eGloXtraValid].c_str(), NULL, 16);
+ mP3.mBdsXtraValid = strtol(mField[eBdsXtraValid].c_str(), NULL, 16);
+ mP3.mGalXtraValid = strtol(mField[eGalXtraValid].c_str(), NULL, 16);
+ mP3.mQzssXtraValid = strtol(mField[eQzssXtraValid].c_str(), NULL, 16);
+ }
+
+ inline SystemStatusPQWP3& get() { return mP3;}
+};
+
+/******************************************************************************
+ SystemStatusPQWP4
+******************************************************************************/
+class SystemStatusPQWP4
+{
+public:
+ uint32_t mGpsEpheValid;
+ uint32_t mGloEpheValid;
+ uint64_t mBdsEpheValid;
+ uint64_t mGalEpheValid;
+ uint8_t mQzssEpheValid;
+};
+
+class SystemStatusPQWP4parser : public SystemStatusNmeaBase
+{
+private:
+ enum
+ {
+ eTalker = 0,
+ eUtcTime = 1,
+ eGpsEpheValid = 2,
+ eGloEpheValid = 3,
+ eBdsEpheValid = 4,
+ eGalEpheValid = 5,
+ eQzssEpheValid = 6,
+ eMax
+ };
+ SystemStatusPQWP4 mP4;
+
+public:
+ inline uint32_t getGpsEpheValid() { return mP4.mGpsEpheValid; }
+ inline uint32_t getGloEpheValid() { return mP4.mGloEpheValid; }
+ inline uint64_t getBdsEpheValid() { return mP4.mBdsEpheValid; }
+ inline uint64_t getGalEpheValid() { return mP4.mGalEpheValid; }
+ inline uint8_t getQzssEpheValid() { return mP4.mQzssEpheValid; }
+
+ SystemStatusPQWP4parser(const char *str_in, uint32_t len_in)
+ : SystemStatusNmeaBase(str_in, len_in)
+ {
+ if (mField.size() < eMax) {
+ return;
+ }
+ memset(&mP4, 0, sizeof(mP4));
+ mP4.mGpsEpheValid = strtol(mField[eGpsEpheValid].c_str(), NULL, 16);
+ mP4.mGloEpheValid = strtol(mField[eGloEpheValid].c_str(), NULL, 16);
+ mP4.mBdsEpheValid = strtol(mField[eBdsEpheValid].c_str(), NULL, 16);
+ mP4.mGalEpheValid = strtol(mField[eGalEpheValid].c_str(), NULL, 16);
+ mP4.mQzssEpheValid = strtol(mField[eQzssEpheValid].c_str(), NULL, 16);
+ }
+
+ inline SystemStatusPQWP4& get() { return mP4;}
+};
+
+/******************************************************************************
+ SystemStatusPQWP5
+******************************************************************************/
+class SystemStatusPQWP5
+{
+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;
+};
+
+class SystemStatusPQWP5parser : public SystemStatusNmeaBase
+{
+private:
+ enum
+ {
+ eTalker = 0,
+ eUtcTime = 1,
+ eGpsUnknownMask = 2,
+ eGloUnknownMask = 3,
+ eBdsUnknownMask = 4,
+ eGalUnknownMask = 5,
+ eQzssUnknownMask = 6,
+ eGpsGoodMask = 7,
+ eGloGoodMask = 8,
+ eBdsGoodMask = 9,
+ eGalGoodMask = 10,
+ eQzssGoodMask = 11,
+ eGpsBadMask = 12,
+ eGloBadMask = 13,
+ eBdsBadMask = 14,
+ eGalBadMask = 15,
+ eQzssBadMask = 16,
+ eMax
+ };
+ SystemStatusPQWP5 mP5;
+
+public:
+ inline uint32_t getGpsUnknownMask() { return mP5.mGpsUnknownMask; }
+ inline uint32_t getGloUnknownMask() { return mP5.mGloUnknownMask; }
+ inline uint64_t getBdsUnknownMask() { return mP5.mBdsUnknownMask; }
+ inline uint64_t getGalUnknownMask() { return mP5.mGalUnknownMask; }
+ inline uint8_t getQzssUnknownMask() { return mP5.mQzssUnknownMask; }
+ inline uint32_t getGpsGoodMask() { return mP5.mGpsGoodMask; }
+ inline uint32_t getGloGoodMask() { return mP5.mGloGoodMask; }
+ inline uint64_t getBdsGoodMask() { return mP5.mBdsGoodMask; }
+ inline uint64_t getGalGoodMask() { return mP5.mGalGoodMask; }
+ inline uint8_t getQzssGoodMask() { return mP5.mQzssGoodMask; }
+ inline uint32_t getGpsBadMask() { return mP5.mGpsBadMask; }
+ inline uint32_t getGloBadMask() { return mP5.mGloBadMask; }
+ inline uint64_t getBdsBadMask() { return mP5.mBdsBadMask; }
+ inline uint64_t getGalBadMask() { return mP5.mGalBadMask; }
+ inline uint8_t getQzssBadMask() { return mP5.mQzssBadMask; }
+
+ SystemStatusPQWP5parser(const char *str_in, uint32_t len_in)
+ : SystemStatusNmeaBase(str_in, len_in)
+ {
+ if (mField.size() < eMax) {
+ return;
+ }
+ memset(&mP5, 0, sizeof(mP5));
+ mP5.mGpsUnknownMask = strtol(mField[eGpsUnknownMask].c_str(), NULL, 16);
+ mP5.mGloUnknownMask = strtol(mField[eGloUnknownMask].c_str(), NULL, 16);
+ mP5.mBdsUnknownMask = strtol(mField[eBdsUnknownMask].c_str(), NULL, 16);
+ mP5.mGalUnknownMask = strtol(mField[eGalUnknownMask].c_str(), NULL, 16);
+ mP5.mQzssUnknownMask = strtol(mField[eQzssUnknownMask].c_str(), NULL, 16);
+ mP5.mGpsGoodMask = strtol(mField[eGpsGoodMask].c_str(), NULL, 16);
+ mP5.mGloGoodMask = strtol(mField[eGloGoodMask].c_str(), NULL, 16);
+ mP5.mBdsGoodMask = strtol(mField[eBdsGoodMask].c_str(), NULL, 16);
+ mP5.mGalGoodMask = strtol(mField[eGalGoodMask].c_str(), NULL, 16);
+ mP5.mQzssGoodMask = strtol(mField[eQzssGoodMask].c_str(), NULL, 16);
+ mP5.mGpsBadMask = strtol(mField[eGpsBadMask].c_str(), NULL, 16);
+ mP5.mGloBadMask = strtol(mField[eGloBadMask].c_str(), NULL, 16);
+ mP5.mBdsBadMask = strtol(mField[eBdsBadMask].c_str(), NULL, 16);
+ mP5.mGalBadMask = strtol(mField[eGalBadMask].c_str(), NULL, 16);
+ mP5.mQzssBadMask = strtol(mField[eQzssBadMask].c_str(), NULL, 16);
+ }
+
+ inline SystemStatusPQWP5& get() { return mP5;}
+};
+
+/******************************************************************************
+ SystemStatusPQWP6parser
+******************************************************************************/
+class SystemStatusPQWP6
+{
+public:
+ uint32_t mFixInfoMask;
+};
+
+class SystemStatusPQWP6parser : public SystemStatusNmeaBase
+{
+private:
+ enum
+ {
+ eTalker = 0,
+ eUtcTime = 1,
+ eFixInfoMask = 2,
+ eMax
+ };
+ SystemStatusPQWP6 mP6;
+
+public:
+ inline uint32_t getFixInfoMask() { return mP6.mFixInfoMask; }
+
+ SystemStatusPQWP6parser(const char *str_in, uint32_t len_in)
+ : SystemStatusNmeaBase(str_in, len_in)
+ {
+ if (mField.size() < eMax) {
+ return;
+ }
+ memset(&mP6, 0, sizeof(mP6));
+ mP6.mFixInfoMask = strtol(mField[eFixInfoMask].c_str(), NULL, 16);
+ }
+
+ inline SystemStatusPQWP6& get() { return mP6;}
+};
+
+/******************************************************************************
+ SystemStatusPQWP7parser
+******************************************************************************/
+class SystemStatusPQWP7
+{
+public:
+ SystemStatusNav mNav[SV_ALL_NUM];
+};
+
+class SystemStatusPQWP7parser : public SystemStatusNmeaBase
+{
+private:
+ enum
+ {
+ eTalker = 0,
+ eUtcTime = 1,
+ eMax = 2 + SV_ALL_NUM*3
+ };
+ SystemStatusPQWP7 mP7;
+
+public:
+ SystemStatusPQWP7parser(const char *str_in, uint32_t len_in)
+ : SystemStatusNmeaBase(str_in, len_in)
+ {
+ if (mField.size() < eMax) {
+ LOC_LOGE("PQWP7parser - invalid size=%zu", mField.size());
+ return;
+ }
+ for (uint32_t i=0; i<SV_ALL_NUM; i++) {
+ mP7.mNav[i].mType = GnssEphemerisType(atoi(mField[i*3+2].c_str()));
+ mP7.mNav[i].mSource = GnssEphemerisSource(atoi(mField[i*3+3].c_str()));
+ mP7.mNav[i].mAgeSec = atoi(mField[i*3+4].c_str());
+ }
+ }
+
+ inline SystemStatusPQWP7& get() { return mP7;}
+};
+
+/******************************************************************************
+ SystemStatusPQWS1parser
+******************************************************************************/
+class SystemStatusPQWS1
+{
+public:
+ uint32_t mFixInfoMask;
+ uint32_t mHepeLimit;
+};
+
+class SystemStatusPQWS1parser : public SystemStatusNmeaBase
+{
+private:
+ enum
+ {
+ eTalker = 0,
+ eUtcTime = 1,
+ eFixInfoMask = 2,
+ eHepeLimit = 3,
+ eMax
+ };
+ SystemStatusPQWS1 mS1;
+
+public:
+ inline uint16_t getFixInfoMask() { return mS1.mFixInfoMask; }
+ inline uint32_t getHepeLimit() { return mS1.mHepeLimit; }
+
+ SystemStatusPQWS1parser(const char *str_in, uint32_t len_in)
+ : SystemStatusNmeaBase(str_in, len_in)
+ {
+ if (mField.size() < eMax) {
+ return;
+ }
+ memset(&mS1, 0, sizeof(mS1));
+ mS1.mFixInfoMask = atoi(mField[eFixInfoMask].c_str());
+ mS1.mHepeLimit = atoi(mField[eHepeLimit].c_str());
+ }
+
+ inline SystemStatusPQWS1& get() { return mS1;}
+};
+
+/******************************************************************************
+ SystemStatusTimeAndClock
+******************************************************************************/
+SystemStatusTimeAndClock::SystemStatusTimeAndClock(const SystemStatusPQWM1& nmea) :
+ mGpsWeek(nmea.mGpsWeek),
+ mGpsTowMs(nmea.mGpsTowMs),
+ mTimeValid(nmea.mTimeValid),
+ mTimeSource(nmea.mTimeSource),
+ mTimeUnc(nmea.mTimeUnc),
+ mClockFreqBias(nmea.mClockFreqBias),
+ mClockFreqBiasUnc(nmea.mClockFreqBiasUnc),
+ mLeapSeconds(nmea.mLeapSeconds),
+ mLeapSecUnc(nmea.mLeapSecUnc)
+{
+}
+
+bool SystemStatusTimeAndClock::equals(SystemStatusTimeAndClock& peer)
+{
+ if ((mGpsWeek != peer.mGpsWeek) ||
+ (mGpsTowMs != peer.mGpsTowMs) ||
+ (mTimeValid != peer.mTimeValid) ||
+ (mTimeSource != peer.mTimeSource) ||
+ (mTimeUnc != peer.mTimeUnc) ||
+ (mClockFreqBias != peer.mClockFreqBias) ||
+ (mClockFreqBiasUnc != peer.mClockFreqBiasUnc) ||
+ (mLeapSeconds != peer.mLeapSeconds) ||
+ (mLeapSecUnc != peer.mLeapSecUnc)) {
+ return false;
+ }
+ return true;
+}
+
+void SystemStatusTimeAndClock::dump()
+{
+ LOC_LOGV("TimeAndClock: u=%ld:%ld g=%d:%d v=%d ts=%d tu=%d b=%d bu=%d ls=%d lu=%d",
+ mUtcTime.tv_sec, mUtcTime.tv_nsec,
+ mGpsWeek,
+ mGpsTowMs,
+ mTimeValid,
+ mTimeSource,
+ mTimeUnc,
+ mClockFreqBias,
+ mClockFreqBiasUnc,
+ mLeapSeconds,
+ mLeapSecUnc);
+ return;
+}
+
+/******************************************************************************
+ SystemStatusXoState
+******************************************************************************/
+SystemStatusXoState::SystemStatusXoState(const SystemStatusPQWM1& nmea) :
+ mXoState(nmea.mXoState)
+{
+}
+
+bool SystemStatusXoState::equals(SystemStatusXoState& peer)
+{
+ if (mXoState != peer.mXoState) {
+ return false;
+ }
+ return true;
+}
+
+void SystemStatusXoState::dump()
+{
+ LOC_LOGV("XoState: u=%ld:%ld x=%d",
+ mUtcTime.tv_sec, mUtcTime.tv_nsec,
+ mXoState);
+ return;
+}
+
+/******************************************************************************
+ SystemStatusRfAndParams
+******************************************************************************/
+SystemStatusRfAndParams::SystemStatusRfAndParams(const SystemStatusPQWM1& nmea) :
+ mPgaGain(nmea.mPgaGain),
+ mGpsBpAmpI(nmea.mGpsBpAmpI),
+ mGpsBpAmpQ(nmea.mGpsBpAmpQ),
+ mAdcI(nmea.mAdcI),
+ mAdcQ(nmea.mAdcQ),
+ mJammerGps(nmea.mJammerGps),
+ mJammerGlo(nmea.mJammerGlo),
+ mJammerBds(nmea.mJammerBds),
+ mJammerGal(nmea.mJammerGal),
+ mAgcGps(nmea.mAgcGps),
+ mAgcGlo(nmea.mAgcGlo),
+ mAgcBds(nmea.mAgcBds),
+ mAgcGal(nmea.mAgcGal)
+{
+}
+
+bool SystemStatusRfAndParams::equals(SystemStatusRfAndParams& peer)
+{
+ if ((mPgaGain != peer.mPgaGain) ||
+ (mGpsBpAmpI != peer.mGpsBpAmpI) ||
+ (mGpsBpAmpQ != peer.mGpsBpAmpQ) ||
+ (mAdcI != peer.mAdcI) ||
+ (mAdcQ != peer.mAdcQ) ||
+ (mJammerGps != peer.mJammerGps) ||
+ (mJammerGlo != peer.mJammerGlo) ||
+ (mJammerBds != peer.mJammerBds) ||
+ (mJammerGal != peer.mJammerGal) ||
+ (mAgcGps != peer.mAgcGps) ||
+ (mAgcGlo != peer.mAgcGlo) ||
+ (mAgcBds != peer.mAgcBds) ||
+ (mAgcGal != peer.mAgcGal)) {
+ return false;
+ }
+ return true;
+}
+
+void SystemStatusRfAndParams::dump()
+{
+ LOC_LOGV("RfAndParams: u=%ld:%ld p=%d bi=%d bq=%d ai=%d aq=%d "
+ "jgp=%d jgl=%d jbd=%d jga=%d "
+ "agp=%lf agl=%lf abd=%lf aga=%lf",
+ mUtcTime.tv_sec, mUtcTime.tv_nsec,
+ mPgaGain,
+ mGpsBpAmpI,
+ mGpsBpAmpQ,
+ mAdcI,
+ mAdcQ,
+ mJammerGps,
+ mJammerGlo,
+ mJammerBds,
+ mJammerGal,
+ mAgcGps,
+ mAgcGlo,
+ mAgcBds,
+ mAgcGal);
+ return;
+}
+
+/******************************************************************************
+ SystemStatusErrRecovery
+******************************************************************************/
+SystemStatusErrRecovery::SystemStatusErrRecovery(const SystemStatusPQWM1& nmea) :
+ mRecErrorRecovery(nmea.mRecErrorRecovery)
+{
+}
+
+bool SystemStatusErrRecovery::equals(SystemStatusErrRecovery& peer)
+{
+ if (mRecErrorRecovery != peer.mRecErrorRecovery) {
+ return false;
+ }
+ return true;
+}
+
+void SystemStatusErrRecovery::dump()
+{
+ LOC_LOGV("ErrRecovery: u=%ld:%ld e=%d",
+ mUtcTime.tv_sec, mUtcTime.tv_nsec,
+ mRecErrorRecovery);
+ return;
+}
+
+/******************************************************************************
+ SystemStatusInjectedPosition
+******************************************************************************/
+SystemStatusInjectedPosition::SystemStatusInjectedPosition(const SystemStatusPQWP1& nmea) :
+ mEpiValidity(nmea.mEpiValidity),
+ mEpiLat(nmea.mEpiLat),
+ mEpiLon(nmea.mEpiLon),
+ mEpiAlt(nmea.mEpiAlt),
+ mEpiHepe(nmea.mEpiHepe),
+ mEpiAltUnc(nmea.mEpiAltUnc),
+ mEpiSrc(nmea.mEpiSrc)
+{
+}
+
+bool SystemStatusInjectedPosition::equals(SystemStatusInjectedPosition& peer)
+{
+ if ((mEpiValidity != peer.mEpiValidity) ||
+ (mEpiLat != peer.mEpiLat) ||
+ (mEpiLon != peer.mEpiLon) ||
+ (mEpiAlt != peer.mEpiAlt) ||
+ (mEpiHepe != peer.mEpiHepe) ||
+ (mEpiAltUnc != peer.mEpiAltUnc) ||
+ (mEpiSrc != peer.mEpiSrc)) {
+ return false;
+ }
+ return true;
+}
+
+void SystemStatusInjectedPosition::dump()
+{
+ LOC_LOGV("InjectedPosition: u=%ld:%ld v=%x la=%f lo=%f al=%f he=%f au=%f es=%d",
+ mUtcTime.tv_sec, mUtcTime.tv_nsec,
+ mEpiValidity,
+ mEpiLat,
+ mEpiLon,
+ mEpiAlt,
+ mEpiHepe,
+ mEpiAltUnc,
+ mEpiSrc);
+ return;
+}
+
+/******************************************************************************
+ SystemStatusBestPosition
+******************************************************************************/
+SystemStatusBestPosition::SystemStatusBestPosition(const SystemStatusPQWP2& nmea) :
+ mValid(true),
+ mBestLat(nmea.mBestLat),
+ mBestLon(nmea.mBestLon),
+ mBestAlt(nmea.mBestAlt),
+ mBestHepe(nmea.mBestHepe),
+ mBestAltUnc(nmea.mBestAltUnc)
+{
+}
+
+bool SystemStatusBestPosition::equals(SystemStatusBestPosition& peer)
+{
+ if ((mBestLat != peer.mBestLat) ||
+ (mBestLon != peer.mBestLon) ||
+ (mBestAlt != peer.mBestAlt) ||
+ (mBestHepe != peer.mBestHepe) ||
+ (mBestAltUnc != peer.mBestAltUnc)) {
+ return false;
+ }
+ return true;
+}
+
+void SystemStatusBestPosition::dump()
+{
+ LOC_LOGV("BestPosition: u=%ld:%ld la=%f lo=%f al=%f he=%f au=%f",
+ mUtcTime.tv_sec, mUtcTime.tv_nsec,
+ mBestLat,
+ mBestLon,
+ mBestAlt,
+ mBestHepe,
+ mBestAltUnc);
+ return;
+}
+
+/******************************************************************************
+ SystemStatusXtra
+******************************************************************************/
+SystemStatusXtra::SystemStatusXtra(const SystemStatusPQWP3& nmea) :
+ mXtraValidMask(nmea.mXtraValidMask),
+ mGpsXtraAge(nmea.mGpsXtraAge),
+ mGloXtraAge(nmea.mGloXtraAge),
+ mBdsXtraAge(nmea.mBdsXtraAge),
+ mGalXtraAge(nmea.mGalXtraAge),
+ mQzssXtraAge(nmea.mQzssXtraAge),
+ mGpsXtraValid(nmea.mGpsXtraValid),
+ mGloXtraValid(nmea.mGloXtraValid),
+ mBdsXtraValid(nmea.mBdsXtraValid),
+ mGalXtraValid(nmea.mGalXtraValid),
+ mQzssXtraValid(nmea.mQzssXtraValid)
+{
+}
+
+bool SystemStatusXtra::equals(SystemStatusXtra& peer)
+{
+ if ((mXtraValidMask != peer.mXtraValidMask) ||
+ (mGpsXtraAge != peer.mGpsXtraAge) ||
+ (mGloXtraAge != peer.mGloXtraAge) ||
+ (mBdsXtraAge != peer.mBdsXtraAge) ||
+ (mGalXtraAge != peer.mGalXtraAge) ||
+ (mQzssXtraAge != peer.mQzssXtraAge) ||
+ (mGpsXtraValid != peer.mGpsXtraValid) ||
+ (mGloXtraValid != peer.mGloXtraValid) ||
+ (mBdsXtraValid != peer.mBdsXtraValid) ||
+ (mGalXtraValid != peer.mGalXtraValid) ||
+ (mQzssXtraValid != peer.mQzssXtraValid)) {
+ return false;
+ }
+ return true;
+}
+
+void SystemStatusXtra::dump()
+{
+ LOC_LOGV("SystemStatusXtra: u=%ld:%ld m=%x a=%d:%d:%d:%d:%d v=%x:%x:%" PRIx64 ":%" PRIx64":%x",
+ mUtcTime.tv_sec, mUtcTime.tv_nsec,
+ mXtraValidMask,
+ mGpsXtraAge,
+ mGloXtraAge,
+ mBdsXtraAge,
+ mGalXtraAge,
+ mQzssXtraAge,
+ mGpsXtraValid,
+ mGloXtraValid,
+ mBdsXtraValid,
+ mGalXtraValid,
+ mQzssXtraValid);
+ return;
+}
+
+/******************************************************************************
+ SystemStatusEphemeris
+******************************************************************************/
+SystemStatusEphemeris::SystemStatusEphemeris(const SystemStatusPQWP4& nmea) :
+ mGpsEpheValid(nmea.mGpsEpheValid),
+ mGloEpheValid(nmea.mGloEpheValid),
+ mBdsEpheValid(nmea.mBdsEpheValid),
+ mGalEpheValid(nmea.mGalEpheValid),
+ mQzssEpheValid(nmea.mQzssEpheValid)
+{
+}
+
+bool SystemStatusEphemeris::equals(SystemStatusEphemeris& peer)
+{
+ if ((mGpsEpheValid != peer.mGpsEpheValid) ||
+ (mGloEpheValid != peer.mGloEpheValid) ||
+ (mBdsEpheValid != peer.mBdsEpheValid) ||
+ (mGalEpheValid != peer.mGalEpheValid) ||
+ (mQzssEpheValid != peer.mQzssEpheValid)) {
+ return false;
+ }
+ return true;
+}
+
+void SystemStatusEphemeris::dump()
+{
+ LOC_LOGV("Ephemeris: u=%ld:%ld ev=%x:%x:%" PRIx64 ":%" PRIx64 ":%x",
+ mUtcTime.tv_sec, mUtcTime.tv_nsec,
+ mGpsEpheValid,
+ mGloEpheValid,
+ mBdsEpheValid,
+ mGalEpheValid,
+ mQzssEpheValid);
+ return;
+}
+
+/******************************************************************************
+ SystemStatusSvHealth
+******************************************************************************/
+SystemStatusSvHealth::SystemStatusSvHealth(const SystemStatusPQWP5& nmea) :
+ mGpsUnknownMask(nmea.mGpsUnknownMask),
+ mGloUnknownMask(nmea.mGloUnknownMask),
+ mBdsUnknownMask(nmea.mBdsUnknownMask),
+ mGalUnknownMask(nmea.mGalUnknownMask),
+ mQzssUnknownMask(nmea.mQzssUnknownMask),
+ mGpsGoodMask(nmea.mGpsGoodMask),
+ mGloGoodMask(nmea.mGloGoodMask),
+ mBdsGoodMask(nmea.mBdsGoodMask),
+ mGalGoodMask(nmea.mGalGoodMask),
+ mQzssGoodMask(nmea.mQzssGoodMask),
+ mGpsBadMask(nmea.mGpsBadMask),
+ mGloBadMask(nmea.mGloBadMask),
+ mBdsBadMask(nmea.mBdsBadMask),
+ mGalBadMask(nmea.mGalBadMask),
+ mQzssBadMask(nmea.mQzssBadMask)
+{
+}
+
+bool SystemStatusSvHealth::equals(SystemStatusSvHealth& peer)
+{
+ if ((mGpsUnknownMask != peer.mGpsUnknownMask) ||
+ (mGloUnknownMask != peer.mGloUnknownMask) ||
+ (mBdsUnknownMask != peer.mBdsUnknownMask) ||
+ (mGalUnknownMask != peer.mGalUnknownMask) ||
+ (mQzssUnknownMask != peer.mQzssUnknownMask) ||
+ (mGpsGoodMask != peer.mGpsGoodMask) ||
+ (mGloGoodMask != peer.mGloGoodMask) ||
+ (mBdsGoodMask != peer.mBdsGoodMask) ||
+ (mGalGoodMask != peer.mGalGoodMask) ||
+ (mQzssGoodMask != peer.mQzssGoodMask) ||
+ (mGpsBadMask != peer.mGpsBadMask) ||
+ (mGloBadMask != peer.mGloBadMask) ||
+ (mBdsBadMask != peer.mBdsBadMask) ||
+ (mGalBadMask != peer.mGalBadMask) ||
+ (mQzssBadMask != peer.mQzssBadMask)) {
+ return false;
+ }
+ return true;
+}
+
+void SystemStatusSvHealth::dump()
+{
+ LOC_LOGV("SvHealth: u=%ld:%ld \
+ u=%x:%x:%" PRIx64 ":%" PRIx64 ":%x \
+ g=%x:%x:%" PRIx64 ":%" PRIx64 ":%x \
+ b=%x:%x:%" PRIx64 ":%" PRIx64 ":%x",
+ mUtcTime.tv_sec, mUtcTime.tv_nsec,
+ mGpsUnknownMask,
+ mGloUnknownMask,
+ mBdsUnknownMask,
+ mGalUnknownMask,
+ mQzssUnknownMask,
+ mGpsGoodMask,
+ mGloGoodMask,
+ mBdsGoodMask,
+ mGalGoodMask,
+ mQzssGoodMask,
+ mGpsBadMask,
+ mGloBadMask,
+ mBdsBadMask,
+ mGalBadMask,
+ mQzssBadMask);
+ return;
+}
+
+/******************************************************************************
+ SystemStatusPdr
+******************************************************************************/
+SystemStatusPdr::SystemStatusPdr(const SystemStatusPQWP6& nmea) :
+ mFixInfoMask(nmea.mFixInfoMask)
+{
+}
+
+bool SystemStatusPdr::equals(SystemStatusPdr& peer)
+{
+ if (mFixInfoMask != peer.mFixInfoMask) {
+ return false;
+ }
+ return true;
+}
+
+void SystemStatusPdr::dump()
+{
+ LOC_LOGV("Pdr: u=%ld:%ld m=%x",
+ mUtcTime.tv_sec, mUtcTime.tv_nsec,
+ mFixInfoMask);
+ return;
+}
+
+/******************************************************************************
+ SystemStatusNavData
+******************************************************************************/
+SystemStatusNavData::SystemStatusNavData(const SystemStatusPQWP7& nmea)
+{
+ for (uint32_t i=0; i<SV_ALL_NUM; i++) {
+ mNav[i] = nmea.mNav[i];
+ }
+}
+
+bool SystemStatusNavData::equals(SystemStatusNavData& peer)
+{
+ for (uint32_t i=0; i<SV_ALL_NUM; i++) {
+ if ((mNav[i].mType != peer.mNav[i].mType) ||
+ (mNav[i].mSource != peer.mNav[i].mSource) ||
+ (mNav[i].mAgeSec != peer.mNav[i].mAgeSec)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+void SystemStatusNavData::dump()
+{
+ LOC_LOGV("NavData: u=%ld:%ld",
+ mUtcTime.tv_sec, mUtcTime.tv_nsec);
+ for (uint32_t i=0; i<SV_ALL_NUM; i++) {
+ LOC_LOGV("i=%d type=%d src=%d age=%d",
+ i, mNav[i].mType, mNav[i].mSource, mNav[i].mAgeSec);
+ }
+ return;
+}
+
+/******************************************************************************
+ SystemStatusPositionFailure
+******************************************************************************/
+SystemStatusPositionFailure::SystemStatusPositionFailure(const SystemStatusPQWS1& nmea) :
+ mFixInfoMask(nmea.mFixInfoMask),
+ mHepeLimit(nmea.mHepeLimit)
+{
+}
+
+bool SystemStatusPositionFailure::equals(SystemStatusPositionFailure& peer)
+{
+ if ((mFixInfoMask != peer.mFixInfoMask) ||
+ (mHepeLimit != peer.mHepeLimit)) {
+ return false;
+ }
+ return true;
+}
+
+void SystemStatusPositionFailure::dump()
+{
+ LOC_LOGV("PositionFailure: u=%ld:%ld m=%d h=%d",
+ mUtcTime.tv_sec, mUtcTime.tv_nsec,
+ mFixInfoMask,
+ mHepeLimit);
+ return;
+}
+
+/******************************************************************************
+ SystemStatusLocation
+******************************************************************************/
+bool SystemStatusLocation::equals(SystemStatusLocation& peer)
+{
+ if ((mLocation.gpsLocation.latitude != peer.mLocation.gpsLocation.latitude) ||
+ (mLocation.gpsLocation.longitude != peer.mLocation.gpsLocation.longitude) ||
+ (mLocation.gpsLocation.altitude != peer.mLocation.gpsLocation.altitude)) {
+ return false;
+ }
+ return true;
+}
+
+void SystemStatusLocation::dump()
+{
+ LOC_LOGV("Location: lat=%f lon=%f alt=%f spd=%f",
+ mLocation.gpsLocation.latitude,
+ mLocation.gpsLocation.longitude,
+ mLocation.gpsLocation.altitude,
+ mLocation.gpsLocation.speed);
+ return;
+}
+
+/******************************************************************************
+ SystemStatus
+******************************************************************************/
+pthread_mutex_t SystemStatus::mMutexSystemStatus = PTHREAD_MUTEX_INITIALIZER;
+SystemStatus* SystemStatus::mInstance = NULL;
+
+SystemStatus* SystemStatus::getInstance(const MsgTask* msgTask)
+{
+ pthread_mutex_lock(&mMutexSystemStatus);
+
+ if (!mInstance) {
+ // Instantiating for the first time. msgTask should not be NULL
+ if (msgTask == NULL) {
+ LOC_LOGE("SystemStatus: msgTask is NULL!!");
+ pthread_mutex_unlock(&mMutexSystemStatus);
+ return NULL;
+ }
+ mInstance = new (nothrow) SystemStatus(msgTask);
+ LOC_LOGD("SystemStatus::getInstance:%p. Msgtask:%p", mInstance, msgTask);
+ }
+
+ pthread_mutex_unlock(&mMutexSystemStatus);
+ return mInstance;
+}
+
+void SystemStatus::destroyInstance()
+{
+ delete mInstance;
+ mInstance = NULL;
+}
+
+IOsObserver* SystemStatus::getOsObserver()
+{
+ return &mSysStatusObsvr;
+}
+
+SystemStatus::SystemStatus(const MsgTask* msgTask) :
+ mSysStatusObsvr(msgTask)
+{
+ int result = 0;
+ ENTRY_LOG ();
+ mCache.mLocation.clear();
+
+ mCache.mTimeAndClock.clear();
+ mCache.mXoState.clear();
+ mCache.mRfAndParams.clear();
+ mCache.mErrRecovery.clear();
+
+ mCache.mInjectedPosition.clear();
+ mCache.mBestPosition.clear();
+ mCache.mXtra.clear();
+ mCache.mEphemeris.clear();
+ mCache.mSvHealth.clear();
+ mCache.mPdr.clear();
+ mCache.mNavData.clear();
+
+ mCache.mPositionFailure.clear();
+
+ EXIT_LOG_WITH_ERROR ("%d",result);
+}
+
+/******************************************************************************
+ SystemStatus - M1 functions
+******************************************************************************/
+bool SystemStatus::setTimeAndCLock(const SystemStatusPQWM1& nmea)
+{
+ SystemStatusTimeAndClock s(nmea);
+ if (!mCache.mTimeAndClock.empty() && mCache.mTimeAndClock.back().equals(s)) {
+ mCache.mTimeAndClock.back().mUtcReported = s.mUtcReported;
+ } else {
+ mCache.mTimeAndClock.push_back(s);
+ if (mCache.mTimeAndClock.size() > maxTimeAndClock) {
+ mCache.mTimeAndClock.erase(mCache.mTimeAndClock.begin());
+ }
+ }
+ return true;
+}
+
+bool SystemStatus::setXoState(const SystemStatusPQWM1& nmea)
+{
+ SystemStatusXoState s(nmea);
+ if (!mCache.mXoState.empty() && mCache.mXoState.back().equals(s)) {
+ mCache.mXoState.back().mUtcReported = s.mUtcReported;
+ } else {
+ mCache.mXoState.push_back(s);
+ if (mCache.mXoState.size() > maxXoState) {
+ mCache.mXoState.erase(mCache.mXoState.begin());
+ }
+ }
+ return true;
+}
+
+bool SystemStatus::setRfAndParams(const SystemStatusPQWM1& nmea)
+{
+ SystemStatusRfAndParams s(nmea);
+ if (!mCache.mRfAndParams.empty() && mCache.mRfAndParams.back().equals(s)) {
+ mCache.mRfAndParams.back().mUtcReported = s.mUtcReported;
+ } else {
+ mCache.mRfAndParams.push_back(s);
+ if (mCache.mRfAndParams.size() > maxRfAndParams) {
+ mCache.mRfAndParams.erase(mCache.mRfAndParams.begin());
+ }
+ }
+ return true;
+}
+
+bool SystemStatus::setErrRecovery(const SystemStatusPQWM1& nmea)
+{
+ SystemStatusErrRecovery s(nmea);
+ if (!mCache.mErrRecovery.empty() && mCache.mErrRecovery.back().equals(s)) {
+ mCache.mErrRecovery.back().mUtcReported = s.mUtcReported;
+ } else {
+ mCache.mErrRecovery.push_back(s);
+ if (mCache.mErrRecovery.size() > maxErrRecovery) {
+ mCache.mErrRecovery.erase(mCache.mErrRecovery.begin());
+ }
+ }
+ return true;
+}
+
+/******************************************************************************
+ SystemStatus - Px functions
+******************************************************************************/
+bool SystemStatus::setInjectedPosition(const SystemStatusPQWP1& nmea)
+{
+ SystemStatusInjectedPosition s(nmea);
+ if (!mCache.mInjectedPosition.empty() && mCache.mInjectedPosition.back().equals(s)) {
+ mCache.mInjectedPosition.back().mUtcReported = s.mUtcReported;
+ } else {
+ mCache.mInjectedPosition.push_back(s);
+ if (mCache.mInjectedPosition.size() > maxInjectedPosition) {
+ mCache.mInjectedPosition.erase(mCache.mInjectedPosition.begin());
+ }
+ }
+ return true;
+}
+
+bool SystemStatus::setBestPosition(const SystemStatusPQWP2& nmea)
+{
+ SystemStatusBestPosition s(nmea);
+ if (!mCache.mBestPosition.empty() && mCache.mBestPosition.back().equals(s)) {
+ mCache.mBestPosition.back().mUtcReported = s.mUtcReported;
+ } else {
+ mCache.mBestPosition.push_back(s);
+ if (mCache.mBestPosition.size() > maxBestPosition) {
+ mCache.mBestPosition.erase(mCache.mBestPosition.begin());
+ }
+ }
+ return true;
+}
+
+bool SystemStatus::setXtra(const SystemStatusPQWP3& nmea)
+{
+ SystemStatusXtra s(nmea);
+ if (!mCache.mXtra.empty() && mCache.mXtra.back().equals(s)) {
+ mCache.mXtra.back().mUtcReported = s.mUtcReported;
+ } else {
+ mCache.mXtra.push_back(s);
+ if (mCache.mXtra.size() > maxXtra) {
+ mCache.mXtra.erase(mCache.mXtra.begin());
+ }
+ }
+ return true;
+}
+
+bool SystemStatus::setEphemeris(const SystemStatusPQWP4& nmea)
+{
+ SystemStatusEphemeris s(nmea);
+ if (!mCache.mEphemeris.empty() && mCache.mEphemeris.back().equals(s)) {
+ mCache.mEphemeris.back().mUtcReported = s.mUtcReported;
+ } else {
+ mCache.mEphemeris.push_back(s);
+ if (mCache.mEphemeris.size() > maxEphemeris) {
+ mCache.mEphemeris.erase(mCache.mEphemeris.begin());
+ }
+ }
+ return true;
+}
+
+bool SystemStatus::setSvHealth(const SystemStatusPQWP5& nmea)
+{
+ SystemStatusSvHealth s(nmea);
+ if (!mCache.mSvHealth.empty() && mCache.mSvHealth.back().equals(s)) {
+ mCache.mSvHealth.back().mUtcReported = s.mUtcReported;
+ } else {
+ mCache.mSvHealth.push_back(s);
+ if (mCache.mSvHealth.size() > maxSvHealth) {
+ mCache.mSvHealth.erase(mCache.mSvHealth.begin());
+ }
+ }
+ return true;
+}
+
+bool SystemStatus::setPdr(const SystemStatusPQWP6& nmea)
+{
+ SystemStatusPdr s(nmea);
+ if (!mCache.mPdr.empty() && mCache.mPdr.back().equals(s)) {
+ mCache.mPdr.back().mUtcReported = s.mUtcReported;
+ } else {
+ mCache.mPdr.push_back(s);
+ if (mCache.mPdr.size() > maxPdr) {
+ mCache.mPdr.erase(mCache.mPdr.begin());
+ }
+ }
+ return true;
+}
+
+bool SystemStatus::setNavData(const SystemStatusPQWP7& nmea)
+{
+ SystemStatusNavData s(nmea);
+ if (!mCache.mNavData.empty() && mCache.mNavData.back().equals(s)) {
+ mCache.mNavData.back().mUtcReported = s.mUtcReported;
+ } else {
+ mCache.mNavData.push_back(s);
+ if (mCache.mNavData.size() > maxNavData) {
+ mCache.mNavData.erase(mCache.mNavData.begin());
+ }
+ }
+ return true;
+}
+
+/******************************************************************************
+ SystemStatus - Sx functions
+******************************************************************************/
+bool SystemStatus::setPositionFailure(const SystemStatusPQWS1& nmea)
+{
+ SystemStatusPositionFailure s(nmea);
+ if (!mCache.mPositionFailure.empty() && mCache.mPositionFailure.back().equals(s)) {
+ mCache.mPositionFailure.back().mUtcReported = s.mUtcReported;
+ } else {
+ mCache.mPositionFailure.push_back(s);
+ if (mCache.mPositionFailure.size() > maxPositionFailure) {
+ mCache.mPositionFailure.erase(mCache.mPositionFailure.begin());
+ }
+ }
+ return true;
+}
+
+/******************************************************************************
+@brief API to set report data into internal buffer
+
+@param[In] data pointer to the NMEA string
+@param[In] len length of the NMEA string
+
+@return true when successfully done
+******************************************************************************/
+static uint32_t cnt = 0;
+static uint32_t cnt_m1 = 0;
+static uint32_t cnt_p1 = 0;
+static uint32_t cnt_p2 = 0;
+static uint32_t cnt_p3 = 0;
+static uint32_t cnt_p4 = 0;
+static uint32_t cnt_p5 = 0;
+static uint32_t cnt_p6 = 0;
+static uint32_t cnt_p7 = 0;
+static uint32_t cnt_s1 = 0;
+
+bool SystemStatus::setNmeaString(const char *data, uint32_t len)
+{
+ bool ret = false;
+ if (!loc_nmea_is_debug(data, len)) {
+ return false;
+ }
+
+ char buf[SystemStatusNmeaBase::NMEA_MAXSIZE + 1] = { 0 };
+ strlcpy(buf, data, sizeof(buf));
+
+ pthread_mutex_lock(&mMutexSystemStatus);
+
+ // parse the received nmea strings here
+ if (0 == strncmp(data, "$PQWM1", SystemStatusNmeaBase::NMEA_MINSIZE)) {
+ SystemStatusPQWM1 s = SystemStatusPQWM1parser(buf, len).get();
+ ret = setTimeAndCLock(s);
+ ret |= setXoState(s);
+ ret |= setRfAndParams(s);
+ ret |= setErrRecovery(s);
+ cnt_m1++;
+ }
+ else if (0 == strncmp(data, "$PQWP1", SystemStatusNmeaBase::NMEA_MINSIZE)) {
+ ret = setInjectedPosition(SystemStatusPQWP1parser(buf, len).get());
+ cnt_p1++;
+ }
+ else if (0 == strncmp(data, "$PQWP2", SystemStatusNmeaBase::NMEA_MINSIZE)) {
+ ret = setBestPosition(SystemStatusPQWP2parser(buf, len).get());
+ cnt_p2++;
+ }
+ else if (0 == strncmp(data, "$PQWP3", SystemStatusNmeaBase::NMEA_MINSIZE)) {
+ ret = setXtra(SystemStatusPQWP3parser(buf, len).get());
+ cnt_p3++;
+ }
+ else if (0 == strncmp(data, "$PQWP4", SystemStatusNmeaBase::NMEA_MINSIZE)) {
+ ret = setEphemeris(SystemStatusPQWP4parser(buf, len).get());
+ cnt_p4++;
+ }
+ else if (0 == strncmp(data, "$PQWP5", SystemStatusNmeaBase::NMEA_MINSIZE)) {
+ ret = setSvHealth(SystemStatusPQWP5parser(buf, len).get());
+ cnt_p5++;
+ }
+ else if (0 == strncmp(data, "$PQWP6", SystemStatusNmeaBase::NMEA_MINSIZE)) {
+ ret = setPdr(SystemStatusPQWP6parser(buf, len).get());
+ cnt_p6++;
+ }
+ else if (0 == strncmp(data, "$PQWP7", SystemStatusNmeaBase::NMEA_MINSIZE)) {
+ ret = setNavData(SystemStatusPQWP7parser(buf, len).get());
+ cnt_p7++;
+ }
+ else if (0 == strncmp(data, "$PQWS1", SystemStatusNmeaBase::NMEA_MINSIZE)) {
+ ret = setPositionFailure(SystemStatusPQWS1parser(buf, len).get());
+ cnt_s1++;
+ }
+ else {
+ // do nothing
+ }
+ cnt++;
+ LOC_LOGV("setNmeaString: cnt=%d M:%d 1:%d 2:%d 3:%d 4:%d 5:%d 6:%d 7:%d S:%d",
+ cnt,
+ cnt_m1,
+ cnt_p1,
+ cnt_p2,
+ cnt_p3,
+ cnt_p4,
+ cnt_p5,
+ cnt_p6,
+ cnt_p7,
+ cnt_s1);
+
+ pthread_mutex_unlock(&mMutexSystemStatus);
+ return ret;
+}
+
+/******************************************************************************
+@brief API to set report position data into internal buffer
+
+@param[In] UlpLocation
+
+@return true when successfully done
+******************************************************************************/
+bool SystemStatus::eventPosition(const UlpLocation& location,
+ const GpsLocationExtended& locationEx)
+{
+ SystemStatusLocation s(location, locationEx);
+ if (!mCache.mLocation.empty() && mCache.mLocation.back().equals(s)) {
+ mCache.mLocation.back().mUtcReported = s.mUtcReported;
+ }
+ else {
+ mCache.mLocation.push_back(s);
+ if (mCache.mLocation.size() > maxLocation) {
+ mCache.mLocation.erase(mCache.mLocation.begin());
+ }
+ }
+ LOC_LOGV("eventPosition - lat=%f lon=%f alt=%f speed=%f",
+ s.mLocation.gpsLocation.latitude,
+ s.mLocation.gpsLocation.longitude,
+ s.mLocation.gpsLocation.altitude,
+ s.mLocation.gpsLocation.speed);
+ return true;
+}
+
+/******************************************************************************
+@brief API to get report data into a given buffer
+
+@param[In] reference to report buffer
+@param[In] bool flag to identify latest only or entire buffer
+
+@return true when successfully done
+******************************************************************************/
+bool SystemStatus::getReport(SystemStatusReports& report, bool isLatestOnly) const
+{
+ pthread_mutex_lock(&mMutexSystemStatus);
+
+ if (isLatestOnly) {
+ // push back only the latest report and return it
+ report.mLocation.clear();
+ if (mCache.mLocation.size() >= 1) {
+ report.mLocation.push_back(mCache.mLocation.back());
+ report.mLocation.back().dump();
+ }
+
+ report.mTimeAndClock.clear();
+ if (mCache.mTimeAndClock.size() >= 1) {
+ report.mTimeAndClock.push_back(mCache.mTimeAndClock.back());
+ report.mTimeAndClock.back().dump();
+ }
+ report.mXoState.clear();
+ if (mCache.mXoState.size() >= 1) {
+ report.mXoState.push_back(mCache.mXoState.back());
+ report.mXoState.back().dump();
+ }
+ report.mRfAndParams.clear();
+ if (mCache.mRfAndParams.size() >= 1) {
+ report.mRfAndParams.push_back(mCache.mRfAndParams.back());
+ report.mRfAndParams.back().dump();
+ }
+ report.mErrRecovery.clear();
+ if (mCache.mErrRecovery.size() >= 1) {
+ report.mErrRecovery.push_back(mCache.mErrRecovery.back());
+ report.mErrRecovery.back().dump();
+ }
+
+ report.mInjectedPosition.clear();
+ if (mCache.mInjectedPosition.size() >= 1) {
+ report.mInjectedPosition.push_back(mCache.mInjectedPosition.back());
+ report.mInjectedPosition.back().dump();
+ }
+ report.mBestPosition.clear();
+ if (mCache.mBestPosition.size() >= 1) {
+ report.mBestPosition.push_back(mCache.mBestPosition.back());
+ report.mBestPosition.back().dump();
+ }
+ report.mXtra.clear();
+ if (mCache.mXtra.size() >= 1) {
+ report.mXtra.push_back(mCache.mXtra.back());
+ report.mXtra.back().dump();
+ }
+ report.mEphemeris.clear();
+ if (mCache.mEphemeris.size() >= 1) {
+ report.mEphemeris.push_back(mCache.mEphemeris.back());
+ report.mEphemeris.back().dump();
+ }
+ report.mSvHealth.clear();
+ if (mCache.mSvHealth.size() >= 1) {
+ report.mSvHealth.push_back(mCache.mSvHealth.back());
+ report.mSvHealth.back().dump();
+ }
+ report.mPdr.clear();
+ if (mCache.mPdr.size() >= 1) {
+ report.mPdr.push_back(mCache.mPdr.back());
+ report.mPdr.back().dump();
+ }
+ report.mNavData.clear();
+ if (mCache.mNavData.size() >= 1) {
+ report.mNavData.push_back(mCache.mNavData.back());
+ report.mNavData.back().dump();
+ }
+
+ report.mPositionFailure.clear();
+ if (mCache.mPositionFailure.size() >= 1) {
+ report.mPositionFailure.push_back(mCache.mPositionFailure.back());
+ report.mPositionFailure.back().dump();
+ }
+ }
+ else {
+ // copy entire reports and return them
+ report.mLocation.clear();
+
+ report.mTimeAndClock.clear();
+ report.mXoState.clear();
+ report.mRfAndParams.clear();
+ report.mErrRecovery.clear();
+
+ report.mInjectedPosition.clear();
+ report.mBestPosition.clear();
+ report.mXtra.clear();
+ report.mEphemeris.clear();
+ report.mSvHealth.clear();
+ report.mPdr.clear();
+ report.mNavData.clear();
+
+ report.mPositionFailure.clear();
+ report = mCache;
+ }
+
+ pthread_mutex_unlock(&mMutexSystemStatus);
+ return true;
+}
+
+/******************************************************************************
+@brief API to set default report data
+
+@param[In] none
+
+@return true when successfully done
+******************************************************************************/
+bool SystemStatus::setDefaultReport(void)
+{
+ pthread_mutex_lock(&mMutexSystemStatus);
+
+ mCache.mLocation.push_back(SystemStatusLocation());
+ if (mCache.mLocation.size() > maxLocation) {
+ mCache.mLocation.erase(mCache.mLocation.begin());
+ }
+
+ mCache.mTimeAndClock.push_back(SystemStatusTimeAndClock());
+ if (mCache.mTimeAndClock.size() > maxTimeAndClock) {
+ mCache.mTimeAndClock.erase(mCache.mTimeAndClock.begin());
+ }
+ mCache.mXoState.push_back(SystemStatusXoState());
+ if (mCache.mXoState.size() > maxXoState) {
+ mCache.mXoState.erase(mCache.mXoState.begin());
+ }
+ mCache.mRfAndParams.push_back(SystemStatusRfAndParams());
+ if (mCache.mRfAndParams.size() > maxRfAndParams) {
+ mCache.mRfAndParams.erase(mCache.mRfAndParams.begin());
+ }
+ mCache.mErrRecovery.push_back(SystemStatusErrRecovery());
+ if (mCache.mErrRecovery.size() > maxErrRecovery) {
+ mCache.mErrRecovery.erase(mCache.mErrRecovery.begin());
+ }
+
+ mCache.mInjectedPosition.push_back(SystemStatusInjectedPosition());
+ if (mCache.mInjectedPosition.size() > maxInjectedPosition) {
+ mCache.mInjectedPosition.erase(mCache.mInjectedPosition.begin());
+ }
+ mCache.mBestPosition.push_back(SystemStatusBestPosition());
+ if (mCache.mBestPosition.size() > maxBestPosition) {
+ mCache.mBestPosition.erase(mCache.mBestPosition.begin());
+ }
+ mCache.mXtra.push_back(SystemStatusXtra());
+ if (mCache.mXtra.size() > maxXtra) {
+ mCache.mXtra.erase(mCache.mXtra.begin());
+ }
+ mCache.mEphemeris.push_back(SystemStatusEphemeris());
+ if (mCache.mEphemeris.size() > maxEphemeris) {
+ mCache.mEphemeris.erase(mCache.mEphemeris.begin());
+ }
+ mCache.mSvHealth.push_back(SystemStatusSvHealth());
+ if (mCache.mSvHealth.size() > maxSvHealth) {
+ mCache.mSvHealth.erase(mCache.mSvHealth.begin());
+ }
+ mCache.mPdr.push_back(SystemStatusPdr());
+ if (mCache.mPdr.size() > maxPdr) {
+ mCache.mPdr.erase(mCache.mPdr.begin());
+ }
+ mCache.mNavData.push_back(SystemStatusNavData());
+ if (mCache.mNavData.size() > maxNavData) {
+ mCache.mNavData.erase(mCache.mNavData.begin());
+ }
+
+ mCache.mPositionFailure.push_back(SystemStatusPositionFailure());
+ if (mCache.mPositionFailure.size() > maxPositionFailure) {
+ mCache.mPositionFailure.erase(mCache.mPositionFailure.begin());
+ }
+
+ pthread_mutex_unlock(&mMutexSystemStatus);
+ return true;
+}
+
+} // namespace loc_core
+
diff --git a/gps/core/SystemStatus.h b/gps/core/SystemStatus.h
new file mode 100644
index 0000000..8cf75b5
--- /dev/null
+++ b/gps/core/SystemStatus.h
@@ -0,0 +1,462 @@
+/* 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 <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);
+};
+
+/******************************************************************************
+ SystemStatusReports
+******************************************************************************/
+class SystemStatusReports
+{
+public:
+ std::vector<SystemStatusLocation> mLocation;
+
+ std::vector<SystemStatusTimeAndClock> mTimeAndClock;
+ std::vector<SystemStatusXoState> mXoState;
+ std::vector<SystemStatusRfAndParams> mRfAndParams;
+ std::vector<SystemStatusErrRecovery> mErrRecovery;
+
+ 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;
+
+ std::vector<SystemStatusPositionFailure> mPositionFailure;
+};
+
+/******************************************************************************
+ 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;
+
+ SystemStatusReports mCache;
+
+ 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);
+
+public:
+ // Static methods
+ static SystemStatus* getInstance(const MsgTask* msgTask);
+ static void destroyInstance();
+ IOsObserver* getOsObserver();
+
+ // Helpers
+ bool eventPosition(const UlpLocation& location,const GpsLocationExtended& locationEx);
+ bool setNmeaString(const char *data, uint32_t len);
+ bool getReport(SystemStatusReports& reports, bool isLatestonly = false) const;
+ bool setDefaultReport(void);
+};
+
+} // namespace loc_core
+
+#endif //__SYSTEM_STATUS__
+
diff --git a/gps/core/SystemStatusOsObserver.cpp b/gps/core/SystemStatusOsObserver.cpp
new file mode 100644
index 0000000..e327f93
--- /dev/null
+++ b/gps/core/SystemStatusOsObserver.cpp
@@ -0,0 +1,646 @@
+/* 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 <string>
+#include <cinttypes>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+#include <pthread.h>
+#include <iterator>
+#include <algorithm>
+
+#include <MsgTask.h>
+#include <SystemStatusOsObserver.h>
+
+#include <DataItemId.h>
+#include <IDataItemCore.h>
+#include <IClientIndex.h>
+#include <IDataItemIndex.h>
+#include <IndexFactory.h>
+
+#include <DataItemsFactoryProxy.h>
+
+#include <platform_lib_log_util.h>
+
+namespace loc_core
+{
+#define BREAK_IF_ZERO(ERR,X) if(0==(X)) {result = (ERR); break;}
+#define BREAK_IF_NON_ZERO(ERR,X) if(0!=(X)) {result = (ERR); break;}
+
+SystemStatusOsObserver::SystemStatusOsObserver(const MsgTask* msgTask) :
+ mAddress ("SystemStatusOsObserver"),
+ mClientIndex(IndexFactory <IDataItemObserver *, DataItemId> :: createClientIndex ()),
+ mDataItemIndex(IndexFactory <IDataItemObserver *, DataItemId> :: createDataItemIndex ())
+{
+ int result = -1;
+ ENTRY_LOG ();
+ do {
+ BREAK_IF_ZERO (1, mClientIndex);
+ BREAK_IF_ZERO (2, mDataItemIndex);
+ mContext.mMsgTask = msgTask;
+ result = 0;
+ } while (0);
+ EXIT_LOG_WITH_ERROR ("%d",result);
+}
+
+SystemStatusOsObserver :: ~SystemStatusOsObserver ()
+{
+ // Close data-item library handle
+ DataItemsFactoryProxy::closeDataItemLibraryHandle();
+
+ // Destroy cache
+ map <DataItemId, IDataItemCore *> :: iterator citer = mDataItemCache.begin ();
+ for (; citer != mDataItemCache.end (); ++citer) {
+ if (citer->second != NULL) { delete citer->second; }
+ }
+ mDataItemCache.clear ();
+ delete mClientIndex;
+ delete mDataItemIndex;
+ mClientIndex = NULL;
+ mDataItemIndex = NULL;
+}
+
+/******************************************************************************
+ Message proc
+******************************************************************************/
+void SystemStatusOsObserver :: HandleSubscribeReq :: proc () const {
+
+ int result = 0;
+ ENTRY_LOG ();
+ do {
+ if (mDataItemList.empty ()) {
+ LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting");
+ result = 0;
+ break;
+ }
+ //mDataItemList.sort ();
+ // Handle First Response
+ list <DataItemId> pendingFirstResponseList;
+ this->mParent->mClientIndex->add (this->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.
+ this->mParent->sendFirstResponse (mDataItemList, this->mClient);
+
+ list <DataItemId> yetToSubscribeDataItemsList;
+ this->mParent->mDataItemIndex->add (this->mClient, mDataItemList, yetToSubscribeDataItemsList);
+ // Send subscription list to framework
+ if (!yetToSubscribeDataItemsList.empty ()) {
+ this->mParent->mContext.mSubscriptionObj->subscribe
+ (
+ yetToSubscribeDataItemsList,
+ this->mParent
+ );
+ LOC_LOGD ("Subscribe Request sent to framework for the following data items");
+ this->mParent->logMe (yetToSubscribeDataItemsList);
+ }
+
+ } while (0);
+ EXIT_LOG_WITH_ERROR ("%d", result);
+ return;
+}
+
+void SystemStatusOsObserver :: HandleUpdateSubscriptionReq :: proc () const {
+ int result = 0;
+ ENTRY_LOG ();
+ do {
+ if (mDataItemList.empty ()) {
+ LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting");
+ result = 0;
+ break;
+ }
+ //mDataItemList.sort ();
+ list <DataItemId> currentlySubscribedList;
+ this->mParent->mClientIndex->getSubscribedList (this->mClient, currentlySubscribedList);
+ list <DataItemId> removeDataItemList;
+ set_difference (currentlySubscribedList.begin (), currentlySubscribedList.end (),
+ mDataItemList.begin (), mDataItemList.end (),
+ inserter (removeDataItemList,removeDataItemList.begin ()));
+ // Handle First Response
+ list <DataItemId> pendingFirstResponseList;
+ this->mParent->mClientIndex->add (this->mClient, mDataItemList, pendingFirstResponseList);
+ // Send First Response
+ this->mParent->sendFirstResponse (pendingFirstResponseList, this->mClient);
+
+ list <DataItemId> yetToSubscribeDataItemsList;
+ this->mParent->mDataItemIndex->add (this->mClient, mDataItemList, yetToSubscribeDataItemsList);
+ // Send subscription list to framework
+ if (!yetToSubscribeDataItemsList.empty ()) {
+ this->mParent->mContext.mSubscriptionObj->subscribe
+ (
+ yetToSubscribeDataItemsList,
+ this->mParent
+ );
+ LOC_LOGD ("Subscribe Request sent to framework for the following data items");
+ this->mParent->logMe (yetToSubscribeDataItemsList);
+ }
+
+ list <DataItemId> unsubscribeList;
+ list <DataItemId> unused;
+ this->mParent->mClientIndex->remove (this->mClient, removeDataItemList, unused);
+
+ if (!this->mParent->mClientIndex->isSubscribedClient (this->mClient)) {
+ this->mParent->mDataItemIndex->remove (list <IDataItemObserver *> (1,this->mClient), unsubscribeList);
+ }
+ if (!unsubscribeList.empty ()) {
+ // Send unsubscribe to framework
+ this->mParent->mContext.mSubscriptionObj->unsubscribe
+ (
+ unsubscribeList,
+ this->mParent
+ );
+ LOC_LOGD ("Unsubscribe Request sent to framework for the following data items");
+ this->mParent->logMe (unsubscribeList);
+ }
+ } while (0);
+ EXIT_LOG_WITH_ERROR ("%d",result);
+}
+
+void SystemStatusOsObserver :: HandleRequestData :: proc () const {
+ int result = 0;
+ ENTRY_LOG ();
+
+ do {
+ if (mDataItemList.empty ()) {
+ LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting");
+ result = 0;
+ break;
+ }
+ //mDataItemList.sort ();
+ list <DataItemId> yetToSubscribeDataItemsList;
+ this->mParent->mClientIndex->add (this->mClient, mDataItemList, yetToSubscribeDataItemsList);
+ this->mParent->mDataItemIndex->add (this->mClient, mDataItemList, yetToSubscribeDataItemsList);
+ // Send subscription list to framework
+ if (!mDataItemList.empty ()) {
+ this->mParent->mContext.mSubscriptionObj->requestData
+ (
+ mDataItemList,
+ this->mParent
+ );
+ LOC_LOGD ("Subscribe Request sent to framework for the following data items");
+ this->mParent->logMe (yetToSubscribeDataItemsList);
+ }
+
+ } while (0);
+ EXIT_LOG_WITH_ERROR ("%d",result);
+}
+
+void SystemStatusOsObserver :: HandleUnsubscribeReq :: proc () const {
+ int result = 0;
+ ENTRY_LOG ();
+ do {
+ if (mDataItemList.empty ()) {
+ LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting");
+ result = 0;
+ break;
+ }
+ //mDataItemList.sort ();
+ list <DataItemId> unsubscribeList;
+ list <DataItemId> unused;
+ this->mParent->mClientIndex->remove (this->mClient, mDataItemList, unused);
+
+ list <DataItemId> :: const_iterator it = mDataItemList.begin ();
+ for (; it != mDataItemList.end (); ++it) {
+ list <IDataItemObserver *> clientListSubs;
+ list <IDataItemObserver *> clientListOut;
+ this->mParent->mDataItemIndex->remove ((*it),
+ list <IDataItemObserver *> (1,this->mClient), clientListOut);
+ // check if there are any other subscribed client for this data item id
+ this->mParent->mDataItemIndex->getListOfSubscribedClients ( (*it), clientListSubs);
+ if (clientListSubs.empty())
+ {
+ LOC_LOGD ("Client list subscribed is empty for dataitem - %d",(*it));
+ unsubscribeList.push_back((*it));
+ }
+ }
+ if (!unsubscribeList.empty ()) {
+ // Send unsubscribe to framework
+ this->mParent->mContext.mSubscriptionObj->unsubscribe
+ (
+ unsubscribeList,
+ this->mParent
+ );
+ LOC_LOGD ("Unsubscribe Request sent to framework for the following data items");
+ this->mParent->logMe (unsubscribeList);
+ }
+ } while (0);
+ EXIT_LOG_WITH_ERROR ("%d",result);
+}
+
+void SystemStatusOsObserver :: HandleUnsubscribeAllReq :: proc () const {
+ int result = 0;
+ ENTRY_LOG ();
+ do {
+ list <IDataItemObserver *> clients (1, this->mClient);
+ list <DataItemId> unsubscribeList;
+ BREAK_IF_NON_ZERO (2, this->mParent->mClientIndex->remove (this->mClient));
+
+
+ this->mParent->mDataItemIndex->remove (clients, unsubscribeList);
+ if (!unsubscribeList.empty ()) {
+ // Send unsubscribe to framework
+ this->mParent->mContext.mSubscriptionObj->unsubscribe
+ (
+ unsubscribeList,
+ this->mParent
+ );
+ LOC_LOGD ("Unsubscribe Request sent to framework for the following data items");
+ this->mParent->logMe (unsubscribeList);
+ }
+ } while (0);
+ EXIT_LOG_WITH_ERROR ("%d",result);
+}
+
+void SystemStatusOsObserver :: HandleNotify :: getListOfClients
+ (const list <DataItemId> & dlist, list <IDataItemObserver *> & clients ) const {
+
+ list <DataItemId> :: const_iterator it = dlist.begin ();
+ for (; it != dlist.end (); ++it) {
+ list <IDataItemObserver *> clientList;
+ this->mParent->mDataItemIndex->getListOfSubscribedClients ( (*it), clientList);
+ list <IDataItemObserver *> :: iterator citer = clientList.begin ();
+ for (; citer != clientList.end (); ++citer) {
+ clients.push_back (*citer);
+ }
+ clientList.clear ();
+ }
+ // remove duplicates
+ clients.unique ();
+}
+
+void SystemStatusOsObserver :: HandleNotify :: proc () const {
+ int result = 0;
+ ENTRY_LOG ();
+ do {
+ // Update Cache with received data items and prepare
+ // list of data items to be sent.
+ list <IDataItemCore *> :: const_iterator it = mDList.begin ();
+ list <DataItemId> dataItemIdsToBeSent;
+ for (; it != mDList.end (); ++it) {
+ bool dataItemUpdated = false;
+ this->mParent->updateCache (*it, dataItemUpdated);
+ if (dataItemUpdated) {
+ dataItemIdsToBeSent.push_back ( (*it)->getId ());
+ }
+ }
+
+ list <IDataItemObserver *> clientList;
+ this->getListOfClients (dataItemIdsToBeSent, clientList);
+ list <IDataItemObserver *> :: iterator citer = clientList.begin ();
+ // Send data item to all subscribed clients
+ LOC_LOGD ("LocTech-Label :: SystemStatusOsObserver :: Data Items Out");
+ for (; citer != clientList.end (); ++citer) {
+ do {
+ list <DataItemId> dataItemIdsSubscribedByThisClient;
+ list <DataItemId> dataItemIdsToBeSentForThisClient;
+ this->mParent->mClientIndex->getSubscribedList (*citer, dataItemIdsSubscribedByThisClient);
+ dataItemIdsSubscribedByThisClient.sort ();
+ dataItemIdsToBeSent.sort ();
+ set_intersection (dataItemIdsToBeSent.begin (),
+ dataItemIdsToBeSent.end (),
+ dataItemIdsSubscribedByThisClient.begin (),
+ dataItemIdsSubscribedByThisClient.end (),
+ inserter (dataItemIdsToBeSentForThisClient,
+ dataItemIdsToBeSentForThisClient.begin ()));
+ BREAK_IF_NON_ZERO (4,this->mParent->sendCachedDataItems (dataItemIdsToBeSentForThisClient, *citer));
+ dataItemIdsSubscribedByThisClient.clear ();
+ dataItemIdsToBeSentForThisClient.clear ();
+ } while (0);
+ }
+ } while (0);
+ EXIT_LOG_WITH_ERROR ("%d", result);
+}
+
+void SystemStatusOsObserver :: HandleTurnOn :: proc () const {
+ int result = 0;
+ ENTRY_LOG ();
+ do {
+ // Send action turn on to framework
+ this->mParent->mContext.mFrameworkActionReqObj->turnOn(mDataItemId, mTimeOut);
+ } while (0);
+ EXIT_LOG_WITH_ERROR ("%d", result);
+}
+
+void SystemStatusOsObserver :: HandleTurnOff :: proc () const {
+ int result = 0;
+ ENTRY_LOG ();
+ do {
+ // Send action turn off to framework
+ this->mParent->mContext.mFrameworkActionReqObj->turnOff(mDataItemId);
+ } while (0);
+ EXIT_LOG_WITH_ERROR ("%d", result);
+}
+
+/******************************************************************************
+ IDataItemSubscription Overrides
+******************************************************************************/
+void SystemStatusOsObserver :: subscribe (const list <DataItemId> & l, IDataItemObserver * client) {
+ int result = 0;
+ ENTRY_LOG ();
+ do {
+ if (mContext.mSubscriptionObj != NULL) {
+ HandleSubscribeReq * msg = new (nothrow) HandleSubscribeReq (this, l, client);
+ mContext.mMsgTask->sendMsg (msg);
+ }
+ else {
+ LOC_LOGE("%s:%d]: Subscription object is NULL", __func__, __LINE__);
+ result = 1;
+ }
+ } while (0);
+ EXIT_LOG_WITH_ERROR ("%d",result);
+}
+
+void SystemStatusOsObserver :: updateSubscription (const list <DataItemId> & l, IDataItemObserver * client) {
+ int result = 0;
+ ENTRY_LOG ();
+ do {
+ if (mContext.mSubscriptionObj != NULL) {
+ mContext.mMsgTask->sendMsg (new (nothrow) HandleUpdateSubscriptionReq (this, l, client));
+ }
+ else {
+ LOC_LOGE("%s:%d]: Subscription object is NULL", __func__, __LINE__);
+ result = 1;
+ }
+ } while (0);
+ EXIT_LOG_WITH_ERROR ("%d",result);
+}
+
+void SystemStatusOsObserver :: requestData (const list <DataItemId> & l, IDataItemObserver * client) {
+ int result = 0;
+ ENTRY_LOG ();
+ do {
+ if (mContext.mSubscriptionObj != NULL) {
+ mContext.mMsgTask->sendMsg (new (nothrow) HandleRequestData (this, l, client));
+ }
+ else {
+ LOC_LOGE("%s:%d]: Subscription object is NULL", __func__, __LINE__);
+ result = 1;
+ }
+ } while (0);
+
+ EXIT_LOG_WITH_ERROR ("%d",result);
+}
+
+void SystemStatusOsObserver :: unsubscribe (const list <DataItemId> & l, IDataItemObserver * client) {
+ int result = 0;
+ ENTRY_LOG ();
+ do {
+ if (mContext.mSubscriptionObj != NULL) {
+ mContext.mMsgTask->sendMsg (new (nothrow) HandleUnsubscribeReq (this, l, client));
+ }
+ else {
+ LOC_LOGE("%s:%d]: Subscription object is NULL", __func__, __LINE__);
+ result = 1;
+ }
+ } while (0);
+ EXIT_LOG_WITH_ERROR ("%d",result);
+}
+
+void SystemStatusOsObserver :: unsubscribeAll (IDataItemObserver * client) {
+ int result = 0;
+ ENTRY_LOG ();
+ do {
+ if (mContext.mSubscriptionObj != NULL) {
+ mContext.mMsgTask->sendMsg (new (nothrow) HandleUnsubscribeAllReq (this, client));
+ }
+ else {
+ LOC_LOGE("%s:%d]: Subscription object is NULL", __func__, __LINE__);
+ result = 1;
+ }
+ } while (0);
+ EXIT_LOG_WITH_ERROR ("%d",result);
+}
+
+/******************************************************************************
+ IDataItemObserver Overrides
+******************************************************************************/
+void SystemStatusOsObserver::getName(string & name) {
+ name = mAddress;
+}
+
+void SystemStatusOsObserver::notify(const std::list <IDataItemCore *> & dlist) {
+ int result = 0;
+ ENTRY_LOG ();
+ do {
+ list <IDataItemCore *> :: const_iterator it = dlist.begin ();
+ list <IDataItemCore *> dataItemList;
+ list <DataItemId> ids;
+ LOC_LOGD("LocTech-Label :: SystemStatusOsObserver :: Data Items In");
+ for (; it != dlist.end (); ++it) {
+ if (*it != NULL) {
+ string dv;
+ (*it)->stringify(dv);
+ LOC_LOGD("LocTech-Value :: Data Item Value: %s", dv.c_str ());
+ IDataItemCore * dataitem = DataItemsFactoryProxy::createNewDataItem((*it)->getId());
+ BREAK_IF_ZERO (2, dataitem);
+ // Copy contents into the newly created data item
+ dataitem->copy(*it);
+ dataItemList.push_back(dataitem);
+ ids.push_back((*it)->getId());
+ }
+ }
+ mContext.mMsgTask->sendMsg(new (nothrow) HandleNotify (this, dataItemList));
+ } while (0);
+ EXIT_LOG_WITH_ERROR ("%d", result);
+}
+
+/******************************************************************************
+ IFrameworkActionReq Overrides
+******************************************************************************/
+void SystemStatusOsObserver :: turnOn (DataItemId dit, int timeOut) {
+ int result = 0;
+ ENTRY_LOG ();
+ do {
+ if (mContext.mFrameworkActionReqObj != NULL) {
+ // 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
+ mContext.mMsgTask->sendMsg (new (nothrow) HandleTurnOn (this, dit, timeOut));
+ } else {
+ // Found in map, update reference count
+ citer->second++;
+ LOC_LOGD("HandleTurnOn - Data item:%d Num_refs:%d",dit,citer->second);
+ }
+ }
+ else {
+ LOC_LOGE("%s:%d]: Framework action request object is NULL", __func__, __LINE__);
+ result = 1;
+ }
+ } while (0);
+
+ EXIT_LOG_WITH_ERROR ("%d", result);
+}
+
+void SystemStatusOsObserver :: turnOff (DataItemId dit) {
+ int result = 0;
+ ENTRY_LOG ();
+ do {
+ if (mContext.mFrameworkActionReqObj != NULL) {
+ // Check if data item exists in mActiveRequestCount
+ map <DataItemId, int> :: iterator citer = mActiveRequestCount.find (dit);
+ if (citer != mActiveRequestCount.end ()) {
+ citer->second--;
+ LOC_LOGD("HandleTurnOff - Data item:%d Remaining Num_refs:%d",dit,citer->second);
+
+ if(citer->second == 0) {
+ LOC_LOGD("Sending turnOff request");
+ // if this was last reference, remove item from map and turn off module
+ mActiveRequestCount.erase(citer);
+ // Send action turn off to framework
+ mContext.mMsgTask->sendMsg (new (nothrow) HandleTurnOff (this, dit));
+ }
+ } else {
+ // Not found in map
+ LOC_LOGD ("Data item id %d not found in FrameworkModuleMap",dit);
+ }
+ }
+ else {
+ LOC_LOGE("%s:%d]: Framework action request object is NULL", __func__, __LINE__);
+ result = 1;
+ }
+ } while (0);
+ EXIT_LOG_WITH_ERROR ("%d", result);
+}
+
+/******************************************************************************
+ Helpers
+******************************************************************************/
+void SystemStatusOsObserver :: logMe (const list <DataItemId> & l) {
+ list <DataItemId> :: const_iterator it = l.begin ();
+ for (;it != l.end (); ++it) {
+ LOC_LOGD ("DataItem %d",*it);
+ }
+}
+
+int SystemStatusOsObserver :: sendFirstResponse (const list <DataItemId> & l, IDataItemObserver * to) {
+ int result = 0;
+ ENTRY_LOG ();
+ do {
+ if (l.empty ()) {
+ LOC_LOGV("list is empty. Nothing to do. Exiting");
+ result = 0;
+ break;
+ }
+
+ string clientName;
+ to->getName (clientName);
+ LOC_LOGD ("First response sent for the following data items To Client: %s", clientName.c_str());
+
+ list <IDataItemCore *> dataItems;
+ list <DataItemId> :: const_iterator diditer = l.begin ();
+ for (; diditer != l.end (); ++diditer) {
+ map <DataItemId, IDataItemCore*> :: const_iterator citer = mDataItemCache.find (*diditer);
+ if (citer != mDataItemCache.end ()) {
+ string dv;
+ IDataItemCore * di = citer->second;
+ di->stringify (dv);
+ LOC_LOGD ("LocTech-Value :: Data Item: %s", dv.c_str ());
+ dataItems.push_back (citer->second);
+ }
+ }
+ if (dataItems.empty ()) {
+ LOC_LOGV("No items to notify. Nothing to do. Exiting");
+ result = 0;
+ break;
+ }
+
+ // Notify Client
+ to->notify (dataItems);
+
+ } while (0);
+ EXIT_LOG_WITH_ERROR ("%d", result);
+ return result;
+}
+
+int SystemStatusOsObserver :: sendCachedDataItems (const list <DataItemId> & l, IDataItemObserver * to) {
+ int result = 0;
+ ENTRY_LOG ();
+ do {
+ list <IDataItemCore *> dataItems;
+ list <DataItemId> :: const_iterator it = l.begin ();
+ string clientName;
+ to->getName (clientName);
+ LOC_LOGD ("LocTech-Value :: To Client: %s", clientName.c_str ());
+ for (; it != l.end (); ++it) {
+ string dv;
+ IDataItemCore * di = this->mDataItemCache [ (*it) ];
+ di->stringify (dv);
+ LOC_LOGI("LocTech-Value :: Data Item: %s >> %s", dv.c_str(), clientName.c_str());
+ dataItems.push_back (di);
+ }
+
+ to->notify (dataItems);
+
+ } while (0);
+ EXIT_LOG_WITH_ERROR ("%d", result);
+ return result;
+}
+
+int SystemStatusOsObserver :: updateCache (IDataItemCore * d, bool &dataItemUpdated) {
+ int result = 0;
+ ENTRY_LOG ();
+ do {
+ BREAK_IF_ZERO (1, d);
+ // 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());
+ BREAK_IF_ZERO (2, dataitem);
+ // 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
+ BREAK_IF_NON_ZERO(3, citer->second->copy (d, &dataItemUpdated));
+ }
+
+ if (dataItemUpdated) {
+ LOC_LOGV("DataItem:%d updated:%d", d->getId (), dataItemUpdated);
+ }
+ } while (0);
+
+ EXIT_LOG_WITH_ERROR ("%d", result);
+ return result;
+}
+
+} // namespace loc_core
+
diff --git a/gps/core/SystemStatusOsObserver.h b/gps/core/SystemStatusOsObserver.h
new file mode 100644
index 0000000..8e42d21
--- /dev/null
+++ b/gps/core/SystemStatusOsObserver.h
@@ -0,0 +1,333 @@
+/* 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 <stdint.h>
+#include <string>
+#include <list>
+#include <map>
+#include <new>
+#include <vector>
+#include <platform_lib_log_util.h>
+#include <DataItemId.h>
+#include <MsgTask.h>
+#include <IOsObserver.h>
+
+namespace loc_core
+{
+
+/******************************************************************************
+ SystemStatusOsObserver
+******************************************************************************/
+// 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) {}
+};
+
+// 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
+ inline void setSubscriptionObj(IDataItemSubscription *subscriptionObj) {
+ mContext.mSubscriptionObj = subscriptionObj;
+ };
+
+ // To set the framework action request object
+ inline void setFrameworkActionReqObj(IFrameworkActionReq *frameworkActionReqObj) {
+ mContext.mFrameworkActionReqObj = frameworkActionReqObj;
+ }
+
+ // IDataItemObserver Overrides
+ virtual void getName (string & name);
+ virtual void notify (const std::list <IDataItemCore *> & dlist);
+
+ // IDataItemSubscription Overrides
+ virtual void subscribe (const std :: list <DataItemId> & l, IDataItemObserver * client);
+ virtual void updateSubscription
+ (
+ const std :: list <DataItemId> & l,
+ IDataItemObserver * client
+ );
+ virtual void requestData
+ (
+ const std :: list <DataItemId> & l,
+ IDataItemObserver * client
+ );
+ virtual void unsubscribe (const std :: list <DataItemId> & l, IDataItemObserver * client);
+ virtual void unsubscribeAll (IDataItemObserver * client);
+
+ // 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;
+
+ // Nested types
+ // Messages
+ struct HandleMsgBase : public LocMsg {
+ HandleMsgBase (SystemStatusOsObserver * parent);
+ virtual ~HandleMsgBase ();
+ // Data members
+ SystemStatusOsObserver * mParent;
+ };
+
+ // Helpers
+ int sendFirstResponse
+ (
+ const list <DataItemId> & l,
+ IDataItemObserver * to
+ );
+
+ int sendCachedDataItems
+ (
+ const list <DataItemId> & l,
+ IDataItemObserver * to
+ );
+
+ int updateCache (IDataItemCore * d, bool &dataItemUpdated);
+ void logMe (const list <DataItemId> & l);
+
+ // Messages
+ struct HandleClientMsg : public LocMsg {
+ HandleClientMsg (SystemStatusOsObserver * parent, IDataItemObserver * client);
+ virtual ~HandleClientMsg ();
+ // Data Members
+ SystemStatusOsObserver * mParent;
+ IDataItemObserver * mClient;
+ };
+
+ struct HandleSubscribeReq : public HandleClientMsg {
+ HandleSubscribeReq (SystemStatusOsObserver * parent,
+ const list <DataItemId> & l,
+ IDataItemObserver * client);
+ virtual ~HandleSubscribeReq ();
+ void proc () const;
+ // Data members
+ const list <DataItemId> mDataItemList;
+ };
+
+ struct HandleUpdateSubscriptionReq : public HandleClientMsg {
+ HandleUpdateSubscriptionReq (SystemStatusOsObserver * parent,
+ const list <DataItemId> & l,
+ IDataItemObserver * client);
+ virtual ~HandleUpdateSubscriptionReq ();
+ void proc () const;
+ // Data members
+ const list <DataItemId> mDataItemList;
+ };
+
+ struct HandleRequestData : public HandleClientMsg {
+ HandleRequestData (SystemStatusOsObserver * parent,
+ const list <DataItemId> & l,
+ IDataItemObserver * client);
+ virtual ~HandleRequestData ();
+ void proc () const;
+ const list <DataItemId> mDataItemList;
+ };
+
+ struct HandleUnsubscribeReq : public HandleClientMsg {
+ HandleUnsubscribeReq (SystemStatusOsObserver * parent,
+ const list <DataItemId> & l,
+ IDataItemObserver * client);
+ virtual ~HandleUnsubscribeReq ();
+ void proc () const;
+ // Data members
+ const list <DataItemId> mDataItemList;
+ };
+
+ struct HandleUnsubscribeAllReq : public HandleClientMsg {
+ HandleUnsubscribeAllReq
+ (
+ SystemStatusOsObserver * parent,
+ IDataItemObserver * client
+ );
+ virtual ~HandleUnsubscribeAllReq ();
+ void proc () const;
+ };
+
+ struct HandleNotify : public HandleMsgBase {
+ HandleNotify (SystemStatusOsObserver * parent, list <IDataItemCore *> dlist);
+ virtual ~HandleNotify ();
+ void getListOfClients
+ (
+ const list <DataItemId> & dlist,
+ list <IDataItemObserver *> & clients
+ ) const;
+ void proc () const;
+ // Data members
+ list <IDataItemCore *> mDList;
+ };
+
+ struct HandleTurnOn : public HandleMsgBase {
+ HandleTurnOn (SystemStatusOsObserver * parent,
+ const DataItemId dit,
+ const int timeOut);
+ virtual ~HandleTurnOn ();
+ void proc () const;
+ // Data members
+ DataItemId mDataItemId;
+ int mTimeOut;
+ };
+
+ struct HandleTurnOff : public HandleMsgBase {
+ HandleTurnOff (SystemStatusOsObserver * parent,const DataItemId dit);
+ virtual ~HandleTurnOff ();
+ void proc () const;
+ // Data members
+ DataItemId mDataItemId;
+ };
+
+};
+
+
+/******************************************************************************
+ Messages
+******************************************************************************/
+// Ctors
+inline SystemStatusOsObserver :: HandleMsgBase :: HandleMsgBase (SystemStatusOsObserver * parent)
+:
+mParent (parent)
+{}
+
+inline SystemStatusOsObserver :: HandleClientMsg :: HandleClientMsg
+(
+ SystemStatusOsObserver * parent,
+ IDataItemObserver * client
+)
+:
+mParent (parent),
+mClient (client)
+{}
+
+inline SystemStatusOsObserver :: HandleSubscribeReq :: HandleSubscribeReq
+ (SystemStatusOsObserver * parent, const list <DataItemId> & l, IDataItemObserver * client)
+:
+HandleClientMsg (parent, client), mDataItemList (l)
+{}
+
+inline SystemStatusOsObserver :: HandleUpdateSubscriptionReq :: HandleUpdateSubscriptionReq
+ (SystemStatusOsObserver * parent, const list <DataItemId> & l, IDataItemObserver * client)
+:
+HandleClientMsg (parent, client), mDataItemList (l)
+{}
+
+inline SystemStatusOsObserver :: HandleRequestData :: HandleRequestData
+ (SystemStatusOsObserver * parent, const list <DataItemId> & l, IDataItemObserver * client)
+:
+HandleClientMsg (parent, client), mDataItemList (l)
+{}
+
+inline SystemStatusOsObserver :: HandleUnsubscribeReq :: HandleUnsubscribeReq
+ (SystemStatusOsObserver * parent, const list <DataItemId> & l, IDataItemObserver * client)
+:
+HandleClientMsg (parent, client), mDataItemList (l)
+{}
+
+inline SystemStatusOsObserver :: HandleUnsubscribeAllReq :: HandleUnsubscribeAllReq
+ (SystemStatusOsObserver * parent, IDataItemObserver * client)
+:
+HandleClientMsg (parent, client)
+{}
+
+inline SystemStatusOsObserver :: HandleNotify :: HandleNotify
+ (SystemStatusOsObserver * parent, list <IDataItemCore *> dlist)
+:
+HandleMsgBase (parent), mDList (dlist)
+{}
+
+inline SystemStatusOsObserver :: HandleTurnOn :: HandleTurnOn
+ (SystemStatusOsObserver * parent, const DataItemId dit,const int timeOut)
+:
+HandleMsgBase (parent), mDataItemId (dit), mTimeOut (timeOut)
+{}
+
+inline SystemStatusOsObserver :: HandleTurnOff :: HandleTurnOff
+ (SystemStatusOsObserver * parent, const DataItemId dit)
+:
+HandleMsgBase (parent), mDataItemId (dit)
+{}
+
+// Dtors
+inline SystemStatusOsObserver :: HandleMsgBase :: ~HandleMsgBase () {}
+inline SystemStatusOsObserver :: HandleClientMsg :: ~HandleClientMsg () {}
+inline SystemStatusOsObserver :: HandleSubscribeReq :: ~HandleSubscribeReq () {}
+inline SystemStatusOsObserver :: HandleUpdateSubscriptionReq :: ~HandleUpdateSubscriptionReq() {}
+inline SystemStatusOsObserver :: HandleRequestData :: ~HandleRequestData() {}
+inline SystemStatusOsObserver :: HandleUnsubscribeReq :: ~HandleUnsubscribeReq () {}
+inline SystemStatusOsObserver :: HandleUnsubscribeAllReq :: ~HandleUnsubscribeAllReq () {}
+
+inline SystemStatusOsObserver :: HandleNotify :: ~HandleNotify () {
+ list <IDataItemCore *> :: iterator it = mDList.begin ();
+ for (; it != mDList.end (); ++it) {
+ delete *it;
+ *it = NULL;
+ }
+}
+
+inline SystemStatusOsObserver :: HandleTurnOn :: ~HandleTurnOn () {}
+inline SystemStatusOsObserver :: HandleTurnOff :: ~HandleTurnOff () {}
+
+
+} // namespace loc_core
+
+#endif //__SYSTEM_STATUS__
+
diff --git a/gps/core/UlpProxyBase.h b/gps/core/UlpProxyBase.h
new file mode 100644
index 0000000..8863b66
--- /dev/null
+++ b/gps/core/UlpProxyBase.h
@@ -0,0 +1,124 @@
+/* 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
+ * 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 ULP_PROXY_BASE_H
+#define ULP_PROXY_BASE_H
+
+#include <gps_extended.h>
+#include <LocationAPI.h>
+
+namespace loc_core {
+
+class LocAdapterBase;
+
+class UlpProxyBase {
+public:
+ LocPosMode mPosMode;
+ bool mFixSet;
+ inline UlpProxyBase() {
+ mPosMode.mode = LOC_POSITION_MODE_INVALID;
+ mFixSet = false;
+ }
+ inline virtual ~UlpProxyBase() {}
+ inline virtual bool sendStartFix() { mFixSet = true; return false; }
+ inline virtual bool sendStopFix() { mFixSet = false; return false; }
+ inline virtual bool sendFixMode(LocPosMode &params) {
+ mPosMode = params;
+ return false;
+ }
+
+ inline virtual bool reportPosition(const UlpLocation &location,
+ const GpsLocationExtended &locationExtended,
+ enum loc_sess_status status,
+ LocPosTechMask loc_technology_mask) {
+ (void)location;
+ (void)locationExtended;
+ (void)status;
+ (void)loc_technology_mask;
+ return false;
+ }
+ inline virtual bool reportSv(const GnssSvNotification& svNotify) {
+ (void)svNotify;
+ return false;
+ }
+ inline virtual bool reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet) {
+ (void)svMeasurementSet;
+ return false;
+ }
+
+ inline virtual bool reportSvPolynomial(GnssSvPolynomial &svPolynomial)
+ {
+ (void)svPolynomial;
+ return false;
+ }
+ inline virtual bool reportStatus(LocGpsStatusValue status) {
+
+ (void)status;
+ return false;
+ }
+ inline virtual void setAdapter(LocAdapterBase* adapter) {
+
+ (void)adapter;
+ }
+ inline virtual void setCapabilities(unsigned long capabilities) {
+
+ (void)capabilities;
+ }
+ 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 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
+
+#endif // ULP_PROXY_BASE_H
diff --git a/gps/core/data-items/DataItemId.h b/gps/core/data-items/DataItemId.h
new file mode 100644
index 0000000..1bf132a
--- /dev/null
+++ b/gps/core/data-items/DataItemId.h
@@ -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__
diff --git a/gps/core/data-items/DataItemsFactoryProxy.cpp b/gps/core/data-items/DataItemsFactoryProxy.cpp
new file mode 100644
index 0000000..130eecf
--- /dev/null
+++ b/gps/core/data-items/DataItemsFactoryProxy.cpp
@@ -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
+
+
diff --git a/gps/core/data-items/DataItemsFactoryProxy.h b/gps/core/data-items/DataItemsFactoryProxy.h
new file mode 100644
index 0000000..cfd447d
--- /dev/null
+++ b/gps/core/data-items/DataItemsFactoryProxy.h
@@ -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__
+
diff --git a/gps/core/data-items/IDataItemCore.h b/gps/core/data-items/IDataItemCore.h
new file mode 100644
index 0000000..6084c92
--- /dev/null
+++ b/gps/core/data-items/IDataItemCore.h
@@ -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__
diff --git a/gps/core/data-items/common/ClientIndex.cpp b/gps/core/data-items/common/ClientIndex.cpp
new file mode 100644
index 0000000..ffb5e1d
--- /dev/null
+++ b/gps/core/data-items/common/ClientIndex.cpp
@@ -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>;
+}
diff --git a/gps/core/data-items/common/ClientIndex.h b/gps/core/data-items/common/ClientIndex.h
new file mode 100644
index 0000000..feccb05
--- /dev/null
+++ b/gps/core/data-items/common/ClientIndex.h
@@ -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__
diff --git a/gps/core/data-items/common/DataItemIndex.cpp b/gps/core/data-items/common/DataItemIndex.cpp
new file mode 100644
index 0000000..7869b43
--- /dev/null
+++ b/gps/core/data-items/common/DataItemIndex.cpp
@@ -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>;
+}
diff --git a/gps/core/data-items/common/DataItemIndex.h b/gps/core/data-items/common/DataItemIndex.h
new file mode 100644
index 0000000..d72e89e
--- /dev/null
+++ b/gps/core/data-items/common/DataItemIndex.h
@@ -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__
diff --git a/gps/core/data-items/common/IClientIndex.h b/gps/core/data-items/common/IClientIndex.h
new file mode 100644
index 0000000..0272e7b
--- /dev/null
+++ b/gps/core/data-items/common/IClientIndex.h
@@ -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__
diff --git a/gps/core/data-items/common/IDataItemIndex.h b/gps/core/data-items/common/IDataItemIndex.h
new file mode 100644
index 0000000..9185582
--- /dev/null
+++ b/gps/core/data-items/common/IDataItemIndex.h
@@ -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__
+
diff --git a/gps/core/data-items/common/IndexFactory.cpp b/gps/core/data-items/common/IndexFactory.cpp
new file mode 100644
index 0000000..cf49475
--- /dev/null
+++ b/gps/core/data-items/common/IndexFactory.cpp
@@ -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>;
+}
diff --git a/gps/core/data-items/common/IndexFactory.h b/gps/core/data-items/common/IndexFactory.h
new file mode 100644
index 0000000..9a2070e
--- /dev/null
+++ b/gps/core/data-items/common/IndexFactory.h
@@ -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__
diff --git a/gps/core/loc_core_log.cpp b/gps/core/loc_core_log.cpp
new file mode 100644
index 0000000..5a627dd
--- /dev/null
+++ b/gps/core/loc_core_log.cpp
@@ -0,0 +1,243 @@
+/* Copyright (c) 2011-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.
+ *
+ */
+
+#define LOG_NDEBUG 0
+#define LOG_TAG "LocSvc_core_log"
+
+#include <loc_log.h>
+#include <loc_core_log.h>
+#include <platform_lib_includes.h>
+
+void LocPosMode::logv() const
+{
+ LOC_LOGV ("Position mode: %s\n Position recurrence: %s\n "
+ "min interval: %d\n preferred accuracy: %d\n "
+ "preferred time: %d\n credentials: %s provider: %s",
+ loc_get_position_mode_name(mode),
+ loc_get_position_recurrence_name(recurrence),
+ min_interval,
+ preferred_accuracy,
+ preferred_time,
+ credentials,
+ provider);
+}
+
+/* GPS status names */
+static const loc_name_val_s_type gps_status_name[] =
+{
+ 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(LocGpsStatusValue gps_status)
+{
+ return loc_get_name_from_val(gps_status_name, gps_status_num,
+ (long) gps_status);
+}
+
+
+
+static const loc_name_val_s_type loc_eng_position_modes[] =
+{
+ NAME_VAL( LOC_POSITION_MODE_STANDALONE ),
+ NAME_VAL( LOC_POSITION_MODE_MS_BASED ),
+ NAME_VAL( LOC_POSITION_MODE_MS_ASSISTED ),
+ NAME_VAL( LOC_POSITION_MODE_RESERVED_1 ),
+ NAME_VAL( LOC_POSITION_MODE_RESERVED_2 ),
+ NAME_VAL( LOC_POSITION_MODE_RESERVED_3 ),
+ NAME_VAL( LOC_POSITION_MODE_RESERVED_4 ),
+ NAME_VAL( LOC_POSITION_MODE_RESERVED_5 )
+};
+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(LocGpsPositionMode mode)
+{
+ return loc_get_name_from_val(loc_eng_position_modes, loc_eng_position_mode_num, (long) mode);
+}
+
+
+
+static const loc_name_val_s_type loc_eng_position_recurrences[] =
+{
+ 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(LocGpsPositionRecurrence recur)
+{
+ return loc_get_name_from_val(loc_eng_position_recurrences, loc_eng_position_recurrence_num, (long) recur);
+}
+
+
+
+static const loc_name_val_s_type loc_eng_aiding_data_bits[] =
+{
+ 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(LocGpsAidingData /*data*/)
+{
+ return NULL;
+}
+
+
+static const loc_name_val_s_type loc_eng_agps_types[] =
+{
+ 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(LocAGpsType type)
+{
+ return loc_get_name_from_val(loc_eng_agps_types, loc_eng_agps_type_num, (long) type);
+}
+
+
+static const loc_name_val_s_type loc_eng_ni_types[] =
+{
+ 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(LocGpsNiType type)
+{
+ return loc_get_name_from_val(loc_eng_ni_types, loc_eng_ni_type_num, (long) type);
+}
+
+
+static const loc_name_val_s_type loc_eng_ni_responses[] =
+{
+ 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(LocGpsUserResponseType response)
+{
+ return loc_get_name_from_val(loc_eng_ni_responses, loc_eng_ni_reponse_num, (long) response);
+}
+
+
+static const loc_name_val_s_type loc_eng_ni_encodings[] =
+{
+ 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(LocGpsNiEncodingType encoding)
+{
+ return loc_get_name_from_val(loc_eng_ni_encodings, loc_eng_ni_encoding_num, (long) encoding);
+}
+
+static const loc_name_val_s_type loc_eng_agps_bears[] =
+{
+ NAME_VAL( AGPS_APN_BEARER_INVALID ),
+ NAME_VAL( AGPS_APN_BEARER_IPV4 ),
+ NAME_VAL( AGPS_APN_BEARER_IPV6 ),
+ NAME_VAL( AGPS_APN_BEARER_IPV4V6 )
+};
+static const int loc_eng_agps_bears_num = sizeof(loc_eng_agps_bears) / sizeof(loc_name_val_s_type);
+
+const char* loc_get_agps_bear_name(AGpsBearerType bearer)
+{
+ return loc_get_name_from_val(loc_eng_agps_bears, loc_eng_agps_bears_num, (long) bearer);
+}
+
+static const loc_name_val_s_type loc_eng_server_types[] =
+{
+ NAME_VAL( LOC_AGPS_CDMA_PDE_SERVER ),
+ NAME_VAL( LOC_AGPS_CUSTOM_PDE_SERVER ),
+ NAME_VAL( LOC_AGPS_MPC_SERVER ),
+ NAME_VAL( LOC_AGPS_SUPL_SERVER )
+};
+static const int loc_eng_server_types_num = sizeof(loc_eng_server_types) / sizeof(loc_name_val_s_type);
+
+const char* loc_get_server_type_name(LocServerType type)
+{
+ return loc_get_name_from_val(loc_eng_server_types, loc_eng_server_types_num, (long) type);
+}
+
+static const loc_name_val_s_type loc_eng_position_sess_status_types[] =
+{
+ NAME_VAL( LOC_SESS_SUCCESS ),
+ NAME_VAL( LOC_SESS_INTERMEDIATE ),
+ NAME_VAL( LOC_SESS_FAILURE )
+};
+static const int loc_eng_position_sess_status_num = sizeof(loc_eng_position_sess_status_types) / sizeof(loc_name_val_s_type);
+
+const char* loc_get_position_sess_status_name(enum loc_sess_status status)
+{
+ return loc_get_name_from_val(loc_eng_position_sess_status_types, loc_eng_position_sess_status_num, (long) status);
+}
+
+static const loc_name_val_s_type loc_eng_agps_status_names[] =
+{
+ 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(LocAGpsStatusValue status)
+{
+ return loc_get_name_from_val(loc_eng_agps_status_names, loc_eng_agps_status_num, (long) status);
+}
diff --git a/gps/core/loc_core_log.h b/gps/core/loc_core_log.h
new file mode 100644
index 0000000..2beb687
--- /dev/null
+++ b/gps/core/loc_core_log.h
@@ -0,0 +1,58 @@
+/* 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
+ * 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 LOC_CORE_LOG_H
+#define LOC_CORE_LOG_H
+
+#include <ctype.h>
+#include <gps_extended.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+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(LocAGpsStatusValue status);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LOC_CORE_LOG_H */
diff --git a/gps/core/observer/IDataItemObserver.h b/gps/core/observer/IDataItemObserver.h
new file mode 100644
index 0000000..7954d85
--- /dev/null
+++ b/gps/core/observer/IDataItemObserver.h
@@ -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__
diff --git a/gps/core/observer/IDataItemSubscription.h b/gps/core/observer/IDataItemSubscription.h
new file mode 100644
index 0000000..7e8b8c8
--- /dev/null
+++ b/gps/core/observer/IDataItemSubscription.h
@@ -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__
+
diff --git a/gps/core/observer/IFrameworkActionReq.h b/gps/core/observer/IFrameworkActionReq.h
new file mode 100644
index 0000000..c7b3ebd
--- /dev/null
+++ b/gps/core/observer/IFrameworkActionReq.h
@@ -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__
+
diff --git a/gps/core/observer/IOsObserver.h b/gps/core/observer/IOsObserver.h
new file mode 100644
index 0000000..3db8a85
--- /dev/null
+++ b/gps/core/observer/IOsObserver.h
@@ -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__