From 1608ffb38b3d156ae5db6483258fca3008ae5c0b Mon Sep 17 00:00:00 2001 From: Mike Cailean Date: Wed, 3 Jul 2019 17:55:17 -0700 Subject: [PATCH] SUPL-2.0-con-034-1/2 test case fails SUPL-2.0-con-034-1/2 Fail because Emergency-NI did not check inprogress session Change-Id: I377955c455830bf3bb7cb7fe05d45c4536dabfbc CRs-fixed: 2483780 --- core/LocAdapterBase.cpp | 4 ++- core/LocAdapterBase.h | 3 ++- core/LocApiBase.cpp | 8 ++++-- core/LocApiBase.h | 3 ++- gnss/GnssAdapter.cpp | 54 +++++++++++++++++++++++++++++++---------- gnss/GnssAdapter.h | 6 +++-- utils/gps_extended_c.h | 6 +++++ 7 files changed, 64 insertions(+), 20 deletions(-) diff --git a/core/LocAdapterBase.cpp b/core/LocAdapterBase.cpp index 5864fa83..ffd3d5a1 100644 --- a/core/LocAdapterBase.cpp +++ b/core/LocAdapterBase.cpp @@ -154,7 +154,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 13c84936..b9b1f1e8 100644 --- a/core/LocAdapterBase.h +++ b/core/LocAdapterBase.h @@ -171,7 +171,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 reportGnssMeasurementsEvent(const GnssMeasurements& gnssMeasurements, diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp index a521ceb6..029f57b6 100644 --- a/core/LocApiBase.cpp +++ b/core/LocApiBase.cpp @@ -514,10 +514,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 1c2afafe..8c885f7f 100644 --- a/core/LocApiBase.h +++ b/core/LocApiBase.h @@ -177,7 +177,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 reportGnssMeasurements(GnssMeasurements& gnssMeasurements, int msInWeek); void reportWwanZppFix(LocGpsLocation &zppLoc); void reportZppBestAvailableFix(LocGpsLocation &zppLoc, GpsLocationExtended &location_extended, diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 9413def6..2481dd55 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -3508,7 +3508,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", @@ -3521,37 +3522,49 @@ GnssAdapter::requestNiNotifyEvent(const GnssNiNotification ¬ify, const void* 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 { + 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) { - if (mAdapter.getE911State() || - (GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_NO == ContextBase::mGps_conf.SUPL_ES)) { - mApi.informNiResponse(GNSS_NI_RESPONSE_ACCEPT, mData); + 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 (mAdapter.getE911State() && - (1 == ContextBase::mGps_conf.CP_MTLR_ES)) { + if (bIsInEmergency && (1 == ContextBase::mGps_conf.CP_MTLR_ES)) { mApi.informNiResponse(GNSS_NI_RESPONSE_ACCEPT, mData); - } else { - mAdapter.requestNiNotify(mNotify, mData); + } + else { + mAdapter.requestNiNotify(mNotify, mData, false); } } else { - mAdapter.requestNiNotify(mNotify, mData); + mAdapter.requestNiNotify(mNotify, mData, false); } } }; - sendMsg(new MsgReportNiNotify(*this, *mLocApi, notify, data)); + sendMsg(new MsgReportNiNotify(*this, *mLocApi, notify, data, emergencyState)); return true; } @@ -3674,7 +3687,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; @@ -3686,6 +3700,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; } diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h index 9a727a20..a44e68c2 100644 --- a/gnss/GnssAdapter.h +++ b/gnss/GnssAdapter.h @@ -359,7 +359,8 @@ public: bool fromEngineHub=false); virtual void reportNmeaEvent(const char* nmea, size_t length); virtual void reportDataEvent(const GnssDataNotification& dataNotify, int msInWeek); - virtual bool requestNiNotifyEvent(const GnssNiNotification& notify, const void* data); + virtual bool requestNiNotifyEvent(const GnssNiNotification& notify, const void* data, + const LocInEmergency emergencyState); virtual void reportGnssMeasurementsEvent(const GnssMeasurements& gnssMeasurements, int msInWeek); virtual void reportSvPolynomialEvent(GnssSvPolynomial &svPolynomial); @@ -389,7 +390,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); diff --git a/utils/gps_extended_c.h b/utils/gps_extended_c.h index 07d67edf..90ec3395 100644 --- a/utils/gps_extended_c.h +++ b/utils/gps_extended_c.h @@ -457,6 +457,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*/