Snap for 7599941 from 3389c76acf5e18ea44b32945fb7a191b76c15d46 to sc-release
Change-Id: I152bacc348559b6fdc16b6b5119adefb214b143c
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 @@
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 @@
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::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 @@
}
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 @@
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 @@
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 @@
/* 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 d597b03..daca704 100644
--- a/gnss/GnssAdapter.cpp
+++ b/gnss/GnssAdapter.cpp
@@ -5260,8 +5260,7 @@
};
// 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) != (unsigned)apnLen)) {
LOC_LOGe("%s]: incorrect apnlen length or incorrect apnName", __func__);
mAgpsManager.reportAtlClosed(agpsType);
} else {