From a66440949c8b4ebfd72d15e6298f787497632704 Mon Sep 17 00:00:00 2001 From: Yingjie Wang Date: Wed, 10 Jul 2019 13:02:35 +0800 Subject: 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 +++++++++++++++++++------------------------------ 1 file changed, 19 insertions(+), 30 deletions(-) (limited to 'gnss/GnssAdapter.cpp') diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 9413def..645ac01 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); })); -- cgit v1.2.3 From fc6f5be4f883675a38d7dd487820e49417fbc0b5 Mon Sep 17 00:00:00 2001 From: Dante Russo Date: Sat, 20 Jul 2019 10:26:55 -0700 Subject: Fix potential NMEA event registration issue The NMEA event may not be registered because of a race condition. Change-Id: Icc04039f0b3a3bc34101b667778881323edf9131 CRs-fixed: 2493919 --- gnss/GnssAdapter.cpp | 234 +++++++++++++++++++++++++-------------------------- 1 file changed, 115 insertions(+), 119 deletions(-) (limited to 'gnss/GnssAdapter.cpp') diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index ef4664b..a393fc8 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -681,130 +681,125 @@ GnssAdapter::setSuplHostServer(const char* server, int port, LocServerType type) } void -GnssAdapter::setConfigCommand() +GnssAdapter::setConfig() { LOC_LOGD("%s]: ", __func__); - struct MsgSetConfig : public LocMsg { - GnssAdapter& mAdapter; - LocApiBase& mApi; - inline MsgSetConfig(GnssAdapter& adapter, LocApiBase& api) : - LocMsg(), - mAdapter(adapter), - mApi(api) {} - inline virtual void proc() const { - if (!mAdapter.isEngineCapabilitiesKnown()) { - mAdapter.mPendingMsgs.push_back(new MsgSetConfig(*this)); - return; - } - // set nmea mask type - uint32_t mask = 0; - if (NMEA_PROVIDER_MP == ContextBase::mGps_conf.NMEA_PROVIDER) { - mask |= LOC_NMEA_ALL_GENERAL_SUPPORTED_MASK; - } - if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_DEBUG_NMEA_V02)) { - mask |= LOC_NMEA_MASK_DEBUG_V02; + // set nmea mask type + uint32_t mask = 0; + if (NMEA_PROVIDER_MP == ContextBase::mGps_conf.NMEA_PROVIDER) { + mask |= LOC_NMEA_ALL_GENERAL_SUPPORTED_MASK; + } + if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_DEBUG_NMEA_V02)) { + mask |= LOC_NMEA_MASK_DEBUG_V02; + } + if (mNmeaMask != mask) { + mNmeaMask = mask; + if (mNmeaMask) { + for (auto it=mClientData.begin(); it != mClientData.end(); ++it) { + if ((it->second.gnssNmeaCb != nullptr)) { + updateEvtMask(LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT, + LOC_REGISTRATION_MASK_ENABLED); + break; + } } - mAdapter.mNmeaMask= mask; - - std::string oldMoServerUrl = mAdapter.getMoServerUrl(); - mAdapter.setSuplHostServer(ContextBase::mGps_conf.SUPL_HOST, - ContextBase::mGps_conf.SUPL_PORT, - LOC_AGPS_SUPL_SERVER); - mAdapter.setSuplHostServer(ContextBase::mGps_conf.MO_SUPL_HOST, - ContextBase::mGps_conf.MO_SUPL_PORT, - LOC_AGPS_MO_SUPL_SERVER); - - // inject the configurations into modem - GnssAdapter& adapter = mAdapter; - loc_gps_cfg_s gpsConf = ContextBase::mGps_conf; - loc_sap_cfg_s_type sapConf = ContextBase::mSap_conf; - - //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 = gpsConf.GPS_LOCK; - - if (gpsConf.AGPS_CONFIG_INJECT) { - 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 | - GNSS_CONFIG_FLAGS_LPP_PROFILE_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; - } - 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()); - mApi.sendMsg(new LocApiMsg( - [&adapter, gpsConf, sapConf, oldMoServerUrl, gnssConfigRequested] () { - adapter.gnssUpdateConfig(oldMoServerUrl, gnssConfigRequested, gnssConfigRequested); - - // set nmea mask type - uint32_t mask = 0; - if (NMEA_PROVIDER_MP == gpsConf.NMEA_PROVIDER) { - mask |= LOC_NMEA_ALL_GENERAL_SUPPORTED_MASK; - } - if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_DEBUG_NMEA_V02)) { - mask |= LOC_NMEA_MASK_DEBUG_V02; - } - - if (mask != 0) { - adapter.mLocApi->setNMEATypesSync(mask); - } - - adapter.mLocApi->setXtraVersionCheckSync(gpsConf.XTRA_VERSION_CHECK); - - adapter.mLocApi->setConstrainedTuncMode( - gpsConf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED == 1, - (float)gpsConf.CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD, - gpsConf.CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET); - adapter.mLocApi->setPositionAssistedClockEstimatorMode( - gpsConf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED == 1); - - if (sapConf.GYRO_BIAS_RANDOM_WALK_VALID || - sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID || - sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID || - sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID || - sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID ) { - adapter.mLocApi->setSensorPropertiesSync( - sapConf.GYRO_BIAS_RANDOM_WALK_VALID, - sapConf.GYRO_BIAS_RANDOM_WALK, - sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID, - sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY, - sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, - sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY, - sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, - sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY, - sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID, - sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY); - } - adapter.mLocApi->setSensorPerfControlConfigSync( - sapConf.SENSOR_CONTROL_MODE, - sapConf.SENSOR_ACCEL_SAMPLES_PER_BATCH, - sapConf.SENSOR_ACCEL_BATCHES_PER_SEC, - sapConf.SENSOR_GYRO_SAMPLES_PER_BATCH, - sapConf.SENSOR_GYRO_BATCHES_PER_SEC, - sapConf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH, - sapConf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH, - sapConf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH, - sapConf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH, - sapConf.SENSOR_ALGORITHM_CONFIG_MASK); - } )); } - }; + } + + std::string oldMoServerUrl = getMoServerUrl(); + setSuplHostServer(ContextBase::mGps_conf.SUPL_HOST, + ContextBase::mGps_conf.SUPL_PORT, + LOC_AGPS_SUPL_SERVER); + setSuplHostServer(ContextBase::mGps_conf.MO_SUPL_HOST, + ContextBase::mGps_conf.MO_SUPL_PORT, + LOC_AGPS_MO_SUPL_SERVER); + + // inject the configurations into modem + loc_gps_cfg_s gpsConf = ContextBase::mGps_conf; + loc_sap_cfg_s_type sapConf = ContextBase::mSap_conf; + + //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 = gpsConf.GPS_LOCK; + + if (gpsConf.AGPS_CONFIG_INJECT) { + 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 | + GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT; + gnssConfigRequested.suplVersion = + mLocApi->convertSuplVersion(gpsConf.SUPL_VER); + gnssConfigRequested.lppProfile = + mLocApi->convertLppProfile(gpsConf.LPP_PROFILE); + gnssConfigRequested.aGlonassPositionProtocolMask = + gpsConf.A_GLONASS_POS_PROTOCOL_SELECT; + } + gnssConfigRequested.lppeControlPlaneMask = + mLocApi->convertLppeCp(gpsConf.LPPE_CP_TECHNOLOGY); + gnssConfigRequested.lppeUserPlaneMask = + mLocApi->convertLppeUp(gpsConf.LPPE_UP_TECHNOLOGY); + gnssConfigRequested.blacklistedSvIds.assign(mBlacklistedSvIds.begin(), + mBlacklistedSvIds.end()); + mLocApi->sendMsg(new LocApiMsg( + [this, gpsConf, sapConf, oldMoServerUrl, gnssConfigRequested] () { + gnssUpdateConfig(oldMoServerUrl, gnssConfigRequested, gnssConfigRequested); + + // set nmea mask type + uint32_t mask = 0; + if (NMEA_PROVIDER_MP == gpsConf.NMEA_PROVIDER) { + mask |= LOC_NMEA_ALL_GENERAL_SUPPORTED_MASK; + } + if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_DEBUG_NMEA_V02)) { + mask |= LOC_NMEA_MASK_DEBUG_V02; + } + + if (mask != 0) { + mLocApi->setNMEATypesSync(mask); + } + + mLocApi->setXtraVersionCheckSync(gpsConf.XTRA_VERSION_CHECK); + + mLocApi->setConstrainedTuncMode( + gpsConf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED == 1, + (float)gpsConf.CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD, + gpsConf.CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET); + mLocApi->setPositionAssistedClockEstimatorMode( + gpsConf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED == 1); + + if (sapConf.GYRO_BIAS_RANDOM_WALK_VALID || + sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID || + sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID || + sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID || + sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID ) { + mLocApi->setSensorPropertiesSync( + sapConf.GYRO_BIAS_RANDOM_WALK_VALID, + sapConf.GYRO_BIAS_RANDOM_WALK, + sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID, + sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY, + sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, + sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY, + sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, + sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY, + sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID, + sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY); + } + mLocApi->setSensorPerfControlConfigSync( + sapConf.SENSOR_CONTROL_MODE, + sapConf.SENSOR_ACCEL_SAMPLES_PER_BATCH, + sapConf.SENSOR_ACCEL_BATCHES_PER_SEC, + sapConf.SENSOR_GYRO_SAMPLES_PER_BATCH, + sapConf.SENSOR_GYRO_BATCHES_PER_SEC, + sapConf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH, + sapConf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH, + sapConf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH, + sapConf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH, + sapConf.SENSOR_ALGORITHM_CONFIG_MASK); + } )); - sendMsg(new MsgSetConfig(*this, *mLocApi)); } std::vector GnssAdapter::gnssUpdateConfig(const std::string& oldMoServerUrl, @@ -2075,6 +2070,8 @@ GnssAdapter::handleEngineUpEvent() virtual void proc() const { mAdapter.setEngineCapabilitiesKnown(true); mAdapter.broadcastCapabilities(mAdapter.getCapabilities()); + // must be called only after capabilities are known + mAdapter.setConfig(); mAdapter.restartSessions(); mAdapter.gnssSvIdConfigUpdate(); mAdapter.gnssSvTypeConfigUpdate(); @@ -2086,7 +2083,6 @@ GnssAdapter::handleEngineUpEvent() }; readConfigCommand(); - setConfigCommand(); sendMsg(new MsgHandleEngineUpEvent(*this)); } -- cgit v1.2.3 From 8a6244be7c1debde865c7770b786ee48b5f06b13 Mon Sep 17 00:00:00 2001 From: Mike Cailean Date: Thu, 11 Jul 2019 10:59:46 -0700 Subject: Allow NFW enable/disable as in 'P' Make changes in HAL coupled with a few recommended changes in JAVA/JNI layer to allow 'P' behavior for setting NFW GPS LOCK Change-Id: I6580eaeffefe0c10bc226660439701057e09e4a4 CRs-fixed: 2488332 --- gnss/GnssAdapter.cpp | 84 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 66 insertions(+), 18 deletions(-) (limited to 'gnss/GnssAdapter.cpp') diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index a393fc8..252b76c 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -73,7 +73,7 @@ GnssAdapter::GnssAdapter() : mGnssSvIdUsedInPosition(), mGnssSvIdUsedInPosAvail(false), mControlCallbacks(), - mPowerVoteId(0), + mAfwControlId(0), mNmeaMask(0), mGnssSvIdConfig(), mGnssSvTypeConfig(), @@ -97,7 +97,8 @@ GnssAdapter::GnssAdapter() : mPowerStateCb(nullptr), mIsE911Session(NULL), mGnssMbSvIdUsedInPosition{}, - mGnssMbSvIdUsedInPosAvail(false) + mGnssMbSvIdUsedInPosAvail(false), + mSupportNfwControl(true) { LOC_LOGD("%s]: Constructor %p", __func__, this); mLocPositionMode.mode = LOC_POSITION_MODE_INVALID; @@ -724,7 +725,24 @@ GnssAdapter::setConfig() 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 = gpsConf.GPS_LOCK; + /* Here we process an SSR. We need to set the GPS_LOCK to the proper values, as follows: + 1. Q behavior. This is identified by mSupportNfwControl being 1. In this case + ContextBase::mGps_conf.GPS_LOCK is a "state", meaning it should reflect the + NV value. Therefore we will set the NV to ContextBase::mGps_conf.GPS_LOCK + 2. P behavior. This is identified by mSupportNfwControl being 0. In this case + ContextBase::mGps_conf.GPS_LOCK is a "configuration", meaning it should hold + the "mask" for NI. There are two subcases: + a. Location enabled in GUI (1 == getAfwControlId()). We need to set + the NV to GNSS_CONFIG_GPS_LOCK_NONE (both MO and NI enabled) + b. Location disabled in GUI (0 == getAfwControlId()). We need to set + the NV to ContextBase::mGps_conf.GPS_LOCK (the "mask", which is SIM-card + specific) + */ + if (mSupportNfwControl || (0 == getAfwControlId())) { + gnssConfigRequested.gpsLock = gpsConf.GPS_LOCK; + } else { + gnssConfigRequested.gpsLock = GNSS_CONFIG_GPS_LOCK_NONE; + } if (gpsConf.AGPS_CONFIG_INJECT) { gnssConfigRequested.flags |= GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT | @@ -1067,8 +1085,31 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config) if (GNSS_CONFIG_GPS_LOCK_NONE == newGpsLock) { newGpsLock = GNSS_CONFIG_GPS_LOCK_MO; } - gnssConfigNeedEngineUpdate.flags &= ~(GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT); ContextBase::mGps_conf.GPS_LOCK = newGpsLock; + /* If we get here it means that the changes in the framework to request for + 'P' behavior were made, and therefore we need to "behave" as in 'P' + However, we need to determine if enableCommand function has already been + called, since it could get called before this function.*/ + if (0 != mAdapter.getAfwControlId()) { + /* enableCommand function has already been called since getAfwControlId + returns non zero. Now there are two possible cases: + 1. This is the first time this function is called + (mSupportNfwControl is true). We need to behave as in 'P', but + for the first time, meaning MO was enabled, but NI was not, so + we need to unlock NI + 2. This is not the first time this function is called, meaning we + are already behaving as in 'P'. No need to update the configuration + in this case (return to 'P' code) */ + if (mAdapter.mSupportNfwControl) { + // case 1 above + newGpsLock &= ~GNSS_CONFIG_GPS_LOCK_NI; + } else { + // case 2 above + gnssConfigNeedEngineUpdate.flags &= ~(GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT); + } + } + gnssConfigRequested.gpsLock = newGpsLock; + mAdapter.mSupportNfwControl = false; index++; } if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) { @@ -2926,18 +2967,20 @@ GnssAdapter::enableCommand(LocationTechnologyType techType) mTechType(techType) {} inline virtual void proc() const { LocationError err = LOCATION_ERROR_SUCCESS; - uint32_t powerVoteId = mAdapter.getAfwControlId(); + uint32_t afwControlId = mAdapter.getAfwControlId(); if (mTechType != LOCATION_TECHNOLOGY_TYPE_GNSS) { err = LOCATION_ERROR_INVALID_PARAMETER; - } else if (powerVoteId > 0) { + } else if (afwControlId > 0) { err = LOCATION_ERROR_ALREADY_STARTED; } else { mContext.modemPowerVote(true); mAdapter.setAfwControlId(mSessionId); GnssConfigGpsLock gpsLock = GNSS_CONFIG_GPS_LOCK_NONE; - ContextBase::mGps_conf.GPS_LOCK &= GNSS_CONFIG_GPS_LOCK_NI; - gpsLock = ContextBase::mGps_conf.GPS_LOCK; + if (mAdapter.mSupportNfwControl) { + ContextBase::mGps_conf.GPS_LOCK &= GNSS_CONFIG_GPS_LOCK_NI; + gpsLock = ContextBase::mGps_conf.GPS_LOCK; + } mApi.sendMsg(new LocApiMsg([&mApi = mApi, gpsLock]() { mApi.setGpsLockSync(gpsLock); })); @@ -2977,21 +3020,22 @@ GnssAdapter::disableCommand(uint32_t id) mSessionId(sessionId) {} inline virtual void proc() const { LocationError err = LOCATION_ERROR_SUCCESS; - uint32_t powerVoteId = mAdapter.getAfwControlId(); - if (powerVoteId != mSessionId) { + uint32_t afwControlId = mAdapter.getAfwControlId(); + if (afwControlId != mSessionId) { err = LOCATION_ERROR_ID_UNKNOWN; } else { mContext.modemPowerVote(false); mAdapter.setAfwControlId(0); - /* We need to disable MO (AFW) */ - ContextBase::mGps_conf.GPS_LOCK |= GNSS_CONFIG_GPS_LOCK_MO; + if (mAdapter.mSupportNfwControl) { + /* We need to disable MO (AFW) */ + ContextBase::mGps_conf.GPS_LOCK |= GNSS_CONFIG_GPS_LOCK_MO; + } GnssConfigGpsLock gpsLock = ContextBase::mGps_conf.GPS_LOCK; - mApi.sendMsg(new LocApiMsg([&mApi = mApi,gpsLock] () { + mApi.sendMsg(new LocApiMsg([&mApi = mApi, gpsLock]() { mApi.setGpsLockSync(gpsLock); })); - mAdapter.mXtraObserver.updateLockStatus( - ContextBase::mGps_conf.GPS_LOCK); + mAdapter.mXtraObserver.updateLockStatus(gpsLock); } mAdapter.reportResponse(err, mSessionId); } @@ -4775,11 +4819,11 @@ GnssAdapter::getGnssEnergyConsumedCommand(GnssEnergyConsumedCallback energyConsu void GnssAdapter::nfwControlCommand(bool enable) { - struct MsgenableNfwLocationAccess : public LocMsg { + struct MsgControlNfwLocationAccess : public LocMsg { GnssAdapter& mAdapter; LocApiBase& mApi; bool mEnable; - inline MsgenableNfwLocationAccess(GnssAdapter& adapter, LocApiBase& api, + inline MsgControlNfwLocationAccess(GnssAdapter& adapter, LocApiBase& api, bool enable) : LocMsg(), mAdapter(adapter), @@ -4801,7 +4845,11 @@ GnssAdapter::nfwControlCommand(bool enable) { } }; - sendMsg(new MsgenableNfwLocationAccess(*this, *mLocApi, enable)); + if (mSupportNfwControl) { + sendMsg(new MsgControlNfwLocationAccess(*this, *mLocApi, enable)); + } else { + LOC_LOGw("NFW control is not supported, do not use this for NFW"); + } } /* ==== Eng Hub Proxy ================================================================= */ -- cgit v1.2.3 From 818dacd2345041fd13ab96b5beefa1480689a519 Mon Sep 17 00:00:00 2001 From: Mike Cailean Date: Tue, 30 Jul 2019 18:35:42 -0700 Subject: GPS_LOCK has the wrong value after killing GNSS process CRs-fixed: 2500864 Change-Id: I5b6cd779ef5c378eedfb54b74b29dbf3191784a1 --- gnss/GnssAdapter.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'gnss/GnssAdapter.cpp') diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 252b76c..47e5527 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -1082,9 +1082,8 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config) if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) { GnssConfigGpsLock newGpsLock = gnssConfigRequested.gpsLock; - if (GNSS_CONFIG_GPS_LOCK_NONE == newGpsLock) { - newGpsLock = GNSS_CONFIG_GPS_LOCK_MO; - } + + newGpsLock |= GNSS_CONFIG_GPS_LOCK_MO; ContextBase::mGps_conf.GPS_LOCK = newGpsLock; /* If we get here it means that the changes in the framework to request for 'P' behavior were made, and therefore we need to "behave" as in 'P' @@ -1102,7 +1101,7 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config) in this case (return to 'P' code) */ if (mAdapter.mSupportNfwControl) { // case 1 above - newGpsLock &= ~GNSS_CONFIG_GPS_LOCK_NI; + newGpsLock = GNSS_CONFIG_GPS_LOCK_NONE; } else { // case 2 above gnssConfigNeedEngineUpdate.flags &= ~(GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT); -- cgit v1.2.3