summaryrefslogtreecommitdiff
path: root/gnss
diff options
context:
space:
mode:
authorWei Chen <weic@codeaurora.org>2018-09-19 10:59:28 -0700
committerWei Chen <weic@codeaurora.org>2018-10-08 12:26:06 -0700
commit21b9c4e47ed5811f53d764c38943e3b971bde5e8 (patch)
tree7050d4d2124d0ff0abd72605cd4a58598892d6a6 /gnss
parent5b53be1d9e037a197cdc56b65c73543c63051df1 (diff)
downloadgps-21b9c4e47ed5811f53d764c38943e3b971bde5e8.tar.gz
FR48381: Support leap second change event
Support leap second change event (1) Info will be available in location api and location client api (2) Engine hub aggregator will use the info to calculate UTC timestamp Change-Id: Ie79c1a38301fa094134a4a31af424487758343f6 CRs-fixed: 2289457
Diffstat (limited to 'gnss')
-rw-r--r--gnss/GnssAdapter.cpp79
-rw-r--r--gnss/GnssAdapter.h5
2 files changed, 83 insertions, 1 deletions
diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp
index 3d3c990..b7c57e8 100644
--- a/gnss/GnssAdapter.cpp
+++ b/gnss/GnssAdapter.cpp
@@ -87,7 +87,8 @@ GnssAdapter::GnssAdapter() :
mSystemStatus(SystemStatus::getInstance(mMsgTask)),
mServerUrl(":"),
mXtraObserver(mSystemStatus->getOsObserver(), mMsgTask),
- mBlockCPIInfo{}
+ mBlockCPIInfo{},
+ mLocSystemInfo{}
{
LOC_LOGD("%s]: Constructor %p", __func__, this);
mLocPositionMode.mode = LOC_POSITION_MODE_INVALID;
@@ -1848,6 +1849,8 @@ GnssAdapter::addClientCommand(LocationAPI* client, const LocationCallbacks& call
mClient(client),
mCallbacks(callbacks) {}
inline virtual void proc() const {
+ // check whether we need to notify client of cached location system info
+ mAdapter.notifyClientOfCachedLocationSystemInfo(mClient, mCallbacks);
mAdapter.saveClient(mClient, mCallbacks);
}
};
@@ -1917,6 +1920,9 @@ GnssAdapter::updateClientsEventMask()
mask |= LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT;
updateNmeaMask(mNmeaMask | LOC_NMEA_MASK_DEBUG_V02);
}
+ if (it->second.locationSystemInfoCb != nullptr) {
+ mask |= LOC_API_ADAPTER_BIT_LOC_SYSTEM_INFO;
+ }
}
/*
@@ -1931,6 +1937,7 @@ GnssAdapter::updateClientsEventMask()
mask |= LOC_API_ADAPTER_BIT_GNSS_SV_POLYNOMIAL_REPORT;
mask |= LOC_API_ADAPTER_BIT_PARSED_UNPROPAGATED_POSITION_REPORT;
mask |= LOC_API_ADAPTER_BIT_GNSS_SV_EPHEMERIS_REPORT;
+ mask |= LOC_API_ADAPTER_BIT_LOC_SYSTEM_INFO;
LOC_LOGd("Auto usecase, Enable MEAS/POLY/EPHEMERIS - mask 0x%" PRIx64 "",
mask);
@@ -2107,6 +2114,35 @@ GnssAdapter::saveClient(LocationAPI* client, const LocationCallbacks& callbacks)
}
void
+GnssAdapter::notifyClientOfCachedLocationSystemInfo(
+ LocationAPI* client, const LocationCallbacks& callbacks) {
+
+ if (mLocSystemInfo.systemInfoMask) {
+ // client need to be notified if client has not yet previously registered
+ // for the info but now register for it.
+ bool notifyClientOfSystemInfo = false;
+ // check whether we need to notify client of cached location system info
+ //
+ // client need to be notified if client has not yet previously registered
+ // for the info but now register for it.
+ if (callbacks.locationSystemInfoCb) {
+ notifyClientOfSystemInfo = true;
+ auto it = mClientData.find(client);
+ if (it != mClientData.end()) {
+ LocationCallbacks oldCallbacks = it->second;
+ if (oldCallbacks.locationSystemInfoCb) {
+ notifyClientOfSystemInfo = false;
+ }
+ }
+ }
+
+ if (notifyClientOfSystemInfo) {
+ callbacks.locationSystemInfoCb(mLocSystemInfo);
+ }
+ }
+}
+
+void
GnssAdapter::eraseClient(LocationAPI* client)
{
auto it = mClientData.find(client);
@@ -3228,6 +3264,47 @@ GnssAdapter::requestNiNotifyEvent(const GnssNiNotification &notify, const void*
return true;
}
+void
+GnssAdapter::reportLocationSystemInfoEvent(const LocationSystemInfo & locationSystemInfo) {
+
+ // send system info to engine hub
+ mEngHubProxy->gnssReportSystemInfo(locationSystemInfo);
+
+ struct MsgLocationSystemInfo : public LocMsg {
+ GnssAdapter& mAdapter;
+ LocationSystemInfo mSystemInfo;
+ inline MsgLocationSystemInfo(GnssAdapter& adapter,
+ const LocationSystemInfo& systemInfo) :
+ LocMsg(),
+ mAdapter(adapter),
+ mSystemInfo(systemInfo) {}
+ inline virtual void proc() const {
+ mAdapter.reportLocationSystemInfo(mSystemInfo);
+ }
+ };
+
+ sendMsg(new MsgLocationSystemInfo(*this, locationSystemInfo));
+}
+
+void
+GnssAdapter::reportLocationSystemInfo(const LocationSystemInfo & locationSystemInfo) {
+ // save the info into the master copy piece by piece, as other system info
+ // may come at different time
+ if (locationSystemInfo.systemInfoMask & LOCATION_SYS_INFO_LEAP_SECOND) {
+ mLocSystemInfo.systemInfoMask |= LOCATION_SYS_INFO_LEAP_SECOND;
+ mLocSystemInfo.leapSecondSysInfo = locationSystemInfo.leapSecondSysInfo;
+ }
+
+ // we received new info, inform client of the newly received info
+ if (locationSystemInfo.systemInfoMask) {
+ for (auto it=mClientData.begin(); it != mClientData.end(); ++it) {
+ if (it->second.locationSystemInfoCb != nullptr) {
+ it->second.locationSystemInfoCb(locationSystemInfo);
+ }
+ }
+ }
+}
+
static void* niThreadProc(void *args)
{
NiSession* pSession = (NiSession*)args;
diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h
index 21ce787..f382c6a 100644
--- a/gnss/GnssAdapter.h
+++ b/gnss/GnssAdapter.h
@@ -172,6 +172,7 @@ class GnssAdapter : public LocAdapterBase {
std::string mServerUrl;
std::string mMoServerUrl;
XtraSystemStatusObserver mXtraObserver;
+ LocationSystemInfo mLocSystemInfo;
/* === Misc ===================================================================== */
BlockCPIInfo mBlockCPIInfo;
@@ -210,6 +211,8 @@ public:
/* ======== UTILITIES ================================================================== */
void saveClient(LocationAPI* client, const LocationCallbacks& callbacks);
void eraseClient(LocationAPI* client);
+ void notifyClientOfCachedLocationSystemInfo(LocationAPI* client,
+ const LocationCallbacks& callbacks);
void updateClientsEventMask();
void stopClientSessions(LocationAPI* client);
LocationCallbacks getClientCallbacks(LocationAPI* client);
@@ -344,6 +347,7 @@ public:
virtual void reportGnssSvIdConfigEvent(const GnssSvIdConfig& config);
virtual void reportGnssSvTypeConfigEvent(const GnssSvTypeConfig& config);
virtual bool reportGnssEngEnergyConsumedEvent(uint64_t energyConsumedSinceFirstBoot);
+ virtual void reportLocationSystemInfoEvent(const LocationSystemInfo& locationSystemInfo);
virtual bool requestATL(int connHandle, LocAGpsType agps_type, LocApnTypeMask apn_type_mask);
virtual bool releaseATL(int connHandle);
@@ -367,6 +371,7 @@ public:
void requestOdcpi(const OdcpiRequestInfo& request);
void invokeGnssEnergyConsumedCallback(uint64_t energyConsumedSinceFirstBoot);
void saveGnssEnergyConsumedCallback(GnssEnergyConsumedCallback energyConsumedCb);
+ void reportLocationSystemInfo(const LocationSystemInfo & locationSystemInfo);
/*======== GNSSDEBUG ================================================================*/
bool getDebugReport(GnssDebugReport& report);