diff options
author | Saurabh Srivastava <ssrivast@codeaurora.org> | 2018-05-04 14:34:17 +0530 |
---|---|---|
committer | Saurabh Srivastava <ssrivast@codeaurora.org> | 2018-07-01 11:05:18 +0530 |
commit | f7e3cd59e391017043829ae1a8cc52c09273e771 (patch) | |
tree | 0446f0e8e3d7e07badaf1e67548655b7ccee444e /android | |
parent | 4819ca816fdbec3d857864f7607efb62df0ff175 (diff) | |
download | gps-f7e3cd59e391017043829ae1a8cc52c09273e771.tar.gz |
Returning failure on GPS blacklisting
Returning false for HIDL Set Blacklist
API when a GPS constellation SV is
passed in for blacklisting.
Change-Id: I4fdaf226111d9db365af11c0e5bb6fa043c0b6fb
CRs-Fixed: 2234230
Diffstat (limited to 'android')
-rw-r--r-- | android/GnssConfiguration.cpp | 22 | ||||
-rw-r--r-- | android/GnssConfiguration.h | 2 |
2 files changed, 20 insertions, 4 deletions
diff --git a/android/GnssConfiguration.cpp b/android/GnssConfiguration.cpp index cee928a..f52ae4b 100644 --- a/android/GnssConfiguration.cpp +++ b/android/GnssConfiguration.cpp @@ -233,6 +233,11 @@ Return<bool> GnssConfiguration::setBlacklist( return false; } + // blValid is true if blacklist is empty, i.e. clearing the BL; + // if blacklist is not empty, blValid is initialied to false, and later + // updated in the for loop to become true only if there is at least + // one {constellation, svid} in the list that is valid. + bool blValid = (0 == blacklist.size()); GnssConfig config; memset(&config, 0, sizeof(GnssConfig)); config.size = sizeof(GnssConfig); @@ -241,25 +246,33 @@ Return<bool> GnssConfiguration::setBlacklist( GnssSvIdSource source = {}; for (int idx = 0; idx < (int)blacklist.size(); idx++) { - setBlacklistedSource(source, blacklist[idx]); + // Set blValid true if any one source is valid + blValid = setBlacklistedSource(source, blacklist[idx]) || blValid; config.blacklistedSvIds.push_back(source); } - return mGnss->updateConfiguration(config); + // Update configuration only if blValid is true + // i.e. only if atleast one source is valid for blacklisting + return (blValid && mGnss->updateConfiguration(config)); } -void GnssConfiguration::setBlacklistedSource( +bool GnssConfiguration::setBlacklistedSource( GnssSvIdSource& copyToSource, const GnssConfiguration::BlacklistedSource& copyFromSource) { + bool retVal = true; copyToSource.size = sizeof(GnssSvIdSource); switch(copyFromSource.constellation) { case GnssConstellationType::GPS: copyToSource.constellation = GNSS_SV_TYPE_GPS; + LOC_LOGe("GPS SVs can't be blacklisted."); + retVal = false; break; case GnssConstellationType::SBAS: copyToSource.constellation = GNSS_SV_TYPE_SBAS; + LOC_LOGe("SBAS SVs can't be blacklisted."); + retVal = false; break; case GnssConstellationType::GLONASS: copyToSource.constellation = GNSS_SV_TYPE_GLONASS; @@ -275,10 +288,13 @@ void GnssConfiguration::setBlacklistedSource( break; default: copyToSource.constellation = GNSS_SV_TYPE_UNKNOWN; + LOC_LOGe("Invalid constellation %d", copyFromSource.constellation); + retVal = false; break; } copyToSource.svId = copyFromSource.svid; + return retVal; } } // namespace implementation diff --git a/android/GnssConfiguration.h b/android/GnssConfiguration.h index 15ee290..96681b6 100644 --- a/android/GnssConfiguration.h +++ b/android/GnssConfiguration.h @@ -64,7 +64,7 @@ struct GnssConfiguration : public IGnssConfiguration { private: Gnss* mGnss = nullptr; - void setBlacklistedSource( + bool setBlacklistedSource( GnssSvIdSource& copyToSource, const GnssConfiguration::BlacklistedSource& copyFromSource); }; |