diff options
author | Wei Chen <weic@codeaurora.org> | 2018-09-19 10:59:28 -0700 |
---|---|---|
committer | Wei Chen <weic@codeaurora.org> | 2018-10-08 12:26:06 -0700 |
commit | 21b9c4e47ed5811f53d764c38943e3b971bde5e8 (patch) | |
tree | 7050d4d2124d0ff0abd72605cd4a58598892d6a6 /gnss/GnssAdapter.cpp | |
parent | 5b53be1d9e037a197cdc56b65c73543c63051df1 (diff) | |
download | gps-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/GnssAdapter.cpp')
-rw-r--r-- | gnss/GnssAdapter.cpp | 79 |
1 files changed, 78 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 ¬ify, 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; |