diff options
-rw-r--r-- | core/ContextBase.cpp | 5 | ||||
-rw-r--r-- | core/ContextBase.h | 2 | ||||
-rw-r--r-- | core/LocAdapterBase.cpp | 4 | ||||
-rw-r--r-- | core/LocAdapterBase.h | 3 | ||||
-rw-r--r-- | core/LocApiBase.cpp | 8 | ||||
-rw-r--r-- | core/LocApiBase.h | 3 | ||||
-rw-r--r-- | etc/gps.conf | 5 | ||||
-rw-r--r-- | gnss/GnssAdapter.cpp | 100 | ||||
-rw-r--r-- | gnss/GnssAdapter.h | 17 | ||||
-rw-r--r-- | utils/gps_extended_c.h | 12 |
10 files changed, 140 insertions, 19 deletions
diff --git a/core/ContextBase.cpp b/core/ContextBase.cpp index b55b758..ee37a0f 100644 --- a/core/ContextBase.cpp +++ b/core/ContextBase.cpp @@ -92,6 +92,8 @@ const loc_param_s_type ContextBase::mGps_conf_table[] = {"GNSS_DEPLOYMENT", &mGps_conf.GNSS_DEPLOYMENT, NULL, 'n'}, {"CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED", &mGps_conf.CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED, NULL, 'n'}, + {"CP_MTLR_ES", &mGps_conf.CP_MTLR_ES, NULL, 'n' }, + {"NI_SUPL_DENY_ON_NFW_LOCKED", &mGps_conf.NI_SUPL_DENY_ON_NFW_LOCKED, NULL, 'n'}, }; const loc_param_s_type ContextBase::mSap_conf_table[] = @@ -126,6 +128,7 @@ void ContextBase::readConfig() mGps_conf.SUPL_VER = 0x10000; mGps_conf.SUPL_MODE = 0x1; mGps_conf.SUPL_ES = 0; + mGps_conf.CP_MTLR_ES = 0; mGps_conf.SUPL_HOST[0] = 0; mGps_conf.SUPL_PORT = 0; mGps_conf.CAPABILITIES = 0x7; @@ -190,6 +193,8 @@ void ContextBase::readConfig() /* default configuration QTI GNSS H/W */ mGps_conf.GNSS_DEPLOYMENT = 0; mGps_conf.CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED = 0; + /* default configuration for NI_SUPL_DENY_ON_NFW_LOCKED */ + mGps_conf.NI_SUPL_DENY_ON_NFW_LOCKED = 0; UTIL_READ_CONF(LOC_PATH_GPS_CONF, mGps_conf_table); UTIL_READ_CONF(LOC_PATH_SAP_CONF, mSap_conf_table); diff --git a/core/ContextBase.h b/core/ContextBase.h index 280316c..c995c9b 100644 --- a/core/ContextBase.h +++ b/core/ContextBase.h @@ -79,6 +79,8 @@ typedef struct loc_gps_cfg_s uint32_t POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED; uint32_t GNSS_DEPLOYMENT; uint32_t CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED; + uint32_t CP_MTLR_ES; + uint32_t NI_SUPL_DENY_ON_NFW_LOCKED; } loc_gps_cfg_s_type; /* NOTE: the implementaiton of the parser casts number diff --git a/core/LocAdapterBase.cpp b/core/LocAdapterBase.cpp index 14e4857..17a3172 100644 --- a/core/LocAdapterBase.cpp +++ b/core/LocAdapterBase.cpp @@ -163,7 +163,9 @@ bool LocAdapterBase:: DEFAULT_IMPL(false) bool LocAdapterBase:: - requestNiNotifyEvent(const GnssNiNotification &/*notify*/, const void* /*data*/) + requestNiNotifyEvent(const GnssNiNotification &/*notify*/, + const void* /*data*/, + const LocInEmergency emergencyState) DEFAULT_IMPL(false) void LocAdapterBase:: diff --git a/core/LocAdapterBase.h b/core/LocAdapterBase.h index b1f5fa7..24ed15c 100644 --- a/core/LocAdapterBase.h +++ b/core/LocAdapterBase.h @@ -181,7 +181,8 @@ public: virtual bool requestATL(int connHandle, LocAGpsType agps_type, LocApnTypeMask apn_type_mask); virtual bool releaseATL(int connHandle); - virtual bool requestNiNotifyEvent(const GnssNiNotification ¬ify, const void* data); + virtual bool requestNiNotifyEvent(const GnssNiNotification ¬ify, const void* data, + const LocInEmergency emergencyState); inline virtual bool isInSession() { return false; } ContextBase* getContext() const { return mContext; } virtual void reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& measurements, diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp index 50d7369..cdbb382 100644 --- a/core/LocApiBase.cpp +++ b/core/LocApiBase.cpp @@ -521,10 +521,14 @@ void LocApiBase::releaseATL(int connHandle) TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->releaseATL(connHandle)); } -void LocApiBase::requestNiNotify(GnssNiNotification ¬ify, const void* data) +void LocApiBase::requestNiNotify(GnssNiNotification ¬ify, const void* data, + const LocInEmergency emergencyState) { // loop through adapters, and deliver to the first handling adapter. - TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestNiNotifyEvent(notify, data)); + TO_1ST_HANDLING_LOCADAPTERS( + mLocAdapters[i]->requestNiNotifyEvent(notify, + data, + emergencyState)); } void* LocApiBase :: getSibling() diff --git a/core/LocApiBase.h b/core/LocApiBase.h index 05f7db5..4b2b887 100644 --- a/core/LocApiBase.h +++ b/core/LocApiBase.h @@ -182,7 +182,8 @@ public: void requestLocation(); void requestATL(int connHandle, LocAGpsType agps_type, LocApnTypeMask apn_type_mask); void releaseATL(int connHandle); - void requestNiNotify(GnssNiNotification ¬ify, const void* data); + void requestNiNotify(GnssNiNotification ¬ify, const void* data, + const LocInEmergency emergencyState); void reportGnssMeasurementData(GnssMeasurementsNotification& measurements, int msInWeek); void reportWwanZppFix(LocGpsLocation &zppLoc); void reportZppBestAvailableFix(LocGpsLocation &zppLoc, GpsLocationExtended &location_extended, diff --git a/etc/gps.conf b/etc/gps.conf index 0efc73e..8af4038 100644 --- a/etc/gps.conf +++ b/etc/gps.conf @@ -341,3 +341,8 @@ D_LEVEL_MAX_CAPACITY = 300 V_LEVEL_TIME_DEPTH = 200 V_LEVEL_MAX_CAPACITY = 400 +##################################### +# CP_MTLR_ES +##################################### +# CP MTLR ES, 1=enable, 0=disable +CP_MTLR_ES=0 diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 116505c..a0d36f6 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -122,7 +122,8 @@ GnssAdapter::GnssAdapter() : mLocSystemInfo{}, mGnssMbSvIdUsedInPosition{}, mGnssMbSvIdUsedInPosAvail(false), - mPowerState(POWER_STATE_UNKNOWN) + mPowerState(POWER_STATE_UNKNOWN), + mIsE911Session(NULL) { LOC_LOGD("%s]: Constructor %p", __func__, this); mLocPositionMode.mode = LOC_POSITION_MODE_INVALID; @@ -2403,6 +2404,10 @@ GnssAdapter::stopClientSessions(LocationAPI* client) } +bool isInEmergencySession() { + return false; +} + void GnssAdapter::updateClientsEventMask() { @@ -2416,9 +2421,6 @@ GnssAdapter::updateClientsEventMask() it->second.engineLocationsInfoCb != nullptr) { mask |= LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT; } - if (it->second.gnssNiCb != nullptr) { - mask |= LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST; - } if (it->second.gnssSvCb != nullptr) { mask |= LOC_API_ADAPTER_BIT_SATELLITE_REPORT; } @@ -2466,6 +2468,15 @@ GnssAdapter::updateClientsEventMask() mask |= LOC_API_ADAPTER_BIT_REQUEST_WIFI; } + // always register for NI NOTIFY VERIFY to handle internally in HAL + mask |= LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST; + // and register callback + + NfwCbInfo cbInfo = {}; + cbInfo.isInEmergencySession = (void*)isInEmergencySession; + + initNfw(cbInfo); + // Enable the latency report if (mask & LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT) { if (mLogger.isLogEnabled()) { @@ -4191,7 +4202,8 @@ GnssAdapter::reportData(GnssDataNotification& dataNotify) } bool -GnssAdapter::requestNiNotifyEvent(const GnssNiNotification ¬ify, const void* data) +GnssAdapter::requestNiNotifyEvent(const GnssNiNotification ¬ify, const void* data, + const LocInEmergency emergencyState) { LOC_LOGI("%s]: notif_type: %d, timeout: %d, default_resp: %d" "requestor_id: %s (encoding: %d) text: %s text (encoding: %d) extras: %s", @@ -4201,21 +4213,60 @@ GnssAdapter::requestNiNotifyEvent(const GnssNiNotification ¬ify, const void* struct MsgReportNiNotify : public LocMsg { GnssAdapter& mAdapter; + LocApiBase& mApi; const GnssNiNotification mNotify; const void* mData; + const LocInEmergency mEmergencyState; inline MsgReportNiNotify(GnssAdapter& adapter, + LocApiBase& api, const GnssNiNotification& notify, - const void* data) : + const void* data, + const LocInEmergency emergencyState) : LocMsg(), mAdapter(adapter), + mApi(api), mNotify(notify), - mData(data) {} + mData(data), + mEmergencyState(emergencyState) {} inline virtual void proc() const { - mAdapter.requestNiNotify(mNotify, mData); + bool bIsInEmergency = false; + bool bInformNiAccept = false; + + bIsInEmergency = ((LOC_IN_EMERGENCY_UNKNOWN == mEmergencyState) && + mAdapter.getE911State()) || // older modems + (LOC_IN_EMERGENCY_SET == mEmergencyState); // newer modems + + if (GNSS_NI_TYPE_EMERGENCY_SUPL == mNotify.type) { + bInformNiAccept = bIsInEmergency || + (GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_NO == ContextBase::mGps_conf.SUPL_ES); + + if (bInformNiAccept) { + mAdapter.requestNiNotify(mNotify, mData, bInformNiAccept); + } else { + mApi.informNiResponse(GNSS_NI_RESPONSE_DENY, mData); + } + } else if (GNSS_NI_TYPE_CONTROL_PLANE == mNotify.type) { + if (bIsInEmergency && (1 == ContextBase::mGps_conf.CP_MTLR_ES)) { + mApi.informNiResponse(GNSS_NI_RESPONSE_ACCEPT, mData); + } + else { + mAdapter.requestNiNotify(mNotify, mData, false); + } + } else if (GNSS_NI_TYPE_SUPL == mNotify.type && !bIsInEmergency && + !(GNSS_NI_OPTIONS_PRIVACY_OVERRIDE_BIT & mNotify.options) && + (GNSS_CONFIG_GPS_LOCK_NI & ContextBase::mGps_conf.GPS_LOCK) && + 1 == ContextBase::mGps_conf.NI_SUPL_DENY_ON_NFW_LOCKED) { + // If 'Q' Lock behavior OR 'P' Lock behavior and GNSS is Locked + // If an NI SUPL Request that does not have Privacy Override option comes when + // NFW is locked and config item NI_SUPL_DENY_ON_NFW_LOCKED = 1, then deny it + mApi.informNiResponse(GNSS_NI_RESPONSE_DENY, mData); + } else { + mAdapter.requestNiNotify(mNotify, mData, false); + } } }; - sendMsg(new MsgReportNiNotify(*this, notify, data)); + sendMsg(new MsgReportNiNotify(*this, *mLocApi, notify, data, emergencyState)); return true; } @@ -4338,7 +4389,8 @@ static void* niThreadProc(void *args) } bool -GnssAdapter::requestNiNotify(const GnssNiNotification& notify, const void* data) +GnssAdapter::requestNiNotify(const GnssNiNotification& notify, const void* data, + const bool bInformNiAccept) { NiSession* pSession = NULL; gnssNiCallback gnssNiCb = nullptr; @@ -4350,6 +4402,20 @@ GnssAdapter::requestNiNotify(const GnssNiNotification& notify, const void* data) } } if (nullptr == gnssNiCb) { + if (GNSS_NI_TYPE_EMERGENCY_SUPL == notify.type) { + if (bInformNiAccept) { + mLocApi->informNiResponse(GNSS_NI_RESPONSE_ACCEPT, data); + NiData& niData = getNiData(); + // ignore any SUPL NI non-Es session if a SUPL NI ES is accepted + if (NULL != niData.session.rawRequest) { + pthread_mutex_lock(&niData.session.tLock); + niData.session.resp = GNSS_NI_RESPONSE_IGNORE; + niData.session.respRecvd = true; + pthread_cond_signal(&niData.session.tCond); + pthread_mutex_unlock(&niData.session.tLock); + } + } + } EXIT_LOG(%s, "no clients with gnssNiCb."); return false; } @@ -4799,9 +4865,19 @@ void GnssAdapter::initAgps(const AgpsCbInfo& cbInfo) { mAgpsManager.createAgpsStateMachines(); + LOC_API_ADAPTER_EVENT_MASK_T mask; + // always register for NI NOTIFY VERIFY to handle internally in HAL + mask = LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST | + LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST; + // and register callback + + NfwCbInfo cbInfo = {}; + cbInfo.isInEmergencySession = (void*)isInEmergencySession; + + initNfw(cbInfo); + /* Register for AGPS event mask */ - updateEvtMask(LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST, - LOC_REGISTRATION_MASK_ENABLED); + updateEvtMask(mask, LOC_REGISTRATION_MASK_ENABLED); } } diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h index 73a5a3b..f1e91f6 100644 --- a/gnss/GnssAdapter.h +++ b/gnss/GnssAdapter.h @@ -233,6 +233,11 @@ class GnssAdapter : public LocAdapterBase { bool mDGnssNeedReport; bool mDGnssDataUsage; void reportDGnssDataUsable(GnssSvMeasurementSet &svMeasurementSet); + /* ==== NFW =========================================================================== */ + IsInEmergencySession mIsE911Session; + inline void initNfw(const NfwCbInfo& cbInfo) { + mIsE911Session = (IsInEmergencySession)cbInfo.isInEmergencySession; + } /* ==== ODCPI ========================================================================== */ OdcpiRequestCallback mOdcpiRequestCb; @@ -463,7 +468,8 @@ public: virtual void reportSvEvent(const GnssSvNotification& svNotify, bool fromEngineHub=false); virtual void reportNmeaEvent(const char* nmea, size_t length); - virtual bool requestNiNotifyEvent(const GnssNiNotification& notify, const void* data); + virtual bool requestNiNotifyEvent(const GnssNiNotification& notify, const void* data, + const LocInEmergency emergencyState); virtual void reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& measurements, int msInWeek); virtual void reportSvMeasurementEvent(GnssSvMeasurementSet &svMeasurementSet); @@ -502,7 +508,8 @@ public: void reportSv(GnssSvNotification& svNotify); void reportNmea(const char* nmea, size_t length); void reportData(GnssDataNotification& dataNotify); - bool requestNiNotify(const GnssNiNotification& notify, const void* data); + bool requestNiNotify(const GnssNiNotification& notify, const void* data, + const bool bInformNiAccept); void reportGnssMeasurementData(const GnssMeasurementsNotification& measurements); void reportGnssSvIdConfig(const GnssSvIdConfig& config); void reportGnssSvTypeConfig(const GnssSvTypeConfig& config); @@ -512,6 +519,12 @@ public: void saveGnssEnergyConsumedCallback(GnssEnergyConsumedCallback energyConsumedCb); void reportLocationSystemInfo(const LocationSystemInfo & locationSystemInfo); void updatePowerState(PowerStateType powerState); + inline bool getE911State(void) { + if (NULL != mIsE911Session) { + return mIsE911Session(); + } + return false; + } /*======== GNSSDEBUG ================================================================*/ bool getDebugReport(GnssDebugReport& report); diff --git a/utils/gps_extended_c.h b/utils/gps_extended_c.h index 691822a..a65b0af 100644 --- a/utils/gps_extended_c.h +++ b/utils/gps_extended_c.h @@ -498,6 +498,12 @@ typedef enum { LOC_RELIABILITY_HIGH = 4 }LocReliability; +typedef enum { + LOC_IN_EMERGENCY_UNKNOWN = 0, + LOC_IN_EMERGENCY_SET = 1, + LOC_IN_EMERGENCY_NOT_SET = 2 +}LocInEmergency; + typedef struct { struct timespec32_t apTimeStamp; /*boottime received from pps-ktimer*/ @@ -2267,6 +2273,12 @@ enum OdcpiPrioritytype { */ typedef void (*AgnssStatusIpV4Cb)(AGnssExtStatusIpV4 status); +typedef bool(*IsInEmergencySession)(void); + +typedef struct { + void* isInEmergencySession; +} NfwCbInfo; + /* * Callback with AGNSS(IpV6) status information. * |