Combine updateConfig in GnssAdapter
Adjust setConfigCommand and gnssUpdateConfigCommand to use one gnssUpdateConfig method. CRs-fixed: 2402752 Change-Id: I6a9ec474bd9ffed52edd2422574af0f6d41493c4
This commit is contained in:
parent
ae8db6cf15
commit
6b687ef48e
2 changed files with 207 additions and 175 deletions
|
@ -681,45 +681,36 @@ GnssAdapter::setConfigCommand()
|
|||
|
||||
mApi.sendMsg(new LocApiMsg(
|
||||
[&adapter, gpsConf, sapConf, oldServerUrl, oldMoServerUrl] () {
|
||||
|
||||
std::string serverUrl = adapter.getServerUrl();
|
||||
std::string moServerUrl = adapter.getMoServerUrl();
|
||||
int serverUrlLen = serverUrl.length();
|
||||
int moServerUrlLen = moServerUrl.length();
|
||||
//cache the injected configuration with GnssConfigRequested struct
|
||||
GnssConfig gnssConfigRequested = {};
|
||||
gnssConfigRequested.flags |= GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT |
|
||||
GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT |
|
||||
GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT |
|
||||
GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT;
|
||||
gnssConfigRequested.gpsLock = GNSS_CONFIG_GPS_LOCK_NONE;
|
||||
if (0 == adapter.getPowerVoteId()) {
|
||||
gnssConfigRequested.gpsLock = adapter.convertGpsLock(gpsConf.GPS_LOCK);
|
||||
}
|
||||
|
||||
if (gpsConf.AGPS_CONFIG_INJECT) {
|
||||
adapter.mLocApi->setSUPLVersionSync(
|
||||
adapter.mLocApi->convertSuplVersion(gpsConf.SUPL_VER));
|
||||
adapter.mLocApi->setLPPConfigSync(
|
||||
adapter.mLocApi->convertLppProfile(gpsConf.LPP_PROFILE));
|
||||
adapter.mLocApi->setAGLONASSProtocolSync(
|
||||
gpsConf.A_GLONASS_POS_PROTOCOL_SELECT);
|
||||
gnssConfigRequested.flags |= GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT |
|
||||
GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT |
|
||||
GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT;
|
||||
gnssConfigRequested.suplVersion =
|
||||
adapter.mLocApi->convertSuplVersion(gpsConf.SUPL_VER);
|
||||
gnssConfigRequested.lppProfile =
|
||||
adapter.mLocApi->convertLppProfile(gpsConf.LPP_PROFILE);
|
||||
gnssConfigRequested.aGlonassPositionProtocolMask =
|
||||
gpsConf.A_GLONASS_POS_PROTOCOL_SELECT;
|
||||
}
|
||||
|
||||
if ((serverUrlLen !=0) && (oldServerUrl.compare(serverUrl) != 0)) {
|
||||
LocationError locErr =
|
||||
adapter.mLocApi->setServerSync(serverUrl.c_str(), serverUrlLen,
|
||||
LOC_AGPS_SUPL_SERVER);
|
||||
if (locErr != LOCATION_ERROR_SUCCESS) {
|
||||
LOC_LOGe("Error while setting SUPL_HOST server:%s",
|
||||
serverUrl.c_str());
|
||||
}
|
||||
}
|
||||
if ((moServerUrlLen != 0) && (oldMoServerUrl.compare(moServerUrl) != 0)) {
|
||||
LocationError locErr =
|
||||
adapter.mLocApi->setServerSync(moServerUrl.c_str(),
|
||||
moServerUrlLen,
|
||||
LOC_AGPS_MO_SUPL_SERVER);
|
||||
if (locErr != LOCATION_ERROR_SUCCESS) {
|
||||
LOC_LOGe("Error while setting MO SUPL_HOST server:%s",
|
||||
moServerUrl.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
adapter.mLocApi->setLPPeProtocolCpSync(
|
||||
adapter.mLocApi->convertLppeCp(gpsConf.LPPE_CP_TECHNOLOGY));
|
||||
adapter.mLocApi->setLPPeProtocolUpSync(
|
||||
adapter.mLocApi->convertLppeUp(gpsConf.LPPE_UP_TECHNOLOGY));
|
||||
gnssConfigRequested.lppeControlPlaneMask =
|
||||
adapter.mLocApi->convertLppeCp(gpsConf.LPPE_CP_TECHNOLOGY);
|
||||
gnssConfigRequested.lppeUserPlaneMask =
|
||||
adapter.mLocApi->convertLppeUp(gpsConf.LPPE_UP_TECHNOLOGY);
|
||||
gnssConfigRequested.blacklistedSvIds.assign(adapter.mBlacklistedSvIds.begin(),
|
||||
adapter.mBlacklistedSvIds.end());
|
||||
adapter.gnssUpdateConfig(oldServerUrl, oldMoServerUrl, gnssConfigRequested,
|
||||
gnssConfigRequested);
|
||||
|
||||
// set nmea mask type
|
||||
uint32_t mask = 0;
|
||||
|
@ -778,6 +769,180 @@ GnssAdapter::setConfigCommand()
|
|||
sendMsg(new MsgSetConfig(*this, *mLocApi));
|
||||
}
|
||||
|
||||
std::vector<LocationError> GnssAdapter::gnssUpdateConfig(const std::string& oldServerUrl,
|
||||
const std::string& oldMoServerUrl, const GnssConfig& gnssConfigRequested,
|
||||
const GnssConfig& gnssConfigNeedEngineUpdate, size_t count) {
|
||||
loc_gps_cfg_s gpsConf = ContextBase::mGps_conf;
|
||||
size_t index = 0;
|
||||
LocationError err = LOCATION_ERROR_SUCCESS;
|
||||
std::vector<LocationError> errsList = {err};
|
||||
if (count > 0) {
|
||||
errsList.insert(errsList.begin(), count, LOCATION_ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
std::string serverUrl = getServerUrl();
|
||||
std::string moServerUrl = getMoServerUrl();
|
||||
|
||||
int serverUrlLen = serverUrl.length();
|
||||
int moServerUrlLen = moServerUrl.length();
|
||||
|
||||
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) {
|
||||
if (gnssConfigNeedEngineUpdate.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) {
|
||||
err = mLocApi->setGpsLockSync(gnssConfigRequested.gpsLock);
|
||||
if (index < count) {
|
||||
errsList[index] = err;
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
if (gnssConfigRequested.flags &
|
||||
GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) {
|
||||
if (gnssConfigNeedEngineUpdate.flags &
|
||||
GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) {
|
||||
if (gnssConfigNeedEngineUpdate.assistanceServer.type ==
|
||||
GNSS_ASSISTANCE_TYPE_SUPL) {
|
||||
if ((serverUrlLen != 0) && (oldServerUrl.compare(serverUrl) !=0)) {
|
||||
|
||||
err = mLocApi->setServerSync(
|
||||
serverUrl.c_str(), serverUrlLen, LOC_AGPS_SUPL_SERVER);
|
||||
if (index < count) {
|
||||
errsList[index] = err;
|
||||
}
|
||||
}
|
||||
if ((moServerUrlLen != 0) && (oldMoServerUrl.compare(moServerUrl) != 0)) {
|
||||
LocationError locErr =
|
||||
mLocApi->setServerSync(moServerUrl.c_str(),
|
||||
moServerUrlLen,
|
||||
LOC_AGPS_MO_SUPL_SERVER);
|
||||
if (locErr != LOCATION_ERROR_SUCCESS) {
|
||||
LOC_LOGe("Error while setting MO SUPL_HOST server:%s",
|
||||
moServerUrl.c_str());
|
||||
}
|
||||
}
|
||||
} else if (gnssConfigNeedEngineUpdate.assistanceServer.type ==
|
||||
GNSS_ASSISTANCE_TYPE_C2K) {
|
||||
struct in_addr addr;
|
||||
struct hostent* hp;
|
||||
bool resolveAddrSuccess = true;
|
||||
|
||||
hp = gethostbyname(
|
||||
gnssConfigNeedEngineUpdate.assistanceServer.hostName);
|
||||
if (hp != NULL) { /* DNS OK */
|
||||
memcpy(&addr, hp->h_addr_list[0], hp->h_length);
|
||||
} else {
|
||||
/* Try IP representation */
|
||||
if (inet_aton(
|
||||
gnssConfigNeedEngineUpdate.assistanceServer.hostName,
|
||||
&addr) == 0) {
|
||||
/* IP not valid */
|
||||
LOC_LOGE("%s]: hostname '%s' cannot be resolved ",
|
||||
__func__,
|
||||
gnssConfigNeedEngineUpdate.assistanceServer.hostName);
|
||||
if (index < count) {
|
||||
errsList[index] = LOCATION_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
} else {
|
||||
resolveAddrSuccess = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (resolveAddrSuccess) {
|
||||
unsigned int ip = htonl(addr.s_addr);
|
||||
err = mLocApi->setServerSync(ip,
|
||||
gnssConfigNeedEngineUpdate.assistanceServer.port,
|
||||
LOC_AGPS_CDMA_PDE_SERVER);
|
||||
if (index < count) {
|
||||
errsList[index] = err;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) {
|
||||
if (gnssConfigNeedEngineUpdate.flags &
|
||||
GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) {
|
||||
err = mLocApi->setSUPLVersionSync(gnssConfigRequested.suplVersion);
|
||||
if (index < count) {
|
||||
errsList[index] = err;
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) {
|
||||
if (gnssConfigNeedEngineUpdate.flags &
|
||||
GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) {
|
||||
err = mLocApi->setLPPConfigSync(gnssConfigRequested.lppProfile);
|
||||
if (index < count) {
|
||||
errsList[index] = err;
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) {
|
||||
if (gnssConfigNeedEngineUpdate.flags &
|
||||
GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) {
|
||||
err = mLocApi->setLPPeProtocolCpSync(
|
||||
gnssConfigRequested.lppeControlPlaneMask);
|
||||
if (index < count) {
|
||||
errsList[index] = err;
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) {
|
||||
if (gnssConfigNeedEngineUpdate.flags &
|
||||
GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) {
|
||||
err = mLocApi->setLPPeProtocolUpSync(
|
||||
gnssConfigRequested.lppeUserPlaneMask);
|
||||
if (index < count) {
|
||||
errsList[index] = err;
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
if (gnssConfigRequested.flags &
|
||||
GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) {
|
||||
if (gnssConfigNeedEngineUpdate.flags &
|
||||
GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) {
|
||||
err = mLocApi->setAGLONASSProtocolSync(
|
||||
gnssConfigRequested.aGlonassPositionProtocolMask);
|
||||
if (index < count) {
|
||||
errsList[index] = err;
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT) {
|
||||
// Check if feature is supported
|
||||
if (!ContextBase::isFeatureSupported(
|
||||
LOC_SUPPORTED_FEATURE_CONSTELLATION_ENABLEMENT_V02)) {
|
||||
LOC_LOGe("Feature constellation enablement not supported.");
|
||||
err = LOCATION_ERROR_NOT_SUPPORTED;
|
||||
} else {
|
||||
// Send the SV ID Config to Modem
|
||||
mBlacklistedSvIds.assign(gnssConfigRequested.blacklistedSvIds.begin(),
|
||||
gnssConfigRequested.blacklistedSvIds.end());
|
||||
err = gnssSvIdConfigUpdateSync(gnssConfigRequested.blacklistedSvIds);
|
||||
if (LOCATION_ERROR_SUCCESS != err) {
|
||||
LOC_LOGe("Failed to send config to modem, err %d", err);
|
||||
}
|
||||
}
|
||||
if (index < count) {
|
||||
errsList[index] = err;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
return errsList;
|
||||
}
|
||||
|
||||
uint32_t*
|
||||
GnssAdapter::gnssUpdateConfigCommand(GnssConfig config)
|
||||
{
|
||||
|
@ -962,148 +1127,11 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config)
|
|||
mApi.sendMsg(new LocApiMsg(
|
||||
[&adapter, gnssConfigRequested, gnssConfigNeedEngineUpdate,
|
||||
countOfConfigs, configCollectiveResponse, errs, oldServerUrl] () {
|
||||
|
||||
size_t index = 0;
|
||||
LocationError err = LOCATION_ERROR_SUCCESS;
|
||||
std::vector<LocationError> errsList(errs);
|
||||
|
||||
std::string serverUrl = adapter.getServerUrl();
|
||||
int serverUrlLen = serverUrl.length();
|
||||
std::vector<LocationError> errsList = adapter.gnssUpdateConfig(oldServerUrl,
|
||||
"", gnssConfigRequested, gnssConfigNeedEngineUpdate, countOfConfigs);
|
||||
|
||||
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) {
|
||||
if (gnssConfigNeedEngineUpdate.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) {
|
||||
err = adapter.mLocApi->setGpsLockSync(gnssConfigRequested.gpsLock);
|
||||
if (index < countOfConfigs) {
|
||||
errsList[index] = err;
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if (gnssConfigRequested.flags &
|
||||
GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) {
|
||||
if (gnssConfigNeedEngineUpdate.flags &
|
||||
GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) {
|
||||
if (gnssConfigNeedEngineUpdate.assistanceServer.type ==
|
||||
GNSS_ASSISTANCE_TYPE_SUPL) {
|
||||
if ((serverUrlLen != 0) && (oldServerUrl.compare(serverUrl) !=0)) {
|
||||
err = adapter.mLocApi->setServerSync(
|
||||
serverUrl.c_str(), serverUrlLen, LOC_AGPS_SUPL_SERVER);
|
||||
if (index < countOfConfigs) {
|
||||
errsList[index] = err;
|
||||
}
|
||||
}
|
||||
} else if (gnssConfigNeedEngineUpdate.assistanceServer.type ==
|
||||
GNSS_ASSISTANCE_TYPE_C2K) {
|
||||
struct in_addr addr;
|
||||
struct hostent* hp;
|
||||
bool resolveAddrSuccess = true;
|
||||
|
||||
hp = gethostbyname(
|
||||
gnssConfigNeedEngineUpdate.assistanceServer.hostName);
|
||||
if (hp != NULL) { /* DNS OK */
|
||||
memcpy(&addr, hp->h_addr_list[0], hp->h_length);
|
||||
} else {
|
||||
/* Try IP representation */
|
||||
if (inet_aton(
|
||||
gnssConfigNeedEngineUpdate.assistanceServer.hostName,
|
||||
&addr) == 0) {
|
||||
/* IP not valid */
|
||||
LOC_LOGE("%s]: hostname '%s' cannot be resolved ",
|
||||
__func__,
|
||||
gnssConfigNeedEngineUpdate.assistanceServer.hostName);
|
||||
if (index < countOfConfigs) {
|
||||
errsList[index] = LOCATION_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
} else {
|
||||
resolveAddrSuccess = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (resolveAddrSuccess) {
|
||||
unsigned int ip = htonl(addr.s_addr);
|
||||
err = adapter.mLocApi->setServerSync(ip,
|
||||
gnssConfigNeedEngineUpdate.assistanceServer.port,
|
||||
LOC_AGPS_CDMA_PDE_SERVER);
|
||||
if (index < countOfConfigs) {
|
||||
errsList[index] = err;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) {
|
||||
if (gnssConfigNeedEngineUpdate.flags &
|
||||
GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) {
|
||||
err = adapter.mLocApi->setSUPLVersionSync(gnssConfigRequested.suplVersion);
|
||||
if (index < countOfConfigs) {
|
||||
errsList[index] = err;
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) {
|
||||
if (gnssConfigNeedEngineUpdate.flags &
|
||||
GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) {
|
||||
err = adapter.mLocApi->setLPPConfigSync(gnssConfigRequested.lppProfile);
|
||||
if (index < countOfConfigs) {
|
||||
errsList[index] = err;
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) {
|
||||
if (gnssConfigNeedEngineUpdate.flags &
|
||||
GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) {
|
||||
err = adapter.mLocApi->setLPPeProtocolCpSync(
|
||||
gnssConfigRequested.lppeControlPlaneMask);
|
||||
if (index < countOfConfigs) {
|
||||
errsList[index] = err;
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) {
|
||||
if (gnssConfigNeedEngineUpdate.flags &
|
||||
GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) {
|
||||
err = adapter.mLocApi->setLPPeProtocolUpSync(
|
||||
gnssConfigRequested.lppeUserPlaneMask);
|
||||
if (index < countOfConfigs) {
|
||||
errsList[index] = err;
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if (gnssConfigRequested.flags &
|
||||
GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) {
|
||||
if (gnssConfigNeedEngineUpdate.flags &
|
||||
GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) {
|
||||
err = adapter.mLocApi->setAGLONASSProtocolSync(
|
||||
gnssConfigRequested.aGlonassPositionProtocolMask);
|
||||
if (index < countOfConfigs) {
|
||||
errsList[index] = err;
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT) {
|
||||
// Check if feature is supported
|
||||
if (!ContextBase::isFeatureSupported(
|
||||
LOC_SUPPORTED_FEATURE_CONSTELLATION_ENABLEMENT_V02)) {
|
||||
LOC_LOGe("Feature constellation enablement not supported.");
|
||||
err = LOCATION_ERROR_NOT_SUPPORTED;
|
||||
} else {
|
||||
// Send the SV ID Config to Modem
|
||||
err = adapter.gnssSvIdConfigUpdateSync(gnssConfigRequested.blacklistedSvIds);
|
||||
if (LOCATION_ERROR_SUCCESS != err) {
|
||||
LOC_LOGe("Failed to send config to modem, err %d", err);
|
||||
}
|
||||
}
|
||||
if (index < countOfConfigs) {
|
||||
errsList[index] = err;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
configCollectiveResponse->returnToSender(errsList);
|
||||
}));
|
||||
}
|
||||
|
|
|
@ -175,6 +175,7 @@ class GnssAdapter : public LocAdapterBase {
|
|||
std::string mMoServerUrl;
|
||||
XtraSystemStatusObserver mXtraObserver;
|
||||
LocationSystemInfo mLocSystemInfo;
|
||||
std::vector<GnssSvIdSource> mBlacklistedSvIds;
|
||||
|
||||
/* === Misc ===================================================================== */
|
||||
BlockCPIInfo mBlockCPIInfo;
|
||||
|
@ -278,6 +279,9 @@ public:
|
|||
uint32_t gnssDeleteAidingDataCommand(GnssAidingData& data);
|
||||
void deleteAidingData(const GnssAidingData &data, uint32_t sessionId);
|
||||
void gnssUpdateXtraThrottleCommand(const bool enabled);
|
||||
std::vector<LocationError> gnssUpdateConfig(const std::string& oldServerUrl,
|
||||
const std::string& oldMoServerUrl, const GnssConfig& gnssConfigRequested,
|
||||
const GnssConfig& gnssConfigNeedEngineUpdate, size_t count = 0);
|
||||
|
||||
/* ==== GNSS SV TYPE CONFIG ============================================================ */
|
||||
/* ==== COMMANDS ====(Called from Client Thread)======================================== */
|
||||
|
|
Loading…
Reference in a new issue