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
This commit is contained in:
parent
4819ca816f
commit
f7e3cd59e3
4 changed files with 41 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -64,7 +64,7 @@ struct GnssConfiguration : public IGnssConfiguration {
|
|||
|
||||
private:
|
||||
Gnss* mGnss = nullptr;
|
||||
void setBlacklistedSource(
|
||||
bool setBlacklistedSource(
|
||||
GnssSvIdSource& copyToSource,
|
||||
const GnssConfiguration::BlacklistedSource& copyFromSource);
|
||||
};
|
||||
|
|
|
@ -1101,10 +1101,14 @@ GnssAdapter::gnssSvIdConfigUpdate(const std::vector<GnssSvIdSource>& blacklisted
|
|||
memset(&mGnssSvIdConfig, 0, sizeof(GnssSvIdConfig));
|
||||
|
||||
// Convert the sv id lists to masks
|
||||
convertToGnssSvIdConfig(blacklistedSvIds, mGnssSvIdConfig);
|
||||
bool convertSuccess = convertToGnssSvIdConfig(blacklistedSvIds, mGnssSvIdConfig);
|
||||
|
||||
// Now send to Modem
|
||||
gnssSvIdConfigUpdate();
|
||||
// Now send to Modem if conversion successful
|
||||
if (convertSuccess) {
|
||||
gnssSvIdConfigUpdate();
|
||||
} else {
|
||||
LOC_LOGe("convertToGnssSvIdConfig failed");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1288,10 +1292,11 @@ GnssAdapter::gnssGetConfigCommand(GnssConfigFlagsMask configMask) {
|
|||
return ids;
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
GnssAdapter::convertToGnssSvIdConfig(
|
||||
const std::vector<GnssSvIdSource>& blacklistedSvIds, GnssSvIdConfig& config)
|
||||
{
|
||||
bool retVal = false;
|
||||
config.size = sizeof(GnssSvIdConfig);
|
||||
|
||||
// Empty vector => Clear any previous blacklisted SVs
|
||||
|
@ -1300,6 +1305,7 @@ GnssAdapter::convertToGnssSvIdConfig(
|
|||
config.bdsBlacklistSvMask = 0;
|
||||
config.qzssBlacklistSvMask = 0;
|
||||
config.galBlacklistSvMask = 0;
|
||||
retVal = true;
|
||||
} else {
|
||||
// Parse the vector and convert SV IDs to mask values
|
||||
for (GnssSvIdSource source : blacklistedSvIds) {
|
||||
|
@ -1340,7 +1346,17 @@ GnssAdapter::convertToGnssSvIdConfig(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return true if any one source is valid
|
||||
if (0 != config.gloBlacklistSvMask ||
|
||||
0 != config.bdsBlacklistSvMask ||
|
||||
0 != config.galBlacklistSvMask ||
|
||||
0 != config.qzssBlacklistSvMask) {
|
||||
retVal = true;
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void GnssAdapter::convertFromGnssSvIdConfig(
|
||||
|
|
|
@ -327,7 +327,7 @@ public:
|
|||
static void convertSatelliteInfo(std::vector<GnssDebugSatelliteInfo>& out,
|
||||
const GnssSvType& in_constellation,
|
||||
const SystemStatusReports& in);
|
||||
static void convertToGnssSvIdConfig(
|
||||
static bool convertToGnssSvIdConfig(
|
||||
const std::vector<GnssSvIdSource>& blacklistedSvIds, GnssSvIdConfig& config);
|
||||
static void convertFromGnssSvIdConfig(
|
||||
const GnssSvIdConfig& svConfig, GnssConfig& config);
|
||||
|
|
Loading…
Reference in a new issue