diff --git a/gps/core/ContextBase.h b/gps/core/ContextBase.h index 7204ddd..296efff 100644 --- a/gps/core/ContextBase.h +++ b/gps/core/ContextBase.h @@ -197,7 +197,10 @@ public: return mLBSProxy->getIzatDevId(); } inline void sendMsg(const LocMsg *msg) { getMsgTask()->sendMsg(msg); } - + inline bool checkFeatureStatus(int* fids, + LocFeatureStatus* status, uint32_t idCount, bool directQwesCall = false) const { + return mLocApiProxy->checkFeatureStatus(fids, status, idCount, directQwesCall); + } static loc_gps_cfg_s_type mGps_conf; static loc_sap_cfg_s_type mSap_conf; static bool sIsEngineCapabilitiesKnown; diff --git a/gps/core/EngineHubProxyBase.h b/gps/core/EngineHubProxyBase.h index bb69483..8e1fa38 100644 --- a/gps/core/EngineHubProxyBase.h +++ b/gps/core/EngineHubProxyBase.h @@ -36,6 +36,7 @@ #else #include #endif +#include namespace loc_core { @@ -151,6 +152,7 @@ typedef std::function &featureMap ) { + //Set Qwes feature status map in ContextBase + ContextBase::setQwesFeatureStatus(featureMap); // loop through adapters, and deliver to all adapters. TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportQwesCapabilities(featureMap)); } diff --git a/gps/core/LocApiBase.h b/gps/core/LocApiBase.h index 7b76489..c3a54f1 100644 --- a/gps/core/LocApiBase.h +++ b/gps/core/LocApiBase.h @@ -145,6 +145,8 @@ public: GnssSvMeasurementHeader& svMeasSetHeader __unused, GnssMeasurementsData& measurementData __unused) { return false; } inline virtual float getGeoidalSeparation(double latitude __unused, double longitude __unused) { return 0.0; } + inline virtual bool checkFeatureStatus(int* fids, LocFeatureStatus* status, + uint32_t idCount, bool directQwesCall = false) {return false;} }; class LocApiBase { @@ -187,6 +189,9 @@ public: mMsgTask->sendMsg(msg); } } + inline MsgTask* getMsgTask() const { + return mMsgTask; + } inline void destroy() { close(); struct LocKillMsg : public LocMsg { diff --git a/gps/core/SystemStatus.cpp b/gps/core/SystemStatus.cpp index 32f77a9..3c9b471 100644 --- a/gps/core/SystemStatus.cpp +++ b/gps/core/SystemStatus.cpp @@ -1809,6 +1809,11 @@ bool SystemStatus::eventDataItemNotify(IDataItemCore* dataitem) ret = setIteminReport(mCache.mBtLeDeviceScanDetail, SystemStatusBtleDeviceScanDetail( *(static_cast(dataitem)))); break; + case LOC_FEATURE_STATUS_DATA_ITEM_ID: + ret = setIteminReport(mCache.mLocFeatureStatus, + SystemStatusLocFeatureStatus( + *(static_cast(dataitem)))); + break; default: break; } @@ -2038,5 +2043,18 @@ void SystemStatus::setTracking(bool tracking) { mTracking = tracking; pthread_mutex_unlock(&mMutexSystemStatus); } + +/****************************************************************************** +@brief API to update Location feature QWES status + +@param[In] Location feature QWES status + +@return true when successfully done +******************************************************************************/ +bool SystemStatus::eventLocFeatureStatus(std::unordered_set fids) { + SystemStatusLocFeatureStatus s(fids); + mSysStatusObsvr.notify({&s.mDataItem}); + return true; +} } // namespace loc_core diff --git a/gps/core/SystemStatus.h b/gps/core/SystemStatus.h index 100bbe3..657c66b 100644 --- a/gps/core/SystemStatus.h +++ b/gps/core/SystemStatus.h @@ -842,6 +842,22 @@ public: } }; +class SystemStatusLocFeatureStatus : public SystemStatusItemBase { +public: + LocFeatureStatusDataItem mDataItem; + inline SystemStatusLocFeatureStatus(std::unordered_set fids) : mDataItem(fids) {} + inline SystemStatusLocFeatureStatus(const LocFeatureStatusDataItem& itemBase): + mDataItem(itemBase) {} + inline bool equals(const SystemStatusItemBase& peer) override { + return mDataItem.mFids == + ((const SystemStatusLocFeatureStatus&)peer).mDataItem.mFids; + } + inline void dump(void) override { + string str; + mDataItem.stringify(str); + LOC_LOGd("Location feature qwes status: %s", str.c_str()); + } +}; /****************************************************************************** SystemStatusReports ******************************************************************************/ @@ -893,6 +909,7 @@ public: std::vector mMccMnc; std::vector mBtDeviceScanDetail; std::vector mBtLeDeviceScanDetail; + std::vector mLocFeatureStatus; }; /****************************************************************************** @@ -945,6 +962,7 @@ public: bool eventRegionStatus(bool region); bool eventInEmergencyCall(bool isEmergency); void setTracking(bool tracking); + bool eventLocFeatureStatus(std::unordered_set fids); }; } // namespace loc_core diff --git a/gps/core/data-items/DataItemConcreteTypes.cpp b/gps/core/data-items/DataItemConcreteTypes.cpp index d82b317..cc31903 100644 --- a/gps/core/data-items/DataItemConcreteTypes.cpp +++ b/gps/core/data-items/DataItemConcreteTypes.cpp @@ -128,6 +128,7 @@ SPDX-License-Identifier: BSD-3-Clause-Clear #define BATTERYLEVEL_FIELD_BATTERY_PCT "BATTERY_PCT" #define IN_EMERGENCY_CALL_FIELD_NAME "IS_EMERGENCY" +#define LOC_FEATURE_STATUS_FIELD_NAME "LOC_FEATURE_STATUS" namespace loc_core { @@ -959,4 +960,35 @@ int32_t InEmergencyCallDataItem::copyFrom(IDataItemCore* src) { EXIT_LOG("%d", result); return result; } + +void LocFeatureStatusDataItem::stringify(string& valueStr) { + int32_t result = 0; + ENTRY_LOG(); + do { + STRINGIFY_ERROR_CHECK_AND_DOWN_CAST( + LocFeatureStatusDataItem, LOC_FEATURE_STATUS_DATA_ITEM_ID); + valueStr.clear (); + valueStr += LOC_FEATURE_STATUS_FIELD_NAME; + valueStr += ": {"; + for (int item : d->mFids) { + valueStr += std::to_string(item) + ", "; + } + valueStr += "}"; + } while (0); + EXIT_LOG_WITH_ERROR("%d", result); +} + +int32_t LocFeatureStatusDataItem::copyFrom(IDataItemCore* src) { + int32_t result = -1; + ENTRY_LOG(); + do { + COPIER_ERROR_CHECK_AND_DOWN_CAST( + LocFeatureStatusDataItem, LOC_FEATURE_STATUS_DATA_ITEM_ID); + s->mFids = d->mFids; + result = 0; + } while (0); + EXIT_LOG("%d", result); + return result; +} + } //namespace loc_core diff --git a/gps/core/data-items/DataItemConcreteTypes.h b/gps/core/data-items/DataItemConcreteTypes.h index ba86d9a..446f551 100644 --- a/gps/core/data-items/DataItemConcreteTypes.h +++ b/gps/core/data-items/DataItemConcreteTypes.h @@ -43,7 +43,7 @@ SPDX-License-Identifier: BSD-3-Clause-Clear #include #include #include - +#include #define MAC_ADDRESS_LENGTH 6 // MAC address length in bytes // QMI_LOC_SRN_MAC_ADDR_LENGTH_V02 @@ -651,6 +651,17 @@ public: bool mIsEmergency; }; +class LocFeatureStatusDataItem: public IDataItemCore { + public: + LocFeatureStatusDataItem(std::unordered_set fids) : + mFids(fids) {mId = LOC_FEATURE_STATUS_DATA_ITEM_ID;} + virtual ~LocFeatureStatusDataItem() {} + virtual void stringify(string& /*valueStr*/) override; + virtual int32_t copyFrom(IDataItemCore* /*src*/) override; + // Data members + std::unordered_set mFids; +}; + } // namespace loc_core #endif //DATAITEM_CONCRETETYPES_H diff --git a/gps/core/data-items/DataItemId.h b/gps/core/data-items/DataItemId.h index 5ba0460..d512dec 100644 --- a/gps/core/data-items/DataItemId.h +++ b/gps/core/data-items/DataItemId.h @@ -73,6 +73,7 @@ typedef enum e_DataItemId { // 26 - BATTERY_LEVEL_DATA_ITEM_ID, IN_EMERGENCY_CALL_DATA_ITEM_ID, + LOC_FEATURE_STATUS_DATA_ITEM_ID, MAX_DATA_ITEM_ID_1_1, } DataItemId; diff --git a/gps/core/data-items/DataItemsFactoryProxy.cpp b/gps/core/data-items/DataItemsFactoryProxy.cpp index 469a562..d8240a9 100644 --- a/gps/core/data-items/DataItemsFactoryProxy.cpp +++ b/gps/core/data-items/DataItemsFactoryProxy.cpp @@ -116,6 +116,9 @@ IDataItemCore* DataItemsFactoryProxy::createNewDataItem(IDataItemCore* dataItem) case BATTERY_LEVEL_DATA_ITEM_ID: mydi = new BatteryLevelDataItem(*((BatteryLevelDataItem*)dataItem)); break; + case LOC_FEATURE_STATUS_DATA_ITEM_ID: + mydi = new LocFeatureStatusDataItem(*((LocFeatureStatusDataItem*)dataItem)); + break; case INVALID_DATA_ITEM_ID: case MAX_DATA_ITEM_ID: default: diff --git a/gps/gnss/GnssAdapter.cpp b/gps/gnss/GnssAdapter.cpp index 6b2a1af..7712269 100644 --- a/gps/gnss/GnssAdapter.cpp +++ b/gps/gnss/GnssAdapter.cpp @@ -5208,9 +5208,6 @@ bool GnssAdapter::reportQwesCapabilities( mAdapter(adapter), mFeatureMap(std::move(featureMap)) {} inline virtual void proc() const { - LOC_LOGi("ReportQwesFeatureStatus before caps %" PRIx64 " ", - mAdapter.getCapabilities()); - ContextBase::setQwesFeatureStatus(mFeatureMap); LOC_LOGi("ReportQwesFeatureStatus After caps %" PRIx64 " ", mAdapter.getCapabilities()); mAdapter.broadcastCapabilities(mAdapter.getCapabilities()); @@ -7164,6 +7161,7 @@ GnssAdapter::initEngHubProxy() { GnssAdapterUpdateQwesFeatureStatusCb updateQwesFeatureStatusCb = [this] (const std::unordered_map &featureMap) { + ContextBase::setQwesFeatureStatus(featureMap); reportQwesCapabilities(featureMap); }; @@ -7171,7 +7169,8 @@ GnssAdapter::initEngHubProxy() { if(getter != nullptr) { // Wait for the script(rootdir/etc/init.qcom.rc) to create socket folder locUtilWaitForDir(SOCKET_DIR_EHUB); - EngineHubProxyBase* hubProxy = (*getter) (mMsgTask, mSystemStatus->getOsObserver(), + EngineHubProxyBase* hubProxy = (*getter) (mMsgTask, mContext, + mSystemStatus->getOsObserver(), engServiceInfo, reportPositionEventCb, reqAidingDataCb, updateNHzRequirementCb, updateQwesFeatureStatusCb); if (hubProxy != nullptr) { diff --git a/gps/utils/gps_extended_c.h b/gps/utils/gps_extended_c.h index cab704c..54b02ff 100644 --- a/gps/utils/gps_extended_c.h +++ b/gps/utils/gps_extended_c.h @@ -2460,6 +2460,13 @@ typedef uint64_t NetworkHandle; #define NETWORK_HANDLE_UNKNOWN ~0 #define MAX_NETWORK_HANDLES 10 +typedef enum { + LOC_FEATURE_STATUS_UNKNOWN = 0, + LOC_FEATURE_STATUS_NONE = 1, + LOC_FEATURE_STATUS_OK = 2, + LOC_FEATURE_STATUS_EXPIRED = 3 +} LocFeatureStatus; + #ifdef __cplusplus } #endif /* __cplusplus */