diff options
author | Dante Russo <drusso@codeaurora.org> | 2021-08-16 11:08:47 -0700 |
---|---|---|
committer | Dante Russo <drusso@codeaurora.org> | 2021-08-16 11:08:47 -0700 |
commit | 01269f41e61e3f1b5322e930aca65aa152358ba8 (patch) | |
tree | 222eb775a6f165430969eb5d0eee7230f3f4d44f | |
parent | 218203ee28390e0588e5928bb2f5455bce09c5e4 (diff) |
Clear Emergency SUPL APN Name of SOS
During Emergency SUPL session, an APN name of
SOS reported by AFW means the APN could not be
found, like in Simless the case, so the APN name
is cleared
Change-Id: I5976b89a0edb3c8e4a98a165b2d388866ace0c78
CRs-fixed: 2996872
-rw-r--r-- | android/2.1/AGnss.cpp | 21 | ||||
-rw-r--r-- | android/2.1/AGnss.h | 2 | ||||
-rw-r--r-- | gnss/Agps.cpp | 2 | ||||
-rw-r--r-- | gnss/Agps.h | 2 | ||||
-rw-r--r-- | gnss/GnssAdapter.cpp | 3 |
5 files changed, 18 insertions, 12 deletions
diff --git a/android/2.1/AGnss.cpp b/android/2.1/AGnss.cpp index c759492..ce7b3aa 100644 --- a/android/2.1/AGnss.cpp +++ b/android/2.1/AGnss.cpp @@ -32,7 +32,7 @@ namespace implementation { static AGnss* spAGnss = nullptr; -AGnss::AGnss(Gnss* gnss) : mGnss(gnss) { +AGnss::AGnss(Gnss* gnss) : mGnss(gnss), mType(LOC_AGPS_TYPE_INVALID) { spAGnss = this; } @@ -51,6 +51,9 @@ void AGnss::statusCb(AGpsExtType type, LocAGpsStatusValue status) { V2_0::IAGnssCallback::AGnssType aType; IAGnssCallback::AGnssStatusValue aStatus; + // cache the AGps Type + mType = type; + switch (type) { case LOC_AGPS_TYPE_SUPL: aType = IAGnssCallback::AGnssType::SUPL; @@ -138,18 +141,20 @@ Return<bool> AGnss::dataConnFailed() { Return<bool> AGnss::dataConnOpen(uint64_t /*networkHandle*/, const hidl_string& apn, V2_0::IAGnss::ApnIpType apnIpType) { - if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){ + if (mGnss == nullptr || mGnss->getGnssInterface() == nullptr){ LOC_LOGE("Null GNSS interface"); return false; } - /* Validate */ - if(apn.empty()){ - LOC_LOGE("Invalid APN"); - return false; + std::string apnString(apn.c_str()); + // During Emergency SUPL, an apn name of "sos" means that no + // apn was found, like in the simless case, so apn is cleared + if (LOC_AGPS_TYPE_SUPL_ES == mType && "sos" == apnString) { + LOC_LOGD("dataConnOpen APN name = [sos] cleared"); + apnString.clear(); } - LOC_LOGD("dataConnOpen APN name = [%s]", apn.c_str()); + LOC_LOGD("dataConnOpen APN name = [%s]", apnString.c_str()); AGpsBearerType bearerType; switch (apnIpType) { @@ -168,7 +173,7 @@ Return<bool> AGnss::dataConnOpen(uint64_t /*networkHandle*/, const hidl_string& } mGnss->getGnssInterface()->agpsDataConnOpen( - LOC_AGPS_TYPE_SUPL, apn.c_str(), apn.size(), (int)bearerType); + LOC_AGPS_TYPE_SUPL, apnString.c_str(), apnString.size(), (int)bearerType); return true; } diff --git a/android/2.1/AGnss.h b/android/2.1/AGnss.h index f6ea997..cf9c8a7 100644 --- a/android/2.1/AGnss.h +++ b/android/2.1/AGnss.h @@ -67,6 +67,8 @@ struct AGnss : public V2_0::IAGnss { private: Gnss* mGnss = nullptr; sp<V2_0::IAGnssCallback> mAGnssCbIface = nullptr; + + AGpsExtType mType; }; } // namespace implementation diff --git a/gnss/Agps.cpp b/gnss/Agps.cpp index 9255f88..4344a6f 100644 --- a/gnss/Agps.cpp +++ b/gnss/Agps.cpp @@ -448,7 +448,7 @@ void AgpsStateMachine::setAPN(char* apn, unsigned int len){ mAPN = NULL; } - if (NULL == apn || len <= 0 || len > MAX_APN_LEN || strlen(apn) != len) { + if (NULL == apn || len > MAX_APN_LEN || strlen(apn) != len) { LOC_LOGD("Invalid apn len (%d) or null apn", len); mAPN = NULL; mAPNLen = 0; diff --git a/gnss/Agps.h b/gnss/Agps.h index 6b43bf5..8a27cd9 100644 --- a/gnss/Agps.h +++ b/gnss/Agps.h @@ -167,7 +167,7 @@ public: /* Getter/Setter methods */ void setAPN(char* apn, unsigned int len); - inline char* getAPN() const { return (char*)mAPN; } + inline char* getAPN() const { return mAPN; } inline uint32_t getAPNLen() const { return mAPNLen; } inline void setBearer(AGpsBearerType bearer) { mBearer = bearer; } inline LocApnTypeMask getApnTypeMask() const { return mApnTypeMask; } diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index b0ed2a3..1938782 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -5256,8 +5256,7 @@ void GnssAdapter::dataConnOpenCommand( }; // Added inital length checks for apnlen check to avoid security issues // In case of failure reporting the same - if (NULL == apnName || apnLen <= 0 || apnLen > MAX_APN_LEN || - (strlen(apnName) != (unsigned)apnLen)) { + if (NULL == apnName || apnLen > MAX_APN_LEN || (strlen(apnName) != apnLen)) { LOC_LOGe("%s]: incorrect apnlen length or incorrect apnName", __func__); mAgpsManager.reportAtlClosed(agpsType); } else { |