Merge remote-tracking branch 'quic/location.lnx.2.9' into HEAD
Change-Id: I7e122e35f0b79a8bfc899fb37935e3f7acb175c3 CRs-Fixed: 2108593
This commit is contained in:
commit
dda1d12998
16 changed files with 1745 additions and 841 deletions
|
@ -164,7 +164,7 @@ void LocApiBase::addAdapter(LocAdapterBase* adapter)
|
|||
if (mLocAdapters[i] == NULL) {
|
||||
mLocAdapters[i] = adapter;
|
||||
mMsgTask->sendMsg(new LocOpenMsg(this,
|
||||
(adapter->getEvtMask())));
|
||||
mMask | adapter->getEvtMask()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
AM_CFLAGS = -I./ \
|
||||
-I../utils \
|
||||
-I../gnss \
|
||||
-I../location \
|
||||
-I./data-items \
|
||||
-I./data-items/common \
|
||||
|
@ -22,6 +23,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 \
|
||||
|
|
|
@ -37,8 +37,10 @@
|
|||
#include <platform_lib_log_util.h>
|
||||
#include <MsgTask.h>
|
||||
#include <loc_nmea.h>
|
||||
#include <DataItemsFactoryProxy.h>
|
||||
#include <SystemStatus.h>
|
||||
#include <SystemStatusOsObserver.h>
|
||||
#include <DataItemConcreteTypesBase.h>
|
||||
|
||||
namespace loc_core
|
||||
{
|
||||
|
@ -1212,7 +1214,8 @@ IOsObserver* SystemStatus::getOsObserver()
|
|||
}
|
||||
|
||||
SystemStatus::SystemStatus(const MsgTask* msgTask) :
|
||||
mSysStatusObsvr(msgTask)
|
||||
mSysStatusObsvr(msgTask),
|
||||
mConnected(false)
|
||||
{
|
||||
int result = 0;
|
||||
ENTRY_LOG ();
|
||||
|
@ -1413,6 +1416,28 @@ bool SystemStatus::setPositionFailure(const SystemStatusPQWS1& nmea)
|
|||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
SystemStatus - storing dataitems
|
||||
******************************************************************************/
|
||||
bool SystemStatus::setNetworkInfo(IDataItemCore* dataitem)
|
||||
{
|
||||
NetworkInfoDataItemBase* data = reinterpret_cast<NetworkInfoDataItemBase*>(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
|
||||
|
||||
|
@ -1533,6 +1558,26 @@ bool SystemStatus::eventPosition(const UlpLocation& location,
|
|||
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
|
||||
|
||||
|
@ -1712,5 +1757,33 @@ bool SystemStatus::setDefaultReport(void)
|
|||
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
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <vector>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <MsgTask.h>
|
||||
#include <IDataItemCore.h>
|
||||
#include <IOsObserver.h>
|
||||
#include <SystemStatusOsObserver.h>
|
||||
|
||||
|
@ -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<SystemStatusGpsState*>(src);
|
||||
mEnabled = gpsstate->mEnabled;
|
||||
if (dataItemCopied) {
|
||||
*dataItemCopied = true;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
class SystemStatusNetworkInfo : public SystemStatusItemBase, public IDataItemCore
|
||||
{
|
||||
public:
|
||||
inline SystemStatusNetworkInfo() :
|
||||
mType(0),
|
||||
mTypeName(""),
|
||||
mSubTypeName(""),
|
||||
mAvailable(false),
|
||||
mConnected(false),
|
||||
mRoaming(false) {}
|
||||
inline SystemStatusNetworkInfo(
|
||||
uint32_t type,
|
||||
std::string typeName,
|
||||
std::string subTypeName,
|
||||
bool available,
|
||||
bool connected,
|
||||
bool roaming) :
|
||||
mType(type),
|
||||
mTypeName(typeName),
|
||||
mSubTypeName(subTypeName),
|
||||
mAvailable(available),
|
||||
mConnected(connected),
|
||||
mRoaming(roaming) {}
|
||||
|
||||
uint32_t mType;
|
||||
std::string mTypeName;
|
||||
std::string mSubTypeName;
|
||||
bool mAvailable;
|
||||
bool mConnected;
|
||||
bool mRoaming;
|
||||
|
||||
inline bool equals(SystemStatusNetworkInfo& peer) {
|
||||
if ((mType != peer.mType) ||
|
||||
(mTypeName != peer.mTypeName) ||
|
||||
(mSubTypeName != peer.mSubTypeName) ||
|
||||
(mAvailable != peer.mAvailable) ||
|
||||
(mConnected != peer.mConnected) ||
|
||||
(mRoaming != peer.mRoaming)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
inline void dump(void) {
|
||||
LOC_LOGD("NetworkInfo: type=%u connected=%u", mType, mConnected);
|
||||
}
|
||||
inline DataItemId getId() {
|
||||
return NETWORKINFO_DATA_ITEM_ID;
|
||||
}
|
||||
inline void stringify(string& /*valueStr*/) { }
|
||||
inline int32_t copy(IDataItemCore* src, bool* dataItemCopied = nullptr) {
|
||||
SystemStatusNetworkInfo* networkinfo = static_cast<SystemStatusNetworkInfo*>(src);
|
||||
mType = networkinfo->mType;
|
||||
mTypeName = networkinfo->mTypeName;
|
||||
mSubTypeName = networkinfo->mSubTypeName;
|
||||
mAvailable = networkinfo->mAvailable;
|
||||
mConnected = networkinfo->mConnected;
|
||||
mRoaming = networkinfo->mRoaming;
|
||||
if (dataItemCopied) {
|
||||
*dataItemCopied = true;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
class SystemStatusTac : public SystemStatusItemBase, public IDataItemCore
|
||||
{
|
||||
public:
|
||||
inline SystemStatusTac() :
|
||||
mValue("") {}
|
||||
inline SystemStatusTac(std::string value) :
|
||||
mValue(value) {}
|
||||
|
||||
std::string mValue;
|
||||
|
||||
inline bool equals(SystemStatusTac& peer) {
|
||||
return (mValue == peer.mValue);
|
||||
}
|
||||
inline void dump(void) {
|
||||
LOC_LOGD("Tac: value=%s", mValue.c_str());
|
||||
}
|
||||
inline DataItemId getId() {
|
||||
return TAC_DATA_ITEM_ID;
|
||||
}
|
||||
inline void stringify(string& /*valueStr*/) { }
|
||||
inline int32_t copy(IDataItemCore* src, bool* dataItemCopied = nullptr) {
|
||||
SystemStatusTac* tac = static_cast<SystemStatusTac*>(src);
|
||||
mValue = tac->mValue;
|
||||
if (dataItemCopied) {
|
||||
*dataItemCopied = true;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
class SystemStatusMccMnc : public SystemStatusItemBase, public IDataItemCore
|
||||
{
|
||||
public:
|
||||
inline SystemStatusMccMnc() :
|
||||
mValue("") {}
|
||||
inline SystemStatusMccMnc(std::string value) :
|
||||
mValue(value) {}
|
||||
|
||||
std::string mValue;
|
||||
|
||||
inline bool equals(SystemStatusMccMnc& peer) {
|
||||
return (mValue == peer.mValue);
|
||||
}
|
||||
inline void dump(void) {
|
||||
LOC_LOGD("TacMccMnc value=%s", mValue.c_str());
|
||||
}
|
||||
inline DataItemId getId() {
|
||||
return MCCMNC_DATA_ITEM_ID;
|
||||
}
|
||||
inline void stringify(string& /*valueStr*/) { }
|
||||
inline int32_t copy(IDataItemCore* src, bool* dataItemCopied = nullptr) {
|
||||
SystemStatusMccMnc* mccmnc = static_cast<SystemStatusMccMnc*>(src);
|
||||
mValue = mccmnc->mValue;
|
||||
if (dataItemCopied) {
|
||||
*dataItemCopied = true;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
SystemStatusReports
|
||||
******************************************************************************/
|
||||
class SystemStatusReports
|
||||
{
|
||||
public:
|
||||
// from QMI_LOC indication
|
||||
std::vector<SystemStatusLocation> mLocation;
|
||||
|
||||
// from ME debug NMEA
|
||||
std::vector<SystemStatusTimeAndClock> mTimeAndClock;
|
||||
std::vector<SystemStatusXoState> mXoState;
|
||||
std::vector<SystemStatusRfAndParams> mRfAndParams;
|
||||
std::vector<SystemStatusErrRecovery> mErrRecovery;
|
||||
|
||||
// from PE debug NMEA
|
||||
std::vector<SystemStatusInjectedPosition> mInjectedPosition;
|
||||
std::vector<SystemStatusBestPosition> mBestPosition;
|
||||
std::vector<SystemStatusXtra> mXtra;
|
||||
|
@ -388,7 +553,14 @@ public:
|
|||
std::vector<SystemStatusPdr> mPdr;
|
||||
std::vector<SystemStatusNavData> mNavData;
|
||||
|
||||
// from SM debug NMEA
|
||||
std::vector<SystemStatusPositionFailure> mPositionFailure;
|
||||
|
||||
// from dataitems observer
|
||||
std::vector<SystemStatusGpsState> mGpsState;
|
||||
std::vector<SystemStatusNetworkInfo> mNetworkInfo;
|
||||
std::vector<SystemStatusTac> mTac;
|
||||
std::vector<SystemStatusMccMnc> mMccMnc;
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
|
@ -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
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -29,36 +29,34 @@
|
|||
#ifndef __SYSTEM_STATUS_OSOBSERVER__
|
||||
#define __SYSTEM_STATUS_OSOBSERVER__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cinttypes>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <new>
|
||||
#include <vector>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <DataItemId.h>
|
||||
|
||||
#include <MsgTask.h>
|
||||
#include <DataItemId.h>
|
||||
#include <IOsObserver.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
|
||||
namespace loc_core
|
||||
{
|
||||
|
||||
/******************************************************************************
|
||||
SystemStatusOsObserver
|
||||
******************************************************************************/
|
||||
using namespace std;
|
||||
|
||||
// Forward Declarations
|
||||
class IDataItemCore;
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
class IClientIndex;
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
class IDataItemIndex;
|
||||
template<typename CT, typename DIT> class IClientIndex;
|
||||
template<typename CT, typename DIT> class IDataItemIndex;
|
||||
|
||||
struct SystemContext {
|
||||
IDataItemSubscription *mSubscriptionObj;
|
||||
IFrameworkActionReq *mFrameworkActionReqObj;
|
||||
const MsgTask *mMsgTask;
|
||||
IDataItemSubscription* mSubscriptionObj;
|
||||
IFrameworkActionReq* mFrameworkActionReqObj;
|
||||
const MsgTask* mMsgTask;
|
||||
|
||||
inline SystemContext() :
|
||||
mSubscriptionObj(NULL),
|
||||
|
@ -66,6 +64,8 @@ struct SystemContext {
|
|||
mMsgTask(NULL) {}
|
||||
};
|
||||
|
||||
typedef map<IDataItemObserver*, list<DataItemId>> ObserverReqCache;
|
||||
|
||||
// Clients wanting to get data from OS/Framework would need to
|
||||
// subscribe with OSObserver using IDataItemSubscription interface.
|
||||
// Such clients would need to implement IDataItemObserver interface
|
||||
|
@ -80,252 +80,68 @@ public:
|
|||
~SystemStatusOsObserver();
|
||||
|
||||
// To set the subscription object
|
||||
inline void setSubscriptionObj(IDataItemSubscription *subscriptionObj) {
|
||||
mContext.mSubscriptionObj = subscriptionObj;
|
||||
};
|
||||
virtual void setSubscriptionObj(IDataItemSubscription* subscriptionObj);
|
||||
|
||||
// To set the framework action request object
|
||||
inline void setFrameworkActionReqObj(IFrameworkActionReq *frameworkActionReqObj) {
|
||||
inline void setFrameworkActionReqObj(IFrameworkActionReq* frameworkActionReqObj) {
|
||||
mContext.mFrameworkActionReqObj = frameworkActionReqObj;
|
||||
#ifdef USE_GLIB
|
||||
if (mBackHaulConnectReqCount > 0) {
|
||||
connectBackhaul();
|
||||
mBackHaulConnectReqCount = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// IDataItemObserver Overrides
|
||||
virtual void getName (string & name);
|
||||
virtual void notify (const std::list <IDataItemCore *> & dlist);
|
||||
|
||||
// IDataItemSubscription Overrides
|
||||
virtual void subscribe (const std :: list <DataItemId> & l, IDataItemObserver * client);
|
||||
virtual void updateSubscription
|
||||
(
|
||||
const std :: list <DataItemId> & l,
|
||||
IDataItemObserver * client
|
||||
);
|
||||
virtual void requestData
|
||||
(
|
||||
const std :: list <DataItemId> & l,
|
||||
IDataItemObserver * client
|
||||
);
|
||||
virtual void unsubscribe (const std :: list <DataItemId> & l, IDataItemObserver * client);
|
||||
virtual void unsubscribeAll (IDataItemObserver * client);
|
||||
virtual void subscribe(const list<DataItemId>& l, IDataItemObserver* client);
|
||||
virtual void updateSubscription(const list<DataItemId>& l, IDataItemObserver* client);
|
||||
virtual void requestData(const list<DataItemId>& l, IDataItemObserver* client);
|
||||
virtual void unsubscribe(const list<DataItemId>& l, IDataItemObserver* client);
|
||||
virtual void unsubscribeAll(IDataItemObserver* client);
|
||||
|
||||
// IDataItemObserver Overrides
|
||||
virtual void notify(const list<IDataItemCore*>& dlist);
|
||||
inline virtual void getName(string& name) {
|
||||
name = mAddress;
|
||||
}
|
||||
|
||||
// IFrameworkActionReq Overrides
|
||||
virtual void turnOn (DataItemId dit, int timeOut = 0);
|
||||
virtual void turnOff (DataItemId dit);
|
||||
virtual void turnOn(DataItemId dit, int timeOut = 0);
|
||||
virtual void turnOff(DataItemId dit);
|
||||
#ifdef USE_GLIB
|
||||
virtual bool connectBackhaul();
|
||||
virtual bool disconnectBackhaul();
|
||||
#endif
|
||||
|
||||
private:
|
||||
SystemContext mContext;
|
||||
const string mAddress;
|
||||
IClientIndex<IDataItemObserver*, DataItemId>* mClientIndex;
|
||||
IDataItemIndex<IDataItemObserver*, DataItemId>* mDataItemIndex;
|
||||
map<DataItemId, IDataItemCore*> mDataItemCache;
|
||||
map<DataItemId, int> mActiveRequestCount;
|
||||
|
||||
SystemContext mContext;
|
||||
const string mAddress;
|
||||
IClientIndex <IDataItemObserver *, DataItemId> *mClientIndex;
|
||||
IDataItemIndex <IDataItemObserver *, DataItemId> *mDataItemIndex;
|
||||
map < DataItemId, IDataItemCore * > mDataItemCache;
|
||||
map < DataItemId, int > mActiveRequestCount;
|
||||
|
||||
// Nested types
|
||||
// Messages
|
||||
struct HandleMsgBase : public LocMsg {
|
||||
HandleMsgBase (SystemStatusOsObserver * parent);
|
||||
virtual ~HandleMsgBase ();
|
||||
// Data members
|
||||
SystemStatusOsObserver * mParent;
|
||||
};
|
||||
// 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
|
||||
|
||||
// Helpers
|
||||
int sendFirstResponse
|
||||
(
|
||||
const list <DataItemId> & l,
|
||||
IDataItemObserver * to
|
||||
);
|
||||
|
||||
int sendCachedDataItems
|
||||
(
|
||||
const list <DataItemId> & l,
|
||||
IDataItemObserver * to
|
||||
);
|
||||
|
||||
int updateCache (IDataItemCore * d, bool &dataItemUpdated);
|
||||
void logMe (const list <DataItemId> & l);
|
||||
|
||||
// Messages
|
||||
struct HandleClientMsg : public LocMsg {
|
||||
HandleClientMsg (SystemStatusOsObserver * parent, IDataItemObserver * client);
|
||||
virtual ~HandleClientMsg ();
|
||||
// Data Members
|
||||
SystemStatusOsObserver * mParent;
|
||||
IDataItemObserver * mClient;
|
||||
};
|
||||
|
||||
struct HandleSubscribeReq : public HandleClientMsg {
|
||||
HandleSubscribeReq (SystemStatusOsObserver * parent,
|
||||
const list <DataItemId> & l,
|
||||
IDataItemObserver * client);
|
||||
virtual ~HandleSubscribeReq ();
|
||||
void proc () const;
|
||||
// Data members
|
||||
const list <DataItemId> mDataItemList;
|
||||
};
|
||||
|
||||
struct HandleUpdateSubscriptionReq : public HandleClientMsg {
|
||||
HandleUpdateSubscriptionReq (SystemStatusOsObserver * parent,
|
||||
const list <DataItemId> & l,
|
||||
IDataItemObserver * client);
|
||||
virtual ~HandleUpdateSubscriptionReq ();
|
||||
void proc () const;
|
||||
// Data members
|
||||
const list <DataItemId> mDataItemList;
|
||||
};
|
||||
|
||||
struct HandleRequestData : public HandleClientMsg {
|
||||
HandleRequestData (SystemStatusOsObserver * parent,
|
||||
const list <DataItemId> & l,
|
||||
IDataItemObserver * client);
|
||||
virtual ~HandleRequestData ();
|
||||
void proc () const;
|
||||
const list <DataItemId> mDataItemList;
|
||||
};
|
||||
|
||||
struct HandleUnsubscribeReq : public HandleClientMsg {
|
||||
HandleUnsubscribeReq (SystemStatusOsObserver * parent,
|
||||
const list <DataItemId> & l,
|
||||
IDataItemObserver * client);
|
||||
virtual ~HandleUnsubscribeReq ();
|
||||
void proc () const;
|
||||
// Data members
|
||||
const list <DataItemId> mDataItemList;
|
||||
};
|
||||
|
||||
struct HandleUnsubscribeAllReq : public HandleClientMsg {
|
||||
HandleUnsubscribeAllReq
|
||||
(
|
||||
SystemStatusOsObserver * parent,
|
||||
IDataItemObserver * client
|
||||
);
|
||||
virtual ~HandleUnsubscribeAllReq ();
|
||||
void proc () const;
|
||||
};
|
||||
|
||||
struct HandleNotify : public HandleMsgBase {
|
||||
HandleNotify (SystemStatusOsObserver * parent, list <IDataItemCore *> dlist);
|
||||
virtual ~HandleNotify ();
|
||||
void getListOfClients
|
||||
(
|
||||
const list <DataItemId> & dlist,
|
||||
list <IDataItemObserver *> & clients
|
||||
) const;
|
||||
void proc () const;
|
||||
// Data members
|
||||
list <IDataItemCore *> mDList;
|
||||
};
|
||||
|
||||
struct HandleTurnOn : public HandleMsgBase {
|
||||
HandleTurnOn (SystemStatusOsObserver * parent,
|
||||
const DataItemId dit,
|
||||
const int timeOut);
|
||||
virtual ~HandleTurnOn ();
|
||||
void proc () const;
|
||||
// Data members
|
||||
DataItemId mDataItemId;
|
||||
int mTimeOut;
|
||||
};
|
||||
|
||||
struct HandleTurnOff : public HandleMsgBase {
|
||||
HandleTurnOff (SystemStatusOsObserver * parent,const DataItemId dit);
|
||||
virtual ~HandleTurnOff ();
|
||||
void proc () const;
|
||||
// Data members
|
||||
DataItemId mDataItemId;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
Messages
|
||||
******************************************************************************/
|
||||
// Ctors
|
||||
inline SystemStatusOsObserver :: HandleMsgBase :: HandleMsgBase (SystemStatusOsObserver * parent)
|
||||
:
|
||||
mParent (parent)
|
||||
{}
|
||||
|
||||
inline SystemStatusOsObserver :: HandleClientMsg :: HandleClientMsg
|
||||
(
|
||||
SystemStatusOsObserver * parent,
|
||||
IDataItemObserver * client
|
||||
)
|
||||
:
|
||||
mParent (parent),
|
||||
mClient (client)
|
||||
{}
|
||||
|
||||
inline SystemStatusOsObserver :: HandleSubscribeReq :: HandleSubscribeReq
|
||||
(SystemStatusOsObserver * parent, const list <DataItemId> & l, IDataItemObserver * client)
|
||||
:
|
||||
HandleClientMsg (parent, client), mDataItemList (l)
|
||||
{}
|
||||
|
||||
inline SystemStatusOsObserver :: HandleUpdateSubscriptionReq :: HandleUpdateSubscriptionReq
|
||||
(SystemStatusOsObserver * parent, const list <DataItemId> & l, IDataItemObserver * client)
|
||||
:
|
||||
HandleClientMsg (parent, client), mDataItemList (l)
|
||||
{}
|
||||
|
||||
inline SystemStatusOsObserver :: HandleRequestData :: HandleRequestData
|
||||
(SystemStatusOsObserver * parent, const list <DataItemId> & l, IDataItemObserver * client)
|
||||
:
|
||||
HandleClientMsg (parent, client), mDataItemList (l)
|
||||
{}
|
||||
|
||||
inline SystemStatusOsObserver :: HandleUnsubscribeReq :: HandleUnsubscribeReq
|
||||
(SystemStatusOsObserver * parent, const list <DataItemId> & l, IDataItemObserver * client)
|
||||
:
|
||||
HandleClientMsg (parent, client), mDataItemList (l)
|
||||
{}
|
||||
|
||||
inline SystemStatusOsObserver :: HandleUnsubscribeAllReq :: HandleUnsubscribeAllReq
|
||||
(SystemStatusOsObserver * parent, IDataItemObserver * client)
|
||||
:
|
||||
HandleClientMsg (parent, client)
|
||||
{}
|
||||
|
||||
inline SystemStatusOsObserver :: HandleNotify :: HandleNotify
|
||||
(SystemStatusOsObserver * parent, list <IDataItemCore *> dlist)
|
||||
:
|
||||
HandleMsgBase (parent), mDList (dlist)
|
||||
{}
|
||||
|
||||
inline SystemStatusOsObserver :: HandleTurnOn :: HandleTurnOn
|
||||
(SystemStatusOsObserver * parent, const DataItemId dit,const int timeOut)
|
||||
:
|
||||
HandleMsgBase (parent), mDataItemId (dit), mTimeOut (timeOut)
|
||||
{}
|
||||
|
||||
inline SystemStatusOsObserver :: HandleTurnOff :: HandleTurnOff
|
||||
(SystemStatusOsObserver * parent, const DataItemId dit)
|
||||
:
|
||||
HandleMsgBase (parent), mDataItemId (dit)
|
||||
{}
|
||||
|
||||
// Dtors
|
||||
inline SystemStatusOsObserver :: HandleMsgBase :: ~HandleMsgBase () {}
|
||||
inline SystemStatusOsObserver :: HandleClientMsg :: ~HandleClientMsg () {}
|
||||
inline SystemStatusOsObserver :: HandleSubscribeReq :: ~HandleSubscribeReq () {}
|
||||
inline SystemStatusOsObserver :: HandleUpdateSubscriptionReq :: ~HandleUpdateSubscriptionReq() {}
|
||||
inline SystemStatusOsObserver :: HandleRequestData :: ~HandleRequestData() {}
|
||||
inline SystemStatusOsObserver :: HandleUnsubscribeReq :: ~HandleUnsubscribeReq () {}
|
||||
inline SystemStatusOsObserver :: HandleUnsubscribeAllReq :: ~HandleUnsubscribeAllReq () {}
|
||||
|
||||
inline SystemStatusOsObserver :: HandleNotify :: ~HandleNotify () {
|
||||
list <IDataItemCore *> :: iterator it = mDList.begin ();
|
||||
for (; it != mDList.end (); ++it) {
|
||||
delete *it;
|
||||
*it = NULL;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline SystemStatusOsObserver :: HandleTurnOn :: ~HandleTurnOn () {}
|
||||
inline SystemStatusOsObserver :: HandleTurnOff :: ~HandleTurnOff () {}
|
||||
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
|
|
446
core/data-items/DataItemConcreteTypesBase.h
Normal file
446
core/data-items/DataItemConcreteTypesBase.h
Normal file
|
@ -0,0 +1,446 @@
|
|||
/* 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:
|
||||
NetworkInfoDataItemBase(
|
||||
int32_t type, string typeName, string subTypeName,
|
||||
bool available, bool connected, bool roaming ):
|
||||
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;}
|
||||
// Data members
|
||||
int32_t mType;
|
||||
string mTypeName;
|
||||
string mSubTypeName;
|
||||
bool mAvailable;
|
||||
bool mConnected;
|
||||
bool mRoaming;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
|
||||
};
|
||||
|
||||
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:
|
||||
RilServiceInfoDataItemBase() :
|
||||
mId(RILSERVICEINFO_DATA_ITEM_ID) {}
|
||||
virtual ~RilServiceInfoDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class RilCellInfoDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
RilCellInfoDataItemBase() :
|
||||
mId(RILCELLINFO_DATA_ITEM_ID) {}
|
||||
virtual ~RilCellInfoDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
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;}
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
#endif //__DATAITEMCONCRETEBASETYPES__
|
|
@ -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
|
||||
|
|
14
etc/gps.conf
14
etc/gps.conf
|
@ -205,3 +205,17 @@ MISSING_PULSE_TIME_DELTA = 900
|
|||
# This settings enables time uncertainty propagation
|
||||
# logic incase of missing PPS pulse
|
||||
PROPAGATION_TIME_UNCERTAINTY = 1
|
||||
|
||||
#######################################
|
||||
# APN / IP Type Configuration
|
||||
# APN and IP Type to use for setting
|
||||
# up WWAN call.
|
||||
# Use below values for IP Type:
|
||||
# v4 = 4
|
||||
# v6 = 6
|
||||
# v4v6 = 10
|
||||
#######################################
|
||||
# INTERNET_APN = abc.xyz
|
||||
# INTERNET_IP_TYPE = 4
|
||||
# SUPL_APN = abc.xyz
|
||||
# SUPL_IP_TYPE = 4
|
||||
|
|
|
@ -462,9 +462,11 @@ void AgpsStateMachine::setAPN(char* apn, unsigned int len){
|
|||
|
||||
if (NULL != apn) {
|
||||
mAPN = new char[len+1];
|
||||
memcpy(mAPN, apn, len);
|
||||
mAPN[len] = '\0';
|
||||
mAPNLen = len;
|
||||
if (NULL != mAPN) {
|
||||
memcpy(mAPN, apn, len);
|
||||
mAPN[len] = '\0';
|
||||
mAPNLen = len;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,9 +44,7 @@
|
|||
#include <Agps.h>
|
||||
#include <SystemStatus.h>
|
||||
|
||||
#include <loc_nmea.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#define RAD2DEG (180.0 / M_PI)
|
||||
|
||||
|
@ -68,7 +66,9 @@ GnssAdapter::GnssAdapter() :
|
|||
mNiData(),
|
||||
mAgpsManager(),
|
||||
mAgpsCbInfo(),
|
||||
mSystemStatus(SystemStatus::getInstance(mMsgTask))
|
||||
mSystemStatus(SystemStatus::getInstance(mMsgTask)),
|
||||
mServerUrl(""),
|
||||
mXtraObserver(mSystemStatus->getOsObserver(), mMsgTask)
|
||||
{
|
||||
LOC_LOGD("%s]: Constructor %p", __func__, this);
|
||||
mUlpPositionMode.mode = LOC_POSITION_MODE_INVALID;
|
||||
|
@ -636,8 +636,6 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config)
|
|||
delete[] mIds;
|
||||
}
|
||||
inline virtual void proc() const {
|
||||
//const size_t MAX_BITS_COUNT = 10;
|
||||
//LocationError errs[MAX_BITS_COUNT] = {};
|
||||
LocationError* errs = new LocationError[mCount];
|
||||
LocationError err = LOCATION_ERROR_SUCCESS;
|
||||
uint32_t index = 0;
|
||||
|
@ -669,30 +667,33 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config)
|
|||
if (GNSS_ASSISTANCE_TYPE_SUPL == mConfig.assistanceServer.type) {
|
||||
if (ContextBase::mGps_conf.AGPS_CONFIG_INJECT) {
|
||||
char serverUrl[MAX_URL_LEN] = {};
|
||||
uint32_t length = 0;
|
||||
int32_t length = 0;
|
||||
const char noHost[] = "NONE";
|
||||
if (NULL == mConfig.assistanceServer.hostName ||
|
||||
strncasecmp(noHost,
|
||||
mConfig.assistanceServer.hostName,
|
||||
sizeof(noHost)) == 0) {
|
||||
err = LOCATION_ERROR_INVALID_PARAMETER;
|
||||
} else {
|
||||
length = snprintf(serverUrl, sizeof(serverUrl), "%s:%u",
|
||||
mConfig.assistanceServer.hostName,
|
||||
mConfig.assistanceServer.port);
|
||||
}
|
||||
|
||||
if (sizeof(serverUrl) > length) {
|
||||
if (length > 0 && strncasecmp(mAdapter.getServerUrl().c_str(),
|
||||
serverUrl, sizeof(serverUrl)) != 0) {
|
||||
mAdapter.setServerUrl(serverUrl);
|
||||
err = mApi.setServer(serverUrl, length);
|
||||
} else {
|
||||
err = LOCATION_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
} else {
|
||||
err = LOCATION_ERROR_SUCCESS;
|
||||
}
|
||||
} else if (GNSS_ASSISTANCE_TYPE_C2K == mConfig.assistanceServer.type) {
|
||||
if (ContextBase::mGps_conf.AGPS_CONFIG_INJECT) {
|
||||
struct in_addr addr;
|
||||
if (!mAdapter.resolveInAddress(mConfig.assistanceServer.hostName, &addr)) {
|
||||
if (!mAdapter.resolveInAddress(mConfig.assistanceServer.hostName,
|
||||
&addr)) {
|
||||
LOC_LOGE("%s]: hostName %s cannot be resolved",
|
||||
__func__, mConfig.assistanceServer.hostName);
|
||||
err = LOCATION_ERROR_INVALID_PARAMETER;
|
||||
|
@ -1246,6 +1247,15 @@ GnssAdapter::eraseTrackingSession(LocationAPI* client, uint32_t sessionId)
|
|||
|
||||
}
|
||||
|
||||
bool GnssAdapter::setUlpPositionMode(const LocPosMode& mode) {
|
||||
if (!mUlpPositionMode.equals(mode)) {
|
||||
mUlpPositionMode = mode;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GnssAdapter::reportResponse(LocationAPI* client, LocationError err, uint32_t sessionId)
|
||||
{
|
||||
|
@ -1411,8 +1421,9 @@ GnssAdapter::setPositionModeCommand(LocPosMode& locPosMode)
|
|||
mLocPosMode(locPosMode) {}
|
||||
inline virtual void proc() const {
|
||||
// saves the mode in adapter to be used when startTrackingCommand is called from ULP
|
||||
mAdapter.setUlpPositionMode(mLocPosMode);
|
||||
mApi.setPositionMode(mLocPosMode);
|
||||
if (mAdapter.setUlpPositionMode(mLocPosMode)) {
|
||||
mApi.setPositionMode(mLocPosMode);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1435,8 +1446,10 @@ GnssAdapter::startTrackingCommand()
|
|||
inline virtual void proc() const {
|
||||
// we get this call from ULP, so just call LocApi without multiplexing because
|
||||
// ulp would be doing the multiplexing for us if it is present
|
||||
LocPosMode& ulpPositionMode = mAdapter.getUlpPositionMode();
|
||||
mApi.startFix(ulpPositionMode);
|
||||
if (!mAdapter.isInSession()) {
|
||||
LocPosMode& ulpPositionMode = mAdapter.getUlpPositionMode();
|
||||
mApi.startFix(ulpPositionMode);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1922,34 +1935,41 @@ GnssAdapter::reportPositionEvent(const UlpLocation& ulpLocation,
|
|||
sendMsg(new MsgReportPosition(*this, ulpLocation, locationExtended, status, techMask));
|
||||
}
|
||||
|
||||
bool
|
||||
GnssAdapter::needReport(const UlpLocation& ulpLocation,
|
||||
enum loc_sess_status status,
|
||||
LocPosTechMask techMask) {
|
||||
bool reported = false;
|
||||
if (LOC_SESS_SUCCESS == status) {
|
||||
// this is a final fix
|
||||
LocPosTechMask mask =
|
||||
LOC_POS_TECH_MASK_SATELLITE | LOC_POS_TECH_MASK_SENSORS | LOC_POS_TECH_MASK_HYBRID;
|
||||
// it is a Satellite fix or a sensor fix
|
||||
reported = (mask & techMask);
|
||||
} else if (LOC_SESS_INTERMEDIATE == status &&
|
||||
LOC_SESS_INTERMEDIATE == ContextBase::mGps_conf.INTERMEDIATE_POS) {
|
||||
// this is a intermediate fix and we accepte intermediate
|
||||
|
||||
// it is NOT the case that
|
||||
// there is inaccuracy; and
|
||||
// we care about inaccuracy; and
|
||||
// the inaccuracy exceeds our tolerance
|
||||
reported = !((ulpLocation.gpsLocation.flags & LOC_GPS_LOCATION_HAS_ACCURACY) &&
|
||||
(ContextBase::mGps_conf.ACCURACY_THRES != 0) &&
|
||||
(ulpLocation.gpsLocation.accuracy > ContextBase::mGps_conf.ACCURACY_THRES));
|
||||
}
|
||||
|
||||
return reported;
|
||||
}
|
||||
|
||||
void
|
||||
GnssAdapter::reportPosition(const UlpLocation& ulpLocation,
|
||||
const GpsLocationExtended& locationExtended,
|
||||
enum loc_sess_status status,
|
||||
LocPosTechMask techMask)
|
||||
{
|
||||
bool reported = false;
|
||||
// what's in the if is... (line by line)
|
||||
// 1. this is a final fix; and
|
||||
// 1.1 it is a Satellite fix; or
|
||||
// 1.2 it is a sensor fix
|
||||
// 2. (must be intermediate fix... implicit)
|
||||
// 2.1 we accepte intermediate; and
|
||||
// 2.2 it is NOT the case that
|
||||
// 2.2.1 there is inaccuracy; and
|
||||
// 2.2.2 we care about inaccuracy; and
|
||||
// 2.2.3 the inaccuracy exceeds our tolerance
|
||||
if ((LOC_SESS_SUCCESS == status &&
|
||||
((LOC_POS_TECH_MASK_SATELLITE |
|
||||
LOC_POS_TECH_MASK_SENSORS |
|
||||
LOC_POS_TECH_MASK_HYBRID) &
|
||||
techMask)) ||
|
||||
(LOC_SESS_INTERMEDIATE == ContextBase::mGps_conf.INTERMEDIATE_POS &&
|
||||
!((ulpLocation.gpsLocation.flags &
|
||||
LOC_GPS_LOCATION_HAS_ACCURACY) &&
|
||||
(ContextBase::mGps_conf.ACCURACY_THRES != 0) &&
|
||||
(ulpLocation.gpsLocation.accuracy >
|
||||
ContextBase::mGps_conf.ACCURACY_THRES)))) {
|
||||
bool reported = needReport(ulpLocation, status, techMask);
|
||||
if (reported) {
|
||||
if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_GNSS_SV_USED_DATA) {
|
||||
mGnssSvIdUsedInPosAvail = true;
|
||||
mGnssSvIdUsedInPosition = locationExtended.gnss_sv_used_ids;
|
||||
|
@ -1966,7 +1986,6 @@ GnssAdapter::reportPosition(const UlpLocation& ulpLocation,
|
|||
it->second.gnssLocationInfoCb(locationInfo);
|
||||
}
|
||||
}
|
||||
reported = true;
|
||||
}
|
||||
|
||||
if (NMEA_PROVIDER_AP == ContextBase::mGps_conf.NMEA_PROVIDER && !mTrackingSessions.empty()) {
|
||||
|
|
|
@ -106,10 +106,11 @@ class GnssAdapter : public LocAdapterBase {
|
|||
// This must be initialized via initAgps()
|
||||
AgpsManager mAgpsManager;
|
||||
AgpsCbInfo mAgpsCbInfo;
|
||||
XtraSystemStatusObserver mXtraObserver;
|
||||
|
||||
/* === SystemStatus ===================================================================== */
|
||||
SystemStatus* mSystemStatus;
|
||||
std::string mServerUrl;
|
||||
XtraSystemStatusObserver mXtraObserver;
|
||||
|
||||
/*==== CONVERSION ===================================================================*/
|
||||
static void convertOptions(LocPosMode& out, const LocationOptions& options);
|
||||
|
@ -170,7 +171,7 @@ public:
|
|||
void saveTrackingSession(LocationAPI* client, uint32_t sessionId,
|
||||
const LocationOptions& options);
|
||||
void eraseTrackingSession(LocationAPI* client, uint32_t sessionId);
|
||||
void setUlpPositionMode(const LocPosMode& mode) { mUlpPositionMode = mode; }
|
||||
bool setUlpPositionMode(const LocPosMode& mode);
|
||||
LocPosMode& getUlpPositionMode() { return mUlpPositionMode; }
|
||||
LocationError startTrackingMultiplex(const LocationOptions& options);
|
||||
LocationError startTracking(const LocationOptions& options);
|
||||
|
@ -215,7 +216,7 @@ public:
|
|||
void setPowerVoteId(uint32_t id) { mPowerVoteId = id; }
|
||||
uint32_t getPowerVoteId() { return mPowerVoteId; }
|
||||
bool resolveInAddress(const char* hostAddress, struct in_addr* inAddress);
|
||||
|
||||
virtual bool isInSession() { return !mTrackingSessions.empty(); }
|
||||
/* ==== REPORTS ======================================================================== */
|
||||
/* ======== EVENTS ====(Called from QMI/ULP Thread)===================================== */
|
||||
virtual void reportPositionEvent(const UlpLocation& ulpLocation,
|
||||
|
@ -238,6 +239,8 @@ public:
|
|||
virtual bool reportDataCallClosed();
|
||||
|
||||
/* ======== UTILITIES ================================================================= */
|
||||
bool needReport(const UlpLocation& ulpLocation,
|
||||
enum loc_sess_status status, LocPosTechMask techMask);
|
||||
void reportPosition(const UlpLocation &ulpLocation,
|
||||
const GpsLocationExtended &locationExtended,
|
||||
enum loc_sess_status status,
|
||||
|
@ -254,6 +257,8 @@ public:
|
|||
|
||||
/*==== SYSTEM STATUS ================================================================*/
|
||||
inline SystemStatus* getSystemStatus(void) { return mSystemStatus; }
|
||||
std::string& getServerUrl(void) { return mServerUrl; }
|
||||
void setServerUrl(const char* server) { mServerUrl.assign(server); }
|
||||
|
||||
/*==== CONVERSION ===================================================================*/
|
||||
static uint32_t convertGpsLock(const GnssConfigGpsLock gpsLock);
|
||||
|
@ -277,10 +282,6 @@ public:
|
|||
void injectLocationCommand(double latitude, double longitude, float accuracy);
|
||||
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
|
||||
|
|
|
@ -45,40 +45,56 @@
|
|||
#include <sstream>
|
||||
#include <XtraSystemStatusObserver.h>
|
||||
#include <LocAdapterBase.h>
|
||||
#include <DataItemId.h>
|
||||
#include <DataItemsFactoryProxy.h>
|
||||
#include <DataItemConcreteTypesBase.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace loc_core;
|
||||
|
||||
#define XTRA_HAL_SOCKET_NAME "/data/vendor/location/xtra/socket_hal_xtra"
|
||||
|
||||
bool XtraSystemStatusObserver::updateLockStatus(uint32_t lock) {
|
||||
std::stringstream ss;
|
||||
stringstream ss;
|
||||
ss << "gpslock";
|
||||
ss << " " << lock;
|
||||
ss << "\n"; // append seperator
|
||||
return ( sendEvent(ss) );
|
||||
}
|
||||
|
||||
bool XtraSystemStatusObserver::updateConnectionStatus(bool connected, uint8_t type) {
|
||||
std::stringstream ss;
|
||||
bool XtraSystemStatusObserver::updateConnectionStatus(bool connected, uint32_t type) {
|
||||
stringstream ss;
|
||||
ss << "connection";
|
||||
ss << " " << (connected ? "1" : "0");
|
||||
ss << " " << (int)type;
|
||||
ss << "\n"; // append seperator
|
||||
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();
|
||||
if (socketFd < 0) {
|
||||
LOC_LOGe("XTRA unreachable. sending failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::string& data = event.str();
|
||||
const string& data = event.str();
|
||||
int remain = data.length();
|
||||
ssize_t sent = 0;
|
||||
|
||||
while (remain > 0 &&
|
||||
(sent = ::send(socketFd, data.c_str() + (data.length() - remain),
|
||||
remain, MSG_NOSIGNAL)) > 0) {
|
||||
|
@ -125,3 +141,221 @@ 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:
|
||||
{
|
||||
NetworkInfoDataItemBase* networkInfo =
|
||||
static_cast<NetworkInfoDataItemBase*>(each);
|
||||
mXtraSysStatObj->updateConnectionStatus(networkInfo->mConnected,
|
||||
networkInfo->mType);
|
||||
}
|
||||
break;
|
||||
|
||||
case TAC_DATA_ITEM_ID:
|
||||
{
|
||||
TacDataItemBase* tac =
|
||||
static_cast<TacDataItemBase*>(each);
|
||||
mXtraSysStatObj->updateTac(tac->mValue);
|
||||
}
|
||||
break;
|
||||
|
||||
case MCCMNC_DATA_ITEM_ID:
|
||||
{
|
||||
MccmncDataItemBase* mccmnc =
|
||||
static_cast<MccmncDataItemBase*>(each);
|
||||
mXtraSysStatObj->updateMccMnc(mccmnc->mValue);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
mMsgTask->sendMsg(new (nothrow) handleOsObserverUpdateMsg(this, dlist));
|
||||
}
|
||||
|
||||
#ifdef USE_GLIB
|
||||
bool XtraSystemStatusObserver::connectBackhaul()
|
||||
{
|
||||
return mSystemStatusObsrvr->connectBackhaul();
|
||||
}
|
||||
|
||||
bool XtraSystemStatusObserver::disconnectBackhaul()
|
||||
{
|
||||
return mSystemStatusObsrvr->disconnectBackhaul();
|
||||
}
|
||||
|
||||
// XtraHalListenerSocket class
|
||||
// TBD - this will be removed once bidirectional socket changes in
|
||||
// xtra-daemon will be implemented
|
||||
void XtraHalListenerSocket::receiveData(const int socketFd) {
|
||||
string data;
|
||||
array<char, 128> buf;
|
||||
const char* bin_msg_conn_backhaul = "connectBackhaul";
|
||||
const char* bin_msg_disconn_backhaul = "disconnectBackhaul";
|
||||
|
||||
while (true) {
|
||||
ssize_t len = recv(socketFd, buf.data(), buf.size(), 0);
|
||||
if (len > 0) {
|
||||
LOC_LOGd("received %lu bytes", len);
|
||||
data.append(buf.data(), len);
|
||||
|
||||
size_t pos = data.find("\n");
|
||||
if (pos == string::npos) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strncmp(data.c_str(), bin_msg_conn_backhaul,
|
||||
sizeof(bin_msg_conn_backhaul) - 1)) {
|
||||
mSystemStatusObsrvr->connectBackhaul();
|
||||
} else if (!strncmp(data.c_str(), bin_msg_disconn_backhaul,
|
||||
sizeof(bin_msg_disconn_backhaul) - 1)) {
|
||||
mSystemStatusObsrvr->disconnectBackhaul();
|
||||
}
|
||||
else {
|
||||
LOC_LOGw("unknown event: %s", data.c_str());
|
||||
}
|
||||
break;
|
||||
|
||||
} else {
|
||||
LOC_LOGd("XtraHalListenerSocket connection broken.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void XtraHalListenerSocket::startListenerThread() {
|
||||
mThread = new (std::nothrow) LocThread();
|
||||
if (!mThread) {
|
||||
LOC_LOGe("create thread failed");
|
||||
}
|
||||
mRunning = true;
|
||||
if (!mThread->start("XtraHalListenerSocketThread", this, true)) {
|
||||
delete mThread;
|
||||
mThread = NULL;
|
||||
}
|
||||
|
||||
LOC_LOGd("Create listener socket in XtraHalListenerSocket");
|
||||
// create socket
|
||||
int socketFd;
|
||||
if ((socketFd = ::socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
|
||||
LOC_LOGe("create socket error. reason:%s", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
const char* socketPath = "/data/vendor/location/xtra/socket_xtra_locnetiface";
|
||||
unlink(socketPath);
|
||||
|
||||
struct sockaddr_un addr = { .sun_family = AF_UNIX };
|
||||
snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", socketPath);
|
||||
|
||||
umask(0157);
|
||||
|
||||
if (::bind(socketFd, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
|
||||
LOC_LOGe("bind socket error. reason:%s", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
// set up connection
|
||||
if (::listen(socketFd, 5/*backlog*/) < 0) {
|
||||
LOC_LOGe("cannot bind socket. reason:%s", strerror(errno));
|
||||
return;
|
||||
}
|
||||
mSocketFd = socketFd;
|
||||
|
||||
}
|
||||
|
||||
bool XtraHalListenerSocket::run() {
|
||||
// infinite while loop till mRunning is false when stopListenXtraDaemon
|
||||
// is called
|
||||
while (mRunning) {
|
||||
int clientFd = -1;
|
||||
LOC_LOGd("XtraHalListenerSocket - waiting for msg...");
|
||||
if ( (clientFd = ::accept(mSocketFd, NULL, NULL)) < 0) {
|
||||
LOC_LOGe("connection error. reason:%s", strerror(errno));
|
||||
} else {
|
||||
LOC_LOGd("XtraHalListenerSocket - receiving data ...");
|
||||
receiveData(clientFd);
|
||||
if (::close(clientFd)) {
|
||||
LOC_LOGe("close connection fail.");
|
||||
}
|
||||
clientFd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// return false once we reach there
|
||||
return false;
|
||||
}
|
||||
|
||||
void XtraHalListenerSocket::stopListenXtraDaemon() {
|
||||
if (mSocketFd >= 0) {
|
||||
if (::close(mSocketFd)) {
|
||||
LOC_LOGe("close hal connection fail.");
|
||||
}
|
||||
mSocketFd = -1;
|
||||
}
|
||||
mRunning = false;
|
||||
mThread->stop();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -29,25 +29,109 @@
|
|||
#ifndef XTRA_SYSTEM_STATUS_OBS_H
|
||||
#define XTRA_SYSTEM_STATUS_OBS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cinttypes>
|
||||
#include <MsgTask.h>
|
||||
#ifdef USE_GLIB
|
||||
#include <LocThread.h>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
using loc_core::IOsObserver;
|
||||
using loc_core::IDataItemObserver;
|
||||
using loc_core::IDataItemCore;
|
||||
|
||||
class XtraSystemStatusObserver {
|
||||
#ifdef USE_GLIB
|
||||
// XtraHalListenerSocket class
|
||||
// listener socket for getting msgs from xtra-daemon in LE for invoking
|
||||
// LocNetIface functions
|
||||
// TBD - this will be removed once bidirectional socket changes in
|
||||
// xtra-daemon will be implemented
|
||||
class XtraHalListenerSocket: public LocRunnable {
|
||||
public :
|
||||
// constructor & destructor
|
||||
XtraSystemStatusObserver() {
|
||||
XtraHalListenerSocket(IOsObserver* sysStatObs) :
|
||||
mThread(NULL),
|
||||
mRunning(false) {
|
||||
mSystemStatusObsrvr = sysStatObs;
|
||||
mRunning = true;
|
||||
// create listener socket in a thread
|
||||
startListenerThread();
|
||||
}
|
||||
XtraHalListenerSocket() {}
|
||||
inline virtual ~XtraHalListenerSocket() {
|
||||
if (mThread) {
|
||||
stopListenXtraDaemon();
|
||||
delete mThread;
|
||||
mThread = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~XtraSystemStatusObserver() {
|
||||
// Overrides of LocRunnable methods
|
||||
// This method will be repeated called until it returns false; or
|
||||
// until thread is stopped.
|
||||
virtual bool run();
|
||||
|
||||
// The method to be run before thread loop (conditionally repeatedly)
|
||||
// calls run()
|
||||
inline virtual void prerun() {}
|
||||
|
||||
// The method to be run after thread loop (conditionally repeatedly)
|
||||
// calls run()
|
||||
inline virtual void postrun() {}
|
||||
|
||||
private:
|
||||
IOsObserver* mSystemStatusObsrvr;
|
||||
int mSocketFd;
|
||||
LocThread* mThread;
|
||||
bool mRunning;
|
||||
void startListenerThread();
|
||||
void stopListenXtraDaemon();
|
||||
void receiveData(const int socketFd);
|
||||
};
|
||||
#endif
|
||||
|
||||
class XtraSystemStatusObserver : public IDataItemObserver {
|
||||
public :
|
||||
// constructor & destructor
|
||||
inline XtraSystemStatusObserver(IOsObserver* sysStatObs, const MsgTask* msgTask):
|
||||
#ifdef USE_GLIB
|
||||
mHalListenerSocket(sysStatObs),
|
||||
#endif
|
||||
mSystemStatusObsrvr(sysStatObs), mMsgTask(msgTask) {
|
||||
subscribe(true);
|
||||
}
|
||||
inline XtraSystemStatusObserver() {};
|
||||
inline virtual ~XtraSystemStatusObserver() { subscribe(false); }
|
||||
|
||||
// IDataItemObserver overrides
|
||||
inline virtual void getName(string& name);
|
||||
virtual void notify(const list<IDataItemCore*>& dlist);
|
||||
|
||||
#ifdef USE_GLIB
|
||||
// IFrameworkActionReq functions reqd
|
||||
virtual bool connectBackhaul();
|
||||
virtual bool disconnectBackhaul();
|
||||
#endif
|
||||
|
||||
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:
|
||||
int createSocket();
|
||||
void closeSocket(const int32_t socketFd);
|
||||
bool sendEvent(std::stringstream& event);
|
||||
bool sendEvent(const stringstream& event);
|
||||
IOsObserver* mSystemStatusObsrvr;
|
||||
const MsgTask* mMsgTask;
|
||||
#ifdef USE_GLIB
|
||||
// XtraHalListenerSocket class
|
||||
// TBD - this will be removed once bidirectional socket changes in
|
||||
// xtra-daemon will be implemented
|
||||
XtraHalListenerSocket mHalListenerSocket;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -253,6 +253,6 @@ static void getDebugReport(GnssDebugReport& report) {
|
|||
|
||||
static void updateConnectionStatus(bool connected, uint8_t type) {
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->updateConnectionStatusCommand(connected, type);
|
||||
gGnssAdapter->getSystemStatus()->eventConnectionStatus(connected, type);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue