sanders: gps: update to LA.UM.7.6.r1-02000-89xx.0 tag
This commit is contained in:
@@ -6,8 +6,7 @@ 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_VENDOR_MODULE := true
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
ifeq ($(TARGET_DEVICE),apq8026_lw)
|
||||
@@ -22,8 +21,7 @@ LOCAL_SHARED_LIBRARIES := \
|
||||
libcutils \
|
||||
libgps.utils \
|
||||
libdl \
|
||||
liblog \
|
||||
libloc_pla
|
||||
liblog
|
||||
|
||||
LOCAL_SRC_FILES += \
|
||||
LocApiBase.cpp \
|
||||
@@ -32,9 +30,6 @@ LOCAL_SRC_FILES += \
|
||||
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
|
||||
|
||||
@@ -48,6 +43,7 @@ LOCAL_C_INCLUDES:= \
|
||||
$(LOCAL_PATH)/observer \
|
||||
|
||||
LOCAL_HEADER_LIBRARIES := \
|
||||
libutils_headers \
|
||||
libgps.utils_headers \
|
||||
libloc_pla_headers \
|
||||
liblocation_api_headers
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include <ContextBase.h>
|
||||
#include <msg_q.h>
|
||||
#include <loc_target.h>
|
||||
#include <platform_lib_includes.h>
|
||||
#include <loc_pla.h>
|
||||
#include <loc_log.h>
|
||||
|
||||
namespace loc_core {
|
||||
@@ -65,6 +65,8 @@ const loc_param_s_type ContextBase::mGps_conf_table[] =
|
||||
{"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'},
|
||||
{"SUPL_HOST", &mGps_conf.SUPL_HOST, NULL, 's'},
|
||||
{"SUPL_PORT", &mGps_conf.SUPL_PORT, NULL, 'n'},
|
||||
};
|
||||
|
||||
const loc_param_s_type ContextBase::mSap_conf_table[] =
|
||||
@@ -98,6 +100,8 @@ void ContextBase::readConfig()
|
||||
mGps_conf.SUPL_VER = 0x10000;
|
||||
mGps_conf.SUPL_MODE = 0x1;
|
||||
mGps_conf.SUPL_ES = 0;
|
||||
mGps_conf.SUPL_HOST[0] = 0;
|
||||
mGps_conf.SUPL_PORT = 0;
|
||||
mGps_conf.CAPABILITIES = 0x7;
|
||||
/* LTE Positioning Profile configuration is disable by default*/
|
||||
mGps_conf.LPP_PROFILE = 0;
|
||||
|
||||
@@ -36,7 +36,8 @@
|
||||
#include <LBSProxyBase.h>
|
||||
#include <loc_cfg.h>
|
||||
|
||||
#define MAX_XTRA_SERVER_URL_LENGTH 256
|
||||
#define MAX_XTRA_SERVER_URL_LENGTH (256)
|
||||
#define MAX_SUPL_SERVER_URL_LENGTH (256)
|
||||
|
||||
/* GPS.conf support */
|
||||
/* NOTE: the implementaiton of the parser casts number
|
||||
@@ -64,6 +65,8 @@ typedef struct loc_gps_cfg_s
|
||||
uint32_t LPPE_CP_TECHNOLOGY;
|
||||
uint32_t LPPE_UP_TECHNOLOGY;
|
||||
uint32_t EXTERNAL_DR_ENABLED;
|
||||
char SUPL_HOST[MAX_SUPL_SERVER_URL_LENGTH];
|
||||
uint32_t SUPL_PORT;
|
||||
} loc_gps_cfg_s_type;
|
||||
|
||||
/* NOTE: the implementaiton of the parser casts number
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include <dlfcn.h>
|
||||
#include <LocAdapterBase.h>
|
||||
#include <loc_target.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <log_util.h>
|
||||
#include <LocAdapterProxyBase.h>
|
||||
|
||||
namespace loc_core {
|
||||
@@ -161,4 +161,8 @@ bool LocAdapterBase::
|
||||
reportWwanZppFix(LocGpsLocation &/*zppLoc*/)
|
||||
DEFAULT_IMPL(false)
|
||||
|
||||
bool LocAdapterBase::
|
||||
reportOdcpiRequestEvent(OdcpiRequestInfo& /*request*/)
|
||||
DEFAULT_IMPL(false)
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
@@ -153,6 +153,7 @@ public:
|
||||
virtual void reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& measurements,
|
||||
int msInWeek);
|
||||
virtual bool reportWwanZppFix(LocGpsLocation &zppLoc);
|
||||
virtual bool reportOdcpiRequestEvent(OdcpiRequestInfo& request);
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <inttypes.h>
|
||||
#include <LocApiBase.h>
|
||||
#include <LocAdapterBase.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <log_util.h>
|
||||
#include <LocDualContext.h>
|
||||
|
||||
namespace loc_core {
|
||||
@@ -107,19 +107,16 @@ struct LocSsrMsg : public LocMsg {
|
||||
|
||||
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)
|
||||
inline LocOpenMsg(LocApiBase* locApi) :
|
||||
LocMsg(), mLocApi(locApi)
|
||||
{
|
||||
locallog();
|
||||
}
|
||||
inline virtual void proc() const {
|
||||
mLocApi->open(mMask);
|
||||
mLocApi->open(mLocApi->getEvtMask());
|
||||
}
|
||||
inline void locallog() const {
|
||||
LOC_LOGV("%s:%d]: LocOpen Mask: %x\n",
|
||||
__func__, __LINE__, mMask);
|
||||
LOC_LOGv("LocOpen Mask: %" PRIx64 "\n", mLocApi->getEvtMask());
|
||||
}
|
||||
inline virtual void log() const {
|
||||
locallog();
|
||||
@@ -163,8 +160,7 @@ 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())));
|
||||
mMsgTask->sendMsg(new LocOpenMsg(this));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -200,7 +196,7 @@ void LocApiBase::removeAdapter(LocAdapterBase* adapter)
|
||||
close();
|
||||
} else {
|
||||
// else we need to remove the bit
|
||||
mMsgTask->sendMsg(new LocOpenMsg(this, getEvtMask()));
|
||||
mMsgTask->sendMsg(new LocOpenMsg(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -208,7 +204,7 @@ void LocApiBase::removeAdapter(LocAdapterBase* adapter)
|
||||
|
||||
void LocApiBase::updateEvtMask()
|
||||
{
|
||||
mMsgTask->sendMsg(new LocOpenMsg(this, getEvtMask()));
|
||||
open(getEvtMask());
|
||||
}
|
||||
|
||||
void LocApiBase::handleEngineUpEvent()
|
||||
@@ -264,6 +260,12 @@ void LocApiBase::reportWwanZppFix(LocGpsLocation &zppLoc)
|
||||
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportWwanZppFix(zppLoc));
|
||||
}
|
||||
|
||||
void LocApiBase::reportOdcpiRequest(OdcpiRequestInfo& request)
|
||||
{
|
||||
// loop through adapters, and deliver to the first handling adapter.
|
||||
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportOdcpiRequestEvent(request));
|
||||
}
|
||||
|
||||
void LocApiBase::reportSv(GnssSvNotification& svNotify)
|
||||
{
|
||||
const char* constellationString[] = { "Unknown", "GPS", "SBAS", "GLONASS",
|
||||
@@ -440,6 +442,10 @@ 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::
|
||||
injectPosition(const Location& /*location*/)
|
||||
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)
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <gps_extended.h>
|
||||
#include <LocationAPI.h>
|
||||
#include <MsgTask.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <log_util.h>
|
||||
|
||||
namespace loc_core {
|
||||
class ContextBase;
|
||||
@@ -134,6 +134,7 @@ public:
|
||||
void reportGnssMeasurementData(GnssMeasurementsNotification& measurements, int msInWeek);
|
||||
void saveSupportedFeatureList(uint8_t *featureList);
|
||||
void reportWwanZppFix(LocGpsLocation &zppLoc);
|
||||
void reportOdcpiRequest(OdcpiRequestInfo& request);
|
||||
|
||||
// downward calls
|
||||
// All below functions are to be defined by adapter specific modules:
|
||||
@@ -153,6 +154,8 @@ public:
|
||||
setAPN(char* apn, int len);
|
||||
virtual enum loc_api_adapter_err
|
||||
injectPosition(double latitude, double longitude, float accuracy);
|
||||
virtual enum loc_api_adapter_err
|
||||
injectPosition(const Location& location);
|
||||
virtual enum loc_api_adapter_err
|
||||
setTime(LocGpsUtcTime time, int64_t timeReference, int uncertainty);
|
||||
virtual enum loc_api_adapter_err
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <unistd.h>
|
||||
#include <LocDualContext.h>
|
||||
#include <msg_q.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <log_util.h>
|
||||
#include <loc_log.h>
|
||||
|
||||
namespace loc_core {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
AM_CFLAGS = -I./ \
|
||||
-I../utils \
|
||||
-I../location \
|
||||
$(LOCPLA_CFLAGS) \
|
||||
$(GPSUTILS_CFLAGS) \
|
||||
-I./data-items/ \
|
||||
-I./data-items/common \
|
||||
-I./observer \
|
||||
-I$(WORKSPACE)/gps-noship/flp \
|
||||
-D__func__=__PRETTY_FUNCTION__ \
|
||||
-fno-short-enums \
|
||||
@@ -19,6 +22,7 @@ libloc_core_la_h_sources = \
|
||||
LocAdapterProxyBase.h \
|
||||
data-items/DataItemId.h \
|
||||
data-items/IDataItemCore.h \
|
||||
data-items/DataItemConcreteTypesBase.h \
|
||||
observer/IDataItemObserver.h \
|
||||
observer/IDataItemSubscription.h \
|
||||
observer/IFrameworkActionReq.h \
|
||||
@@ -33,13 +37,10 @@ libloc_core_la_c_sources = \
|
||||
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_includedir = $(pkgincludedir)
|
||||
|
||||
library_include_HEADERS = $(libloc_core_la_h_sources)
|
||||
|
||||
@@ -55,7 +56,11 @@ 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)
|
||||
libloc_core_la_LIBADD = -ldl $(GPSUTILS_LIBS)
|
||||
|
||||
#Create and Install libraries
|
||||
lib_LTLIBRARIES = libloc_core.la
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = loc-core.pc
|
||||
EXTRA_DIST = $(pkgconfig_DATA)
|
||||
|
||||
@@ -34,12 +34,13 @@
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <pthread.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <MsgTask.h>
|
||||
#include <loc_pla.h>
|
||||
#include <log_util.h>
|
||||
#include <loc_nmea.h>
|
||||
#include <DataItemsFactoryProxy.h>
|
||||
#include <SystemStatus.h>
|
||||
#include <SystemStatusOsObserver.h>
|
||||
#include <DataItemConcreteTypesBase.h>
|
||||
|
||||
namespace loc_core
|
||||
{
|
||||
@@ -119,6 +120,12 @@ public:
|
||||
double mAgcGal; // x16
|
||||
int32_t mLeapSeconds;// x17
|
||||
int32_t mLeapSecUnc; // x18
|
||||
uint32_t mGloBpAmpI; // x19
|
||||
uint32_t mGloBpAmpQ; // x1A
|
||||
uint32_t mBdsBpAmpI; // x1B
|
||||
uint32_t mBdsBpAmpQ; // x1C
|
||||
uint32_t mGalBpAmpI; // x1D
|
||||
uint32_t mGalBpAmpQ; // x1E
|
||||
};
|
||||
|
||||
// parser
|
||||
@@ -150,8 +157,15 @@ private:
|
||||
eAgcGlo = 20,
|
||||
eAgcBds = 21,
|
||||
eAgcGal = 22,
|
||||
eMax0 = eAgcGal,
|
||||
eLeapSeconds = 23,
|
||||
eLeapSecUnc = 24,
|
||||
eGloBpAmpI = 25,
|
||||
eGloBpAmpQ = 26,
|
||||
eBdsBpAmpI = 27,
|
||||
eBdsBpAmpQ = 28,
|
||||
eGalBpAmpI = 29,
|
||||
eGalBpAmpQ = 30,
|
||||
eMax
|
||||
};
|
||||
SystemStatusPQWM1 mM1;
|
||||
@@ -181,12 +195,18 @@ public:
|
||||
inline uint32_t getRecErrorRecovery() { return mM1.mRecErrorRecovery; }
|
||||
inline int32_t getLeapSeconds(){ return mM1.mLeapSeconds; }
|
||||
inline int32_t getLeapSecUnc() { return mM1.mLeapSecUnc; }
|
||||
inline uint32_t getGloBpAmpI() { return mM1.mGloBpAmpI; }
|
||||
inline uint32_t getGloBpAmpQ() { return mM1.mGloBpAmpQ; }
|
||||
inline uint32_t getBdsBpAmpI() { return mM1.mBdsBpAmpI; }
|
||||
inline uint32_t getBdsBpAmpQ() { return mM1.mBdsBpAmpQ; }
|
||||
inline uint32_t getGalBpAmpI() { return mM1.mGalBpAmpI; }
|
||||
inline uint32_t getGalBpAmpQ() { return mM1.mGalBpAmpQ; }
|
||||
|
||||
SystemStatusPQWM1parser(const char *str_in, uint32_t len_in)
|
||||
: SystemStatusNmeaBase(str_in, len_in)
|
||||
{
|
||||
memset(&mM1, 0, sizeof(mM1));
|
||||
if (mField.size() < eMax) {
|
||||
if (mField.size() <= eMax0) {
|
||||
LOC_LOGE("PQWM1parser - invalid size=%zu", mField.size());
|
||||
mM1.mTimeValid = 0;
|
||||
return;
|
||||
@@ -213,8 +233,18 @@ public:
|
||||
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());
|
||||
if (mField.size() > eLeapSecUnc) {
|
||||
mM1.mLeapSeconds = atoi(mField[eLeapSeconds].c_str());
|
||||
mM1.mLeapSecUnc = atoi(mField[eLeapSecUnc].c_str());
|
||||
}
|
||||
if (mField.size() > eGalBpAmpQ) {
|
||||
mM1.mGloBpAmpI = atoi(mField[eGloBpAmpI].c_str());
|
||||
mM1.mGloBpAmpQ = atoi(mField[eGloBpAmpQ].c_str());
|
||||
mM1.mBdsBpAmpI = atoi(mField[eBdsBpAmpI].c_str());
|
||||
mM1.mBdsBpAmpQ = atoi(mField[eBdsBpAmpQ].c_str());
|
||||
mM1.mGalBpAmpI = atoi(mField[eGalBpAmpI].c_str());
|
||||
mM1.mGalBpAmpQ = atoi(mField[eGalBpAmpQ].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
inline SystemStatusPQWM1& get() { return mM1;} //getparser
|
||||
@@ -689,7 +719,7 @@ SystemStatusTimeAndClock::SystemStatusTimeAndClock(const SystemStatusPQWM1& nmea
|
||||
{
|
||||
}
|
||||
|
||||
bool SystemStatusTimeAndClock::equals(SystemStatusTimeAndClock& peer)
|
||||
bool SystemStatusTimeAndClock::equals(const SystemStatusTimeAndClock& peer)
|
||||
{
|
||||
if ((mGpsWeek != peer.mGpsWeek) ||
|
||||
(mGpsTowMs != peer.mGpsTowMs) ||
|
||||
@@ -729,7 +759,7 @@ SystemStatusXoState::SystemStatusXoState(const SystemStatusPQWM1& nmea) :
|
||||
{
|
||||
}
|
||||
|
||||
bool SystemStatusXoState::equals(SystemStatusXoState& peer)
|
||||
bool SystemStatusXoState::equals(const SystemStatusXoState& peer)
|
||||
{
|
||||
if (mXoState != peer.mXoState) {
|
||||
return false;
|
||||
@@ -761,11 +791,17 @@ SystemStatusRfAndParams::SystemStatusRfAndParams(const SystemStatusPQWM1& nmea)
|
||||
mAgcGps(nmea.mAgcGps),
|
||||
mAgcGlo(nmea.mAgcGlo),
|
||||
mAgcBds(nmea.mAgcBds),
|
||||
mAgcGal(nmea.mAgcGal)
|
||||
mAgcGal(nmea.mAgcGal),
|
||||
mGloBpAmpI(nmea.mGloBpAmpI),
|
||||
mGloBpAmpQ(nmea.mGloBpAmpQ),
|
||||
mBdsBpAmpI(nmea.mBdsBpAmpI),
|
||||
mBdsBpAmpQ(nmea.mBdsBpAmpQ),
|
||||
mGalBpAmpI(nmea.mGalBpAmpI),
|
||||
mGalBpAmpQ(nmea.mGalBpAmpQ)
|
||||
{
|
||||
}
|
||||
|
||||
bool SystemStatusRfAndParams::equals(SystemStatusRfAndParams& peer)
|
||||
bool SystemStatusRfAndParams::equals(const SystemStatusRfAndParams& peer)
|
||||
{
|
||||
if ((mPgaGain != peer.mPgaGain) ||
|
||||
(mGpsBpAmpI != peer.mGpsBpAmpI) ||
|
||||
@@ -779,7 +815,13 @@ bool SystemStatusRfAndParams::equals(SystemStatusRfAndParams& peer)
|
||||
(mAgcGps != peer.mAgcGps) ||
|
||||
(mAgcGlo != peer.mAgcGlo) ||
|
||||
(mAgcBds != peer.mAgcBds) ||
|
||||
(mAgcGal != peer.mAgcGal)) {
|
||||
(mAgcGal != peer.mAgcGal) ||
|
||||
(mGloBpAmpI != peer.mGloBpAmpI) ||
|
||||
(mGloBpAmpQ != peer.mGloBpAmpQ) ||
|
||||
(mBdsBpAmpI != peer.mBdsBpAmpI) ||
|
||||
(mBdsBpAmpQ != peer.mBdsBpAmpQ) ||
|
||||
(mGalBpAmpI != peer.mGalBpAmpI) ||
|
||||
(mGalBpAmpQ != peer.mGalBpAmpQ)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -815,7 +857,7 @@ SystemStatusErrRecovery::SystemStatusErrRecovery(const SystemStatusPQWM1& nmea)
|
||||
{
|
||||
}
|
||||
|
||||
bool SystemStatusErrRecovery::equals(SystemStatusErrRecovery& peer)
|
||||
bool SystemStatusErrRecovery::equals(const SystemStatusErrRecovery& peer)
|
||||
{
|
||||
if (mRecErrorRecovery != peer.mRecErrorRecovery) {
|
||||
return false;
|
||||
@@ -845,7 +887,7 @@ SystemStatusInjectedPosition::SystemStatusInjectedPosition(const SystemStatusPQW
|
||||
{
|
||||
}
|
||||
|
||||
bool SystemStatusInjectedPosition::equals(SystemStatusInjectedPosition& peer)
|
||||
bool SystemStatusInjectedPosition::equals(const SystemStatusInjectedPosition& peer)
|
||||
{
|
||||
if ((mEpiValidity != peer.mEpiValidity) ||
|
||||
(mEpiLat != peer.mEpiLat) ||
|
||||
@@ -886,7 +928,7 @@ SystemStatusBestPosition::SystemStatusBestPosition(const SystemStatusPQWP2& nmea
|
||||
{
|
||||
}
|
||||
|
||||
bool SystemStatusBestPosition::equals(SystemStatusBestPosition& peer)
|
||||
bool SystemStatusBestPosition::equals(const SystemStatusBestPosition& peer)
|
||||
{
|
||||
if ((mBestLat != peer.mBestLat) ||
|
||||
(mBestLon != peer.mBestLon) ||
|
||||
@@ -928,7 +970,7 @@ SystemStatusXtra::SystemStatusXtra(const SystemStatusPQWP3& nmea) :
|
||||
{
|
||||
}
|
||||
|
||||
bool SystemStatusXtra::equals(SystemStatusXtra& peer)
|
||||
bool SystemStatusXtra::equals(const SystemStatusXtra& peer)
|
||||
{
|
||||
if ((mXtraValidMask != peer.mXtraValidMask) ||
|
||||
(mGpsXtraAge != peer.mGpsXtraAge) ||
|
||||
@@ -976,7 +1018,7 @@ SystemStatusEphemeris::SystemStatusEphemeris(const SystemStatusPQWP4& nmea) :
|
||||
{
|
||||
}
|
||||
|
||||
bool SystemStatusEphemeris::equals(SystemStatusEphemeris& peer)
|
||||
bool SystemStatusEphemeris::equals(const SystemStatusEphemeris& peer)
|
||||
{
|
||||
if ((mGpsEpheValid != peer.mGpsEpheValid) ||
|
||||
(mGloEpheValid != peer.mGloEpheValid) ||
|
||||
@@ -1022,7 +1064,7 @@ SystemStatusSvHealth::SystemStatusSvHealth(const SystemStatusPQWP5& nmea) :
|
||||
{
|
||||
}
|
||||
|
||||
bool SystemStatusSvHealth::equals(SystemStatusSvHealth& peer)
|
||||
bool SystemStatusSvHealth::equals(const SystemStatusSvHealth& peer)
|
||||
{
|
||||
if ((mGpsUnknownMask != peer.mGpsUnknownMask) ||
|
||||
(mGloUnknownMask != peer.mGloUnknownMask) ||
|
||||
@@ -1077,7 +1119,7 @@ SystemStatusPdr::SystemStatusPdr(const SystemStatusPQWP6& nmea) :
|
||||
{
|
||||
}
|
||||
|
||||
bool SystemStatusPdr::equals(SystemStatusPdr& peer)
|
||||
bool SystemStatusPdr::equals(const SystemStatusPdr& peer)
|
||||
{
|
||||
if (mFixInfoMask != peer.mFixInfoMask) {
|
||||
return false;
|
||||
@@ -1103,7 +1145,7 @@ SystemStatusNavData::SystemStatusNavData(const SystemStatusPQWP7& nmea)
|
||||
}
|
||||
}
|
||||
|
||||
bool SystemStatusNavData::equals(SystemStatusNavData& peer)
|
||||
bool SystemStatusNavData::equals(const SystemStatusNavData& peer)
|
||||
{
|
||||
for (uint32_t i=0; i<SV_ALL_NUM; i++) {
|
||||
if ((mNav[i].mType != peer.mNav[i].mType) ||
|
||||
@@ -1135,7 +1177,7 @@ SystemStatusPositionFailure::SystemStatusPositionFailure(const SystemStatusPQWS1
|
||||
{
|
||||
}
|
||||
|
||||
bool SystemStatusPositionFailure::equals(SystemStatusPositionFailure& peer)
|
||||
bool SystemStatusPositionFailure::equals(const SystemStatusPositionFailure& peer)
|
||||
{
|
||||
if ((mFixInfoMask != peer.mFixInfoMask) ||
|
||||
(mHepeLimit != peer.mHepeLimit)) {
|
||||
@@ -1156,7 +1198,7 @@ void SystemStatusPositionFailure::dump()
|
||||
/******************************************************************************
|
||||
SystemStatusLocation
|
||||
******************************************************************************/
|
||||
bool SystemStatusLocation::equals(SystemStatusLocation& peer)
|
||||
bool SystemStatusLocation::equals(const SystemStatusLocation& peer)
|
||||
{
|
||||
if ((mLocation.gpsLocation.latitude != peer.mLocation.gpsLocation.latitude) ||
|
||||
(mLocation.gpsLocation.longitude != peer.mLocation.gpsLocation.longitude) ||
|
||||
@@ -1213,8 +1255,7 @@ IOsObserver* SystemStatus::getOsObserver()
|
||||
}
|
||||
|
||||
SystemStatus::SystemStatus(const MsgTask* msgTask) :
|
||||
mSysStatusObsvr(msgTask),
|
||||
mConnected(false)
|
||||
mSysStatusObsvr(this, msgTask)
|
||||
{
|
||||
int result = 0;
|
||||
ENTRY_LOG ();
|
||||
@@ -1235,230 +1276,81 @@ SystemStatus::SystemStatus(const MsgTask* msgTask) :
|
||||
|
||||
mCache.mPositionFailure.clear();
|
||||
|
||||
mCache.mAirplaneMode.clear();
|
||||
mCache.mENH.clear();
|
||||
mCache.mGPSState.clear();
|
||||
mCache.mNLPStatus.clear();
|
||||
mCache.mWifiHardwareState.clear();
|
||||
mCache.mNetworkInfo.clear();
|
||||
mCache.mRilServiceInfo.clear();
|
||||
mCache.mRilCellInfo.clear();
|
||||
mCache.mServiceStatus.clear();
|
||||
mCache.mModel.clear();
|
||||
mCache.mManufacturer.clear();
|
||||
mCache.mAssistedGps.clear();
|
||||
mCache.mScreenState.clear();
|
||||
mCache.mPowerConnectState.clear();
|
||||
mCache.mTimeZoneChange.clear();
|
||||
mCache.mTimeChange.clear();
|
||||
mCache.mWifiSupplicantStatus.clear();
|
||||
mCache.mShutdownState.clear();
|
||||
mCache.mTac.clear();
|
||||
mCache.mMccMnc.clear();
|
||||
mCache.mBtDeviceScanDetail.clear();
|
||||
mCache.mBtLeDeviceScanDetail.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;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
SystemStatus - storing dataitems
|
||||
******************************************************************************/
|
||||
bool SystemStatus::setNetworkInfo(IDataItemCore* dataitem)
|
||||
template <typename TYPE_REPORT, typename TYPE_ITEM>
|
||||
bool SystemStatus::setIteminReport(TYPE_REPORT& report, TYPE_ITEM&& s)
|
||||
{
|
||||
SystemStatusNetworkInfo* data = reinterpret_cast<SystemStatusNetworkInfo*>(dataitem);
|
||||
SystemStatusNetworkInfo s(data->mType,data->mTypeName,data->mSubTypeName,
|
||||
data->mAvailable,data->mConnected,data->mRoaming);
|
||||
s.dump();
|
||||
mConnected = data->mConnected;
|
||||
if (!report.empty() && report.back().equals(static_cast<TYPE_ITEM&>(s.collate(report.back())))) {
|
||||
// there is no change - just update reported timestamp
|
||||
report.back().mUtcReported = s.mUtcReported;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mCache.mNetworkInfo.empty() && mCache.mNetworkInfo.back().equals(s)) {
|
||||
mCache.mNetworkInfo.back().mUtcReported = s.mUtcReported;
|
||||
} else {
|
||||
mCache.mNetworkInfo.push_back(s);
|
||||
if (mCache.mNetworkInfo.size() > maxNetworkInfo) {
|
||||
mCache.mNetworkInfo.erase(mCache.mNetworkInfo.begin());
|
||||
}
|
||||
// first event or updated
|
||||
report.push_back(s);
|
||||
if (report.size() > s.maxItem) {
|
||||
report.erase(report.begin());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename TYPE_REPORT, typename TYPE_ITEM>
|
||||
void SystemStatus::setDefaultIteminReport(TYPE_REPORT& report, const TYPE_ITEM& s)
|
||||
{
|
||||
report.push_back(s);
|
||||
if (report.size() > s.maxItem) {
|
||||
report.erase(report.begin());
|
||||
}
|
||||
}
|
||||
|
||||
template <typename TYPE_REPORT, typename TYPE_ITEM>
|
||||
void SystemStatus::getIteminReport(TYPE_REPORT& reportout, const TYPE_ITEM& c) const
|
||||
{
|
||||
reportout.clear();
|
||||
if (c.size() >= 1) {
|
||||
reportout.push_back(c.back());
|
||||
reportout.back().dump();
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@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
|
||||
@return true when the NMEA is consumed by the method.
|
||||
******************************************************************************/
|
||||
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;
|
||||
}
|
||||
@@ -1469,64 +1361,51 @@ bool SystemStatus::setNmeaString(const char *data, uint32_t len)
|
||||
pthread_mutex_lock(&mMutexSystemStatus);
|
||||
|
||||
// parse the received nmea strings here
|
||||
if (0 == strncmp(data, "$PQWM1", SystemStatusNmeaBase::NMEA_MINSIZE)) {
|
||||
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++;
|
||||
setIteminReport(mCache.mTimeAndClock, SystemStatusTimeAndClock(s));
|
||||
setIteminReport(mCache.mXoState, SystemStatusXoState(s));
|
||||
setIteminReport(mCache.mRfAndParams, SystemStatusRfAndParams(s));
|
||||
setIteminReport(mCache.mErrRecovery, SystemStatusErrRecovery(s));
|
||||
}
|
||||
else if (0 == strncmp(data, "$PQWP1", SystemStatusNmeaBase::NMEA_MINSIZE)) {
|
||||
ret = setInjectedPosition(SystemStatusPQWP1parser(buf, len).get());
|
||||
cnt_p1++;
|
||||
setIteminReport(mCache.mInjectedPosition,
|
||||
SystemStatusInjectedPosition(SystemStatusPQWP1parser(buf, len).get()));
|
||||
}
|
||||
else if (0 == strncmp(data, "$PQWP2", SystemStatusNmeaBase::NMEA_MINSIZE)) {
|
||||
ret = setBestPosition(SystemStatusPQWP2parser(buf, len).get());
|
||||
cnt_p2++;
|
||||
setIteminReport(mCache.mBestPosition,
|
||||
SystemStatusBestPosition(SystemStatusPQWP2parser(buf, len).get()));
|
||||
}
|
||||
else if (0 == strncmp(data, "$PQWP3", SystemStatusNmeaBase::NMEA_MINSIZE)) {
|
||||
ret = setXtra(SystemStatusPQWP3parser(buf, len).get());
|
||||
cnt_p3++;
|
||||
setIteminReport(mCache.mXtra,
|
||||
SystemStatusXtra(SystemStatusPQWP3parser(buf, len).get()));
|
||||
}
|
||||
else if (0 == strncmp(data, "$PQWP4", SystemStatusNmeaBase::NMEA_MINSIZE)) {
|
||||
ret = setEphemeris(SystemStatusPQWP4parser(buf, len).get());
|
||||
cnt_p4++;
|
||||
setIteminReport(mCache.mEphemeris,
|
||||
SystemStatusEphemeris(SystemStatusPQWP4parser(buf, len).get()));
|
||||
}
|
||||
else if (0 == strncmp(data, "$PQWP5", SystemStatusNmeaBase::NMEA_MINSIZE)) {
|
||||
ret = setSvHealth(SystemStatusPQWP5parser(buf, len).get());
|
||||
cnt_p5++;
|
||||
setIteminReport(mCache.mSvHealth,
|
||||
SystemStatusSvHealth(SystemStatusPQWP5parser(buf, len).get()));
|
||||
}
|
||||
else if (0 == strncmp(data, "$PQWP6", SystemStatusNmeaBase::NMEA_MINSIZE)) {
|
||||
ret = setPdr(SystemStatusPQWP6parser(buf, len).get());
|
||||
cnt_p6++;
|
||||
setIteminReport(mCache.mPdr,
|
||||
SystemStatusPdr(SystemStatusPQWP6parser(buf, len).get()));
|
||||
}
|
||||
else if (0 == strncmp(data, "$PQWP7", SystemStatusNmeaBase::NMEA_MINSIZE)) {
|
||||
ret = setNavData(SystemStatusPQWP7parser(buf, len).get());
|
||||
cnt_p7++;
|
||||
setIteminReport(mCache.mNavData,
|
||||
SystemStatusNavData(SystemStatusPQWP7parser(buf, len).get()));
|
||||
}
|
||||
else if (0 == strncmp(data, "$PQWS1", SystemStatusNmeaBase::NMEA_MINSIZE)) {
|
||||
ret = setPositionFailure(SystemStatusPQWS1parser(buf, len).get());
|
||||
cnt_s1++;
|
||||
setIteminReport(mCache.mPositionFailure,
|
||||
SystemStatusPositionFailure(SystemStatusPQWS1parser(buf, len).get()));
|
||||
}
|
||||
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;
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -1539,22 +1418,18 @@ bool SystemStatus::setNmeaString(const char *data, uint32_t len)
|
||||
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());
|
||||
}
|
||||
}
|
||||
bool ret = false;
|
||||
pthread_mutex_lock(&mMutexSystemStatus);
|
||||
|
||||
ret = setIteminReport(mCache.mLocation, SystemStatusLocation(location, locationEx));
|
||||
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;
|
||||
location.gpsLocation.latitude,
|
||||
location.gpsLocation.longitude,
|
||||
location.gpsLocation.altitude,
|
||||
location.gpsLocation.speed);
|
||||
|
||||
pthread_mutex_unlock(&mMutexSystemStatus);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -1562,19 +1437,107 @@ bool SystemStatus::eventPosition(const UlpLocation& location,
|
||||
|
||||
@param[In] DataItem
|
||||
|
||||
@return true when successfully done
|
||||
@return true when info is updatated
|
||||
******************************************************************************/
|
||||
bool SystemStatus::eventDataItemNotify(IDataItemCore* dataitem)
|
||||
{
|
||||
bool ret = false;
|
||||
pthread_mutex_lock(&mMutexSystemStatus);
|
||||
switch(dataitem->getId())
|
||||
{
|
||||
case AIRPLANEMODE_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mAirplaneMode,
|
||||
SystemStatusAirplaneMode(*(static_cast<AirplaneModeDataItemBase*>(dataitem))));
|
||||
break;
|
||||
case ENH_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mENH,
|
||||
SystemStatusENH(*(static_cast<ENHDataItemBase*>(dataitem))));
|
||||
break;
|
||||
case GPSSTATE_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mGPSState,
|
||||
SystemStatusGpsState(*(static_cast<GPSStateDataItemBase*>(dataitem))));
|
||||
break;
|
||||
case NLPSTATUS_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mNLPStatus,
|
||||
SystemStatusNLPStatus(*(static_cast<NLPStatusDataItemBase*>(dataitem))));
|
||||
break;
|
||||
case WIFIHARDWARESTATE_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mWifiHardwareState,
|
||||
SystemStatusWifiHardwareState(*(static_cast<WifiHardwareStateDataItemBase*>(dataitem))));
|
||||
break;
|
||||
case NETWORKINFO_DATA_ITEM_ID:
|
||||
setNetworkInfo(dataitem);
|
||||
ret = setIteminReport(mCache.mNetworkInfo,
|
||||
SystemStatusNetworkInfo(*(static_cast<NetworkInfoDataItemBase*>(dataitem))));
|
||||
break;
|
||||
case RILSERVICEINFO_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mRilServiceInfo,
|
||||
SystemStatusServiceInfo(*(static_cast<RilServiceInfoDataItemBase*>(dataitem))));
|
||||
break;
|
||||
case RILCELLINFO_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mRilCellInfo,
|
||||
SystemStatusRilCellInfo(*(static_cast<RilCellInfoDataItemBase*>(dataitem))));
|
||||
break;
|
||||
case SERVICESTATUS_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mServiceStatus,
|
||||
SystemStatusServiceStatus(*(static_cast<ServiceStatusDataItemBase*>(dataitem))));
|
||||
break;
|
||||
case MODEL_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mModel,
|
||||
SystemStatusModel(*(static_cast<ModelDataItemBase*>(dataitem))));
|
||||
break;
|
||||
case MANUFACTURER_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mManufacturer,
|
||||
SystemStatusManufacturer(*(static_cast<ManufacturerDataItemBase*>(dataitem))));
|
||||
break;
|
||||
case ASSISTED_GPS_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mAssistedGps,
|
||||
SystemStatusAssistedGps(*(static_cast<AssistedGpsDataItemBase*>(dataitem))));
|
||||
break;
|
||||
case SCREEN_STATE_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mScreenState,
|
||||
SystemStatusScreenState(*(static_cast<ScreenStateDataItemBase*>(dataitem))));
|
||||
break;
|
||||
case POWER_CONNECTED_STATE_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mPowerConnectState,
|
||||
SystemStatusPowerConnectState(*(static_cast<PowerConnectStateDataItemBase*>(dataitem))));
|
||||
break;
|
||||
case TIMEZONE_CHANGE_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mTimeZoneChange,
|
||||
SystemStatusTimeZoneChange(*(static_cast<TimeZoneChangeDataItemBase*>(dataitem))));
|
||||
break;
|
||||
case TIME_CHANGE_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mTimeChange,
|
||||
SystemStatusTimeChange(*(static_cast<TimeChangeDataItemBase*>(dataitem))));
|
||||
break;
|
||||
case WIFI_SUPPLICANT_STATUS_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mWifiSupplicantStatus,
|
||||
SystemStatusWifiSupplicantStatus(*(static_cast<WifiSupplicantStatusDataItemBase*>(dataitem))));
|
||||
break;
|
||||
case SHUTDOWN_STATE_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mShutdownState,
|
||||
SystemStatusShutdownState(*(static_cast<ShutdownStateDataItemBase*>(dataitem))));
|
||||
break;
|
||||
case TAC_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mTac,
|
||||
SystemStatusTac(*(static_cast<TacDataItemBase*>(dataitem))));
|
||||
break;
|
||||
case MCCMNC_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mMccMnc,
|
||||
SystemStatusMccMnc(*(static_cast<MccmncDataItemBase*>(dataitem))));
|
||||
break;
|
||||
case BTLE_SCAN_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mBtDeviceScanDetail,
|
||||
SystemStatusBtDeviceScanDetail(*(static_cast<BtDeviceScanDetailsDataItemBase*>(dataitem))));
|
||||
break;
|
||||
case BT_SCAN_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mBtLeDeviceScanDetail,
|
||||
SystemStatusBtleDeviceScanDetail(*(static_cast<BtLeDeviceScanDetailsDataItemBase*>(dataitem))));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
pthread_mutex_unlock(&mMutexSystemStatus);
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -1591,74 +1554,45 @@ bool SystemStatus::getReport(SystemStatusReports& report, bool isLatestOnly) con
|
||||
|
||||
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();
|
||||
}
|
||||
getIteminReport(report.mLocation, mCache.mLocation);
|
||||
|
||||
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();
|
||||
}
|
||||
getIteminReport(report.mTimeAndClock, mCache.mTimeAndClock);
|
||||
getIteminReport(report.mXoState, mCache.mXoState);
|
||||
getIteminReport(report.mRfAndParams, mCache.mRfAndParams);
|
||||
getIteminReport(report.mErrRecovery, mCache.mErrRecovery);
|
||||
|
||||
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();
|
||||
}
|
||||
getIteminReport(report.mInjectedPosition, mCache.mInjectedPosition);
|
||||
getIteminReport(report.mBestPosition, mCache.mBestPosition);
|
||||
getIteminReport(report.mXtra, mCache.mXtra);
|
||||
getIteminReport(report.mEphemeris, mCache.mEphemeris);
|
||||
getIteminReport(report.mSvHealth, mCache.mSvHealth);
|
||||
getIteminReport(report.mPdr, mCache.mPdr);
|
||||
getIteminReport(report.mNavData, mCache.mNavData);
|
||||
|
||||
report.mPositionFailure.clear();
|
||||
if (mCache.mPositionFailure.size() >= 1) {
|
||||
report.mPositionFailure.push_back(mCache.mPositionFailure.back());
|
||||
report.mPositionFailure.back().dump();
|
||||
}
|
||||
getIteminReport(report.mPositionFailure, mCache.mPositionFailure);
|
||||
|
||||
getIteminReport(report.mAirplaneMode, mCache.mAirplaneMode);
|
||||
getIteminReport(report.mENH, mCache.mENH);
|
||||
getIteminReport(report.mGPSState, mCache.mGPSState);
|
||||
getIteminReport(report.mNLPStatus, mCache.mNLPStatus);
|
||||
getIteminReport(report.mWifiHardwareState, mCache.mWifiHardwareState);
|
||||
getIteminReport(report.mNetworkInfo, mCache.mNetworkInfo);
|
||||
getIteminReport(report.mRilServiceInfo, mCache.mRilServiceInfo);
|
||||
getIteminReport(report.mRilCellInfo, mCache.mRilCellInfo);
|
||||
getIteminReport(report.mServiceStatus, mCache.mServiceStatus);
|
||||
getIteminReport(report.mModel, mCache.mModel);
|
||||
getIteminReport(report.mManufacturer, mCache.mManufacturer);
|
||||
getIteminReport(report.mAssistedGps, mCache.mAssistedGps);
|
||||
getIteminReport(report.mScreenState, mCache.mScreenState);
|
||||
getIteminReport(report.mPowerConnectState, mCache.mPowerConnectState);
|
||||
getIteminReport(report.mTimeZoneChange, mCache.mTimeZoneChange);
|
||||
getIteminReport(report.mTimeChange, mCache.mTimeChange);
|
||||
getIteminReport(report.mWifiSupplicantStatus, mCache.mWifiSupplicantStatus);
|
||||
getIteminReport(report.mShutdownState, mCache.mShutdownState);
|
||||
getIteminReport(report.mTac, mCache.mTac);
|
||||
getIteminReport(report.mMccMnc, mCache.mMccMnc);
|
||||
getIteminReport(report.mBtDeviceScanDetail, mCache.mBtDeviceScanDetail);
|
||||
getIteminReport(report.mBtLeDeviceScanDetail, mCache.mBtLeDeviceScanDetail);
|
||||
}
|
||||
else {
|
||||
// copy entire reports and return them
|
||||
@@ -1678,6 +1612,30 @@ bool SystemStatus::getReport(SystemStatusReports& report, bool isLatestOnly) con
|
||||
report.mNavData.clear();
|
||||
|
||||
report.mPositionFailure.clear();
|
||||
|
||||
report.mAirplaneMode.clear();
|
||||
report.mENH.clear();
|
||||
report.mGPSState.clear();
|
||||
report.mNLPStatus.clear();
|
||||
report.mWifiHardwareState.clear();
|
||||
report.mNetworkInfo.clear();
|
||||
report.mRilServiceInfo.clear();
|
||||
report.mRilCellInfo.clear();
|
||||
report.mServiceStatus.clear();
|
||||
report.mModel.clear();
|
||||
report.mManufacturer.clear();
|
||||
report.mAssistedGps.clear();
|
||||
report.mScreenState.clear();
|
||||
report.mPowerConnectState.clear();
|
||||
report.mTimeZoneChange.clear();
|
||||
report.mTimeChange.clear();
|
||||
report.mWifiSupplicantStatus.clear();
|
||||
report.mShutdownState.clear();
|
||||
report.mTac.clear();
|
||||
report.mMccMnc.clear();
|
||||
report.mBtDeviceScanDetail.clear();
|
||||
report.mBtLeDeviceScanDetail.clear();
|
||||
|
||||
report = mCache;
|
||||
}
|
||||
|
||||
@@ -1692,65 +1650,26 @@ bool SystemStatus::getReport(SystemStatusReports& report, bool isLatestOnly) con
|
||||
|
||||
@return true when successfully done
|
||||
******************************************************************************/
|
||||
bool SystemStatus::setDefaultReport(void)
|
||||
bool SystemStatus::setDefaultGnssEngineStates(void)
|
||||
{
|
||||
pthread_mutex_lock(&mMutexSystemStatus);
|
||||
|
||||
mCache.mLocation.push_back(SystemStatusLocation());
|
||||
if (mCache.mLocation.size() > maxLocation) {
|
||||
mCache.mLocation.erase(mCache.mLocation.begin());
|
||||
}
|
||||
setDefaultIteminReport(mCache.mLocation, SystemStatusLocation());
|
||||
|
||||
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());
|
||||
}
|
||||
setDefaultIteminReport(mCache.mTimeAndClock, SystemStatusTimeAndClock());
|
||||
setDefaultIteminReport(mCache.mXoState, SystemStatusXoState());
|
||||
setDefaultIteminReport(mCache.mRfAndParams, SystemStatusRfAndParams());
|
||||
setDefaultIteminReport(mCache.mErrRecovery, SystemStatusErrRecovery());
|
||||
|
||||
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());
|
||||
}
|
||||
setDefaultIteminReport(mCache.mInjectedPosition, SystemStatusInjectedPosition());
|
||||
setDefaultIteminReport(mCache.mBestPosition, SystemStatusBestPosition());
|
||||
setDefaultIteminReport(mCache.mXtra, SystemStatusXtra());
|
||||
setDefaultIteminReport(mCache.mEphemeris, SystemStatusEphemeris());
|
||||
setDefaultIteminReport(mCache.mSvHealth, SystemStatusSvHealth());
|
||||
setDefaultIteminReport(mCache.mPdr, SystemStatusPdr());
|
||||
setDefaultIteminReport(mCache.mNavData, SystemStatusNavData());
|
||||
|
||||
mCache.mPositionFailure.push_back(SystemStatusPositionFailure());
|
||||
if (mCache.mPositionFailure.size() > maxPositionFailure) {
|
||||
mCache.mPositionFailure.erase(mCache.mPositionFailure.begin());
|
||||
}
|
||||
setDefaultIteminReport(mCache.mPositionFailure, SystemStatusPositionFailure());
|
||||
|
||||
pthread_mutex_unlock(&mMutexSystemStatus);
|
||||
return true;
|
||||
@@ -1763,24 +1682,12 @@ bool SystemStatus::setDefaultReport(void)
|
||||
|
||||
@return true when successfully done
|
||||
******************************************************************************/
|
||||
bool SystemStatus::eventConnectionStatus(bool connected, uint8_t type)
|
||||
bool SystemStatus::eventConnectionStatus(bool connected, int8_t type)
|
||||
{
|
||||
if (connected != mConnected) {
|
||||
mConnected = connected;
|
||||
// send networkinof dataitem to systemstatus observer clients
|
||||
SystemStatusNetworkInfo s(type, "", "", connected);
|
||||
mSysStatusObsvr.notify({&s});
|
||||
|
||||
// send networkinof dataitem to systemstatus observer clients
|
||||
SystemStatusNetworkInfo s(type, "", "", false, connected, false);
|
||||
IDataItemCore *networkinfo =
|
||||
DataItemsFactoryProxy::createNewDataItem(NETWORKINFO_DATA_ITEM_ID);
|
||||
if (nullptr == networkinfo) {
|
||||
LOC_LOGE("Unable to create dataitemd");
|
||||
return false;
|
||||
}
|
||||
networkinfo->copy(&s);
|
||||
list<IDataItemCore*> dl(0);
|
||||
dl.push_back(networkinfo);
|
||||
mSysStatusObsvr.notify(dl);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,12 +30,14 @@
|
||||
#define __SYSTEM_STATUS__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <sys/time.h>
|
||||
#include <vector>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <loc_pla.h>
|
||||
#include <log_util.h>
|
||||
#include <MsgTask.h>
|
||||
#include <IDataItemCore.h>
|
||||
#include <IOsObserver.h>
|
||||
#include <DataItemConcreteTypesBase.h>
|
||||
#include <SystemStatusOsObserver.h>
|
||||
|
||||
#include <gps_extended_c.h>
|
||||
@@ -66,16 +68,20 @@ class SystemStatusItemBase
|
||||
public:
|
||||
timespec mUtcTime; // UTC timestamp when this info was last updated
|
||||
timespec mUtcReported; // UTC timestamp when this info was reported
|
||||
static const uint32_t maxItem = 5;
|
||||
|
||||
SystemStatusItemBase() {
|
||||
timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
struct timespec tv;
|
||||
clock_gettime(CLOCK_MONOTONIC, &tv);
|
||||
mUtcTime.tv_sec = tv.tv_sec;
|
||||
mUtcTime.tv_nsec = tv.tv_usec *1000ULL;
|
||||
mUtcTime.tv_nsec = tv.tv_nsec;
|
||||
mUtcReported = mUtcTime;
|
||||
};
|
||||
virtual ~SystemStatusItemBase() { };
|
||||
virtual void dump(void) { };
|
||||
virtual ~SystemStatusItemBase() {};
|
||||
inline virtual SystemStatusItemBase& collate(SystemStatusItemBase&) {
|
||||
return *this;
|
||||
}
|
||||
virtual void dump(void) {};
|
||||
};
|
||||
|
||||
class SystemStatusLocation : public SystemStatusItemBase
|
||||
@@ -90,8 +96,8 @@ public:
|
||||
const GpsLocationExtended& locationEx) :
|
||||
mValid(true),
|
||||
mLocation(location),
|
||||
mLocationEx(locationEx) { }
|
||||
bool equals(SystemStatusLocation& peer);
|
||||
mLocationEx(locationEx) {}
|
||||
bool equals(const SystemStatusLocation& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
@@ -119,7 +125,7 @@ public:
|
||||
mLeapSeconds(0),
|
||||
mLeapSecUnc(0) {}
|
||||
inline SystemStatusTimeAndClock(const SystemStatusPQWM1& nmea);
|
||||
bool equals(SystemStatusTimeAndClock& peer);
|
||||
bool equals(const SystemStatusTimeAndClock& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
@@ -130,7 +136,7 @@ public:
|
||||
inline SystemStatusXoState() :
|
||||
mXoState(0) {}
|
||||
inline SystemStatusXoState(const SystemStatusPQWM1& nmea);
|
||||
bool equals(SystemStatusXoState& peer);
|
||||
bool equals(const SystemStatusXoState& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
@@ -150,6 +156,12 @@ public:
|
||||
double mAgcGlo;
|
||||
double mAgcBds;
|
||||
double mAgcGal;
|
||||
uint32_t mGloBpAmpI;
|
||||
uint32_t mGloBpAmpQ;
|
||||
uint32_t mBdsBpAmpI;
|
||||
uint32_t mBdsBpAmpQ;
|
||||
uint32_t mGalBpAmpI;
|
||||
uint32_t mGalBpAmpQ;
|
||||
inline SystemStatusRfAndParams() :
|
||||
mPgaGain(0),
|
||||
mGpsBpAmpI(0),
|
||||
@@ -163,9 +175,15 @@ public:
|
||||
mAgcGps(0),
|
||||
mAgcGlo(0),
|
||||
mAgcBds(0),
|
||||
mAgcGal(0) {}
|
||||
mAgcGal(0),
|
||||
mGloBpAmpI(0),
|
||||
mGloBpAmpQ(0),
|
||||
mBdsBpAmpI(0),
|
||||
mBdsBpAmpQ(0),
|
||||
mGalBpAmpI(0),
|
||||
mGalBpAmpQ(0) {}
|
||||
inline SystemStatusRfAndParams(const SystemStatusPQWM1& nmea);
|
||||
bool equals(SystemStatusRfAndParams& peer);
|
||||
bool equals(const SystemStatusRfAndParams& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
@@ -176,7 +194,7 @@ public:
|
||||
inline SystemStatusErrRecovery() :
|
||||
mRecErrorRecovery(0) {};
|
||||
inline SystemStatusErrRecovery(const SystemStatusPQWM1& nmea);
|
||||
bool equals(SystemStatusErrRecovery& peer);
|
||||
bool equals(const SystemStatusErrRecovery& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
@@ -200,7 +218,7 @@ public:
|
||||
mEpiAltUnc(0),
|
||||
mEpiSrc(0) {}
|
||||
inline SystemStatusInjectedPosition(const SystemStatusPQWP1& nmea);
|
||||
bool equals(SystemStatusInjectedPosition& peer);
|
||||
bool equals(const SystemStatusInjectedPosition& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
@@ -222,7 +240,7 @@ public:
|
||||
mBestHepe(0),
|
||||
mBestAltUnc(0) {}
|
||||
inline SystemStatusBestPosition(const SystemStatusPQWP2& nmea);
|
||||
bool equals(SystemStatusBestPosition& peer);
|
||||
bool equals(const SystemStatusBestPosition& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
@@ -254,7 +272,7 @@ public:
|
||||
mGalXtraValid(0ULL),
|
||||
mQzssXtraValid(0) {}
|
||||
inline SystemStatusXtra(const SystemStatusPQWP3& nmea);
|
||||
bool equals(SystemStatusXtra& peer);
|
||||
bool equals(const SystemStatusXtra& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
@@ -274,7 +292,7 @@ public:
|
||||
mGalEpheValid(0ULL),
|
||||
mQzssEpheValid(0) {}
|
||||
inline SystemStatusEphemeris(const SystemStatusPQWP4& nmea);
|
||||
bool equals(SystemStatusEphemeris& peer);
|
||||
bool equals(const SystemStatusEphemeris& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
@@ -314,7 +332,7 @@ public:
|
||||
mGalBadMask(0ULL),
|
||||
mQzssBadMask(0) {}
|
||||
inline SystemStatusSvHealth(const SystemStatusPQWP5& nmea);
|
||||
bool equals(SystemStatusSvHealth& peer);
|
||||
bool equals(const SystemStatusSvHealth& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
@@ -326,7 +344,7 @@ public:
|
||||
inline SystemStatusPdr() :
|
||||
mFixInfoMask(0) {}
|
||||
inline SystemStatusPdr(const SystemStatusPQWP6& nmea);
|
||||
bool equals(SystemStatusPdr& peer);
|
||||
bool equals(const SystemStatusPdr& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
@@ -350,7 +368,7 @@ public:
|
||||
}
|
||||
}
|
||||
inline SystemStatusNavData(const SystemStatusPQWP7& nmea);
|
||||
bool equals(SystemStatusNavData& peer);
|
||||
bool equals(const SystemStatusNavData& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
@@ -364,168 +382,352 @@ public:
|
||||
mFixInfoMask(0),
|
||||
mHepeLimit(0) {}
|
||||
inline SystemStatusPositionFailure(const SystemStatusPQWS1& nmea);
|
||||
bool equals(SystemStatusPositionFailure& peer);
|
||||
bool equals(const SystemStatusPositionFailure& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
SystemStatus report data structure - from DataItem observer
|
||||
******************************************************************************/
|
||||
class SystemStatusGpsState : public SystemStatusItemBase, public IDataItemCore
|
||||
class SystemStatusAirplaneMode : public SystemStatusItemBase,
|
||||
public AirplaneModeDataItemBase
|
||||
{
|
||||
public:
|
||||
inline SystemStatusGpsState() :
|
||||
mEnabled(false) {}
|
||||
inline SystemStatusGpsState(bool enabled) :
|
||||
mEnabled(enabled) {}
|
||||
inline SystemStatusAirplaneMode(bool mode=false) :
|
||||
AirplaneModeDataItemBase(mode) {}
|
||||
inline SystemStatusAirplaneMode(const AirplaneModeDataItemBase& itemBase) :
|
||||
AirplaneModeDataItemBase(itemBase) {}
|
||||
inline bool equals(const SystemStatusAirplaneMode& peer) {
|
||||
return (mMode == peer.mMode);
|
||||
}
|
||||
};
|
||||
|
||||
bool mEnabled;
|
||||
|
||||
inline bool equals(SystemStatusGpsState& peer) {
|
||||
class SystemStatusENH : public SystemStatusItemBase,
|
||||
public ENHDataItemBase
|
||||
{
|
||||
public:
|
||||
inline SystemStatusENH(bool enabled=false) :
|
||||
ENHDataItemBase(enabled) {}
|
||||
inline SystemStatusENH(const ENHDataItemBase& itemBase) :
|
||||
ENHDataItemBase(itemBase) {}
|
||||
inline bool equals(const SystemStatusENH& peer) {
|
||||
return (mEnabled == peer.mEnabled);
|
||||
}
|
||||
inline void dump(void) {
|
||||
};
|
||||
|
||||
class SystemStatusGpsState : public SystemStatusItemBase,
|
||||
public GPSStateDataItemBase
|
||||
{
|
||||
public:
|
||||
inline SystemStatusGpsState(bool enabled=false) :
|
||||
GPSStateDataItemBase(enabled) {}
|
||||
inline SystemStatusGpsState(const GPSStateDataItemBase& itemBase) :
|
||||
GPSStateDataItemBase(itemBase) {}
|
||||
inline bool equals(const SystemStatusGpsState& peer) {
|
||||
return (mEnabled == peer.mEnabled);
|
||||
}
|
||||
inline void dump(void) override {
|
||||
LOC_LOGD("GpsState: state=%u", mEnabled);
|
||||
}
|
||||
inline DataItemId getId() {
|
||||
return GPSSTATE_DATA_ITEM_ID;
|
||||
}
|
||||
inline void stringify(string& valueStr) {
|
||||
valueStr.clear();
|
||||
valueStr += "GpsState: enabled=";
|
||||
valueStr += to_string(mEnabled);
|
||||
}
|
||||
inline int32_t copy(IDataItemCore* src, bool* dataItemCopied = nullptr) {
|
||||
SystemStatusGpsState* gpsstate = static_cast<SystemStatusGpsState*>(src);
|
||||
mEnabled = gpsstate->mEnabled;
|
||||
if (dataItemCopied) {
|
||||
*dataItemCopied = true;
|
||||
}
|
||||
return 1;
|
||||
};
|
||||
|
||||
class SystemStatusNLPStatus : public SystemStatusItemBase,
|
||||
public NLPStatusDataItemBase
|
||||
{
|
||||
public:
|
||||
inline SystemStatusNLPStatus(bool enabled=false) :
|
||||
NLPStatusDataItemBase(enabled) {}
|
||||
inline SystemStatusNLPStatus(const NLPStatusDataItemBase& itemBase) :
|
||||
NLPStatusDataItemBase(itemBase) {}
|
||||
inline bool equals(const SystemStatusNLPStatus& peer) {
|
||||
return (mEnabled == peer.mEnabled);
|
||||
}
|
||||
};
|
||||
|
||||
class SystemStatusNetworkInfo : public SystemStatusItemBase, public IDataItemCore
|
||||
class SystemStatusWifiHardwareState : public SystemStatusItemBase,
|
||||
public WifiHardwareStateDataItemBase
|
||||
{
|
||||
public:
|
||||
inline SystemStatusNetworkInfo() :
|
||||
mType(0),
|
||||
mTypeName(""),
|
||||
mSubTypeName(""),
|
||||
mAvailable(false),
|
||||
mConnected(false),
|
||||
mRoaming(false) {}
|
||||
inline SystemStatusWifiHardwareState(bool enabled=false) :
|
||||
WifiHardwareStateDataItemBase(enabled) {}
|
||||
inline SystemStatusWifiHardwareState(const WifiHardwareStateDataItemBase& itemBase) :
|
||||
WifiHardwareStateDataItemBase(itemBase) {}
|
||||
inline bool equals(const SystemStatusWifiHardwareState& peer) {
|
||||
return (mEnabled == peer.mEnabled);
|
||||
}
|
||||
};
|
||||
|
||||
class SystemStatusNetworkInfo : public SystemStatusItemBase,
|
||||
public NetworkInfoDataItemBase
|
||||
{
|
||||
NetworkInfoDataItemBase* mSrcObjPtr;
|
||||
public:
|
||||
inline SystemStatusNetworkInfo(
|
||||
uint32_t type,
|
||||
std::string typeName,
|
||||
std::string subTypeName,
|
||||
bool available,
|
||||
bool connected,
|
||||
bool roaming) :
|
||||
mType(type),
|
||||
mTypeName(typeName),
|
||||
mSubTypeName(subTypeName),
|
||||
mAvailable(available),
|
||||
mConnected(connected),
|
||||
mRoaming(roaming) {}
|
||||
int32_t type=0,
|
||||
std::string typeName="",
|
||||
string subTypeName="",
|
||||
bool connected=false,
|
||||
bool roaming=false) :
|
||||
NetworkInfoDataItemBase(
|
||||
(NetworkType)type,
|
||||
type,
|
||||
typeName,
|
||||
subTypeName,
|
||||
connected && (!roaming),
|
||||
connected,
|
||||
roaming),
|
||||
mSrcObjPtr(nullptr) {}
|
||||
inline SystemStatusNetworkInfo(const NetworkInfoDataItemBase& itemBase) :
|
||||
NetworkInfoDataItemBase(itemBase),
|
||||
mSrcObjPtr((NetworkInfoDataItemBase*)&itemBase) {
|
||||
mType = itemBase.getType();
|
||||
}
|
||||
inline bool equals(const SystemStatusNetworkInfo& peer) {
|
||||
return (mAllTypes == peer.mAllTypes);
|
||||
}
|
||||
inline virtual SystemStatusItemBase& collate(SystemStatusItemBase& curInfo) {
|
||||
uint64_t allTypes = (static_cast<SystemStatusNetworkInfo&>(curInfo)).mAllTypes;
|
||||
if (mConnected) {
|
||||
mAllTypes |= allTypes;
|
||||
} else if (0 != mAllTypes) {
|
||||
mAllTypes = (allTypes & (~mAllTypes));
|
||||
} // else (mConnected == false && mAllTypes == 0)
|
||||
// we keep mAllTypes as 0, which means no more connections.
|
||||
|
||||
uint32_t mType;
|
||||
std::string mTypeName;
|
||||
std::string mSubTypeName;
|
||||
bool mAvailable;
|
||||
bool mConnected;
|
||||
bool mRoaming;
|
||||
|
||||
inline bool equals(SystemStatusNetworkInfo& peer) {
|
||||
if ((mType != peer.mType) ||
|
||||
(mTypeName != peer.mTypeName) ||
|
||||
(mSubTypeName != peer.mSubTypeName) ||
|
||||
(mAvailable != peer.mAvailable) ||
|
||||
(mConnected != peer.mConnected) ||
|
||||
(mRoaming != peer.mRoaming)) {
|
||||
return false;
|
||||
if (nullptr != mSrcObjPtr) {
|
||||
// this is critical, changing mAllTypes of the original obj
|
||||
mSrcObjPtr->mAllTypes = mAllTypes;
|
||||
}
|
||||
return true;
|
||||
return *this;
|
||||
}
|
||||
inline void dump(void) {
|
||||
LOC_LOGD("NetworkInfo: type=%u connected=%u", mType, mConnected);
|
||||
}
|
||||
inline DataItemId getId() {
|
||||
return NETWORKINFO_DATA_ITEM_ID;
|
||||
}
|
||||
inline void stringify(string& /*valueStr*/) { }
|
||||
inline int32_t copy(IDataItemCore* src, bool* dataItemCopied = nullptr) {
|
||||
SystemStatusNetworkInfo* networkinfo = static_cast<SystemStatusNetworkInfo*>(src);
|
||||
mType = networkinfo->mType;
|
||||
mTypeName = networkinfo->mTypeName;
|
||||
mSubTypeName = networkinfo->mSubTypeName;
|
||||
mAvailable = networkinfo->mAvailable;
|
||||
mConnected = networkinfo->mConnected;
|
||||
mRoaming = networkinfo->mRoaming;
|
||||
if (dataItemCopied) {
|
||||
*dataItemCopied = true;
|
||||
}
|
||||
return 1;
|
||||
inline void dump(void) override {
|
||||
LOC_LOGD("NetworkInfo: mAllTypes=%" PRIx64 " connected=%u mType=%x",
|
||||
mAllTypes, mConnected, mType);
|
||||
}
|
||||
};
|
||||
|
||||
class SystemStatusTac : public SystemStatusItemBase, public IDataItemCore
|
||||
class SystemStatusServiceInfo : public SystemStatusItemBase,
|
||||
public RilServiceInfoDataItemBase
|
||||
{
|
||||
public:
|
||||
inline SystemStatusTac() :
|
||||
mValue("") {}
|
||||
inline SystemStatusTac(std::string value) :
|
||||
mValue(value) {}
|
||||
inline SystemStatusServiceInfo() :
|
||||
RilServiceInfoDataItemBase() {}
|
||||
inline SystemStatusServiceInfo(const RilServiceInfoDataItemBase& itemBase) :
|
||||
RilServiceInfoDataItemBase(itemBase) {}
|
||||
inline bool equals(const SystemStatusServiceInfo& peer) {
|
||||
return static_cast<const RilServiceInfoDataItemBase&>(peer) ==
|
||||
static_cast<const RilServiceInfoDataItemBase&>(*this);
|
||||
}
|
||||
};
|
||||
|
||||
std::string mValue;
|
||||
class SystemStatusRilCellInfo : public SystemStatusItemBase,
|
||||
public RilCellInfoDataItemBase
|
||||
{
|
||||
public:
|
||||
inline SystemStatusRilCellInfo() :
|
||||
RilCellInfoDataItemBase() {}
|
||||
inline SystemStatusRilCellInfo(const RilCellInfoDataItemBase& itemBase) :
|
||||
RilCellInfoDataItemBase(itemBase) {}
|
||||
inline bool equals(const SystemStatusRilCellInfo& peer) {
|
||||
return static_cast<const RilCellInfoDataItemBase&>(peer) ==
|
||||
static_cast<const RilCellInfoDataItemBase&>(*this);
|
||||
}
|
||||
};
|
||||
|
||||
inline bool equals(SystemStatusTac& peer) {
|
||||
class SystemStatusServiceStatus : public SystemStatusItemBase,
|
||||
public ServiceStatusDataItemBase
|
||||
{
|
||||
public:
|
||||
inline SystemStatusServiceStatus(int32_t mServiceState=0) :
|
||||
ServiceStatusDataItemBase(mServiceState) {}
|
||||
inline SystemStatusServiceStatus(const ServiceStatusDataItemBase& itemBase) :
|
||||
ServiceStatusDataItemBase(itemBase) {}
|
||||
inline bool equals(const SystemStatusServiceStatus& peer) {
|
||||
return (mServiceState == peer.mServiceState);
|
||||
}
|
||||
};
|
||||
|
||||
class SystemStatusModel : public SystemStatusItemBase,
|
||||
public ModelDataItemBase
|
||||
{
|
||||
public:
|
||||
inline SystemStatusModel(string name="") :
|
||||
ModelDataItemBase(name) {}
|
||||
inline SystemStatusModel(const ModelDataItemBase& itemBase) :
|
||||
ModelDataItemBase(itemBase) {}
|
||||
inline bool equals(const SystemStatusModel& peer) {
|
||||
return (mModel == peer.mModel);
|
||||
}
|
||||
};
|
||||
|
||||
class SystemStatusManufacturer : public SystemStatusItemBase,
|
||||
public ManufacturerDataItemBase
|
||||
{
|
||||
public:
|
||||
inline SystemStatusManufacturer(string name="") :
|
||||
ManufacturerDataItemBase(name) {}
|
||||
inline SystemStatusManufacturer(const ManufacturerDataItemBase& itemBase) :
|
||||
ManufacturerDataItemBase(itemBase) {}
|
||||
inline bool equals(const SystemStatusManufacturer& peer) {
|
||||
return (mManufacturer == peer.mManufacturer);
|
||||
}
|
||||
};
|
||||
|
||||
class SystemStatusAssistedGps : public SystemStatusItemBase,
|
||||
public AssistedGpsDataItemBase
|
||||
{
|
||||
public:
|
||||
inline SystemStatusAssistedGps(bool enabled=false) :
|
||||
AssistedGpsDataItemBase(enabled) {}
|
||||
inline SystemStatusAssistedGps(const AssistedGpsDataItemBase& itemBase) :
|
||||
AssistedGpsDataItemBase(itemBase) {}
|
||||
inline bool equals(const SystemStatusAssistedGps& peer) {
|
||||
return (mEnabled == peer.mEnabled);
|
||||
}
|
||||
};
|
||||
|
||||
class SystemStatusScreenState : public SystemStatusItemBase,
|
||||
public ScreenStateDataItemBase
|
||||
{
|
||||
public:
|
||||
inline SystemStatusScreenState(bool state=false) :
|
||||
ScreenStateDataItemBase(state) {}
|
||||
inline SystemStatusScreenState(const ScreenStateDataItemBase& itemBase) :
|
||||
ScreenStateDataItemBase(itemBase) {}
|
||||
inline bool equals(const SystemStatusScreenState& peer) {
|
||||
return (mState == peer.mState);
|
||||
}
|
||||
};
|
||||
|
||||
class SystemStatusPowerConnectState : public SystemStatusItemBase,
|
||||
public PowerConnectStateDataItemBase
|
||||
{
|
||||
public:
|
||||
inline SystemStatusPowerConnectState(bool state=false) :
|
||||
PowerConnectStateDataItemBase(state) {}
|
||||
inline SystemStatusPowerConnectState(const PowerConnectStateDataItemBase& itemBase) :
|
||||
PowerConnectStateDataItemBase(itemBase) {}
|
||||
inline bool equals(const SystemStatusPowerConnectState& peer) {
|
||||
return (mState == peer.mState);
|
||||
}
|
||||
};
|
||||
|
||||
class SystemStatusTimeZoneChange : public SystemStatusItemBase,
|
||||
public TimeZoneChangeDataItemBase
|
||||
{
|
||||
public:
|
||||
inline SystemStatusTimeZoneChange(
|
||||
int64_t currTimeMillis=0ULL, int32_t rawOffset=0, int32_t dstOffset=0) :
|
||||
TimeZoneChangeDataItemBase(currTimeMillis, rawOffset, dstOffset) {}
|
||||
inline SystemStatusTimeZoneChange(const TimeZoneChangeDataItemBase& itemBase) :
|
||||
TimeZoneChangeDataItemBase(itemBase) {}
|
||||
inline bool equals(const SystemStatusTimeZoneChange& peer) {
|
||||
return ((mCurrTimeMillis == peer.mCurrTimeMillis) &&
|
||||
(mRawOffsetTZ == peer.mRawOffsetTZ) &&
|
||||
(mDstOffsetTZ == peer.mDstOffsetTZ));
|
||||
}
|
||||
};
|
||||
|
||||
class SystemStatusTimeChange : public SystemStatusItemBase,
|
||||
public TimeChangeDataItemBase
|
||||
{
|
||||
public:
|
||||
inline SystemStatusTimeChange(
|
||||
int64_t currTimeMillis=0ULL, int32_t rawOffset=0, int32_t dstOffset=0) :
|
||||
TimeChangeDataItemBase(currTimeMillis, rawOffset, dstOffset) {}
|
||||
inline SystemStatusTimeChange(const TimeChangeDataItemBase& itemBase) :
|
||||
TimeChangeDataItemBase(itemBase) {}
|
||||
inline bool equals(const SystemStatusTimeChange& peer) {
|
||||
return ((mCurrTimeMillis == peer.mCurrTimeMillis) &&
|
||||
(mRawOffsetTZ == peer.mRawOffsetTZ) &&
|
||||
(mDstOffsetTZ == peer.mDstOffsetTZ));
|
||||
}
|
||||
};
|
||||
|
||||
class SystemStatusWifiSupplicantStatus : public SystemStatusItemBase,
|
||||
public WifiSupplicantStatusDataItemBase
|
||||
{
|
||||
public:
|
||||
inline SystemStatusWifiSupplicantStatus() :
|
||||
WifiSupplicantStatusDataItemBase() {}
|
||||
inline SystemStatusWifiSupplicantStatus(const WifiSupplicantStatusDataItemBase& itemBase) :
|
||||
WifiSupplicantStatusDataItemBase(itemBase) {}
|
||||
inline bool equals(const SystemStatusWifiSupplicantStatus& peer) {
|
||||
return ((mState == peer.mState) &&
|
||||
(mApMacAddressValid == peer.mApMacAddressValid) &&
|
||||
(mWifiApSsidValid == peer.mWifiApSsidValid) &&
|
||||
(mWifiApSsid == peer.mWifiApSsid));
|
||||
}
|
||||
};
|
||||
|
||||
class SystemStatusShutdownState : public SystemStatusItemBase,
|
||||
public ShutdownStateDataItemBase
|
||||
{
|
||||
public:
|
||||
inline SystemStatusShutdownState(bool state=false) :
|
||||
ShutdownStateDataItemBase(state) {}
|
||||
inline SystemStatusShutdownState(const ShutdownStateDataItemBase& itemBase) :
|
||||
ShutdownStateDataItemBase(itemBase) {}
|
||||
inline bool equals(const SystemStatusShutdownState& peer) {
|
||||
return (mState == peer.mState);
|
||||
}
|
||||
};
|
||||
|
||||
class SystemStatusTac : public SystemStatusItemBase,
|
||||
public TacDataItemBase
|
||||
{
|
||||
public:
|
||||
inline SystemStatusTac(std::string value="") :
|
||||
TacDataItemBase(value) {}
|
||||
inline SystemStatusTac(const TacDataItemBase& itemBase) :
|
||||
TacDataItemBase(itemBase) {}
|
||||
inline bool equals(const SystemStatusTac& peer) {
|
||||
return (mValue == peer.mValue);
|
||||
}
|
||||
inline void dump(void) {
|
||||
LOC_LOGD("Tac: value=%s", mValue.c_str());
|
||||
}
|
||||
inline DataItemId getId() {
|
||||
return TAC_DATA_ITEM_ID;
|
||||
}
|
||||
inline void stringify(string& /*valueStr*/) { }
|
||||
inline int32_t copy(IDataItemCore* src, bool* dataItemCopied = nullptr) {
|
||||
SystemStatusTac* tac = static_cast<SystemStatusTac*>(src);
|
||||
mValue = tac->mValue;
|
||||
if (dataItemCopied) {
|
||||
*dataItemCopied = true;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
class SystemStatusMccMnc : public SystemStatusItemBase, public IDataItemCore
|
||||
class SystemStatusMccMnc : public SystemStatusItemBase,
|
||||
public MccmncDataItemBase
|
||||
{
|
||||
public:
|
||||
inline SystemStatusMccMnc() :
|
||||
mValue("") {}
|
||||
inline SystemStatusMccMnc(std::string value) :
|
||||
mValue(value) {}
|
||||
|
||||
std::string mValue;
|
||||
|
||||
inline bool equals(SystemStatusMccMnc& peer) {
|
||||
inline SystemStatusMccMnc(std::string value="") :
|
||||
MccmncDataItemBase(value) {}
|
||||
inline SystemStatusMccMnc(const MccmncDataItemBase& itemBase) :
|
||||
MccmncDataItemBase(itemBase) {}
|
||||
inline bool equals(const SystemStatusMccMnc& peer) {
|
||||
return (mValue == peer.mValue);
|
||||
}
|
||||
inline void dump(void) {
|
||||
LOC_LOGD("TacMccMnc value=%s", mValue.c_str());
|
||||
}
|
||||
inline DataItemId getId() {
|
||||
return MCCMNC_DATA_ITEM_ID;
|
||||
};
|
||||
|
||||
class SystemStatusBtDeviceScanDetail : public SystemStatusItemBase,
|
||||
public BtDeviceScanDetailsDataItemBase
|
||||
{
|
||||
public:
|
||||
inline SystemStatusBtDeviceScanDetail() :
|
||||
BtDeviceScanDetailsDataItemBase() {}
|
||||
inline SystemStatusBtDeviceScanDetail(const BtDeviceScanDetailsDataItemBase& itemBase) :
|
||||
BtDeviceScanDetailsDataItemBase(itemBase) {}
|
||||
inline bool equals(const SystemStatusBtDeviceScanDetail& /*peer*/) {
|
||||
return true;
|
||||
}
|
||||
inline void stringify(string& /*valueStr*/) { }
|
||||
inline int32_t copy(IDataItemCore* src, bool* dataItemCopied = nullptr) {
|
||||
SystemStatusMccMnc* mccmnc = static_cast<SystemStatusMccMnc*>(src);
|
||||
mValue = mccmnc->mValue;
|
||||
if (dataItemCopied) {
|
||||
*dataItemCopied = true;
|
||||
}
|
||||
return 1;
|
||||
};
|
||||
|
||||
class SystemStatusBtleDeviceScanDetail : public SystemStatusItemBase,
|
||||
public BtLeDeviceScanDetailsDataItemBase
|
||||
{
|
||||
public:
|
||||
inline SystemStatusBtleDeviceScanDetail() :
|
||||
BtLeDeviceScanDetailsDataItemBase() {}
|
||||
inline SystemStatusBtleDeviceScanDetail(const BtLeDeviceScanDetailsDataItemBase& itemBase) :
|
||||
BtLeDeviceScanDetailsDataItemBase(itemBase) {}
|
||||
inline bool equals(const SystemStatusBtleDeviceScanDetail& /*peer*/) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -557,10 +759,28 @@ public:
|
||||
std::vector<SystemStatusPositionFailure> mPositionFailure;
|
||||
|
||||
// from dataitems observer
|
||||
std::vector<SystemStatusGpsState> mGpsState;
|
||||
std::vector<SystemStatusAirplaneMode> mAirplaneMode;
|
||||
std::vector<SystemStatusENH> mENH;
|
||||
std::vector<SystemStatusGpsState> mGPSState;
|
||||
std::vector<SystemStatusNLPStatus> mNLPStatus;
|
||||
std::vector<SystemStatusWifiHardwareState> mWifiHardwareState;
|
||||
std::vector<SystemStatusNetworkInfo> mNetworkInfo;
|
||||
std::vector<SystemStatusServiceInfo> mRilServiceInfo;
|
||||
std::vector<SystemStatusRilCellInfo> mRilCellInfo;
|
||||
std::vector<SystemStatusServiceStatus> mServiceStatus;
|
||||
std::vector<SystemStatusModel> mModel;
|
||||
std::vector<SystemStatusManufacturer> mManufacturer;
|
||||
std::vector<SystemStatusAssistedGps> mAssistedGps;
|
||||
std::vector<SystemStatusScreenState> mScreenState;
|
||||
std::vector<SystemStatusPowerConnectState> mPowerConnectState;
|
||||
std::vector<SystemStatusTimeZoneChange> mTimeZoneChange;
|
||||
std::vector<SystemStatusTimeChange> mTimeChange;
|
||||
std::vector<SystemStatusWifiSupplicantStatus> mWifiSupplicantStatus;
|
||||
std::vector<SystemStatusShutdownState> mShutdownState;
|
||||
std::vector<SystemStatusTac> mTac;
|
||||
std::vector<SystemStatusMccMnc> mMccMnc;
|
||||
std::vector<SystemStatusBtDeviceScanDetail> mBtDeviceScanDetail;
|
||||
std::vector<SystemStatusBtleDeviceScanDetail> mBtLeDeviceScanDetail;
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
@@ -578,50 +798,17 @@ private:
|
||||
|
||||
// Data members
|
||||
static pthread_mutex_t mMutexSystemStatus;
|
||||
|
||||
static const uint32_t maxLocation = 5;
|
||||
|
||||
static const uint32_t maxTimeAndClock = 5;
|
||||
static const uint32_t maxXoState = 5;
|
||||
static const uint32_t maxRfAndParams = 5;
|
||||
static const uint32_t maxErrRecovery = 5;
|
||||
|
||||
static const uint32_t maxInjectedPosition = 5;
|
||||
static const uint32_t maxBestPosition = 5;
|
||||
static const uint32_t maxXtra = 5;
|
||||
static const uint32_t maxEphemeris = 5;
|
||||
static const uint32_t maxSvHealth = 5;
|
||||
static const uint32_t maxPdr = 5;
|
||||
static const uint32_t maxNavData = 5;
|
||||
|
||||
static const uint32_t maxPositionFailure = 5;
|
||||
|
||||
static const uint32_t maxGpsState = 5;
|
||||
static const uint32_t maxNetworkInfo = 5;
|
||||
static const uint32_t maxTac = 5;
|
||||
static const uint32_t maxMccMnc = 5;
|
||||
|
||||
SystemStatusReports mCache;
|
||||
bool mConnected;
|
||||
|
||||
bool setLocation(const UlpLocation& location);
|
||||
template <typename TYPE_REPORT, typename TYPE_ITEM>
|
||||
bool setIteminReport(TYPE_REPORT& report, TYPE_ITEM&& s);
|
||||
|
||||
bool setTimeAndCLock(const SystemStatusPQWM1& nmea);
|
||||
bool setXoState(const SystemStatusPQWM1& nmea);
|
||||
bool setRfAndParams(const SystemStatusPQWM1& nmea);
|
||||
bool setErrRecovery(const SystemStatusPQWM1& nmea);
|
||||
// set default dataitem derived item in report cache
|
||||
template <typename TYPE_REPORT, typename TYPE_ITEM>
|
||||
void setDefaultIteminReport(TYPE_REPORT& report, const TYPE_ITEM& s);
|
||||
|
||||
bool setInjectedPosition(const SystemStatusPQWP1& nmea);
|
||||
bool setBestPosition(const SystemStatusPQWP2& nmea);
|
||||
bool setXtra(const SystemStatusPQWP3& nmea);
|
||||
bool setEphemeris(const SystemStatusPQWP4& nmea);
|
||||
bool setSvHealth(const SystemStatusPQWP5& nmea);
|
||||
bool setPdr(const SystemStatusPQWP6& nmea);
|
||||
bool setNavData(const SystemStatusPQWP7& nmea);
|
||||
|
||||
bool setPositionFailure(const SystemStatusPQWS1& nmea);
|
||||
|
||||
bool setNetworkInfo(IDataItemCore* dataitem);
|
||||
template <typename TYPE_REPORT, typename TYPE_ITEM>
|
||||
void getIteminReport(TYPE_REPORT& reportout, const TYPE_ITEM& c) const;
|
||||
|
||||
public:
|
||||
// Static methods
|
||||
@@ -634,8 +821,8 @@ public:
|
||||
bool eventDataItemNotify(IDataItemCore* dataitem);
|
||||
bool setNmeaString(const char *data, uint32_t len);
|
||||
bool getReport(SystemStatusReports& reports, bool isLatestonly = false) const;
|
||||
bool setDefaultReport(void);
|
||||
bool eventConnectionStatus(bool connected, uint8_t type);
|
||||
bool setDefaultGnssEngineStates(void);
|
||||
bool eventConnectionStatus(bool connected, int8_t type);
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
@@ -32,23 +32,20 @@
|
||||
#include <SystemStatus.h>
|
||||
#include <SystemStatusOsObserver.h>
|
||||
#include <IDataItemCore.h>
|
||||
#include <IClientIndex.h>
|
||||
#include <IDataItemIndex.h>
|
||||
#include <IndexFactory.h>
|
||||
#include <DataItemsFactoryProxy.h>
|
||||
|
||||
namespace loc_core
|
||||
{
|
||||
SystemStatusOsObserver::SystemStatusOsObserver(const MsgTask* msgTask) :
|
||||
mAddress("SystemStatusOsObserver"),
|
||||
mClientIndex(IndexFactory<IDataItemObserver*, DataItemId> :: createClientIndex()),
|
||||
mDataItemIndex(IndexFactory<IDataItemObserver*, DataItemId> :: createDataItemIndex())
|
||||
{
|
||||
mContext.mMsgTask = msgTask;
|
||||
template <typename CINT, typename COUT>
|
||||
COUT SystemStatusOsObserver::containerTransfer(CINT& inContainer) {
|
||||
COUT outContainer(0);
|
||||
for (auto item : inContainer) {
|
||||
outContainer.insert(outContainer.begin(), item);
|
||||
}
|
||||
return outContainer;
|
||||
}
|
||||
|
||||
SystemStatusOsObserver::~SystemStatusOsObserver()
|
||||
{
|
||||
SystemStatusOsObserver::~SystemStatusOsObserver() {
|
||||
// Close data-item library handle
|
||||
DataItemsFactoryProxy::closeDataItemLibraryHandle();
|
||||
|
||||
@@ -60,290 +57,238 @@ SystemStatusOsObserver::~SystemStatusOsObserver()
|
||||
}
|
||||
|
||||
mDataItemCache.clear();
|
||||
delete mClientIndex;
|
||||
delete mDataItemIndex;
|
||||
}
|
||||
|
||||
void SystemStatusOsObserver::setSubscriptionObj(IDataItemSubscription* subscriptionObj)
|
||||
{
|
||||
mContext.mSubscriptionObj = subscriptionObj;
|
||||
struct SetSubsObj : public LocMsg {
|
||||
ObserverContext& mContext;
|
||||
IDataItemSubscription* mSubsObj;
|
||||
inline SetSubsObj(ObserverContext& context, IDataItemSubscription* subscriptionObj) :
|
||||
mContext(context), mSubsObj(subscriptionObj) {}
|
||||
void proc() const {
|
||||
mContext.mSubscriptionObj = mSubsObj;
|
||||
|
||||
LOC_LOGD("Request cache size - Subscribe:%zu RequestData:%zu",
|
||||
mSubscribeReqCache.size(), mReqDataCache.size());
|
||||
|
||||
// we have received the subscription object. process cached requests
|
||||
// process - subscribe request cache
|
||||
for (auto each : mSubscribeReqCache) {
|
||||
subscribe(each.second, each.first);
|
||||
}
|
||||
// process - requestData request cache
|
||||
for (auto each : mReqDataCache) {
|
||||
requestData(each.second, each.first);
|
||||
}
|
||||
}
|
||||
|
||||
// Helper to cache requests subscribe and requestData till subscription obj is obtained
|
||||
void SystemStatusOsObserver::cacheObserverRequest(ObserverReqCache& reqCache,
|
||||
const list<DataItemId>& l, IDataItemObserver* client)
|
||||
{
|
||||
ObserverReqCache::iterator dicIter = reqCache.find(client);
|
||||
if (dicIter != reqCache.end()) {
|
||||
// found
|
||||
list<DataItemId> difference(0);
|
||||
set_difference(l.begin(), l.end(),
|
||||
dicIter->second.begin(), dicIter->second.end(),
|
||||
inserter(difference, difference.begin()));
|
||||
if (!difference.empty()) {
|
||||
difference.sort();
|
||||
dicIter->second.merge(difference);
|
||||
dicIter->second.unique();
|
||||
if (!mContext.mSSObserver->mDataItemToClients.empty()) {
|
||||
list<DataItemId> dis(
|
||||
containerTransfer<unordered_set<DataItemId>, list<DataItemId>>(
|
||||
mContext.mSSObserver->mDataItemToClients.getKeys()));
|
||||
mContext.mSubscriptionObj->subscribe(dis, mContext.mSSObserver);
|
||||
mContext.mSubscriptionObj->requestData(dis, mContext.mSSObserver);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// not found
|
||||
reqCache[client] = l;
|
||||
};
|
||||
|
||||
if (nullptr == subscriptionObj) {
|
||||
LOC_LOGw("subscriptionObj is NULL");
|
||||
} else {
|
||||
mContext.mMsgTask->sendMsg(new SetSubsObj(mContext, subscriptionObj));
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
IDataItemSubscription Overrides
|
||||
******************************************************************************/
|
||||
void SystemStatusOsObserver::subscribe(
|
||||
const list<DataItemId>& l, IDataItemObserver* client)
|
||||
void SystemStatusOsObserver::subscribe(const list<DataItemId>& l, IDataItemObserver* client,
|
||||
bool toRequestData)
|
||||
{
|
||||
if (nullptr == mContext.mSubscriptionObj) {
|
||||
LOC_LOGD("%s]: Subscription object is NULL. Caching requests", __func__);
|
||||
cacheObserverRequest(mSubscribeReqCache, l, client);
|
||||
return;
|
||||
}
|
||||
|
||||
struct HandleSubscribeReq : public LocMsg {
|
||||
HandleSubscribeReq(SystemStatusOsObserver* parent,
|
||||
const list<DataItemId>& l, IDataItemObserver* client) :
|
||||
mParent(parent), mClient(client), mDataItemList(l) {}
|
||||
virtual ~HandleSubscribeReq() {}
|
||||
inline HandleSubscribeReq(SystemStatusOsObserver* parent,
|
||||
list<DataItemId>& l, IDataItemObserver* client, bool requestData) :
|
||||
mParent(parent), mClient(client),
|
||||
mDataItemSet(containerTransfer<list<DataItemId>, unordered_set<DataItemId>>(l)),
|
||||
mToRequestData(requestData) {}
|
||||
|
||||
void proc() const {
|
||||
unordered_set<DataItemId> dataItemsToSubscribe(0);
|
||||
mParent->mDataItemToClients.add(mDataItemSet, {mClient}, &dataItemsToSubscribe);
|
||||
mParent->mClientToDataItems.add(mClient, mDataItemSet);
|
||||
|
||||
if (mDataItemList.empty()) {
|
||||
LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting");
|
||||
return;
|
||||
}
|
||||
mParent->sendCachedDataItems(mDataItemSet, mClient);
|
||||
|
||||
// Handle First Response
|
||||
list<DataItemId> pendingFirstResponseList(0);
|
||||
mParent->mClientIndex->add(mClient, mDataItemList, pendingFirstResponseList);
|
||||
|
||||
// Do not send first response for only pendingFirstResponseList,
|
||||
// instead send for all the data items (present in the cache) that
|
||||
// have been subscribed for each time.
|
||||
mParent->sendFirstResponse(mDataItemList, mClient);
|
||||
|
||||
list<DataItemId> yetToSubscribeDataItemsList(0);
|
||||
mParent->mDataItemIndex->add(mClient, mDataItemList, yetToSubscribeDataItemsList);
|
||||
|
||||
// Send subscription list to framework
|
||||
if (!yetToSubscribeDataItemsList.empty()) {
|
||||
mParent->mContext.mSubscriptionObj->subscribe(yetToSubscribeDataItemsList, mParent);
|
||||
// Send subscription set to framework
|
||||
if (nullptr != mParent->mContext.mSubscriptionObj && !dataItemsToSubscribe.empty()) {
|
||||
LOC_LOGD("Subscribe Request sent to framework for the following");
|
||||
mParent->logMe(yetToSubscribeDataItemsList);
|
||||
mParent->logMe(dataItemsToSubscribe);
|
||||
|
||||
if (mToRequestData) {
|
||||
mParent->mContext.mSubscriptionObj->requestData(
|
||||
containerTransfer<unordered_set<DataItemId>, list<DataItemId>>(
|
||||
std::move(dataItemsToSubscribe)),
|
||||
mParent);
|
||||
} else {
|
||||
mParent->mContext.mSubscriptionObj->subscribe(
|
||||
containerTransfer<unordered_set<DataItemId>, list<DataItemId>>(
|
||||
std::move(dataItemsToSubscribe)),
|
||||
mParent);
|
||||
}
|
||||
}
|
||||
}
|
||||
SystemStatusOsObserver* mParent;
|
||||
mutable SystemStatusOsObserver* mParent;
|
||||
IDataItemObserver* mClient;
|
||||
const list<DataItemId> mDataItemList;
|
||||
const unordered_set<DataItemId> mDataItemSet;
|
||||
bool mToRequestData;
|
||||
};
|
||||
mContext.mMsgTask->sendMsg(new (nothrow) HandleSubscribeReq(this, l, client));
|
||||
|
||||
if (l.empty() || nullptr == client) {
|
||||
LOC_LOGw("Data item set is empty or client is nullptr");
|
||||
} else {
|
||||
mContext.mMsgTask->sendMsg(
|
||||
new HandleSubscribeReq(this, (list<DataItemId>&)l, client, toRequestData));
|
||||
}
|
||||
}
|
||||
|
||||
void SystemStatusOsObserver::updateSubscription(
|
||||
const list<DataItemId>& l, IDataItemObserver* client)
|
||||
{
|
||||
if (nullptr == mContext.mSubscriptionObj) {
|
||||
LOC_LOGE("%s:%d]: Subscription object is NULL", __func__, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
struct HandleUpdateSubscriptionReq : public LocMsg {
|
||||
HandleUpdateSubscriptionReq(SystemStatusOsObserver* parent,
|
||||
const list<DataItemId>& l, IDataItemObserver* client) :
|
||||
mParent(parent), mClient(client), mDataItemList(l) {}
|
||||
virtual ~HandleUpdateSubscriptionReq() {}
|
||||
list<DataItemId>& l, IDataItemObserver* client) :
|
||||
mParent(parent), mClient(client),
|
||||
mDataItemSet(containerTransfer<list<DataItemId>, unordered_set<DataItemId>>(l)) {}
|
||||
|
||||
void proc() const {
|
||||
if (mDataItemList.empty()) {
|
||||
LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting");
|
||||
return;
|
||||
}
|
||||
|
||||
list<DataItemId> currentlySubscribedList(0);
|
||||
mParent->mClientIndex->getSubscribedList(mClient, currentlySubscribedList);
|
||||
|
||||
list<DataItemId> removeDataItemList(0);
|
||||
set_difference(currentlySubscribedList.begin(), currentlySubscribedList.end(),
|
||||
mDataItemList.begin(), mDataItemList.end(),
|
||||
inserter(removeDataItemList,removeDataItemList.begin()));
|
||||
|
||||
// Handle First Response
|
||||
list<DataItemId> pendingFirstResponseList(0);
|
||||
mParent->mClientIndex->add(mClient, mDataItemList, pendingFirstResponseList);
|
||||
unordered_set<DataItemId> dataItemsToSubscribe(0);
|
||||
unordered_set<DataItemId> dataItemsToUnsubscribe(0);
|
||||
unordered_set<IDataItemObserver*> clients({mClient});
|
||||
// below removes clients from all entries keyed with the return of the
|
||||
// mClientToDataItems.update() call. If leaving an empty set of clients as the
|
||||
// result, the entire entry will be removed. dataItemsToUnsubscribe will be
|
||||
// populated to keep the keys of the removed entries.
|
||||
mParent->mDataItemToClients.trimOrRemove(
|
||||
// this call updates <IDataItemObserver*, DataItemId> map; removes
|
||||
// the DataItemId's that are not new to the clietn from mDataItemSet;
|
||||
// and returns a set of mDataItemSet's that are no longer used by client.
|
||||
// This unused set of mDataItemSet's is passed to trimOrRemove method of
|
||||
// <DataItemId, IDataItemObserver*> map to remove the client from the
|
||||
// corresponding entries, and gets a set of the entries that are
|
||||
// removed from the <DataItemId, IDataItemObserver*> map as a result.
|
||||
mParent->mClientToDataItems.update(mClient,
|
||||
(unordered_set<DataItemId>&)mDataItemSet),
|
||||
clients, &dataItemsToUnsubscribe, nullptr);
|
||||
// below adds mClient to <DataItemId, IDataItemObserver*> map, and populates
|
||||
// new keys added to that map, which are DataItemIds to be subscribed.
|
||||
mParent->mDataItemToClients.add(mDataItemSet, clients, &dataItemsToSubscribe);
|
||||
|
||||
// Send First Response
|
||||
mParent->sendFirstResponse(pendingFirstResponseList, mClient);
|
||||
mParent->sendCachedDataItems(mDataItemSet, mClient);
|
||||
|
||||
list<DataItemId> yetToSubscribeDataItemsList(0);
|
||||
mParent->mDataItemIndex->add(
|
||||
mClient, mDataItemList, yetToSubscribeDataItemsList);
|
||||
if (nullptr != mParent->mContext.mSubscriptionObj) {
|
||||
// Send subscription set to framework
|
||||
if (!dataItemsToSubscribe.empty()) {
|
||||
LOC_LOGD("Subscribe Request sent to framework for the following");
|
||||
mParent->logMe(dataItemsToSubscribe);
|
||||
|
||||
// Send subscription list to framework
|
||||
if (!yetToSubscribeDataItemsList.empty()) {
|
||||
mParent->mContext.mSubscriptionObj->subscribe(
|
||||
yetToSubscribeDataItemsList, mParent);
|
||||
LOC_LOGD("Subscribe Request sent to framework for the following");
|
||||
mParent->logMe(yetToSubscribeDataItemsList);
|
||||
}
|
||||
mParent->mContext.mSubscriptionObj->subscribe(
|
||||
containerTransfer<unordered_set<DataItemId>, list<DataItemId>>(
|
||||
std::move(dataItemsToSubscribe)),
|
||||
mParent);
|
||||
}
|
||||
|
||||
list<DataItemId> unsubscribeList(0);
|
||||
list<DataItemId> unused(0);
|
||||
mParent->mClientIndex->remove(mClient, removeDataItemList, unused);
|
||||
|
||||
if (!mParent->mClientIndex->isSubscribedClient(mClient)) {
|
||||
mParent->mDataItemIndex->remove(
|
||||
list<IDataItemObserver*> (1,mClient), unsubscribeList);
|
||||
}
|
||||
if (!unsubscribeList.empty()) {
|
||||
// Send unsubscribe to framework
|
||||
mParent->mContext.mSubscriptionObj->unsubscribe(unsubscribeList, mParent);
|
||||
LOC_LOGD("Unsubscribe Request sent to framework for the following");
|
||||
mParent->logMe(unsubscribeList);
|
||||
if (!dataItemsToUnsubscribe.empty()) {
|
||||
LOC_LOGD("Unsubscribe Request sent to framework for the following");
|
||||
mParent->logMe(dataItemsToUnsubscribe);
|
||||
|
||||
mParent->mContext.mSubscriptionObj->unsubscribe(
|
||||
containerTransfer<unordered_set<DataItemId>, list<DataItemId>>(
|
||||
std::move(dataItemsToUnsubscribe)),
|
||||
mParent);
|
||||
}
|
||||
}
|
||||
}
|
||||
SystemStatusOsObserver* mParent;
|
||||
IDataItemObserver* mClient;
|
||||
const list<DataItemId> mDataItemList;
|
||||
unordered_set<DataItemId> mDataItemSet;
|
||||
};
|
||||
mContext.mMsgTask->sendMsg(new (nothrow) HandleUpdateSubscriptionReq(this, l, client));
|
||||
}
|
||||
|
||||
void SystemStatusOsObserver::requestData(
|
||||
const list<DataItemId>& l, IDataItemObserver* client)
|
||||
{
|
||||
if (nullptr == mContext.mSubscriptionObj) {
|
||||
LOC_LOGD("%s]: Subscription object is NULL. Caching requests", __func__);
|
||||
cacheObserverRequest(mReqDataCache, l, client);
|
||||
return;
|
||||
if (l.empty() || nullptr == client) {
|
||||
LOC_LOGw("Data item set is empty or client is nullptr");
|
||||
} else {
|
||||
mContext.mMsgTask->sendMsg(
|
||||
new HandleUpdateSubscriptionReq(this, (list<DataItemId>&)l, client));
|
||||
}
|
||||
|
||||
struct HandleRequestData : public LocMsg {
|
||||
HandleRequestData(SystemStatusOsObserver* parent,
|
||||
const list<DataItemId>& l, IDataItemObserver* client) :
|
||||
mParent(parent), mClient(client), mDataItemList(l) {}
|
||||
virtual ~HandleRequestData() {}
|
||||
void proc() const {
|
||||
if (mDataItemList.empty()) {
|
||||
LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting");
|
||||
return;
|
||||
}
|
||||
|
||||
list<DataItemId> yetToSubscribeDataItemsList(0);
|
||||
mParent->mClientIndex->add(
|
||||
mClient, mDataItemList, yetToSubscribeDataItemsList);
|
||||
mParent->mDataItemIndex->add(
|
||||
mClient, mDataItemList, yetToSubscribeDataItemsList);
|
||||
|
||||
// Send subscription list to framework
|
||||
if (!mDataItemList.empty()) {
|
||||
mParent->mContext.mSubscriptionObj->requestData(mDataItemList, mParent);
|
||||
LOC_LOGD("Subscribe Request sent to framework for the following");
|
||||
mParent->logMe(yetToSubscribeDataItemsList);
|
||||
}
|
||||
}
|
||||
SystemStatusOsObserver* mParent;
|
||||
IDataItemObserver* mClient;
|
||||
const list<DataItemId> mDataItemList;
|
||||
};
|
||||
mContext.mMsgTask->sendMsg(new (nothrow) HandleRequestData(this, l, client));
|
||||
}
|
||||
|
||||
void SystemStatusOsObserver::unsubscribe(
|
||||
const list<DataItemId>& l, IDataItemObserver* client)
|
||||
{
|
||||
if (nullptr == mContext.mSubscriptionObj) {
|
||||
LOC_LOGE("%s:%d]: Subscription object is NULL", __func__, __LINE__);
|
||||
return;
|
||||
}
|
||||
struct HandleUnsubscribeReq : public LocMsg {
|
||||
HandleUnsubscribeReq(SystemStatusOsObserver* parent,
|
||||
const list<DataItemId>& l, IDataItemObserver* client) :
|
||||
mParent(parent), mClient(client), mDataItemList(l) {}
|
||||
virtual ~HandleUnsubscribeReq() {}
|
||||
list<DataItemId>& l, IDataItemObserver* client) :
|
||||
mParent(parent), mClient(client),
|
||||
mDataItemSet(containerTransfer<list<DataItemId>, unordered_set<DataItemId>>(l)) {}
|
||||
|
||||
void proc() const {
|
||||
if (mDataItemList.empty()) {
|
||||
LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting");
|
||||
return;
|
||||
}
|
||||
unordered_set<DataItemId> dataItemsUnusedByClient(0);
|
||||
unordered_set<IDataItemObserver*> clientToRemove(0);
|
||||
mParent->mClientToDataItems.trimOrRemove({mClient}, mDataItemSet, &clientToRemove,
|
||||
&dataItemsUnusedByClient);
|
||||
unordered_set<DataItemId> dataItemsToUnsubscribe(0);
|
||||
mParent->mDataItemToClients.trimOrRemove(dataItemsUnusedByClient, {mClient},
|
||||
&dataItemsToUnsubscribe, nullptr);
|
||||
|
||||
list<DataItemId> unsubscribeList(0);
|
||||
list<DataItemId> unused(0);
|
||||
mParent->mClientIndex->remove(mClient, mDataItemList, unused);
|
||||
|
||||
for (auto each : mDataItemList) {
|
||||
list<IDataItemObserver*> clientListSubs(0);
|
||||
list<IDataItemObserver*> clientListOut(0);
|
||||
mParent->mDataItemIndex->remove(
|
||||
each, list<IDataItemObserver*> (1,mClient), clientListOut);
|
||||
// check if there are any other subscribed client for this data item id
|
||||
mParent->mDataItemIndex->getListOfSubscribedClients(each, clientListSubs);
|
||||
if (clientListSubs.empty())
|
||||
{
|
||||
LOC_LOGD("Client list subscribed is empty for dataitem - %d", each);
|
||||
unsubscribeList.push_back(each);
|
||||
}
|
||||
}
|
||||
|
||||
if (!unsubscribeList.empty()) {
|
||||
// Send unsubscribe to framework
|
||||
mParent->mContext.mSubscriptionObj->unsubscribe(unsubscribeList, mParent);
|
||||
if (nullptr != mParent->mContext.mSubscriptionObj && !dataItemsToUnsubscribe.empty()) {
|
||||
LOC_LOGD("Unsubscribe Request sent to framework for the following data items");
|
||||
mParent->logMe(unsubscribeList);
|
||||
mParent->logMe(dataItemsToUnsubscribe);
|
||||
|
||||
// Send unsubscribe to framework
|
||||
mParent->mContext.mSubscriptionObj->unsubscribe(
|
||||
containerTransfer<unordered_set<DataItemId>, list<DataItemId>>(
|
||||
std::move(dataItemsToUnsubscribe)),
|
||||
mParent);
|
||||
}
|
||||
}
|
||||
SystemStatusOsObserver* mParent;
|
||||
IDataItemObserver* mClient;
|
||||
const list<DataItemId> mDataItemList;
|
||||
unordered_set<DataItemId> mDataItemSet;
|
||||
};
|
||||
mContext.mMsgTask->sendMsg(new (nothrow) HandleUnsubscribeReq(this, l, client));
|
||||
|
||||
if (l.empty() || nullptr == client) {
|
||||
LOC_LOGw("Data item set is empty or client is nullptr");
|
||||
} else {
|
||||
mContext.mMsgTask->sendMsg(new HandleUnsubscribeReq(this, (list<DataItemId>&)l, client));
|
||||
}
|
||||
}
|
||||
|
||||
void SystemStatusOsObserver::unsubscribeAll(IDataItemObserver* client)
|
||||
{
|
||||
if (nullptr == mContext.mSubscriptionObj) {
|
||||
LOC_LOGE("%s:%d]: Subscription object is NULL", __func__, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
struct HandleUnsubscribeAllReq : public LocMsg {
|
||||
HandleUnsubscribeAllReq(SystemStatusOsObserver* parent,
|
||||
IDataItemObserver* client) :
|
||||
mParent(parent), mClient(client) {}
|
||||
virtual ~HandleUnsubscribeAllReq() {}
|
||||
void proc() const {
|
||||
list<IDataItemObserver*> clients(1, mClient);
|
||||
list<DataItemId> unsubscribeList(0);
|
||||
if(0 == mParent->mClientIndex->remove(mClient)) {
|
||||
return;
|
||||
}
|
||||
mParent->mDataItemIndex->remove(clients, unsubscribeList);
|
||||
|
||||
if (!unsubscribeList.empty()) {
|
||||
// Send unsubscribe to framework
|
||||
mParent->mContext.mSubscriptionObj->unsubscribe(unsubscribeList, mParent);
|
||||
LOC_LOGD("Unsubscribe Request sent to framework for the following data items");
|
||||
mParent->logMe(unsubscribeList);
|
||||
void proc() const {
|
||||
unordered_set<DataItemId> diByClient = mParent->mClientToDataItems.getValSet(mClient);
|
||||
if (!diByClient.empty()) {
|
||||
unordered_set<DataItemId> dataItemsToUnsubscribe;
|
||||
mParent->mClientToDataItems.remove(mClient);
|
||||
mParent->mDataItemToClients.trimOrRemove(diByClient, {mClient},
|
||||
&dataItemsToUnsubscribe, nullptr);
|
||||
|
||||
if (!dataItemsToUnsubscribe.empty() &&
|
||||
nullptr != mParent->mContext.mSubscriptionObj) {
|
||||
|
||||
LOC_LOGD("Unsubscribe Request sent to framework for the following data items");
|
||||
mParent->logMe(dataItemsToUnsubscribe);
|
||||
|
||||
// Send unsubscribe to framework
|
||||
mParent->mContext.mSubscriptionObj->unsubscribe(
|
||||
containerTransfer<unordered_set<DataItemId>, list<DataItemId>>(
|
||||
std::move(dataItemsToUnsubscribe)),
|
||||
mParent);
|
||||
}
|
||||
}
|
||||
}
|
||||
SystemStatusOsObserver* mParent;
|
||||
IDataItemObserver* mClient;
|
||||
};
|
||||
mContext.mMsgTask->sendMsg(new (nothrow) HandleUnsubscribeAllReq(this, client));
|
||||
|
||||
if (nullptr == client) {
|
||||
LOC_LOGw("Data item set is empty or client is nullptr");
|
||||
} else {
|
||||
mContext.mMsgTask->sendMsg(new HandleUnsubscribeAllReq(this, client));
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -351,84 +296,78 @@ void SystemStatusOsObserver::unsubscribeAll(IDataItemObserver* client)
|
||||
******************************************************************************/
|
||||
void SystemStatusOsObserver::notify(const list<IDataItemCore*>& dlist)
|
||||
{
|
||||
list<IDataItemCore*> dataItemList(0);
|
||||
|
||||
for (auto each : dlist) {
|
||||
string dv;
|
||||
each->stringify(dv);
|
||||
LOC_LOGD("notify: DataItem In Value:%s", dv.c_str());
|
||||
|
||||
IDataItemCore* di = DataItemsFactoryProxy::createNewDataItem(each->getId());
|
||||
if (nullptr == di) {
|
||||
LOC_LOGE("Unable to create dataitem:%d", each->getId());
|
||||
return;
|
||||
}
|
||||
|
||||
// Copy contents into the newly created data item
|
||||
di->copy(each);
|
||||
dataItemList.push_back(di);
|
||||
// Request systemstatus to record this dataitem in its cache
|
||||
SystemStatus* systemstatus = SystemStatus::getInstance(mContext.mMsgTask);
|
||||
if(nullptr != systemstatus) {
|
||||
systemstatus->eventDataItemNotify(di);
|
||||
}
|
||||
}
|
||||
|
||||
struct HandleNotify : public LocMsg {
|
||||
HandleNotify(SystemStatusOsObserver* parent, const list<IDataItemCore*>& l) :
|
||||
mParent(parent), mDList(l) {}
|
||||
virtual ~HandleNotify() {
|
||||
for (auto each : mDList) {
|
||||
delete each;
|
||||
HandleNotify(SystemStatusOsObserver* parent, vector<IDataItemCore*>& v) :
|
||||
mParent(parent), mDiVec(std::move(v)) {}
|
||||
|
||||
inline virtual ~HandleNotify() {
|
||||
for (auto item : mDiVec) {
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
|
||||
void proc() const {
|
||||
// Update Cache with received data items and prepare
|
||||
// list of data items to be sent.
|
||||
list<DataItemId> dataItemIdsToBeSent(0);
|
||||
for (auto item : mDList) {
|
||||
bool dataItemUpdated = false;
|
||||
mParent->updateCache(item, dataItemUpdated);
|
||||
if (dataItemUpdated) {
|
||||
dataItemIdsToBeSent.push_back(item->getId());
|
||||
unordered_set<DataItemId> dataItemIdsToBeSent(0);
|
||||
for (auto item : mDiVec) {
|
||||
if (mParent->updateCache(item)) {
|
||||
dataItemIdsToBeSent.insert(item->getId());
|
||||
}
|
||||
}
|
||||
|
||||
// Send data item to all subscribed clients
|
||||
list<IDataItemObserver*> clientList(0);
|
||||
unordered_set<IDataItemObserver*> clientSet(0);
|
||||
for (auto each : dataItemIdsToBeSent) {
|
||||
list<IDataItemObserver*> clients(0);
|
||||
mParent->mDataItemIndex->getListOfSubscribedClients(each, clients);
|
||||
for (auto each_cient: clients) {
|
||||
clientList.push_back(each_cient);
|
||||
auto clients = mParent->mDataItemToClients.getValSetPtr(each);
|
||||
if (nullptr != clients) {
|
||||
clientSet.insert(clients->begin(), clients->end());
|
||||
}
|
||||
}
|
||||
clientList.unique();
|
||||
|
||||
for (auto client : clientList) {
|
||||
list<DataItemId> dataItemIdsSubscribedByThisClient(0);
|
||||
list<DataItemId> dataItemIdsToBeSentForThisClient(0);
|
||||
mParent->mClientIndex->getSubscribedList(
|
||||
client, dataItemIdsSubscribedByThisClient);
|
||||
dataItemIdsSubscribedByThisClient.sort();
|
||||
dataItemIdsToBeSent.sort();
|
||||
for (auto client : clientSet) {
|
||||
unordered_set<DataItemId> dataItemIdsForThisClient(
|
||||
mParent->mClientToDataItems.getValSet(client));
|
||||
for (auto id : dataItemIdsForThisClient) {
|
||||
if (dataItemIdsToBeSent.find(id) == dataItemIdsToBeSent.end()) {
|
||||
dataItemIdsForThisClient.erase(id);
|
||||
}
|
||||
}
|
||||
|
||||
set_intersection(dataItemIdsToBeSent.begin(),
|
||||
dataItemIdsToBeSent.end(),
|
||||
dataItemIdsSubscribedByThisClient.begin(),
|
||||
dataItemIdsSubscribedByThisClient.end(),
|
||||
inserter(dataItemIdsToBeSentForThisClient,
|
||||
dataItemIdsToBeSentForThisClient.begin()));
|
||||
|
||||
mParent->sendCachedDataItems(dataItemIdsToBeSentForThisClient, client);
|
||||
dataItemIdsSubscribedByThisClient.clear();
|
||||
dataItemIdsToBeSentForThisClient.clear();
|
||||
mParent->sendCachedDataItems(dataItemIdsForThisClient, client);
|
||||
}
|
||||
}
|
||||
SystemStatusOsObserver* mParent;
|
||||
const list<IDataItemCore*> mDList;
|
||||
const vector<IDataItemCore*> mDiVec;
|
||||
};
|
||||
mContext.mMsgTask->sendMsg(new (nothrow) HandleNotify(this, dataItemList));
|
||||
|
||||
if (!dlist.empty()) {
|
||||
vector<IDataItemCore*> dataItemVec(dlist.size());
|
||||
|
||||
for (auto each : dlist) {
|
||||
IF_LOC_LOGD {
|
||||
string dv;
|
||||
each->stringify(dv);
|
||||
LOC_LOGD("notify: DataItem In Value:%s", dv.c_str());
|
||||
}
|
||||
|
||||
IDataItemCore* di = DataItemsFactoryProxy::createNewDataItem(each->getId());
|
||||
if (nullptr == di) {
|
||||
LOC_LOGw("Unable to create dataitem:%d", each->getId());
|
||||
continue;
|
||||
}
|
||||
|
||||
// Copy contents into the newly created data item
|
||||
di->copy(each);
|
||||
|
||||
// add this dataitem if updated from last one
|
||||
dataItemVec.push_back(di);
|
||||
}
|
||||
|
||||
if (!dataItemVec.empty()) {
|
||||
mContext.mMsgTask->sendMsg(new HandleNotify(this, dataItemVec));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -442,7 +381,7 @@ void SystemStatusOsObserver::turnOn(DataItemId dit, int timeOut)
|
||||
}
|
||||
|
||||
// Check if data item exists in mActiveRequestCount
|
||||
map<DataItemId, int>::iterator citer = mActiveRequestCount.find(dit);
|
||||
DataItemIdToInt::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
|
||||
@@ -480,7 +419,7 @@ void SystemStatusOsObserver::turnOff(DataItemId dit)
|
||||
}
|
||||
|
||||
// Check if data item exists in mActiveRequestCount
|
||||
map<DataItemId, int>::iterator citer = mActiveRequestCount.find(dit);
|
||||
DataItemIdToInt::iterator citer = mActiveRequestCount.find(dit);
|
||||
if (citer != mActiveRequestCount.end()) {
|
||||
// found
|
||||
citer->second--;
|
||||
@@ -506,87 +445,127 @@ void SystemStatusOsObserver::turnOff(DataItemId dit)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_GLIB
|
||||
bool SystemStatusOsObserver::connectBackhaul()
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if (mContext.mFrameworkActionReqObj != NULL) {
|
||||
struct HandleConnectBackhaul : public LocMsg {
|
||||
HandleConnectBackhaul(IFrameworkActionReq* fwkActReq) :
|
||||
mFwkActionReqObj(fwkActReq) {}
|
||||
virtual ~HandleConnectBackhaul() {}
|
||||
void proc() const {
|
||||
LOC_LOGD("HandleConnectBackhaul");
|
||||
mFwkActionReqObj->connectBackhaul();
|
||||
}
|
||||
IFrameworkActionReq* mFwkActionReqObj;
|
||||
};
|
||||
mContext.mMsgTask->sendMsg(
|
||||
new (nothrow) HandleConnectBackhaul(mContext.mFrameworkActionReqObj));
|
||||
result = true;
|
||||
}
|
||||
else {
|
||||
++mBackHaulConnectReqCount;
|
||||
LOC_LOGE("Framework action request object is NULL.Caching connect request: %d",
|
||||
mBackHaulConnectReqCount);
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
bool SystemStatusOsObserver::disconnectBackhaul()
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if (mContext.mFrameworkActionReqObj != NULL) {
|
||||
struct HandleDisconnectBackhaul : public LocMsg {
|
||||
HandleDisconnectBackhaul(IFrameworkActionReq* fwkActReq) :
|
||||
mFwkActionReqObj(fwkActReq) {}
|
||||
virtual ~HandleDisconnectBackhaul() {}
|
||||
void proc() const {
|
||||
LOC_LOGD("HandleDisconnectBackhaul");
|
||||
mFwkActionReqObj->disconnectBackhaul();
|
||||
}
|
||||
IFrameworkActionReq* mFwkActionReqObj;
|
||||
};
|
||||
mContext.mMsgTask->sendMsg(
|
||||
new (nothrow) HandleDisconnectBackhaul(mContext.mFrameworkActionReqObj));
|
||||
}
|
||||
else {
|
||||
if (mBackHaulConnectReqCount > 0) {
|
||||
--mBackHaulConnectReqCount;
|
||||
}
|
||||
LOC_LOGE("Framework action request object is NULL.Caching disconnect request: %d",
|
||||
mBackHaulConnectReqCount);
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
/******************************************************************************
|
||||
Helpers
|
||||
******************************************************************************/
|
||||
void SystemStatusOsObserver::sendFirstResponse(
|
||||
const list<DataItemId>& l, IDataItemObserver* to)
|
||||
{
|
||||
if (l.empty()) {
|
||||
LOC_LOGV("list is empty. Nothing to do. Exiting");
|
||||
return;
|
||||
}
|
||||
|
||||
string clientName;
|
||||
to->getName(clientName);
|
||||
list<IDataItemCore*> dataItems(0);
|
||||
|
||||
for (auto each : l) {
|
||||
map<DataItemId, IDataItemCore*>::const_iterator citer = mDataItemCache.find(each);
|
||||
if (citer != mDataItemCache.end()) {
|
||||
string dv;
|
||||
citer->second->stringify(dv);
|
||||
LOC_LOGI("DataItem: %s >> %s", dv.c_str(), clientName.c_str());
|
||||
dataItems.push_back(citer->second);
|
||||
}
|
||||
}
|
||||
if (dataItems.empty()) {
|
||||
LOC_LOGV("No items to notify. Nothing to do. Exiting");
|
||||
return;
|
||||
}
|
||||
to->notify(dataItems);
|
||||
}
|
||||
|
||||
void SystemStatusOsObserver::sendCachedDataItems(
|
||||
const list<DataItemId>& l, IDataItemObserver* to)
|
||||
const unordered_set<DataItemId>& s, IDataItemObserver* to)
|
||||
{
|
||||
string clientName;
|
||||
to->getName(clientName);
|
||||
list<IDataItemCore*> dataItems(0);
|
||||
if (nullptr == to) {
|
||||
LOC_LOGv("client pointer is NULL.");
|
||||
} else {
|
||||
string clientName;
|
||||
to->getName(clientName);
|
||||
list<IDataItemCore*> dataItems(0);
|
||||
|
||||
for (auto each : l) {
|
||||
string dv;
|
||||
IDataItemCore* di = mDataItemCache[each];
|
||||
di->stringify(dv);
|
||||
LOC_LOGI("DataItem: %s >> %s", dv.c_str(), clientName.c_str());
|
||||
dataItems.push_back(di);
|
||||
for (auto each : s) {
|
||||
auto citer = mDataItemCache.find(each);
|
||||
if (citer != mDataItemCache.end()) {
|
||||
string dv;
|
||||
citer->second->stringify(dv);
|
||||
LOC_LOGI("DataItem: %s >> %s", dv.c_str(), clientName.c_str());
|
||||
dataItems.push_front(citer->second);
|
||||
}
|
||||
}
|
||||
|
||||
if (dataItems.empty()) {
|
||||
LOC_LOGv("No items to notify.");
|
||||
} else {
|
||||
to->notify(dataItems);
|
||||
}
|
||||
}
|
||||
to->notify(dataItems);
|
||||
}
|
||||
|
||||
void SystemStatusOsObserver::updateCache(IDataItemCore* d, bool& dataItemUpdated)
|
||||
bool SystemStatusOsObserver::updateCache(IDataItemCore* d)
|
||||
{
|
||||
if (nullptr == d) {
|
||||
return;
|
||||
}
|
||||
bool dataItemUpdated = false;
|
||||
|
||||
// Check if data item exists in cache
|
||||
map<DataItemId, IDataItemCore*>::iterator citer =
|
||||
mDataItemCache.find(d->getId());
|
||||
if (citer == mDataItemCache.end()) {
|
||||
// New data item; not found in cache
|
||||
IDataItemCore* dataitem = DataItemsFactoryProxy::createNewDataItem(d->getId());
|
||||
if (nullptr == dataitem) {
|
||||
return;
|
||||
// Request systemstatus to record this dataitem in its cache
|
||||
// if the return is false, it means that SystemStatus is not
|
||||
// handling it, so SystemStatusOsObserver also doesn't.
|
||||
// So it has to be true to proceed.
|
||||
if (nullptr != d && mSystemStatus->eventDataItemNotify(d)) {
|
||||
auto citer = mDataItemCache.find(d->getId());
|
||||
if (citer == mDataItemCache.end()) {
|
||||
// New data item; not found in cache
|
||||
IDataItemCore* dataitem = DataItemsFactoryProxy::createNewDataItem(d->getId());
|
||||
if (nullptr != dataitem) {
|
||||
// Copy the contents of the data item
|
||||
dataitem->copy(d);
|
||||
// Insert in mDataItemCache
|
||||
mDataItemCache.insert(std::make_pair(d->getId(), dataitem));
|
||||
dataItemUpdated = true;
|
||||
}
|
||||
} else {
|
||||
// Found in cache; Update cache if necessary
|
||||
citer->second->copy(d, &dataItemUpdated);
|
||||
}
|
||||
|
||||
// Copy the contents of the data item
|
||||
dataitem->copy(d);
|
||||
pair<DataItemId, IDataItemCore*> cpair(d->getId(), dataitem);
|
||||
// Insert in mDataItemCache
|
||||
mDataItemCache.insert(cpair);
|
||||
dataItemUpdated = true;
|
||||
}
|
||||
else {
|
||||
// Found in cache; Update cache if necessary
|
||||
if(0 == citer->second->copy(d, &dataItemUpdated)) {
|
||||
return;
|
||||
if (dataItemUpdated) {
|
||||
LOC_LOGV("DataItem:%d updated:%d", d->getId(), dataItemUpdated);
|
||||
}
|
||||
}
|
||||
|
||||
if (dataItemUpdated) {
|
||||
LOC_LOGV("DataItem:%d updated:%d", d->getId(), dataItemUpdated);
|
||||
}
|
||||
return dataItemUpdated;
|
||||
}
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
@@ -39,7 +39,9 @@
|
||||
#include <MsgTask.h>
|
||||
#include <DataItemId.h>
|
||||
#include <IOsObserver.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <loc_pla.h>
|
||||
#include <log_util.h>
|
||||
#include <LocUnorderedSetMap.h>
|
||||
|
||||
namespace loc_core
|
||||
{
|
||||
@@ -47,25 +49,29 @@ namespace loc_core
|
||||
SystemStatusOsObserver
|
||||
******************************************************************************/
|
||||
using namespace std;
|
||||
using namespace loc_util;
|
||||
|
||||
// Forward Declarations
|
||||
class IDataItemCore;
|
||||
template<typename CT, typename DIT> class IClientIndex;
|
||||
template<typename CT, typename DIT> class IDataItemIndex;
|
||||
class SystemStatus;
|
||||
class SystemStatusOsObserver;
|
||||
typedef map<IDataItemObserver*, list<DataItemId>> ObserverReqCache;
|
||||
typedef LocUnorderedSetMap<IDataItemObserver*, DataItemId> ClientToDataItems;
|
||||
typedef LocUnorderedSetMap<DataItemId, IDataItemObserver*> DataItemToClients;
|
||||
typedef unordered_map<DataItemId, IDataItemCore*> DataItemIdToCore;
|
||||
typedef unordered_map<DataItemId, int> DataItemIdToInt;
|
||||
|
||||
struct SystemContext {
|
||||
struct ObserverContext {
|
||||
IDataItemSubscription* mSubscriptionObj;
|
||||
IFrameworkActionReq* mFrameworkActionReqObj;
|
||||
const MsgTask* mMsgTask;
|
||||
SystemStatusOsObserver* mSSObserver;
|
||||
|
||||
inline SystemContext() :
|
||||
mSubscriptionObj(NULL),
|
||||
mFrameworkActionReqObj(NULL),
|
||||
mMsgTask(NULL) {}
|
||||
inline ObserverContext(const MsgTask* msgTask, SystemStatusOsObserver* observer) :
|
||||
mSubscriptionObj(NULL), mFrameworkActionReqObj(NULL),
|
||||
mMsgTask(msgTask), mSSObserver(observer) {}
|
||||
};
|
||||
|
||||
typedef map<IDataItemObserver*, list<DataItemId>> ObserverReqCache;
|
||||
|
||||
// Clients wanting to get data from OS/Framework would need to
|
||||
// subscribe with OSObserver using IDataItemSubscription interface.
|
||||
// Such clients would need to implement IDataItemObserver interface
|
||||
@@ -74,57 +80,92 @@ class SystemStatusOsObserver : public IOsObserver {
|
||||
|
||||
public:
|
||||
// ctor
|
||||
SystemStatusOsObserver(const MsgTask* msgTask);
|
||||
inline SystemStatusOsObserver(SystemStatus* systemstatus, const MsgTask* msgTask) :
|
||||
mSystemStatus(systemstatus), mContext(msgTask, this),
|
||||
mAddress("SystemStatusOsObserver"),
|
||||
mClientToDataItems(MAX_DATA_ITEM_ID), mDataItemToClients(MAX_DATA_ITEM_ID)
|
||||
#ifdef USE_GLIB
|
||||
, mBackHaulConnectReqCount(0)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
// dtor
|
||||
~SystemStatusOsObserver();
|
||||
|
||||
template <typename CINT, typename COUT>
|
||||
static COUT containerTransfer(CINT& s);
|
||||
template <typename CINT, typename COUT>
|
||||
inline static COUT containerTransfer(CINT&& s) {
|
||||
return containerTransfer<CINT, COUT>(s);
|
||||
}
|
||||
|
||||
// To set the subscription object
|
||||
virtual void setSubscriptionObj(IDataItemSubscription* subscriptionObj);
|
||||
|
||||
// To set the framework action request object
|
||||
inline void setFrameworkActionReqObj(IFrameworkActionReq* frameworkActionReqObj) {
|
||||
mContext.mFrameworkActionReqObj = frameworkActionReqObj;
|
||||
#ifdef USE_GLIB
|
||||
if (mBackHaulConnectReqCount > 0) {
|
||||
connectBackhaul();
|
||||
mBackHaulConnectReqCount = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// IDataItemSubscription Overrides
|
||||
virtual void subscribe(const list<DataItemId>& l, IDataItemObserver* client);
|
||||
virtual void updateSubscription(const list<DataItemId>& l, IDataItemObserver* client);
|
||||
virtual void requestData(const list<DataItemId>& l, IDataItemObserver* client);
|
||||
virtual void unsubscribe(const list<DataItemId>& l, IDataItemObserver* client);
|
||||
virtual void unsubscribeAll(IDataItemObserver* client);
|
||||
inline virtual void subscribe(const list<DataItemId>& l, IDataItemObserver* client) override {
|
||||
subscribe(l, client, false);
|
||||
}
|
||||
virtual void updateSubscription(const list<DataItemId>& l, IDataItemObserver* client) override;
|
||||
inline virtual void requestData(const list<DataItemId>& l, IDataItemObserver* client) override {
|
||||
subscribe(l, client, true);
|
||||
}
|
||||
virtual void unsubscribe(const list<DataItemId>& l, IDataItemObserver* client) override;
|
||||
virtual void unsubscribeAll(IDataItemObserver* client) override;
|
||||
|
||||
// IDataItemObserver Overrides
|
||||
virtual void notify(const list<IDataItemCore*>& dlist);
|
||||
inline virtual void getName(string& name) {
|
||||
virtual void notify(const list<IDataItemCore*>& dlist) override;
|
||||
inline virtual void getName(string& name) override {
|
||||
name = mAddress;
|
||||
}
|
||||
|
||||
// IFrameworkActionReq Overrides
|
||||
virtual void turnOn(DataItemId dit, int timeOut = 0);
|
||||
virtual void turnOff(DataItemId dit);
|
||||
virtual void turnOn(DataItemId dit, int timeOut = 0) override;
|
||||
virtual void turnOff(DataItemId dit) override;
|
||||
#ifdef USE_GLIB
|
||||
virtual bool connectBackhaul() override;
|
||||
virtual bool disconnectBackhaul();
|
||||
#endif
|
||||
|
||||
private:
|
||||
SystemContext mContext;
|
||||
SystemStatus* mSystemStatus;
|
||||
ObserverContext mContext;
|
||||
const string mAddress;
|
||||
IClientIndex<IDataItemObserver*, DataItemId>* mClientIndex;
|
||||
IDataItemIndex<IDataItemObserver*, DataItemId>* mDataItemIndex;
|
||||
map<DataItemId, IDataItemCore*> mDataItemCache;
|
||||
map<DataItemId, int> mActiveRequestCount;
|
||||
ClientToDataItems mClientToDataItems;
|
||||
DataItemToClients mDataItemToClients;
|
||||
DataItemIdToCore mDataItemCache;
|
||||
DataItemIdToInt mActiveRequestCount;
|
||||
|
||||
// Cache the subscribe and requestData till subscription obj is obtained
|
||||
ObserverReqCache mSubscribeReqCache;
|
||||
ObserverReqCache mReqDataCache;
|
||||
void cacheObserverRequest(ObserverReqCache& reqCache,
|
||||
const list<DataItemId>& l, IDataItemObserver* client);
|
||||
#ifdef USE_GLIB
|
||||
// Cache the framework action request for connect/disconnect
|
||||
int mBackHaulConnectReqCount;
|
||||
#endif
|
||||
|
||||
void subscribe(const list<DataItemId>& l, IDataItemObserver* client, bool toRequestData);
|
||||
|
||||
// Helpers
|
||||
void sendFirstResponse(const list<DataItemId>& l, IDataItemObserver* to);
|
||||
void sendCachedDataItems(const list<DataItemId>& l, IDataItemObserver* to);
|
||||
void updateCache(IDataItemCore* d, bool& dataItemUpdated);
|
||||
inline void logMe(const list<DataItemId>& l) {
|
||||
for (auto id : l) {
|
||||
LOC_LOGD("DataItem %d", id);
|
||||
void sendCachedDataItems(const unordered_set<DataItemId>& s, IDataItemObserver* to);
|
||||
bool updateCache(IDataItemCore* d);
|
||||
inline void logMe(const unordered_set<DataItemId>& l) {
|
||||
IF_LOC_LOGD {
|
||||
for (auto id : l) {
|
||||
LOC_LOGD("DataItem %d", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
82
gps/core/configure.ac
Normal file
82
gps/core/configure.ac
Normal file
@@ -0,0 +1,82 @@
|
||||
# configure.ac -- Autoconf script for gps loc-core
|
||||
#
|
||||
# Process this file with autoconf to produce a configure script
|
||||
|
||||
# Requires autoconf tool later than 2.61
|
||||
AC_PREREQ(2.61)
|
||||
# Initialize the gps loc-hal package version 1.0.0
|
||||
AC_INIT([loc-core],1.0.0)
|
||||
# Does not strictly follow GNU Coding standards
|
||||
AM_INIT_AUTOMAKE([foreign])
|
||||
# Disables auto rebuilding of configure, Makefile.ins
|
||||
AM_MAINTAINER_MODE
|
||||
# Verifies the --srcdir is correct by checking for the path
|
||||
AC_CONFIG_SRCDIR([loc-core.pc.in])
|
||||
# defines some macros variable to be included by source
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_LIBTOOL
|
||||
AC_PROG_CXX
|
||||
AC_PROG_CC
|
||||
AM_PROG_CC_C_O
|
||||
AC_PROG_AWK
|
||||
AC_PROG_CPP
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_MAKE_SET
|
||||
PKG_PROG_PKG_CONFIG
|
||||
|
||||
# Checks for libraries.
|
||||
PKG_CHECK_MODULES([GPSUTILS], [gps-utils])
|
||||
AC_SUBST([GPSUTILS_CFLAGS])
|
||||
AC_SUBST([GPSUTILS_LIBS])
|
||||
|
||||
AC_ARG_WITH([core_includes],
|
||||
AC_HELP_STRING([--with-core-includes=@<:@dir@:>@],
|
||||
[Specify the location of the core headers]),
|
||||
[core_incdir=$withval],
|
||||
with_core_includes=no)
|
||||
|
||||
if test "x$with_core_includes" != "xno"; then
|
||||
CPPFLAGS="${CPPFLAGS} -I${core_incdir}"
|
||||
fi
|
||||
|
||||
AC_ARG_WITH([locpla_includes],
|
||||
AC_HELP_STRING([--with-locpla-includes=@<:@dir@:>@],
|
||||
[specify the path to locpla-includes in loc-pla_git.bb]),
|
||||
[locpla_incdir=$withval],
|
||||
with_locpla_includes=no)
|
||||
|
||||
if test "x$with_locpla_includes" != "xno"; then
|
||||
AC_SUBST(LOCPLA_CFLAGS, "-I${locpla_incdir}")
|
||||
fi
|
||||
|
||||
AC_SUBST([CPPFLAGS])
|
||||
|
||||
AC_ARG_WITH([glib],
|
||||
AC_HELP_STRING([--with-glib],
|
||||
[enable glib, building HLOS systems which use glib]))
|
||||
|
||||
if (test "x${with_glib}" = "xyes"); then
|
||||
AC_DEFINE(ENABLE_USEGLIB, 1, [Define if HLOS systems uses glib])
|
||||
PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes,
|
||||
AC_MSG_ERROR(GThread >= 2.16 is required))
|
||||
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes,
|
||||
AC_MSG_ERROR(GLib >= 2.16 is required))
|
||||
GLIB_CFLAGS="$GLIB_CFLAGS $GTHREAD_CFLAGS"
|
||||
GLIB_LIBS="$GLIB_LIBS $GTHREAD_LIBS"
|
||||
|
||||
AC_SUBST(GLIB_CFLAGS)
|
||||
AC_SUBST(GLIB_LIBS)
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(USE_GLIB, test "x${with_glib}" = "xyes")
|
||||
|
||||
AC_CONFIG_FILES([ \
|
||||
Makefile \
|
||||
loc-core.pc \
|
||||
])
|
||||
|
||||
AC_OUTPUT
|
||||
496
gps/core/data-items/DataItemConcreteTypesBase.h
Normal file
496
gps/core/data-items/DataItemConcreteTypesBase.h
Normal file
@@ -0,0 +1,496 @@
|
||||
/* 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 __DATAITEMCONCRETEBASETYPES__
|
||||
#define __DATAITEMCONCRETEBASETYPES__
|
||||
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <DataItemId.h>
|
||||
#include <IDataItemCore.h>
|
||||
|
||||
#define MAC_ADDRESS_LENGTH 6
|
||||
// MAC address length in bytes
|
||||
// QMI_LOC_SRN_MAC_ADDR_LENGTH_V02
|
||||
#define SRN_MAC_ADDRESS_LENGTH 6
|
||||
#define WIFI_SUPPLICANT_DEFAULT_STATE 0
|
||||
|
||||
namespace loc_core
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
class AirplaneModeDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
AirplaneModeDataItemBase(bool mode):
|
||||
mMode(mode),
|
||||
mId(AIRPLANEMODE_DATA_ITEM_ID) {}
|
||||
virtual ~AirplaneModeDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
bool mMode;
|
||||
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class ENHDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
ENHDataItemBase(bool enabled) :
|
||||
mEnabled(enabled),
|
||||
mId(ENH_DATA_ITEM_ID) {}
|
||||
virtual ~ENHDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
bool mEnabled;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class GPSStateDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
GPSStateDataItemBase(bool enabled) :
|
||||
mEnabled(enabled),
|
||||
mId(GPSSTATE_DATA_ITEM_ID) {}
|
||||
virtual ~GPSStateDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
bool mEnabled;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class NLPStatusDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
NLPStatusDataItemBase(bool enabled) :
|
||||
mEnabled(enabled),
|
||||
mId(NLPSTATUS_DATA_ITEM_ID) {}
|
||||
virtual ~NLPStatusDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
bool mEnabled;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class WifiHardwareStateDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
WifiHardwareStateDataItemBase(bool enabled) :
|
||||
mEnabled(enabled),
|
||||
mId(WIFIHARDWARESTATE_DATA_ITEM_ID) {}
|
||||
virtual ~WifiHardwareStateDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
bool mEnabled;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class ScreenStateDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
ScreenStateDataItemBase(bool state) :
|
||||
mState(state),
|
||||
mId(SCREEN_STATE_DATA_ITEM_ID) {}
|
||||
virtual ~ScreenStateDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
bool mState;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class PowerConnectStateDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
PowerConnectStateDataItemBase(bool state) :
|
||||
mState(state),
|
||||
mId(POWER_CONNECTED_STATE_DATA_ITEM_ID) {}
|
||||
virtual ~PowerConnectStateDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
bool mState;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class TimeZoneChangeDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
TimeZoneChangeDataItemBase(int64_t currTimeMillis, int32_t rawOffset, int32_t dstOffset) :
|
||||
mCurrTimeMillis (currTimeMillis),
|
||||
mRawOffsetTZ (rawOffset),
|
||||
mDstOffsetTZ (dstOffset),
|
||||
mId(TIMEZONE_CHANGE_DATA_ITEM_ID) {}
|
||||
virtual ~TimeZoneChangeDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
int64_t mCurrTimeMillis;
|
||||
int32_t mRawOffsetTZ;
|
||||
int32_t mDstOffsetTZ;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class TimeChangeDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
TimeChangeDataItemBase(int64_t currTimeMillis, int32_t rawOffset, int32_t dstOffset) :
|
||||
mCurrTimeMillis (currTimeMillis),
|
||||
mRawOffsetTZ (rawOffset),
|
||||
mDstOffsetTZ (dstOffset),
|
||||
mId(TIME_CHANGE_DATA_ITEM_ID) {}
|
||||
virtual ~TimeChangeDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
int64_t mCurrTimeMillis;
|
||||
int32_t mRawOffsetTZ;
|
||||
int32_t mDstOffsetTZ;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class ShutdownStateDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
ShutdownStateDataItemBase(bool state) :
|
||||
mState (state),
|
||||
mId(SHUTDOWN_STATE_DATA_ITEM_ID) {}
|
||||
virtual ~ShutdownStateDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
bool mState;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class AssistedGpsDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
AssistedGpsDataItemBase(bool enabled) :
|
||||
mEnabled(enabled),
|
||||
mId(ASSISTED_GPS_DATA_ITEM_ID) {}
|
||||
virtual ~AssistedGpsDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
bool mEnabled;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class NetworkInfoDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
enum NetworkType {
|
||||
TYPE_MOBILE,
|
||||
TYPE_WIFI,
|
||||
TYPE_ETHERNET,
|
||||
TYPE_BLUETOOTH,
|
||||
TYPE_MMS,
|
||||
TYPE_SUPL,
|
||||
TYPE_DUN,
|
||||
TYPE_HIPRI,
|
||||
TYPE_WIMAX,
|
||||
TYPE_UNKNOWN,
|
||||
};
|
||||
NetworkInfoDataItemBase(
|
||||
NetworkType initialType, int32_t type, string typeName, string subTypeName,
|
||||
bool available, bool connected, bool roaming ):
|
||||
mAllTypes(typeToAllTypes(initialType)),
|
||||
mType(type),
|
||||
mTypeName(typeName),
|
||||
mSubTypeName(subTypeName),
|
||||
mAvailable(available),
|
||||
mConnected(connected),
|
||||
mRoaming(roaming),
|
||||
mId(NETWORKINFO_DATA_ITEM_ID) {}
|
||||
virtual ~NetworkInfoDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
inline virtual NetworkType getType(void) const {
|
||||
return (NetworkType)mType;
|
||||
}
|
||||
inline uint64_t getAllTypes() { return mAllTypes; }
|
||||
// Data members
|
||||
uint64_t mAllTypes;
|
||||
int32_t mType;
|
||||
string mTypeName;
|
||||
string mSubTypeName;
|
||||
bool mAvailable;
|
||||
bool mConnected;
|
||||
bool mRoaming;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
inline uint64_t typeToAllTypes(NetworkType type) {
|
||||
return (type >= TYPE_UNKNOWN || type < TYPE_MOBILE) ? 0 : (1<<type);
|
||||
}
|
||||
};
|
||||
|
||||
class ServiceStatusDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
ServiceStatusDataItemBase(int32_t serviceState) :
|
||||
mServiceState (serviceState),
|
||||
mId(SERVICESTATUS_DATA_ITEM_ID) {}
|
||||
virtual ~ServiceStatusDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
int32_t mServiceState;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class ModelDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
ModelDataItemBase(const string & name) :
|
||||
mModel (name),
|
||||
mId(MODEL_DATA_ITEM_ID) {}
|
||||
virtual ~ModelDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
string mModel;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class ManufacturerDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
ManufacturerDataItemBase(const string & name) :
|
||||
mManufacturer (name),
|
||||
mId(MANUFACTURER_DATA_ITEM_ID) {}
|
||||
virtual ~ManufacturerDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
string mManufacturer;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class RilServiceInfoDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
inline RilServiceInfoDataItemBase() :
|
||||
mData(nullptr), mId(RILSERVICEINFO_DATA_ITEM_ID) {}
|
||||
inline virtual ~RilServiceInfoDataItemBase() { if (nullptr != mData) free(mData); }
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
inline RilServiceInfoDataItemBase(const RilServiceInfoDataItemBase& peer) :
|
||||
RilServiceInfoDataItemBase() {
|
||||
peer.setPeerData(*this);
|
||||
}
|
||||
inline virtual bool operator==(const RilServiceInfoDataItemBase& other) const {
|
||||
return other.mData == mData;
|
||||
}
|
||||
inline virtual void setPeerData(RilServiceInfoDataItemBase& /*peer*/) const {}
|
||||
void* mData;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class RilCellInfoDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
inline RilCellInfoDataItemBase() :
|
||||
mData(nullptr), mId(RILCELLINFO_DATA_ITEM_ID) {}
|
||||
inline virtual ~RilCellInfoDataItemBase() { if (nullptr != mData) free(mData); }
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
inline RilCellInfoDataItemBase(const RilCellInfoDataItemBase& peer) :
|
||||
RilCellInfoDataItemBase() {
|
||||
peer.setPeerData(*this);
|
||||
}
|
||||
inline virtual bool operator==(const RilCellInfoDataItemBase& other) const {
|
||||
return other.mData == mData;
|
||||
}
|
||||
inline virtual void setPeerData(RilCellInfoDataItemBase& /*peer*/) const {}
|
||||
void* mData;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class WifiSupplicantStatusDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
WifiSupplicantStatusDataItemBase() :
|
||||
mState((WifiSupplicantState)WIFI_SUPPLICANT_DEFAULT_STATE),
|
||||
mApMacAddressValid(false),
|
||||
mWifiApSsidValid(false),
|
||||
mId(WIFI_SUPPLICANT_STATUS_DATA_ITEM_ID) {
|
||||
memset (&mApMacAddress, 0, sizeof (mApMacAddress));
|
||||
mWifiApSsid.clear();
|
||||
}
|
||||
virtual ~WifiSupplicantStatusDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
typedef enum WifiSupplicantState {
|
||||
DISCONNECTED,
|
||||
INTERFACE_DISABLED,
|
||||
INACTIVE,
|
||||
SCANNING,
|
||||
AUTHENTICATING,
|
||||
ASSOCIATING,
|
||||
ASSOCIATED,
|
||||
FOUR_WAY_HANDSHAKE,
|
||||
GROUP_HANDSHAKE,
|
||||
COMPLETED,
|
||||
DORMANT,
|
||||
UNINITIALIZED,
|
||||
INVALID
|
||||
} WifiSupplicantState;
|
||||
/* Represents whether access point attach state*/
|
||||
WifiSupplicantState mState;
|
||||
/* Represents info on whether ap mac address is valid */
|
||||
bool mApMacAddressValid;
|
||||
/* Represents mac address of the wifi access point*/
|
||||
uint8_t mApMacAddress[MAC_ADDRESS_LENGTH];
|
||||
/* Represents info on whether ap SSID is valid */
|
||||
bool mWifiApSsidValid;
|
||||
/* Represents Wifi SSID string*/
|
||||
string mWifiApSsid;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class TacDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
TacDataItemBase(const string & name) :
|
||||
mValue (name),
|
||||
mId(TAC_DATA_ITEM_ID) {}
|
||||
virtual ~TacDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
string mValue;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class MccmncDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
MccmncDataItemBase(const string & name) :
|
||||
mValue(name),
|
||||
mId(MCCMNC_DATA_ITEM_ID) {}
|
||||
virtual ~MccmncDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
string mValue;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class SrnDeviceScanDetailsDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
SrnDeviceScanDetailsDataItemBase(DataItemId Id) :
|
||||
mValidSrnData(false),
|
||||
mApSrnRssi(-1),
|
||||
mApSrnTimestamp(0),
|
||||
mRequestTimestamp(0),
|
||||
mReceiveTimestamp(0),
|
||||
mErrorCause(-1),
|
||||
mId(Id) {}
|
||||
virtual ~SrnDeviceScanDetailsDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
// Data members common to all SRN tech types
|
||||
/* Represents info on whether SRN data is valid (no error)*/
|
||||
bool mValidSrnData;
|
||||
/* SRN device RSSI reported */
|
||||
int32_t mApSrnRssi;
|
||||
/* MAC adress of SRN device */
|
||||
uint8_t mApSrnMacAddress[SRN_MAC_ADDRESS_LENGTH];
|
||||
/* UTC timestamp at which the scan was requested.for this SRN device*/
|
||||
int64_t mApSrnTimestamp;
|
||||
/* UTC timestamp at which the scan was started. */
|
||||
int64_t mRequestTimestamp;
|
||||
/* UTC timestamp at which the scan was received.*/
|
||||
int64_t mReceiveTimestamp;
|
||||
/* Reason for the error/failure if SRN details are not valid */
|
||||
int32_t mErrorCause;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class BtDeviceScanDetailsDataItemBase : public SrnDeviceScanDetailsDataItemBase {
|
||||
|
||||
public:
|
||||
BtDeviceScanDetailsDataItemBase() :
|
||||
SrnDeviceScanDetailsDataItemBase(BT_SCAN_DATA_ITEM_ID) {}
|
||||
virtual ~BtDeviceScanDetailsDataItemBase() {}
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
};
|
||||
|
||||
class BtLeDeviceScanDetailsDataItemBase : public SrnDeviceScanDetailsDataItemBase {
|
||||
|
||||
public:
|
||||
BtLeDeviceScanDetailsDataItemBase() :
|
||||
SrnDeviceScanDetailsDataItemBase(BTLE_SCAN_DATA_ITEM_ID) {}
|
||||
virtual ~BtLeDeviceScanDetailsDataItemBase() {}
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
};
|
||||
|
||||
class BatteryLevelDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
inline BatteryLevelDataItemBase(uint8_t batteryPct) :
|
||||
mBatteryPct(batteryPct), mId(BATTERY_LEVEL_DATA_ITEM_ID) {}
|
||||
inline ~BatteryLevelDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
// Data members
|
||||
uint8_t mBatteryPct;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
#endif //__DATAITEMCONCRETEBASETYPES__
|
||||
@@ -67,7 +67,13 @@ typedef enum e_DataItemId {
|
||||
BTLE_SCAN_DATA_ITEM_ID,
|
||||
BT_SCAN_DATA_ITEM_ID,
|
||||
OEM_GTP_UPLOAD_TRIGGER_READY_ITEM_ID,
|
||||
MAX_DATA_ITEM_ID
|
||||
|
||||
MAX_DATA_ITEM_ID,
|
||||
|
||||
// 26 -
|
||||
BATTERY_LEVEL_DATA_ITEM_ID,
|
||||
|
||||
MAX_DATA_ITEM_ID_1_1,
|
||||
} DataItemId;
|
||||
|
||||
#endif // #ifndef __DATAITEMID_H__
|
||||
|
||||
@@ -32,7 +32,8 @@
|
||||
#include <DataItemId.h>
|
||||
#include <IDataItemCore.h>
|
||||
#include <DataItemsFactoryProxy.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <loc_pla.h>
|
||||
#include <log_util.h>
|
||||
|
||||
namespace loc_core
|
||||
{
|
||||
@@ -68,7 +69,7 @@ IDataItemCore* DataItemsFactoryProxy::createNewDataItem(DataItemId id)
|
||||
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);
|
||||
LOC_LOGD("Loaded function %s : %p",DATA_ITEMS_GET_CONCRETE_DI,getConcreteDIFunc);
|
||||
mydi = (*getConcreteDIFunc)(id);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
/* 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>;
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/* 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__
|
||||
@@ -1,202 +0,0 @@
|
||||
/* 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>;
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/* 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__
|
||||
@@ -1,83 +0,0 @@
|
||||
/* 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__
|
||||
@@ -1,94 +0,0 @@
|
||||
/* 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__
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/* 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>;
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/* 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__
|
||||
10
gps/core/loc-core.pc.in
Normal file
10
gps/core/loc-core.pc.in
Normal file
@@ -0,0 +1,10 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: loc-core
|
||||
Description: QTI GPS Loc Core
|
||||
Version: @VERSION@
|
||||
Libs: -L${libdir} -lloc_core
|
||||
Cflags: -I${includedir}/loc-core
|
||||
@@ -30,9 +30,10 @@
|
||||
#define LOG_NDEBUG 0
|
||||
#define LOG_TAG "LocSvc_core_log"
|
||||
|
||||
#include <log_util.h>
|
||||
#include <loc_log.h>
|
||||
#include <loc_core_log.h>
|
||||
#include <platform_lib_includes.h>
|
||||
#include <loc_pla.h>
|
||||
|
||||
void LocPosMode::logv() const
|
||||
{
|
||||
@@ -100,26 +101,6 @@ 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;
|
||||
|
||||
@@ -70,6 +70,24 @@ public:
|
||||
*/
|
||||
virtual void turnOff (DataItemId dit) = 0;
|
||||
|
||||
#ifdef USE_GLIB
|
||||
/**
|
||||
* @brief Setup WWAN backhaul
|
||||
* @details Setup WWAN backhaul
|
||||
*
|
||||
* @param None
|
||||
*/
|
||||
virtual bool connectBackhaul() = 0;
|
||||
|
||||
/**
|
||||
* @brief Disconnects the WWANbackhaul
|
||||
* @details Disconnects the WWANbackhaul, only if it was setup by us
|
||||
*
|
||||
* @param None
|
||||
*/
|
||||
virtual bool disconnectBackhaul() = 0;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Destructor
|
||||
* @details Destructor
|
||||
|
||||
@@ -90,6 +90,10 @@ public:
|
||||
// IFrameworkActionReq Overrides
|
||||
inline virtual void turnOn (DataItemId /*dit*/, int /*timeOut*/){}
|
||||
inline virtual void turnOff (DataItemId /*dit*/) {}
|
||||
#ifdef USE_GLIB
|
||||
inline virtual bool connectBackhaul() {}
|
||||
inline virtual bool disconnectBackhaul() {}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Destructor
|
||||
|
||||
Reference in New Issue
Block a user