Merge "Integrate XtraSysStatObs with SystemStatusObserver"

This commit is contained in:
Linux Build Service Account 2017-09-07 20:35:04 -07:00 committed by Gerrit - the friendly Code Review server
commit 099f9405b1
9 changed files with 921 additions and 797 deletions

View file

@ -37,6 +37,7 @@
#include <platform_lib_log_util.h> #include <platform_lib_log_util.h>
#include <MsgTask.h> #include <MsgTask.h>
#include <loc_nmea.h> #include <loc_nmea.h>
#include <DataItemsFactoryProxy.h>
#include <SystemStatus.h> #include <SystemStatus.h>
#include <SystemStatusOsObserver.h> #include <SystemStatusOsObserver.h>
@ -1212,7 +1213,8 @@ IOsObserver* SystemStatus::getOsObserver()
} }
SystemStatus::SystemStatus(const MsgTask* msgTask) : SystemStatus::SystemStatus(const MsgTask* msgTask) :
mSysStatusObsvr(msgTask) mSysStatusObsvr(msgTask),
mConnected(false)
{ {
int result = 0; int result = 0;
ENTRY_LOG (); ENTRY_LOG ();
@ -1413,6 +1415,28 @@ bool SystemStatus::setPositionFailure(const SystemStatusPQWS1& nmea)
return true; return true;
} }
/******************************************************************************
SystemStatus - storing dataitems
******************************************************************************/
bool SystemStatus::setNetworkInfo(IDataItemCore* dataitem)
{
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 (!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());
}
}
return true;
}
/****************************************************************************** /******************************************************************************
@brief API to set report data into internal buffer @brief API to set report data into internal buffer
@ -1533,6 +1557,26 @@ bool SystemStatus::eventPosition(const UlpLocation& location,
return true; return true;
} }
/******************************************************************************
@brief API to set report DataItem event into internal buffer
@param[In] DataItem
@return true when successfully done
******************************************************************************/
bool SystemStatus::eventDataItemNotify(IDataItemCore* dataitem)
{
pthread_mutex_lock(&mMutexSystemStatus);
switch(dataitem->getId())
{
case NETWORKINFO_DATA_ITEM_ID:
setNetworkInfo(dataitem);
break;
}
pthread_mutex_unlock(&mMutexSystemStatus);
return true;
}
/****************************************************************************** /******************************************************************************
@brief API to get report data into a given buffer @brief API to get report data into a given buffer
@ -1712,5 +1756,33 @@ bool SystemStatus::setDefaultReport(void)
return true; return true;
} }
/******************************************************************************
@brief API to handle connection status update event from GnssRil
@param[In] Connection status
@return true when successfully done
******************************************************************************/
bool SystemStatus::eventConnectionStatus(bool connected, uint8_t type)
{
if (connected != mConnected) {
mConnected = connected;
// 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;
}
} // namespace loc_core } // namespace loc_core

View file

@ -34,6 +34,7 @@
#include <vector> #include <vector>
#include <platform_lib_log_util.h> #include <platform_lib_log_util.h>
#include <MsgTask.h> #include <MsgTask.h>
#include <IDataItemCore.h>
#include <IOsObserver.h> #include <IOsObserver.h>
#include <SystemStatusOsObserver.h> #include <SystemStatusOsObserver.h>
@ -367,19 +368,183 @@ public:
void dump(void); void dump(void);
}; };
/******************************************************************************
SystemStatus report data structure - from DataItem observer
******************************************************************************/
class SystemStatusGpsState : public SystemStatusItemBase, public IDataItemCore
{
public:
inline SystemStatusGpsState() :
mEnabled(false) {}
inline SystemStatusGpsState(bool enabled) :
mEnabled(enabled) {}
bool mEnabled;
inline bool equals(SystemStatusGpsState& peer) {
return (mEnabled == peer.mEnabled);
}
inline void dump(void) {
LOC_LOGD("GpsState: state=%u", mEnabled);
}
inline DataItemId getId() {
return GPSSTATE_DATA_ITEM_ID;
}
inline void stringify(string& valueStr) {
valueStr.clear();
valueStr += "GpsState: enabled=";
valueStr += to_string(mEnabled);
}
inline int32_t copy(IDataItemCore* src, bool* dataItemCopied = nullptr) {
SystemStatusGpsState* gpsstate = static_cast<SystemStatusGpsState*>(src);
mEnabled = gpsstate->mEnabled;
if (dataItemCopied) {
*dataItemCopied = true;
}
return 1;
}
};
class SystemStatusNetworkInfo : public SystemStatusItemBase, public IDataItemCore
{
public:
inline SystemStatusNetworkInfo() :
mType(0),
mTypeName(""),
mSubTypeName(""),
mAvailable(false),
mConnected(false),
mRoaming(false) {}
inline SystemStatusNetworkInfo(
uint32_t type,
std::string typeName,
std::string subTypeName,
bool available,
bool connected,
bool roaming) :
mType(type),
mTypeName(typeName),
mSubTypeName(subTypeName),
mAvailable(available),
mConnected(connected),
mRoaming(roaming) {}
uint32_t mType;
std::string mTypeName;
std::string mSubTypeName;
bool mAvailable;
bool mConnected;
bool mRoaming;
inline bool equals(SystemStatusNetworkInfo& peer) {
if ((mType != peer.mType) ||
(mTypeName != peer.mTypeName) ||
(mSubTypeName != peer.mSubTypeName) ||
(mAvailable != peer.mAvailable) ||
(mConnected != peer.mConnected) ||
(mRoaming != peer.mRoaming)) {
return false;
}
return true;
}
inline void dump(void) {
LOC_LOGD("NetworkInfo: type=%u connected=%u", mType, mConnected);
}
inline DataItemId getId() {
return NETWORKINFO_DATA_ITEM_ID;
}
inline void stringify(string& /*valueStr*/) { }
inline int32_t copy(IDataItemCore* src, bool* dataItemCopied = nullptr) {
SystemStatusNetworkInfo* networkinfo = static_cast<SystemStatusNetworkInfo*>(src);
mType = networkinfo->mType;
mTypeName = networkinfo->mTypeName;
mSubTypeName = networkinfo->mSubTypeName;
mAvailable = networkinfo->mAvailable;
mConnected = networkinfo->mConnected;
mRoaming = networkinfo->mRoaming;
if (dataItemCopied) {
*dataItemCopied = true;
}
return 1;
}
};
class SystemStatusTac : public SystemStatusItemBase, public IDataItemCore
{
public:
inline SystemStatusTac() :
mValue("") {}
inline SystemStatusTac(std::string value) :
mValue(value) {}
std::string mValue;
inline bool equals(SystemStatusTac& peer) {
return (mValue == peer.mValue);
}
inline void dump(void) {
LOC_LOGD("Tac: value=%s", mValue.c_str());
}
inline DataItemId getId() {
return TAC_DATA_ITEM_ID;
}
inline void stringify(string& /*valueStr*/) { }
inline int32_t copy(IDataItemCore* src, bool* dataItemCopied = nullptr) {
SystemStatusTac* tac = static_cast<SystemStatusTac*>(src);
mValue = tac->mValue;
if (dataItemCopied) {
*dataItemCopied = true;
}
return 1;
}
};
class SystemStatusMccMnc : public SystemStatusItemBase, public IDataItemCore
{
public:
inline SystemStatusMccMnc() :
mValue("") {}
inline SystemStatusMccMnc(std::string value) :
mValue(value) {}
std::string mValue;
inline bool equals(SystemStatusMccMnc& peer) {
return (mValue == peer.mValue);
}
inline void dump(void) {
LOC_LOGD("TacMccMnc value=%s", mValue.c_str());
}
inline DataItemId getId() {
return MCCMNC_DATA_ITEM_ID;
}
inline void stringify(string& /*valueStr*/) { }
inline int32_t copy(IDataItemCore* src, bool* dataItemCopied = nullptr) {
SystemStatusMccMnc* mccmnc = static_cast<SystemStatusMccMnc*>(src);
mValue = mccmnc->mValue;
if (dataItemCopied) {
*dataItemCopied = true;
}
return 1;
}
};
/****************************************************************************** /******************************************************************************
SystemStatusReports SystemStatusReports
******************************************************************************/ ******************************************************************************/
class SystemStatusReports class SystemStatusReports
{ {
public: public:
// from QMI_LOC indication
std::vector<SystemStatusLocation> mLocation; std::vector<SystemStatusLocation> mLocation;
// from ME debug NMEA
std::vector<SystemStatusTimeAndClock> mTimeAndClock; std::vector<SystemStatusTimeAndClock> mTimeAndClock;
std::vector<SystemStatusXoState> mXoState; std::vector<SystemStatusXoState> mXoState;
std::vector<SystemStatusRfAndParams> mRfAndParams; std::vector<SystemStatusRfAndParams> mRfAndParams;
std::vector<SystemStatusErrRecovery> mErrRecovery; std::vector<SystemStatusErrRecovery> mErrRecovery;
// from PE debug NMEA
std::vector<SystemStatusInjectedPosition> mInjectedPosition; std::vector<SystemStatusInjectedPosition> mInjectedPosition;
std::vector<SystemStatusBestPosition> mBestPosition; std::vector<SystemStatusBestPosition> mBestPosition;
std::vector<SystemStatusXtra> mXtra; std::vector<SystemStatusXtra> mXtra;
@ -388,7 +553,14 @@ public:
std::vector<SystemStatusPdr> mPdr; std::vector<SystemStatusPdr> mPdr;
std::vector<SystemStatusNavData> mNavData; std::vector<SystemStatusNavData> mNavData;
// from SM debug NMEA
std::vector<SystemStatusPositionFailure> mPositionFailure; std::vector<SystemStatusPositionFailure> mPositionFailure;
// from dataitems observer
std::vector<SystemStatusGpsState> mGpsState;
std::vector<SystemStatusNetworkInfo> mNetworkInfo;
std::vector<SystemStatusTac> mTac;
std::vector<SystemStatusMccMnc> mMccMnc;
}; };
/****************************************************************************** /******************************************************************************
@ -424,7 +596,13 @@ private:
static const uint32_t maxPositionFailure = 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; SystemStatusReports mCache;
bool mConnected;
bool setLocation(const UlpLocation& location); bool setLocation(const UlpLocation& location);
@ -443,6 +621,8 @@ private:
bool setPositionFailure(const SystemStatusPQWS1& nmea); bool setPositionFailure(const SystemStatusPQWS1& nmea);
bool setNetworkInfo(IDataItemCore* dataitem);
public: public:
// Static methods // Static methods
static SystemStatus* getInstance(const MsgTask* msgTask); static SystemStatus* getInstance(const MsgTask* msgTask);
@ -451,9 +631,11 @@ public:
// Helpers // Helpers
bool eventPosition(const UlpLocation& location,const GpsLocationExtended& locationEx); bool eventPosition(const UlpLocation& location,const GpsLocationExtended& locationEx);
bool eventDataItemNotify(IDataItemCore* dataitem);
bool setNmeaString(const char *data, uint32_t len); bool setNmeaString(const char *data, uint32_t len);
bool getReport(SystemStatusReports& reports, bool isLatestonly = false) const; bool getReport(SystemStatusReports& reports, bool isLatestonly = false) const;
bool setDefaultReport(void); bool setDefaultReport(void);
bool eventConnectionStatus(bool connected, uint8_t type);
}; };
} // namespace loc_core } // namespace loc_core

View file

@ -28,47 +28,23 @@
*/ */
#define LOG_TAG "LocSvc_SystemStatusOsObserver" #define LOG_TAG "LocSvc_SystemStatusOsObserver"
#include <string>
#include <cinttypes>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <pthread.h>
#include <iterator>
#include <algorithm> #include <algorithm>
#include <SystemStatus.h>
#include <MsgTask.h>
#include <SystemStatusOsObserver.h> #include <SystemStatusOsObserver.h>
#include <DataItemId.h>
#include <IDataItemCore.h> #include <IDataItemCore.h>
#include <IClientIndex.h> #include <IClientIndex.h>
#include <IDataItemIndex.h> #include <IDataItemIndex.h>
#include <IndexFactory.h> #include <IndexFactory.h>
#include <DataItemsFactoryProxy.h> #include <DataItemsFactoryProxy.h>
#include <platform_lib_log_util.h>
namespace loc_core namespace loc_core
{ {
#define BREAK_IF_ZERO(ERR,X) if(0==(X)) {result = (ERR); break;}
#define BREAK_IF_NON_ZERO(ERR,X) if(0!=(X)) {result = (ERR); break;}
SystemStatusOsObserver::SystemStatusOsObserver(const MsgTask* msgTask) : SystemStatusOsObserver::SystemStatusOsObserver(const MsgTask* msgTask) :
mAddress("SystemStatusOsObserver"), mAddress("SystemStatusOsObserver"),
mClientIndex(IndexFactory<IDataItemObserver*, DataItemId> :: createClientIndex()), mClientIndex(IndexFactory<IDataItemObserver*, DataItemId> :: createClientIndex()),
mDataItemIndex(IndexFactory<IDataItemObserver*, DataItemId> :: createDataItemIndex()) mDataItemIndex(IndexFactory<IDataItemObserver*, DataItemId> :: createDataItemIndex())
{ {
int result = -1;
ENTRY_LOG ();
do {
BREAK_IF_ZERO (1, mClientIndex);
BREAK_IF_ZERO (2, mDataItemIndex);
mContext.mMsgTask = msgTask; mContext.mMsgTask = msgTask;
result = 0;
} while (0);
EXIT_LOG_WITH_ERROR ("%d",result);
} }
SystemStatusOsObserver::~SystemStatusOsObserver() SystemStatusOsObserver::~SystemStatusOsObserver()
@ -77,410 +53,394 @@ SystemStatusOsObserver :: ~SystemStatusOsObserver ()
DataItemsFactoryProxy::closeDataItemLibraryHandle(); DataItemsFactoryProxy::closeDataItemLibraryHandle();
// Destroy cache // Destroy cache
map <DataItemId, IDataItemCore *> :: iterator citer = mDataItemCache.begin (); for (auto each : mDataItemCache) {
for (; citer != mDataItemCache.end (); ++citer) { if (nullptr != each.second) {
if (citer->second != NULL) { delete citer->second; } delete each.second;
} }
}
mDataItemCache.clear(); mDataItemCache.clear();
delete mClientIndex; delete mClientIndex;
delete mDataItemIndex; delete mDataItemIndex;
mClientIndex = NULL; }
mDataItemIndex = NULL;
void SystemStatusOsObserver::setSubscriptionObj(IDataItemSubscription* subscriptionObj)
{
mContext.mSubscriptionObj = subscriptionObj;
LOC_LOGD("Request cache size - Subscribe:%zu RequestData:%zu",
mSubscribeReqCache.size(), mReqDataCache.size());
// we have received the subscription object. process cached requests
// process - subscribe request cache
for (auto each : mSubscribeReqCache) {
subscribe(each.second, each.first);
}
// process - requestData request cache
for (auto each : mReqDataCache) {
requestData(each.second, each.first);
}
}
// Helper to cache requests subscribe and requestData till subscription obj is obtained
void SystemStatusOsObserver::cacheObserverRequest(ObserverReqCache& reqCache,
const list<DataItemId>& l, IDataItemObserver* client)
{
ObserverReqCache::iterator dicIter = reqCache.find(client);
if (dicIter != reqCache.end()) {
// found
list<DataItemId> difference(0);
set_difference(l.begin(), l.end(),
dicIter->second.begin(), dicIter->second.end(),
inserter(difference, difference.begin()));
if (!difference.empty()) {
difference.sort();
dicIter->second.merge(difference);
dicIter->second.unique();
}
}
else {
// not found
reqCache[client] = l;
}
} }
/****************************************************************************** /******************************************************************************
Message proc IDataItemSubscription Overrides
******************************************************************************/ ******************************************************************************/
void SystemStatusOsObserver :: HandleSubscribeReq :: proc () const { void SystemStatusOsObserver::subscribe(
const list<DataItemId>& l, IDataItemObserver* client)
{
if (nullptr == mContext.mSubscriptionObj) {
LOC_LOGD("%s]: Subscription object is NULL. Caching requests", __func__);
cacheObserverRequest(mSubscribeReqCache, l, client);
return;
}
struct HandleSubscribeReq : public LocMsg {
HandleSubscribeReq(SystemStatusOsObserver* parent,
const list<DataItemId>& l, IDataItemObserver* client) :
mParent(parent), mClient(client), mDataItemList(l) {}
virtual ~HandleSubscribeReq() {}
void proc() const {
int result = 0;
ENTRY_LOG ();
do {
if (mDataItemList.empty()) { if (mDataItemList.empty()) {
LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting"); LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting");
result = 0; return;
break;
} }
//mDataItemList.sort ();
// Handle First Response // Handle First Response
list <DataItemId> pendingFirstResponseList; list<DataItemId> pendingFirstResponseList(0);
this->mParent->mClientIndex->add (this->mClient, mDataItemList, pendingFirstResponseList); mParent->mClientIndex->add(mClient, mDataItemList, pendingFirstResponseList);
// Do not send first response for only pendingFirstResponseList, // Do not send first response for only pendingFirstResponseList,
// instead send for all the data items (present in the cache) that // instead send for all the data items (present in the cache) that
// have been subscribed for each time. // have been subscribed for each time.
this->mParent->sendFirstResponse (mDataItemList, this->mClient); mParent->sendFirstResponse(mDataItemList, mClient);
list<DataItemId> yetToSubscribeDataItemsList(0);
mParent->mDataItemIndex->add(mClient, mDataItemList, yetToSubscribeDataItemsList);
list <DataItemId> yetToSubscribeDataItemsList;
this->mParent->mDataItemIndex->add (this->mClient, mDataItemList, yetToSubscribeDataItemsList);
// Send subscription list to framework // Send subscription list to framework
if (!yetToSubscribeDataItemsList.empty()) { if (!yetToSubscribeDataItemsList.empty()) {
this->mParent->mContext.mSubscriptionObj->subscribe mParent->mContext.mSubscriptionObj->subscribe(yetToSubscribeDataItemsList, mParent);
( LOC_LOGD("Subscribe Request sent to framework for the following");
yetToSubscribeDataItemsList, mParent->logMe(yetToSubscribeDataItemsList);
this->mParent }
); }
LOC_LOGD ("Subscribe Request sent to framework for the following data items"); SystemStatusOsObserver* mParent;
this->mParent->logMe (yetToSubscribeDataItemsList); IDataItemObserver* mClient;
const list<DataItemId> mDataItemList;
};
mContext.mMsgTask->sendMsg(new (nothrow) HandleSubscribeReq(this, l, client));
} }
} while (0); void SystemStatusOsObserver::updateSubscription(
EXIT_LOG_WITH_ERROR ("%d", result); const list<DataItemId>& l, IDataItemObserver* client)
{
if (nullptr == mContext.mSubscriptionObj) {
LOC_LOGE("%s:%d]: Subscription object is NULL", __func__, __LINE__);
return; return;
} }
void SystemStatusOsObserver :: HandleUpdateSubscriptionReq :: proc () const { struct HandleUpdateSubscriptionReq : public LocMsg {
int result = 0; HandleUpdateSubscriptionReq(SystemStatusOsObserver* parent,
ENTRY_LOG (); const list<DataItemId>& l, IDataItemObserver* client) :
do { mParent(parent), mClient(client), mDataItemList(l) {}
virtual ~HandleUpdateSubscriptionReq() {}
void proc() const {
if (mDataItemList.empty()) { if (mDataItemList.empty()) {
LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting"); LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting");
result = 0; return;
break;
} }
//mDataItemList.sort ();
list <DataItemId> currentlySubscribedList; list<DataItemId> currentlySubscribedList(0);
this->mParent->mClientIndex->getSubscribedList (this->mClient, currentlySubscribedList); mParent->mClientIndex->getSubscribedList(mClient, currentlySubscribedList);
list <DataItemId> removeDataItemList;
list<DataItemId> removeDataItemList(0);
set_difference(currentlySubscribedList.begin(), currentlySubscribedList.end(), set_difference(currentlySubscribedList.begin(), currentlySubscribedList.end(),
mDataItemList.begin(), mDataItemList.end(), mDataItemList.begin(), mDataItemList.end(),
inserter(removeDataItemList,removeDataItemList.begin())); inserter(removeDataItemList,removeDataItemList.begin()));
// Handle First Response
list <DataItemId> pendingFirstResponseList;
this->mParent->mClientIndex->add (this->mClient, mDataItemList, pendingFirstResponseList);
// Send First Response
this->mParent->sendFirstResponse (pendingFirstResponseList, this->mClient);
list <DataItemId> yetToSubscribeDataItemsList; // Handle First Response
this->mParent->mDataItemIndex->add (this->mClient, mDataItemList, yetToSubscribeDataItemsList); list<DataItemId> pendingFirstResponseList(0);
mParent->mClientIndex->add(mClient, mDataItemList, pendingFirstResponseList);
// Send First Response
mParent->sendFirstResponse(pendingFirstResponseList, mClient);
list<DataItemId> yetToSubscribeDataItemsList(0);
mParent->mDataItemIndex->add(
mClient, mDataItemList, yetToSubscribeDataItemsList);
// Send subscription list to framework // Send subscription list to framework
if (!yetToSubscribeDataItemsList.empty()) { if (!yetToSubscribeDataItemsList.empty()) {
this->mParent->mContext.mSubscriptionObj->subscribe mParent->mContext.mSubscriptionObj->subscribe(
( yetToSubscribeDataItemsList, mParent);
yetToSubscribeDataItemsList, LOC_LOGD("Subscribe Request sent to framework for the following");
this->mParent mParent->logMe(yetToSubscribeDataItemsList);
);
LOC_LOGD ("Subscribe Request sent to framework for the following data items");
this->mParent->logMe (yetToSubscribeDataItemsList);
} }
list <DataItemId> unsubscribeList; list<DataItemId> unsubscribeList(0);
list <DataItemId> unused; list<DataItemId> unused(0);
this->mParent->mClientIndex->remove (this->mClient, removeDataItemList, unused); mParent->mClientIndex->remove(mClient, removeDataItemList, unused);
if (!this->mParent->mClientIndex->isSubscribedClient (this->mClient)) { if (!mParent->mClientIndex->isSubscribedClient(mClient)) {
this->mParent->mDataItemIndex->remove (list <IDataItemObserver *> (1,this->mClient), unsubscribeList); mParent->mDataItemIndex->remove(
list<IDataItemObserver*> (1,mClient), unsubscribeList);
} }
if (!unsubscribeList.empty()) { if (!unsubscribeList.empty()) {
// Send unsubscribe to framework // Send unsubscribe to framework
this->mParent->mContext.mSubscriptionObj->unsubscribe mParent->mContext.mSubscriptionObj->unsubscribe(unsubscribeList, mParent);
( LOC_LOGD("Unsubscribe Request sent to framework for the following");
unsubscribeList, mParent->logMe(unsubscribeList);
this->mParent
);
LOC_LOGD ("Unsubscribe Request sent to framework for the following data items");
this->mParent->logMe (unsubscribeList);
} }
} while (0); }
EXIT_LOG_WITH_ERROR ("%d",result); SystemStatusOsObserver* mParent;
IDataItemObserver* mClient;
const list<DataItemId> mDataItemList;
};
mContext.mMsgTask->sendMsg(new (nothrow) HandleUpdateSubscriptionReq(this, l, client));
} }
void SystemStatusOsObserver :: HandleRequestData :: proc () const { void SystemStatusOsObserver::requestData(
int result = 0; const list<DataItemId>& l, IDataItemObserver* client)
ENTRY_LOG (); {
if (nullptr == mContext.mSubscriptionObj) {
LOC_LOGD("%s]: Subscription object is NULL. Caching requests", __func__);
cacheObserverRequest(mReqDataCache, l, client);
return;
}
do { 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()) { if (mDataItemList.empty()) {
LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting"); LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting");
result = 0; return;
break;
} }
//mDataItemList.sort ();
list <DataItemId> yetToSubscribeDataItemsList; list<DataItemId> yetToSubscribeDataItemsList(0);
this->mParent->mClientIndex->add (this->mClient, mDataItemList, yetToSubscribeDataItemsList); mParent->mClientIndex->add(
this->mParent->mDataItemIndex->add (this->mClient, mDataItemList, yetToSubscribeDataItemsList); mClient, mDataItemList, yetToSubscribeDataItemsList);
mParent->mDataItemIndex->add(
mClient, mDataItemList, yetToSubscribeDataItemsList);
// Send subscription list to framework // Send subscription list to framework
if (!mDataItemList.empty()) { if (!mDataItemList.empty()) {
this->mParent->mContext.mSubscriptionObj->requestData mParent->mContext.mSubscriptionObj->requestData(mDataItemList, mParent);
( LOC_LOGD("Subscribe Request sent to framework for the following");
mDataItemList, mParent->logMe(yetToSubscribeDataItemsList);
this->mParent }
); }
LOC_LOGD ("Subscribe Request sent to framework for the following data items"); SystemStatusOsObserver* mParent;
this->mParent->logMe (yetToSubscribeDataItemsList); IDataItemObserver* mClient;
const list<DataItemId> mDataItemList;
};
mContext.mMsgTask->sendMsg(new (nothrow) HandleRequestData(this, l, client));
} }
} while (0); void SystemStatusOsObserver::unsubscribe(
EXIT_LOG_WITH_ERROR ("%d",result); 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 {
void SystemStatusOsObserver :: HandleUnsubscribeReq :: proc () const { HandleUnsubscribeReq(SystemStatusOsObserver* parent,
int result = 0; const list<DataItemId>& l, IDataItemObserver* client) :
ENTRY_LOG (); mParent(parent), mClient(client), mDataItemList(l) {}
do { virtual ~HandleUnsubscribeReq() {}
void proc() const {
if (mDataItemList.empty()) { if (mDataItemList.empty()) {
LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting"); LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting");
result = 0; return;
break;
} }
//mDataItemList.sort ();
list <DataItemId> unsubscribeList;
list <DataItemId> unused;
this->mParent->mClientIndex->remove (this->mClient, mDataItemList, unused);
list <DataItemId> :: const_iterator it = mDataItemList.begin (); list<DataItemId> unsubscribeList(0);
for (; it != mDataItemList.end (); ++it) { list<DataItemId> unused(0);
list <IDataItemObserver *> clientListSubs; mParent->mClientIndex->remove(mClient, mDataItemList, unused);
list <IDataItemObserver *> clientListOut;
this->mParent->mDataItemIndex->remove ((*it), for (auto each : mDataItemList) {
list <IDataItemObserver *> (1,this->mClient), clientListOut); 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 // check if there are any other subscribed client for this data item id
this->mParent->mDataItemIndex->getListOfSubscribedClients ( (*it), clientListSubs); mParent->mDataItemIndex->getListOfSubscribedClients(each, clientListSubs);
if (clientListSubs.empty()) if (clientListSubs.empty())
{ {
LOC_LOGD ("Client list subscribed is empty for dataitem - %d",(*it)); LOC_LOGD("Client list subscribed is empty for dataitem - %d", each);
unsubscribeList.push_back((*it)); unsubscribeList.push_back(each);
} }
} }
if (!unsubscribeList.empty()) { if (!unsubscribeList.empty()) {
// Send unsubscribe to framework // Send unsubscribe to framework
this->mParent->mContext.mSubscriptionObj->unsubscribe mParent->mContext.mSubscriptionObj->unsubscribe(unsubscribeList, mParent);
(
unsubscribeList,
this->mParent
);
LOC_LOGD("Unsubscribe Request sent to framework for the following data items"); LOC_LOGD("Unsubscribe Request sent to framework for the following data items");
this->mParent->logMe (unsubscribeList); mParent->logMe(unsubscribeList);
} }
} while (0); }
EXIT_LOG_WITH_ERROR ("%d",result); SystemStatusOsObserver* mParent;
IDataItemObserver* mClient;
const list<DataItemId> mDataItemList;
};
mContext.mMsgTask->sendMsg(new (nothrow) HandleUnsubscribeReq(this, l, client));
} }
void SystemStatusOsObserver :: HandleUnsubscribeAllReq :: proc () const { void SystemStatusOsObserver::unsubscribeAll(IDataItemObserver* client)
int result = 0; {
ENTRY_LOG (); if (nullptr == mContext.mSubscriptionObj) {
do { LOC_LOGE("%s:%d]: Subscription object is NULL", __func__, __LINE__);
list <IDataItemObserver *> clients (1, this->mClient); return;
list <DataItemId> unsubscribeList; }
BREAK_IF_NON_ZERO (2, this->mParent->mClientIndex->remove (this->mClient));
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);
this->mParent->mDataItemIndex->remove (clients, unsubscribeList);
if (!unsubscribeList.empty()) { if (!unsubscribeList.empty()) {
// Send unsubscribe to framework // Send unsubscribe to framework
this->mParent->mContext.mSubscriptionObj->unsubscribe mParent->mContext.mSubscriptionObj->unsubscribe(unsubscribeList, mParent);
(
unsubscribeList,
this->mParent
);
LOC_LOGD("Unsubscribe Request sent to framework for the following data items"); LOC_LOGD("Unsubscribe Request sent to framework for the following data items");
this->mParent->logMe (unsubscribeList); mParent->logMe(unsubscribeList);
} }
} while (0); }
EXIT_LOG_WITH_ERROR ("%d",result); SystemStatusOsObserver* mParent;
IDataItemObserver* mClient;
};
mContext.mMsgTask->sendMsg(new (nothrow) HandleUnsubscribeAllReq(this, client));
} }
void SystemStatusOsObserver :: HandleNotify :: getListOfClients /******************************************************************************
(const list <DataItemId> & dlist, list <IDataItemObserver *> & clients ) const { IDataItemObserver Overrides
******************************************************************************/
void SystemStatusOsObserver::notify(const list<IDataItemCore*>& dlist)
{
list<IDataItemCore*> dataItemList(0);
list <DataItemId> :: const_iterator it = dlist.begin (); for (auto each : dlist) {
for (; it != dlist.end (); ++it) { string dv;
list <IDataItemObserver *> clientList; each->stringify(dv);
this->mParent->mDataItemIndex->getListOfSubscribedClients ( (*it), clientList); LOC_LOGD("notify: DataItem In Value:%s", dv.c_str());
list <IDataItemObserver *> :: iterator citer = clientList.begin ();
for (; citer != clientList.end (); ++citer) { IDataItemCore* di = DataItemsFactoryProxy::createNewDataItem(each->getId());
clients.push_back (*citer); if (nullptr == di) {
} LOC_LOGE("Unable to create dataitem:%d", each->getId());
clientList.clear (); return;
}
// remove duplicates
clients.unique ();
} }
void SystemStatusOsObserver :: HandleNotify :: proc () const { // Copy contents into the newly created data item
int result = 0; di->copy(each);
ENTRY_LOG (); dataItemList.push_back(di);
do { // Request systemstatus to record this dataitem in its cache
SystemStatus* systemstatus = SystemStatus::getInstance(mContext.mMsgTask);
if(nullptr != systemstatus) {
systemstatus->eventDataItemNotify(di);
}
}
struct HandleNotify : public LocMsg {
HandleNotify(SystemStatusOsObserver* parent, const list<IDataItemCore*>& l) :
mParent(parent), mDList(l) {}
virtual ~HandleNotify() {
for (auto each : mDList) {
delete each;
}
}
void proc() const {
// Update Cache with received data items and prepare // Update Cache with received data items and prepare
// list of data items to be sent. // list of data items to be sent.
list <IDataItemCore *> :: const_iterator it = mDList.begin (); list<DataItemId> dataItemIdsToBeSent(0);
list <DataItemId> dataItemIdsToBeSent; for (auto item : mDList) {
for (; it != mDList.end (); ++it) {
bool dataItemUpdated = false; bool dataItemUpdated = false;
this->mParent->updateCache (*it, dataItemUpdated); mParent->updateCache(item, dataItemUpdated);
if (dataItemUpdated) { if (dataItemUpdated) {
dataItemIdsToBeSent.push_back ( (*it)->getId ()); dataItemIdsToBeSent.push_back(item->getId());
} }
} }
list <IDataItemObserver *> clientList;
this->getListOfClients (dataItemIdsToBeSent, clientList);
list <IDataItemObserver *> :: iterator citer = clientList.begin ();
// Send data item to all subscribed clients // Send data item to all subscribed clients
LOC_LOGD ("LocTech-Label :: SystemStatusOsObserver :: Data Items Out"); list<IDataItemObserver*> clientList(0);
for (; citer != clientList.end (); ++citer) { for (auto each : dataItemIdsToBeSent) {
do { list<IDataItemObserver*> clients(0);
list <DataItemId> dataItemIdsSubscribedByThisClient; mParent->mDataItemIndex->getListOfSubscribedClients(each, clients);
list <DataItemId> dataItemIdsToBeSentForThisClient; for (auto each_cient: clients) {
this->mParent->mClientIndex->getSubscribedList (*citer, dataItemIdsSubscribedByThisClient); clientList.push_back(each_cient);
}
}
clientList.unique();
for (auto client : clientList) {
list<DataItemId> dataItemIdsSubscribedByThisClient(0);
list<DataItemId> dataItemIdsToBeSentForThisClient(0);
mParent->mClientIndex->getSubscribedList(
client, dataItemIdsSubscribedByThisClient);
dataItemIdsSubscribedByThisClient.sort(); dataItemIdsSubscribedByThisClient.sort();
dataItemIdsToBeSent.sort(); dataItemIdsToBeSent.sort();
set_intersection(dataItemIdsToBeSent.begin(), set_intersection(dataItemIdsToBeSent.begin(),
dataItemIdsToBeSent.end(), dataItemIdsToBeSent.end(),
dataItemIdsSubscribedByThisClient.begin(), dataItemIdsSubscribedByThisClient.begin(),
dataItemIdsSubscribedByThisClient.end(), dataItemIdsSubscribedByThisClient.end(),
inserter(dataItemIdsToBeSentForThisClient, inserter(dataItemIdsToBeSentForThisClient,
dataItemIdsToBeSentForThisClient.begin())); dataItemIdsToBeSentForThisClient.begin()));
BREAK_IF_NON_ZERO (4,this->mParent->sendCachedDataItems (dataItemIdsToBeSentForThisClient, *citer));
mParent->sendCachedDataItems(dataItemIdsToBeSentForThisClient, client);
dataItemIdsSubscribedByThisClient.clear(); dataItemIdsSubscribedByThisClient.clear();
dataItemIdsToBeSentForThisClient.clear(); dataItemIdsToBeSentForThisClient.clear();
} while (0);
}
} while (0);
EXIT_LOG_WITH_ERROR ("%d", result);
}
void SystemStatusOsObserver :: HandleTurnOn :: proc () const {
int result = 0;
ENTRY_LOG ();
do {
// Send action turn on to framework
this->mParent->mContext.mFrameworkActionReqObj->turnOn(mDataItemId, mTimeOut);
} while (0);
EXIT_LOG_WITH_ERROR ("%d", result);
}
void SystemStatusOsObserver :: HandleTurnOff :: proc () const {
int result = 0;
ENTRY_LOG ();
do {
// Send action turn off to framework
this->mParent->mContext.mFrameworkActionReqObj->turnOff(mDataItemId);
} while (0);
EXIT_LOG_WITH_ERROR ("%d", result);
}
/******************************************************************************
IDataItemSubscription Overrides
******************************************************************************/
void SystemStatusOsObserver :: subscribe (const list <DataItemId> & l, IDataItemObserver * client) {
int result = 0;
ENTRY_LOG ();
do {
if (mContext.mSubscriptionObj != NULL) {
HandleSubscribeReq * msg = new (nothrow) HandleSubscribeReq (this, l, client);
mContext.mMsgTask->sendMsg (msg);
}
else {
LOC_LOGE("%s:%d]: Subscription object is NULL", __func__, __LINE__);
result = 1;
}
} while (0);
EXIT_LOG_WITH_ERROR ("%d",result);
}
void SystemStatusOsObserver :: updateSubscription (const list <DataItemId> & l, IDataItemObserver * client) {
int result = 0;
ENTRY_LOG ();
do {
if (mContext.mSubscriptionObj != NULL) {
mContext.mMsgTask->sendMsg (new (nothrow) HandleUpdateSubscriptionReq (this, l, client));
}
else {
LOC_LOGE("%s:%d]: Subscription object is NULL", __func__, __LINE__);
result = 1;
}
} while (0);
EXIT_LOG_WITH_ERROR ("%d",result);
}
void SystemStatusOsObserver :: requestData (const list <DataItemId> & l, IDataItemObserver * client) {
int result = 0;
ENTRY_LOG ();
do {
if (mContext.mSubscriptionObj != NULL) {
mContext.mMsgTask->sendMsg (new (nothrow) HandleRequestData (this, l, client));
}
else {
LOC_LOGE("%s:%d]: Subscription object is NULL", __func__, __LINE__);
result = 1;
}
} while (0);
EXIT_LOG_WITH_ERROR ("%d",result);
}
void SystemStatusOsObserver :: unsubscribe (const list <DataItemId> & l, IDataItemObserver * client) {
int result = 0;
ENTRY_LOG ();
do {
if (mContext.mSubscriptionObj != NULL) {
mContext.mMsgTask->sendMsg (new (nothrow) HandleUnsubscribeReq (this, l, client));
}
else {
LOC_LOGE("%s:%d]: Subscription object is NULL", __func__, __LINE__);
result = 1;
}
} while (0);
EXIT_LOG_WITH_ERROR ("%d",result);
}
void SystemStatusOsObserver :: unsubscribeAll (IDataItemObserver * client) {
int result = 0;
ENTRY_LOG ();
do {
if (mContext.mSubscriptionObj != NULL) {
mContext.mMsgTask->sendMsg (new (nothrow) HandleUnsubscribeAllReq (this, client));
}
else {
LOC_LOGE("%s:%d]: Subscription object is NULL", __func__, __LINE__);
result = 1;
}
} while (0);
EXIT_LOG_WITH_ERROR ("%d",result);
}
/******************************************************************************
IDataItemObserver Overrides
******************************************************************************/
void SystemStatusOsObserver::getName(string & name) {
name = mAddress;
}
void SystemStatusOsObserver::notify(const std::list <IDataItemCore *> & dlist) {
int result = 0;
ENTRY_LOG ();
do {
list <IDataItemCore *> :: const_iterator it = dlist.begin ();
list <IDataItemCore *> dataItemList;
list <DataItemId> ids;
LOC_LOGD("LocTech-Label :: SystemStatusOsObserver :: Data Items In");
for (; it != dlist.end (); ++it) {
if (*it != NULL) {
string dv;
(*it)->stringify(dv);
LOC_LOGD("LocTech-Value :: Data Item Value: %s", dv.c_str ());
IDataItemCore * dataitem = DataItemsFactoryProxy::createNewDataItem((*it)->getId());
BREAK_IF_ZERO (2, dataitem);
// Copy contents into the newly created data item
dataitem->copy(*it);
dataItemList.push_back(dataitem);
ids.push_back((*it)->getId());
} }
} }
SystemStatusOsObserver* mParent;
const list<IDataItemCore*> mDList;
};
mContext.mMsgTask->sendMsg(new (nothrow) HandleNotify(this, dataItemList)); mContext.mMsgTask->sendMsg(new (nothrow) HandleNotify(this, dataItemList));
} while (0);
EXIT_LOG_WITH_ERROR ("%d", result);
} }
/****************************************************************************** /******************************************************************************
IFrameworkActionReq Overrides IFrameworkActionReq Overrides
******************************************************************************/ ******************************************************************************/
void SystemStatusOsObserver :: turnOn (DataItemId dit, int timeOut) { void SystemStatusOsObserver::turnOn(DataItemId dit, int timeOut)
int result = 0; {
ENTRY_LOG (); if (nullptr == mContext.mFrameworkActionReqObj) {
do { LOC_LOGE("%s:%d]: Framework action request object is NULL", __func__, __LINE__);
if (mContext.mFrameworkActionReqObj != NULL) { return;
}
// Check if data item exists in mActiveRequestCount // Check if data item exists in mActiveRequestCount
map<DataItemId, int>::iterator citer = mActiveRequestCount.find(dit); map<DataItemId, int>::iterator citer = mActiveRequestCount.find(dit);
if (citer == mActiveRequestCount.end()) { if (citer == mActiveRequestCount.end()) {
@ -489,157 +449,144 @@ void SystemStatusOsObserver :: turnOn (DataItemId dit, int timeOut) {
pair<DataItemId, int> cpair(dit, 1); pair<DataItemId, int> cpair(dit, 1);
mActiveRequestCount.insert(cpair); mActiveRequestCount.insert(cpair);
LOC_LOGD("Sending turnOn request"); LOC_LOGD("Sending turnOn request");
// Send action turn on to framework // Send action turn on to framework
mContext.mMsgTask->sendMsg (new (nothrow) HandleTurnOn (this, dit, timeOut)); struct HandleTurnOnMsg : public LocMsg {
} else { HandleTurnOnMsg(IFrameworkActionReq* framework,
// Found in map, update reference count DataItemId dit, int timeOut) :
citer->second++; mFrameworkActionReqObj(framework), mDataItemId(dit), mTimeOut(timeOut) {}
LOC_LOGD("HandleTurnOn - Data item:%d Num_refs:%d",dit,citer->second); virtual ~HandleTurnOnMsg() {}
void proc() const {
mFrameworkActionReqObj->turnOn(mDataItemId, mTimeOut);
} }
IFrameworkActionReq* mFrameworkActionReqObj;
DataItemId mDataItemId;
int mTimeOut;
};
mContext.mMsgTask->sendMsg(new (nothrow) HandleTurnOnMsg(this, dit, timeOut));
} }
else { else {
// Found in map, update reference count
citer->second++;
LOC_LOGD("turnOn - Data item:%d Num_refs:%d", dit, citer->second);
}
}
void SystemStatusOsObserver::turnOff(DataItemId dit)
{
if (nullptr == mContext.mFrameworkActionReqObj) {
LOC_LOGE("%s:%d]: Framework action request object is NULL", __func__, __LINE__); LOC_LOGE("%s:%d]: Framework action request object is NULL", __func__, __LINE__);
result = 1; return;
}
} while (0);
EXIT_LOG_WITH_ERROR ("%d", result);
} }
void SystemStatusOsObserver :: turnOff (DataItemId dit) {
int result = 0;
ENTRY_LOG ();
do {
if (mContext.mFrameworkActionReqObj != NULL) {
// Check if data item exists in mActiveRequestCount // Check if data item exists in mActiveRequestCount
map<DataItemId, int>::iterator citer = mActiveRequestCount.find(dit); map<DataItemId, int>::iterator citer = mActiveRequestCount.find(dit);
if (citer != mActiveRequestCount.end()) { if (citer != mActiveRequestCount.end()) {
// found
citer->second--; citer->second--;
LOC_LOGD("HandleTurnOff - Data item:%d Remaining Num_refs:%d",dit,citer->second); LOC_LOGD("turnOff - Data item:%d Remaining:%d", dit, citer->second);
if(citer->second == 0) { if(citer->second == 0) {
LOC_LOGD("Sending turnOff request");
// if this was last reference, remove item from map and turn off module // if this was last reference, remove item from map and turn off module
mActiveRequestCount.erase(citer); mActiveRequestCount.erase(citer);
// Send action turn off to framework // Send action turn off to framework
mContext.mMsgTask->sendMsg (new (nothrow) HandleTurnOff (this, dit)); struct HandleTurnOffMsg : public LocMsg {
HandleTurnOffMsg(IFrameworkActionReq* framework, DataItemId dit) :
mFrameworkActionReqObj(framework), mDataItemId(dit) {}
virtual ~HandleTurnOffMsg() {}
void proc() const {
mFrameworkActionReqObj->turnOff(mDataItemId);
} }
} else { IFrameworkActionReq* mFrameworkActionReqObj;
// Not found in map DataItemId mDataItemId;
LOC_LOGD ("Data item id %d not found in FrameworkModuleMap",dit); };
mContext.mMsgTask->sendMsg(
new (nothrow) HandleTurnOffMsg(mContext.mFrameworkActionReqObj, dit));
} }
} }
else {
LOC_LOGE("%s:%d]: Framework action request object is NULL", __func__, __LINE__);
result = 1;
}
} while (0);
EXIT_LOG_WITH_ERROR ("%d", result);
} }
/****************************************************************************** /******************************************************************************
Helpers Helpers
******************************************************************************/ ******************************************************************************/
void SystemStatusOsObserver :: logMe (const list <DataItemId> & l) { void SystemStatusOsObserver::sendFirstResponse(
list <DataItemId> :: const_iterator it = l.begin (); const list<DataItemId>& l, IDataItemObserver* to)
for (;it != l.end (); ++it) { {
LOC_LOGD ("DataItem %d",*it);
}
}
int SystemStatusOsObserver :: sendFirstResponse (const list <DataItemId> & l, IDataItemObserver * to) {
int result = 0;
ENTRY_LOG ();
do {
if (l.empty()) { if (l.empty()) {
LOC_LOGV("list is empty. Nothing to do. Exiting"); LOC_LOGV("list is empty. Nothing to do. Exiting");
result = 0; return;
break;
} }
string clientName; string clientName;
to->getName(clientName); to->getName(clientName);
LOC_LOGD ("First response sent for the following data items To Client: %s", clientName.c_str()); list<IDataItemCore*> dataItems(0);
list <IDataItemCore *> dataItems; for (auto each : l) {
list <DataItemId> :: const_iterator diditer = l.begin (); map<DataItemId, IDataItemCore*>::const_iterator citer = mDataItemCache.find(each);
for (; diditer != l.end (); ++diditer) {
map <DataItemId, IDataItemCore*> :: const_iterator citer = mDataItemCache.find (*diditer);
if (citer != mDataItemCache.end()) { if (citer != mDataItemCache.end()) {
string dv; string dv;
IDataItemCore * di = citer->second; citer->second->stringify(dv);
di->stringify (dv); LOC_LOGI("DataItem: %s >> %s", dv.c_str(), clientName.c_str());
LOC_LOGD ("LocTech-Value :: Data Item: %s", dv.c_str ());
dataItems.push_back(citer->second); dataItems.push_back(citer->second);
} }
} }
if (dataItems.empty()) { if (dataItems.empty()) {
LOC_LOGV("No items to notify. Nothing to do. Exiting"); LOC_LOGV("No items to notify. Nothing to do. Exiting");
result = 0; return;
break;
} }
// Notify Client
to->notify(dataItems); to->notify(dataItems);
} while (0);
EXIT_LOG_WITH_ERROR ("%d", result);
return result;
} }
int SystemStatusOsObserver :: sendCachedDataItems (const list <DataItemId> & l, IDataItemObserver * to) { void SystemStatusOsObserver::sendCachedDataItems(
int result = 0; const list<DataItemId>& l, IDataItemObserver* to)
ENTRY_LOG (); {
do {
list <IDataItemCore *> dataItems;
list <DataItemId> :: const_iterator it = l.begin ();
string clientName; string clientName;
to->getName(clientName); to->getName(clientName);
LOC_LOGD ("LocTech-Value :: To Client: %s", clientName.c_str ()); list<IDataItemCore*> dataItems(0);
for (; it != l.end (); ++it) {
for (auto each : l) {
string dv; string dv;
IDataItemCore * di = this->mDataItemCache [ (*it) ]; IDataItemCore* di = mDataItemCache[each];
di->stringify(dv); di->stringify(dv);
LOC_LOGI("LocTech-Value :: Data Item: %s >> %s", dv.c_str(), clientName.c_str()); LOC_LOGI("DataItem: %s >> %s", dv.c_str(), clientName.c_str());
dataItems.push_back(di); dataItems.push_back(di);
} }
to->notify(dataItems); to->notify(dataItems);
} while (0);
EXIT_LOG_WITH_ERROR ("%d", result);
return result;
} }
int SystemStatusOsObserver :: updateCache (IDataItemCore * d, bool &dataItemUpdated) { void SystemStatusOsObserver::updateCache(IDataItemCore* d, bool& dataItemUpdated)
int result = 0; {
ENTRY_LOG (); if (nullptr == d) {
do { return;
BREAK_IF_ZERO (1, d); }
// Check if data item exists in cache // Check if data item exists in cache
map <DataItemId, IDataItemCore*> :: iterator citer = mDataItemCache.find (d->getId ()); map<DataItemId, IDataItemCore*>::iterator citer =
mDataItemCache.find(d->getId());
if (citer == mDataItemCache.end()) { if (citer == mDataItemCache.end()) {
// New data item; not found in cache // New data item; not found in cache
IDataItemCore* dataitem = DataItemsFactoryProxy::createNewDataItem(d->getId()); IDataItemCore* dataitem = DataItemsFactoryProxy::createNewDataItem(d->getId());
BREAK_IF_ZERO (2, dataitem); if (nullptr == dataitem) {
return;
}
// Copy the contents of the data item // Copy the contents of the data item
dataitem->copy(d); dataitem->copy(d);
pair<DataItemId, IDataItemCore*> cpair(d->getId(), dataitem); pair<DataItemId, IDataItemCore*> cpair(d->getId(), dataitem);
// Insert in mDataItemCache // Insert in mDataItemCache
mDataItemCache.insert(cpair); mDataItemCache.insert(cpair);
dataItemUpdated = true; dataItemUpdated = true;
} else { }
else {
// Found in cache; Update cache if necessary // Found in cache; Update cache if necessary
BREAK_IF_NON_ZERO(3, citer->second->copy (d, &dataItemUpdated)); if(0 == citer->second->copy(d, &dataItemUpdated)) {
return;
}
} }
if (dataItemUpdated) { if (dataItemUpdated) {
LOC_LOGV("DataItem:%d updated:%d", d->getId(), dataItemUpdated); LOC_LOGV("DataItem:%d updated:%d", d->getId(), dataItemUpdated);
} }
} while (0);
EXIT_LOG_WITH_ERROR ("%d", result);
return result;
} }
} // namespace loc_core } // namespace loc_core

View file

@ -29,31 +29,29 @@
#ifndef __SYSTEM_STATUS_OSOBSERVER__ #ifndef __SYSTEM_STATUS_OSOBSERVER__
#define __SYSTEM_STATUS_OSOBSERVER__ #define __SYSTEM_STATUS_OSOBSERVER__
#include <stdint.h> #include <cinttypes>
#include <string> #include <string>
#include <list> #include <list>
#include <map> #include <map>
#include <new> #include <new>
#include <vector> #include <vector>
#include <platform_lib_log_util.h>
#include <DataItemId.h>
#include <MsgTask.h> #include <MsgTask.h>
#include <DataItemId.h>
#include <IOsObserver.h> #include <IOsObserver.h>
#include <platform_lib_log_util.h>
namespace loc_core namespace loc_core
{ {
/****************************************************************************** /******************************************************************************
SystemStatusOsObserver SystemStatusOsObserver
******************************************************************************/ ******************************************************************************/
using namespace std;
// Forward Declarations // Forward Declarations
class IDataItemCore; class IDataItemCore;
template<typename CT, typename DIT> class IClientIndex;
template <typename CT, typename DIT> template<typename CT, typename DIT> class IDataItemIndex;
class IClientIndex;
template <typename CT, typename DIT>
class IDataItemIndex;
struct SystemContext { struct SystemContext {
IDataItemSubscription* mSubscriptionObj; IDataItemSubscription* mSubscriptionObj;
@ -66,6 +64,8 @@ struct SystemContext {
mMsgTask(NULL) {} mMsgTask(NULL) {}
}; };
typedef map<IDataItemObserver*, list<DataItemId>> ObserverReqCache;
// Clients wanting to get data from OS/Framework would need to // Clients wanting to get data from OS/Framework would need to
// subscribe with OSObserver using IDataItemSubscription interface. // subscribe with OSObserver using IDataItemSubscription interface.
// Such clients would need to implement IDataItemObserver interface // Such clients would need to implement IDataItemObserver interface
@ -80,40 +80,31 @@ public:
~SystemStatusOsObserver(); ~SystemStatusOsObserver();
// To set the subscription object // To set the subscription object
inline void setSubscriptionObj(IDataItemSubscription *subscriptionObj) { virtual void setSubscriptionObj(IDataItemSubscription* subscriptionObj);
mContext.mSubscriptionObj = subscriptionObj;
};
// To set the framework action request object // To set the framework action request object
inline void setFrameworkActionReqObj(IFrameworkActionReq* frameworkActionReqObj) { inline void setFrameworkActionReqObj(IFrameworkActionReq* frameworkActionReqObj) {
mContext.mFrameworkActionReqObj = frameworkActionReqObj; mContext.mFrameworkActionReqObj = frameworkActionReqObj;
} }
// IDataItemObserver Overrides
virtual void getName (string & name);
virtual void notify (const std::list <IDataItemCore *> & dlist);
// IDataItemSubscription Overrides // IDataItemSubscription Overrides
virtual void subscribe (const std :: list <DataItemId> & l, IDataItemObserver * client); virtual void subscribe(const list<DataItemId>& l, IDataItemObserver* client);
virtual void updateSubscription virtual void updateSubscription(const list<DataItemId>& l, IDataItemObserver* client);
( virtual void requestData(const list<DataItemId>& l, IDataItemObserver* client);
const std :: list <DataItemId> & l, virtual void unsubscribe(const list<DataItemId>& l, IDataItemObserver* client);
IDataItemObserver * client
);
virtual void requestData
(
const std :: list <DataItemId> & l,
IDataItemObserver * client
);
virtual void unsubscribe (const std :: list <DataItemId> & l, IDataItemObserver * client);
virtual void unsubscribeAll(IDataItemObserver* client); virtual void unsubscribeAll(IDataItemObserver* client);
// IDataItemObserver Overrides
virtual void notify(const list<IDataItemCore*>& dlist);
inline virtual void getName(string& name) {
name = mAddress;
}
// IFrameworkActionReq Overrides // IFrameworkActionReq Overrides
virtual void turnOn(DataItemId dit, int timeOut = 0); virtual void turnOn(DataItemId dit, int timeOut = 0);
virtual void turnOff(DataItemId dit); virtual void turnOff(DataItemId dit);
private: private:
SystemContext mContext; SystemContext mContext;
const string mAddress; const string mAddress;
IClientIndex<IDataItemObserver*, DataItemId>* mClientIndex; IClientIndex<IDataItemObserver*, DataItemId>* mClientIndex;
@ -121,211 +112,22 @@ private:
map<DataItemId, IDataItemCore*> mDataItemCache; map<DataItemId, IDataItemCore*> mDataItemCache;
map<DataItemId, int> mActiveRequestCount; map<DataItemId, int> mActiveRequestCount;
// Nested types // Cache the subscribe and requestData till subscription obj is obtained
// Messages ObserverReqCache mSubscribeReqCache;
struct HandleMsgBase : public LocMsg { ObserverReqCache mReqDataCache;
HandleMsgBase (SystemStatusOsObserver * parent); void cacheObserverRequest(ObserverReqCache& reqCache,
virtual ~HandleMsgBase (); const list<DataItemId>& l, IDataItemObserver* client);
// Data members
SystemStatusOsObserver * mParent;
};
// Helpers // Helpers
int sendFirstResponse void sendFirstResponse(const list<DataItemId>& l, IDataItemObserver* to);
( void sendCachedDataItems(const list<DataItemId>& l, IDataItemObserver* to);
const list <DataItemId> & l, void updateCache(IDataItemCore* d, bool& dataItemUpdated);
IDataItemObserver * to inline void logMe(const list<DataItemId>& l) {
); for (auto id : l) {
LOC_LOGD("DataItem %d", id);
int sendCachedDataItems
(
const list <DataItemId> & l,
IDataItemObserver * to
);
int updateCache (IDataItemCore * d, bool &dataItemUpdated);
void logMe (const list <DataItemId> & l);
// Messages
struct HandleClientMsg : public LocMsg {
HandleClientMsg (SystemStatusOsObserver * parent, IDataItemObserver * client);
virtual ~HandleClientMsg ();
// Data Members
SystemStatusOsObserver * mParent;
IDataItemObserver * mClient;
};
struct HandleSubscribeReq : public HandleClientMsg {
HandleSubscribeReq (SystemStatusOsObserver * parent,
const list <DataItemId> & l,
IDataItemObserver * client);
virtual ~HandleSubscribeReq ();
void proc () const;
// Data members
const list <DataItemId> mDataItemList;
};
struct HandleUpdateSubscriptionReq : public HandleClientMsg {
HandleUpdateSubscriptionReq (SystemStatusOsObserver * parent,
const list <DataItemId> & l,
IDataItemObserver * client);
virtual ~HandleUpdateSubscriptionReq ();
void proc () const;
// Data members
const list <DataItemId> mDataItemList;
};
struct HandleRequestData : public HandleClientMsg {
HandleRequestData (SystemStatusOsObserver * parent,
const list <DataItemId> & l,
IDataItemObserver * client);
virtual ~HandleRequestData ();
void proc () const;
const list <DataItemId> mDataItemList;
};
struct HandleUnsubscribeReq : public HandleClientMsg {
HandleUnsubscribeReq (SystemStatusOsObserver * parent,
const list <DataItemId> & l,
IDataItemObserver * client);
virtual ~HandleUnsubscribeReq ();
void proc () const;
// Data members
const list <DataItemId> mDataItemList;
};
struct HandleUnsubscribeAllReq : public HandleClientMsg {
HandleUnsubscribeAllReq
(
SystemStatusOsObserver * parent,
IDataItemObserver * client
);
virtual ~HandleUnsubscribeAllReq ();
void proc () const;
};
struct HandleNotify : public HandleMsgBase {
HandleNotify (SystemStatusOsObserver * parent, list <IDataItemCore *> dlist);
virtual ~HandleNotify ();
void getListOfClients
(
const list <DataItemId> & dlist,
list <IDataItemObserver *> & clients
) const;
void proc () const;
// Data members
list <IDataItemCore *> mDList;
};
struct HandleTurnOn : public HandleMsgBase {
HandleTurnOn (SystemStatusOsObserver * parent,
const DataItemId dit,
const int timeOut);
virtual ~HandleTurnOn ();
void proc () const;
// Data members
DataItemId mDataItemId;
int mTimeOut;
};
struct HandleTurnOff : public HandleMsgBase {
HandleTurnOff (SystemStatusOsObserver * parent,const DataItemId dit);
virtual ~HandleTurnOff ();
void proc () const;
// Data members
DataItemId mDataItemId;
};
};
/******************************************************************************
Messages
******************************************************************************/
// Ctors
inline SystemStatusOsObserver :: HandleMsgBase :: HandleMsgBase (SystemStatusOsObserver * parent)
:
mParent (parent)
{}
inline SystemStatusOsObserver :: HandleClientMsg :: HandleClientMsg
(
SystemStatusOsObserver * parent,
IDataItemObserver * client
)
:
mParent (parent),
mClient (client)
{}
inline SystemStatusOsObserver :: HandleSubscribeReq :: HandleSubscribeReq
(SystemStatusOsObserver * parent, const list <DataItemId> & l, IDataItemObserver * client)
:
HandleClientMsg (parent, client), mDataItemList (l)
{}
inline SystemStatusOsObserver :: HandleUpdateSubscriptionReq :: HandleUpdateSubscriptionReq
(SystemStatusOsObserver * parent, const list <DataItemId> & l, IDataItemObserver * client)
:
HandleClientMsg (parent, client), mDataItemList (l)
{}
inline SystemStatusOsObserver :: HandleRequestData :: HandleRequestData
(SystemStatusOsObserver * parent, const list <DataItemId> & l, IDataItemObserver * client)
:
HandleClientMsg (parent, client), mDataItemList (l)
{}
inline SystemStatusOsObserver :: HandleUnsubscribeReq :: HandleUnsubscribeReq
(SystemStatusOsObserver * parent, const list <DataItemId> & l, IDataItemObserver * client)
:
HandleClientMsg (parent, client), mDataItemList (l)
{}
inline SystemStatusOsObserver :: HandleUnsubscribeAllReq :: HandleUnsubscribeAllReq
(SystemStatusOsObserver * parent, IDataItemObserver * client)
:
HandleClientMsg (parent, client)
{}
inline SystemStatusOsObserver :: HandleNotify :: HandleNotify
(SystemStatusOsObserver * parent, list <IDataItemCore *> dlist)
:
HandleMsgBase (parent), mDList (dlist)
{}
inline SystemStatusOsObserver :: HandleTurnOn :: HandleTurnOn
(SystemStatusOsObserver * parent, const DataItemId dit,const int timeOut)
:
HandleMsgBase (parent), mDataItemId (dit), mTimeOut (timeOut)
{}
inline SystemStatusOsObserver :: HandleTurnOff :: HandleTurnOff
(SystemStatusOsObserver * parent, const DataItemId dit)
:
HandleMsgBase (parent), mDataItemId (dit)
{}
// Dtors
inline SystemStatusOsObserver :: HandleMsgBase :: ~HandleMsgBase () {}
inline SystemStatusOsObserver :: HandleClientMsg :: ~HandleClientMsg () {}
inline SystemStatusOsObserver :: HandleSubscribeReq :: ~HandleSubscribeReq () {}
inline SystemStatusOsObserver :: HandleUpdateSubscriptionReq :: ~HandleUpdateSubscriptionReq() {}
inline SystemStatusOsObserver :: HandleRequestData :: ~HandleRequestData() {}
inline SystemStatusOsObserver :: HandleUnsubscribeReq :: ~HandleUnsubscribeReq () {}
inline SystemStatusOsObserver :: HandleUnsubscribeAllReq :: ~HandleUnsubscribeAllReq () {}
inline SystemStatusOsObserver :: HandleNotify :: ~HandleNotify () {
list <IDataItemCore *> :: iterator it = mDList.begin ();
for (; it != mDList.end (); ++it) {
delete *it;
*it = NULL;
} }
} }
};
inline SystemStatusOsObserver :: HandleTurnOn :: ~HandleTurnOn () {}
inline SystemStatusOsObserver :: HandleTurnOff :: ~HandleTurnOff () {}
} // namespace loc_core } // namespace loc_core

View file

@ -67,7 +67,8 @@ GnssAdapter::GnssAdapter() :
mAgpsManager(), mAgpsManager(),
mAgpsCbInfo(), mAgpsCbInfo(),
mSystemStatus(SystemStatus::getInstance(mMsgTask)), mSystemStatus(SystemStatus::getInstance(mMsgTask)),
mServerUrl("") mServerUrl(""),
mXtraObserver(mSystemStatus->getOsObserver(), mMsgTask)
{ {
LOC_LOGD("%s]: Constructor %p", __func__, this); LOC_LOGD("%s]: Constructor %p", __func__, this);
mUlpPositionMode.mode = LOC_POSITION_MODE_INVALID; mUlpPositionMode.mode = LOC_POSITION_MODE_INVALID;

View file

@ -106,11 +106,11 @@ class GnssAdapter : public LocAdapterBase {
// This must be initialized via initAgps() // This must be initialized via initAgps()
AgpsManager mAgpsManager; AgpsManager mAgpsManager;
AgpsCbInfo mAgpsCbInfo; AgpsCbInfo mAgpsCbInfo;
XtraSystemStatusObserver mXtraObserver;
/* === SystemStatus ===================================================================== */ /* === SystemStatus ===================================================================== */
SystemStatus* mSystemStatus; SystemStatus* mSystemStatus;
std::string mServerUrl; std::string mServerUrl;
XtraSystemStatusObserver mXtraObserver;
/*==== CONVERSION ===================================================================*/ /*==== CONVERSION ===================================================================*/
static void convertOptions(LocPosMode& out, const LocationOptions& options); static void convertOptions(LocPosMode& out, const LocationOptions& options);
@ -282,10 +282,6 @@ public:
void injectLocationCommand(double latitude, double longitude, float accuracy); void injectLocationCommand(double latitude, double longitude, float accuracy);
void injectTimeCommand(int64_t time, int64_t timeReference, int32_t uncertainty); void injectTimeCommand(int64_t time, int64_t timeReference, int32_t uncertainty);
inline void updateConnectionStatusCommand(bool connected, uint8_t type) {
mXtraObserver.updateConnectionStatus(connected, type);
}
}; };
#endif //GNSS_ADAPTER_H #endif //GNSS_ADAPTER_H

View file

@ -45,40 +45,55 @@
#include <sstream> #include <sstream>
#include <XtraSystemStatusObserver.h> #include <XtraSystemStatusObserver.h>
#include <LocAdapterBase.h> #include <LocAdapterBase.h>
#include <DataItemId.h>
#include <DataItemsFactoryProxy.h>
using namespace std;
using namespace loc_core; using namespace loc_core;
#define XTRA_HAL_SOCKET_NAME "/data/vendor/location/xtra/socket_hal_xtra" #define XTRA_HAL_SOCKET_NAME "/data/vendor/location/xtra/socket_hal_xtra"
bool XtraSystemStatusObserver::updateLockStatus(uint32_t lock) { bool XtraSystemStatusObserver::updateLockStatus(uint32_t lock) {
std::stringstream ss; stringstream ss;
ss << "gpslock"; ss << "gpslock";
ss << " " << lock; ss << " " << lock;
ss << "\n"; // append seperator ss << "\n"; // append seperator
return ( sendEvent(ss) ); return ( sendEvent(ss) );
} }
bool XtraSystemStatusObserver::updateConnectionStatus(bool connected, uint8_t type) { bool XtraSystemStatusObserver::updateConnectionStatus(bool connected, uint32_t type) {
std::stringstream ss; stringstream ss;
ss << "connection"; ss << "connection";
ss << " " << (connected ? "1" : "0"); ss << " " << (connected ? "1" : "0");
ss << " " << (int)type; ss << " " << (int)type;
ss << "\n"; // append seperator ss << "\n"; // append seperator
return ( sendEvent(ss) ); return ( sendEvent(ss) );
} }
bool XtraSystemStatusObserver::updateTac(const string& tac) {
stringstream ss;
ss << "tac";
ss << " " << tac.c_str();
ss << "\n"; // append seperator
return ( sendEvent(ss) );
}
bool XtraSystemStatusObserver::sendEvent(std::stringstream& event) { bool XtraSystemStatusObserver::updateMccMnc(const string& mccmnc) {
stringstream ss;
ss << "mncmcc";
ss << " " << mccmnc.c_str();
ss << "\n"; // append seperator
return ( sendEvent(ss) );
}
bool XtraSystemStatusObserver::sendEvent(const stringstream& event) {
int socketFd = createSocket(); int socketFd = createSocket();
if (socketFd < 0) { if (socketFd < 0) {
LOC_LOGe("XTRA unreachable. sending failed."); LOC_LOGe("XTRA unreachable. sending failed.");
return false; return false;
} }
const std::string& data = event.str(); const string& data = event.str();
int remain = data.length(); int remain = data.length();
ssize_t sent = 0; ssize_t sent = 0;
while (remain > 0 && while (remain > 0 &&
(sent = ::send(socketFd, data.c_str() + (data.length() - remain), (sent = ::send(socketFd, data.c_str() + (data.length() - remain),
remain, MSG_NOSIGNAL)) > 0) { remain, MSG_NOSIGNAL)) > 0) {
@ -125,3 +140,95 @@ void XtraSystemStatusObserver::closeSocket(const int socketFd) {
} }
} }
} }
void XtraSystemStatusObserver::subscribe(bool yes)
{
// Subscription data list
list<DataItemId> subItemIdList;
subItemIdList.push_back(NETWORKINFO_DATA_ITEM_ID);
subItemIdList.push_back(MCCMNC_DATA_ITEM_ID);
if (yes) {
mSystemStatusObsrvr->subscribe(subItemIdList, this);
list<DataItemId> reqItemIdList;
reqItemIdList.push_back(TAC_DATA_ITEM_ID);
mSystemStatusObsrvr->requestData(reqItemIdList, this);
} else {
mSystemStatusObsrvr->unsubscribe(subItemIdList, this);
}
}
// IDataItemObserver overrides
void XtraSystemStatusObserver::getName(string& name)
{
name = "XtraSystemStatusObserver";
}
void XtraSystemStatusObserver::notify(const list<IDataItemCore*>& dlist)
{
struct handleOsObserverUpdateMsg : public LocMsg {
XtraSystemStatusObserver* mXtraSysStatObj;
list <IDataItemCore*> mDataItemList;
inline handleOsObserverUpdateMsg(XtraSystemStatusObserver* xtraSysStatObs,
const list<IDataItemCore*>& dataItemList) :
mXtraSysStatObj(xtraSysStatObs) {
for (auto eachItem : dataItemList) {
IDataItemCore* dataitem = DataItemsFactoryProxy::createNewDataItem(
eachItem->getId());
if (NULL == dataitem) {
break;
}
// Copy the contents of the data item
dataitem->copy(eachItem);
mDataItemList.push_back(dataitem);
}
}
inline ~handleOsObserverUpdateMsg() {
for (auto each : mDataItemList) {
delete each;
}
}
inline void proc() const {
for (auto each : mDataItemList) {
switch (each->getId())
{
case NETWORKINFO_DATA_ITEM_ID:
{
SystemStatusNetworkInfo* networkInfo =
reinterpret_cast<SystemStatusNetworkInfo*>(each);
mXtraSysStatObj->updateConnectionStatus(networkInfo->mConnected,
networkInfo->mType);
}
break;
case TAC_DATA_ITEM_ID:
{
SystemStatusTac* tac = reinterpret_cast<SystemStatusTac*>(each);
mXtraSysStatObj->updateTac(tac->mValue);
}
break;
case MCCMNC_DATA_ITEM_ID:
{
SystemStatusMccMnc* mccmnc = reinterpret_cast<SystemStatusMccMnc*>(each);
mXtraSysStatObj->updateMccMnc(mccmnc->mValue);
}
break;
default:
break;
}
}
}
};
mMsgTask->sendMsg(new (nothrow) handleOsObserverUpdateMsg(this, dlist));
}

View file

@ -29,25 +29,42 @@
#ifndef XTRA_SYSTEM_STATUS_OBS_H #ifndef XTRA_SYSTEM_STATUS_OBS_H
#define XTRA_SYSTEM_STATUS_OBS_H #define XTRA_SYSTEM_STATUS_OBS_H
#include <stdint.h> #include <cinttypes>
#include <MsgTask.h>
using namespace std;
using loc_core::IOsObserver;
using loc_core::IDataItemObserver;
using loc_core::IDataItemCore;
class XtraSystemStatusObserver { class XtraSystemStatusObserver : public IDataItemObserver {
public : public :
// constructor & destructor // constructor & destructor
XtraSystemStatusObserver() { inline XtraSystemStatusObserver(IOsObserver* sysStatObs, const MsgTask* msgTask):
mSystemStatusObsrvr(sysStatObs), mMsgTask(msgTask) {
subscribe(true);
} }
inline XtraSystemStatusObserver() {};
inline virtual ~XtraSystemStatusObserver() { subscribe(false); }
virtual ~XtraSystemStatusObserver() { // IDataItemObserver overrides
} inline virtual void getName(string& name);
virtual void notify(const list<IDataItemCore*>& dlist);
bool updateLockStatus(uint32_t lock); bool updateLockStatus(uint32_t lock);
bool updateConnectionStatus(bool connected, uint8_t type); bool updateConnectionStatus(bool connected, uint32_t type);
bool updateTac(const string& tac);
bool updateMccMnc(const string& mccmnc);
inline const MsgTask* getMsgTask() { return mMsgTask; }
void subscribe(bool yes);
private: private:
int createSocket(); int createSocket();
void closeSocket(const int32_t socketFd); void closeSocket(const int32_t socketFd);
bool sendEvent(std::stringstream& event); bool sendEvent(const stringstream& event);
IOsObserver* mSystemStatusObsrvr;
const MsgTask* mMsgTask;
}; };

View file

@ -253,6 +253,6 @@ static void getDebugReport(GnssDebugReport& report) {
static void updateConnectionStatus(bool connected, uint8_t type) { static void updateConnectionStatus(bool connected, uint8_t type) {
if (NULL != gGnssAdapter) { if (NULL != gGnssAdapter) {
gGnssAdapter->updateConnectionStatusCommand(connected, type); gGnssAdapter->getSystemStatus()->eventConnectionStatus(connected, type);
} }
} }