From ff8b31761cff3098444c41c8daa7baa6dff92ccd Mon Sep 17 00:00:00 2001 From: Harikrishnan Hariharan Date: Fri, 11 Aug 2017 17:36:10 +0530 Subject: Integrate XtraSysStatObs with SystemStatusObserver Use SystemStatusObserver to subscribe for dataitems in XtraSystemStatusObserver. Change-Id: Ib1828b9025c9c5bb5194a36014249472ed3f6f9e CRs-Fixed: 2093290 --- core/SystemStatus.h | 182 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) (limited to 'core/SystemStatus.h') diff --git a/core/SystemStatus.h b/core/SystemStatus.h index 8cf75b5..5dc2d9f 100644 --- a/core/SystemStatus.h +++ b/core/SystemStatus.h @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -367,19 +368,183 @@ public: void dump(void); }; +/****************************************************************************** + SystemStatus report data structure - from DataItem observer +******************************************************************************/ +class SystemStatusGpsState : public SystemStatusItemBase, public IDataItemCore +{ +public: + inline SystemStatusGpsState() : + mEnabled(false) {} + inline SystemStatusGpsState(bool enabled) : + mEnabled(enabled) {} + + bool mEnabled; + + inline bool equals(SystemStatusGpsState& peer) { + return (mEnabled == peer.mEnabled); + } + inline void dump(void) { + LOC_LOGD("GpsState: state=%u", mEnabled); + } + inline DataItemId getId() { + return GPSSTATE_DATA_ITEM_ID; + } + inline void stringify(string& valueStr) { + valueStr.clear(); + valueStr += "GpsState: enabled="; + valueStr += to_string(mEnabled); + } + inline int32_t copy(IDataItemCore* src, bool* dataItemCopied = nullptr) { + SystemStatusGpsState* gpsstate = static_cast(src); + mEnabled = gpsstate->mEnabled; + if (dataItemCopied) { + *dataItemCopied = true; + } + return 1; + } +}; + +class SystemStatusNetworkInfo : public SystemStatusItemBase, public IDataItemCore +{ +public: + inline SystemStatusNetworkInfo() : + mType(0), + mTypeName(""), + mSubTypeName(""), + mAvailable(false), + mConnected(false), + mRoaming(false) {} + inline SystemStatusNetworkInfo( + uint32_t type, + std::string typeName, + std::string subTypeName, + bool available, + bool connected, + bool roaming) : + mType(type), + mTypeName(typeName), + mSubTypeName(subTypeName), + mAvailable(available), + mConnected(connected), + mRoaming(roaming) {} + + uint32_t mType; + std::string mTypeName; + std::string mSubTypeName; + bool mAvailable; + bool mConnected; + bool mRoaming; + + inline bool equals(SystemStatusNetworkInfo& peer) { + if ((mType != peer.mType) || + (mTypeName != peer.mTypeName) || + (mSubTypeName != peer.mSubTypeName) || + (mAvailable != peer.mAvailable) || + (mConnected != peer.mConnected) || + (mRoaming != peer.mRoaming)) { + return false; + } + return true; + } + inline void dump(void) { + LOC_LOGD("NetworkInfo: type=%u connected=%u", mType, mConnected); + } + inline DataItemId getId() { + return NETWORKINFO_DATA_ITEM_ID; + } + inline void stringify(string& /*valueStr*/) { } + inline int32_t copy(IDataItemCore* src, bool* dataItemCopied = nullptr) { + SystemStatusNetworkInfo* networkinfo = static_cast(src); + mType = networkinfo->mType; + mTypeName = networkinfo->mTypeName; + mSubTypeName = networkinfo->mSubTypeName; + mAvailable = networkinfo->mAvailable; + mConnected = networkinfo->mConnected; + mRoaming = networkinfo->mRoaming; + if (dataItemCopied) { + *dataItemCopied = true; + } + return 1; + } +}; + +class SystemStatusTac : public SystemStatusItemBase, public IDataItemCore +{ +public: + inline SystemStatusTac() : + mValue("") {} + inline SystemStatusTac(std::string value) : + mValue(value) {} + + std::string mValue; + + inline bool equals(SystemStatusTac& peer) { + return (mValue == peer.mValue); + } + inline void dump(void) { + LOC_LOGD("Tac: value=%s", mValue.c_str()); + } + inline DataItemId getId() { + return TAC_DATA_ITEM_ID; + } + inline void stringify(string& /*valueStr*/) { } + inline int32_t copy(IDataItemCore* src, bool* dataItemCopied = nullptr) { + SystemStatusTac* tac = static_cast(src); + mValue = tac->mValue; + if (dataItemCopied) { + *dataItemCopied = true; + } + return 1; + } +}; + +class SystemStatusMccMnc : public SystemStatusItemBase, public IDataItemCore +{ +public: + inline SystemStatusMccMnc() : + mValue("") {} + inline SystemStatusMccMnc(std::string value) : + mValue(value) {} + + std::string mValue; + + inline bool equals(SystemStatusMccMnc& peer) { + return (mValue == peer.mValue); + } + inline void dump(void) { + LOC_LOGD("TacMccMnc value=%s", mValue.c_str()); + } + inline DataItemId getId() { + return MCCMNC_DATA_ITEM_ID; + } + inline void stringify(string& /*valueStr*/) { } + inline int32_t copy(IDataItemCore* src, bool* dataItemCopied = nullptr) { + SystemStatusMccMnc* mccmnc = static_cast(src); + mValue = mccmnc->mValue; + if (dataItemCopied) { + *dataItemCopied = true; + } + return 1; + } +}; + /****************************************************************************** SystemStatusReports ******************************************************************************/ class SystemStatusReports { public: + // from QMI_LOC indication std::vector mLocation; + // from ME debug NMEA std::vector mTimeAndClock; std::vector mXoState; std::vector mRfAndParams; std::vector mErrRecovery; + // from PE debug NMEA std::vector mInjectedPosition; std::vector mBestPosition; std::vector mXtra; @@ -388,7 +553,14 @@ public: std::vector mPdr; std::vector mNavData; + // from SM debug NMEA std::vector mPositionFailure; + + // from dataitems observer + std::vector mGpsState; + std::vector mNetworkInfo; + std::vector mTac; + std::vector mMccMnc; }; /****************************************************************************** @@ -424,7 +596,13 @@ private: 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); @@ -443,6 +621,8 @@ private: bool setPositionFailure(const SystemStatusPQWS1& nmea); + bool setNetworkInfo(IDataItemCore* dataitem); + public: // Static methods static SystemStatus* getInstance(const MsgTask* msgTask); @@ -451,9 +631,11 @@ public: // Helpers bool eventPosition(const UlpLocation& location,const GpsLocationExtended& locationEx); + bool eventDataItemNotify(IDataItemCore* dataitem); bool setNmeaString(const char *data, uint32_t len); bool getReport(SystemStatusReports& reports, bool isLatestonly = false) const; bool setDefaultReport(void); + bool eventConnectionStatus(bool connected, uint8_t type); }; } // namespace loc_core -- cgit v1.2.3