From a66440949c8b4ebfd72d15e6298f787497632704 Mon Sep 17 00:00:00 2001 From: Yingjie Wang Date: Wed, 10 Jul 2019 13:02:35 +0800 Subject: [PATCH] Drop SUPL URL dup check in set and update command Get rid of Supl url duplication check both in setConfig and updateConfig commands. Also clean gnssUpdateConfig() params Change-Id: I432995a44c08192955bd50630649120933006ff9 CRs-fixed: 2487784 --- gnss/GnssAdapter.cpp | 49 +++++++++++++++++--------------------------- gnss/GnssAdapter.h | 4 ++-- 2 files changed, 21 insertions(+), 32 deletions(-) diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 9413def6..645ac013 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -666,17 +666,15 @@ GnssAdapter::setSuplHostServer(const char* server, int port, LocServerType type) } if (LOC_AGPS_SUPL_SERVER != type && LOC_AGPS_MO_SUPL_SERVER != type) { LOC_LOGe("Invalid type=%d", type); - } else { - string& url = (LOC_AGPS_SUPL_SERVER == type) ? getServerUrl() : getMoServerUrl(); - if (length >= 0 && strncasecmp(url.c_str(), serverUrl, sizeof(serverUrl)) != 0) { - url.assign(serverUrl); - - if (LOC_AGPS_SUPL_SERVER == type) { - strlcpy(ContextBase::mGps_conf.SUPL_HOST, server, LOC_MAX_PARAM_STRING); - ContextBase::mGps_conf.SUPL_PORT = port; + } else if (length >= 0) { + if (LOC_AGPS_SUPL_SERVER == type) { + getServerUrl().assign(serverUrl); + strlcpy(ContextBase::mGps_conf.SUPL_HOST, server, LOC_MAX_PARAM_STRING); + ContextBase::mGps_conf.SUPL_PORT = port; + } else { + if (strncasecmp(getMoServerUrl().c_str(), serverUrl, sizeof(serverUrl)) != 0) { + getMoServerUrl().assign(serverUrl); } - - LOC_LOGv("serverUrl=%s length=%d type=%d", serverUrl, length, type); } } } @@ -709,7 +707,6 @@ GnssAdapter::setConfigCommand() } mAdapter.mNmeaMask= mask; - std::string oldServerUrl = mAdapter.getServerUrl(); std::string oldMoServerUrl = mAdapter.getMoServerUrl(); mAdapter.setSuplHostServer(ContextBase::mGps_conf.SUPL_HOST, ContextBase::mGps_conf.SUPL_PORT, @@ -750,10 +747,8 @@ GnssAdapter::setConfigCommand() gnssConfigRequested.blacklistedSvIds.assign(adapter.mBlacklistedSvIds.begin(), adapter.mBlacklistedSvIds.end()); mApi.sendMsg(new LocApiMsg( - [&adapter, gpsConf, sapConf, oldServerUrl, - oldMoServerUrl, gnssConfigRequested] () { - adapter.gnssUpdateConfig(oldServerUrl, oldMoServerUrl, gnssConfigRequested, - gnssConfigRequested); + [&adapter, gpsConf, sapConf, oldMoServerUrl, gnssConfigRequested] () { + adapter.gnssUpdateConfig(oldMoServerUrl, gnssConfigRequested, gnssConfigRequested); // set nmea mask type uint32_t mask = 0; @@ -812,8 +807,8 @@ GnssAdapter::setConfigCommand() sendMsg(new MsgSetConfig(*this, *mLocApi)); } -std::vector GnssAdapter::gnssUpdateConfig(const std::string& oldServerUrl, - const std::string& oldMoServerUrl, const GnssConfig& gnssConfigRequested, +std::vector GnssAdapter::gnssUpdateConfig(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; @@ -846,13 +841,10 @@ std::vector GnssAdapter::gnssUpdateConfig(const std::string& oldS GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) { if (gnssConfigNeedEngineUpdate.assistanceServer.type == GNSS_ASSISTANCE_TYPE_SUPL) { - if (0 != oldServerUrl.compare(serverUrl)) { - - err = mLocApi->setServerSync( - serverUrl.c_str(), serverUrlLen, LOC_AGPS_SUPL_SERVER); - if (index < count) { - errsList[index] = err; - } + err = mLocApi->setServerSync( + serverUrl.c_str(), serverUrlLen, LOC_AGPS_SUPL_SERVER); + if (index < count) { + errsList[index] = err; } if (0 != oldMoServerUrl.compare(moServerUrl)) { LocationError locErr = @@ -1069,7 +1061,6 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config) size_t countOfConfigs = mCount; GnssConfig gnssConfigRequested = mConfig; GnssConfig gnssConfigNeedEngineUpdate = mConfig; - std::string oldServerUrl = mAdapter.getServerUrl(); std::vector sessionIds; sessionIds.assign(mIds, mIds + mCount); @@ -1162,11 +1153,9 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config) mApi.sendMsg(new LocApiMsg( [&adapter, gnssConfigRequested, gnssConfigNeedEngineUpdate, - countOfConfigs, configCollectiveResponse, errs, oldServerUrl] () { - std::string serverUrl = adapter.getServerUrl(); - int serverUrlLen = serverUrl.length(); - std::vector errsList = adapter.gnssUpdateConfig(oldServerUrl, - "", gnssConfigRequested, gnssConfigNeedEngineUpdate, countOfConfigs); + countOfConfigs, configCollectiveResponse, errs] () { + std::vector errsList = adapter.gnssUpdateConfig("", + gnssConfigRequested, gnssConfigNeedEngineUpdate, countOfConfigs); configCollectiveResponse->returnToSender(errsList); })); diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h index 9a727a20..52004222 100644 --- a/gnss/GnssAdapter.h +++ b/gnss/GnssAdapter.h @@ -289,8 +289,8 @@ public: uint32_t gnssDeleteAidingDataCommand(GnssAidingData& data); void deleteAidingData(const GnssAidingData &data, uint32_t sessionId); void gnssUpdateXtraThrottleCommand(const bool enabled); - std::vector gnssUpdateConfig(const std::string& oldServerUrl, - const std::string& oldMoServerUrl, const GnssConfig& gnssConfigRequested, + std::vector gnssUpdateConfig(const std::string& oldMoServerUrl, + const GnssConfig& gnssConfigRequested, const GnssConfig& gnssConfigNeedEngineUpdate, size_t count = 0); /* ==== GNSS SV TYPE CONFIG ============================================================ */