summaryrefslogtreecommitdiff
path: root/gnss
diff options
context:
space:
mode:
authorCyan_Hsieh <cyanhsieh@google.com>2019-12-30 18:26:47 +0800
committerCyan_Hsieh <cyanhsieh@google.com>2019-12-30 18:28:33 +0800
commitc81977c14bd9c7ae1cdd2e297cfa6681fe662546 (patch)
treec694b598b1b0a2e58bdf28bf1acb670f6000ba4b /gnss
parente88586065a860ca114e0e4e8c072618a54fd758a (diff)
parentd71529af0f5b103cdbe2679148bd7268cb4713b8 (diff)
downloadgps-c81977c14bd9c7ae1cdd2e297cfa6681fe662546.tar.gz
Merge remote-tracking branch 'goog/qcom/release/LA.UM.8.1.C9.09.00.00.518.370' into qt-qpr1-dev
Bug: 146991028 Change-Id: I9f84a0fac45ecd4552d265a4686f73a4cbe73638
Diffstat (limited to 'gnss')
-rw-r--r--gnss/GnssAdapter.cpp297
-rw-r--r--gnss/GnssAdapter.h33
-rw-r--r--gnss/location_gnss.cpp57
3 files changed, 378 insertions, 9 deletions
diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp
index 339f9a0..4dbd182 100644
--- a/gnss/GnssAdapter.cpp
+++ b/gnss/GnssAdapter.cpp
@@ -80,6 +80,7 @@ GnssAdapter::GnssAdapter() :
mGnssSvIdConfig(),
mGnssSvTypeConfig(),
mGnssSvTypeConfigCb(nullptr),
+ mLocConfigInfo{},
mNiData(),
mAgpsManager(),
mOdcpiRequestCb(nullptr),
@@ -533,6 +534,8 @@ inline uint32_t
GnssAdapter::convertSuplVersion(const GnssConfigSuplVersion suplVersion)
{
switch (suplVersion) {
+ case GNSS_CONFIG_SUPL_VERSION_2_0_4:
+ return 0x00020004;
case GNSS_CONFIG_SUPL_VERSION_2_0_0:
return 0x00020000;
case GNSS_CONFIG_SUPL_VERSION_2_0_2:
@@ -829,12 +832,32 @@ GnssAdapter::setConfig()
mLocApi->setXtraVersionCheckSync(gpsConf.XTRA_VERSION_CHECK);
+ // load tunc configuration from config file on first boot-up,
+ // e.g.: adapter.mLocConfigInfo.tuncConfigInfo.isValid is false
+ if (mLocConfigInfo.tuncConfigInfo.isValid == false) {
+ mLocConfigInfo.tuncConfigInfo.isValid = true;
+ mLocConfigInfo.tuncConfigInfo.enable =
+ (gpsConf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED == 1);
+ mLocConfigInfo.tuncConfigInfo.tuncThresholdMs =
+ (float)gpsConf.CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD;
+ mLocConfigInfo.tuncConfigInfo.energyBudget =
+ gpsConf.CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET;
+ }
+
mLocApi->setConstrainedTuncMode(
- gpsConf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED == 1,
- (float)gpsConf.CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD,
- gpsConf.CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET);
+ mLocConfigInfo.tuncConfigInfo.enable,
+ mLocConfigInfo.tuncConfigInfo.tuncThresholdMs,
+ mLocConfigInfo.tuncConfigInfo.energyBudget);
+
+ // load pace configuration from config file on first boot-up,
+ // e.g.: adapter.mLocConfigInfo.paceConfigInfo.isValid is false
+ if (mLocConfigInfo.paceConfigInfo.isValid == false) {
+ mLocConfigInfo.paceConfigInfo.isValid = true;
+ mLocConfigInfo.paceConfigInfo.enable =
+ (gpsConf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED==1);
+ }
mLocApi->setPositionAssistedClockEstimatorMode(
- gpsConf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED == 1);
+ mLocConfigInfo.paceConfigInfo.enable);
if (sapConf.GYRO_BIAS_RANDOM_WALK_VALID ||
sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID ||
@@ -3374,10 +3397,11 @@ GnssAdapter::reportPosition(const UlpLocation& ulpLocation,
}
}
- // if engine hub is running and the fix is from sensor, e.g.: DRE,
- // inject DRE fix to modem
- if ((1 == ContextBase::mGps_conf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED) &&
- (true == initEngHubProxy()) && (LOC_POS_TECH_MASK_SENSORS & techMask)) {
+ // if PACE is enabled and engine hub is running and the fix is from sensor,
+ // e.g.: DRE, inject DRE fix to modem
+ if ((true == mLocConfigInfo.paceConfigInfo.isValid &&
+ true == mLocConfigInfo.paceConfigInfo.enable) &&
+ (true == initEngHubProxy()) && (LOC_POS_TECH_MASK_SENSORS & techMask)) {
mLocApi->injectPosition(locationInfo, false);
}
}
@@ -5059,6 +5083,263 @@ GnssAdapter::nfwControlCommand(bool enable) {
}
}
+// Set tunc constrained mode, use 0 session id to indicate
+// that no callback is needed. Session id 0 is used for calls that
+// are not invoked from the integration api, e.g.: initial configuration
+// from the configure file
+void
+GnssAdapter::setConstrainedTunc(bool enable, float tuncConstraint,
+ uint32_t energyBudget, uint32_t sessionId) {
+
+ mLocConfigInfo.tuncConfigInfo.isValid = true;
+ mLocConfigInfo.tuncConfigInfo.enable = enable;
+ mLocConfigInfo.tuncConfigInfo.tuncThresholdMs = tuncConstraint;
+ mLocConfigInfo.tuncConfigInfo.energyBudget = energyBudget;
+
+ LocApiResponse* locApiResponse = nullptr;
+ if (sessionId != 0) {
+ locApiResponse =
+ new LocApiResponse(*getContext(),
+ [this, sessionId] (LocationError err) {
+ reportResponse(err, sessionId);});
+ if (!locApiResponse) {
+ LOC_LOGe("memory alloc failed");
+ }
+ }
+ mLocApi->setConstrainedTuncMode(
+ enable, tuncConstraint, energyBudget, locApiResponse);
+}
+
+uint32_t
+GnssAdapter::setConstrainedTuncCommand (bool enable, float tuncConstraint,
+ uint32_t energyBudget) {
+ // generated session id will be none-zero
+ uint32_t sessionId = generateSessionId();
+ LOC_LOGd("session id %u", sessionId);
+
+ struct MsgEnableTUNC : public LocMsg {
+ GnssAdapter& mAdapter;
+ uint32_t mSessionId;
+ bool mEnable;
+ float mTuncConstraint;
+ uint32_t mEnergyBudget;
+
+ inline MsgEnableTUNC(GnssAdapter& adapter,
+ uint32_t sessionId,
+ bool enable,
+ float tuncConstraint,
+ uint32_t energyBudget) :
+ LocMsg(),
+ mAdapter(adapter),
+ mSessionId(sessionId),
+ mEnable(enable),
+ mTuncConstraint(tuncConstraint),
+ mEnergyBudget(energyBudget) {}
+ inline virtual void proc() const {
+ mAdapter.setConstrainedTunc(mEnable, mTuncConstraint,
+ mEnergyBudget, mSessionId);
+ }
+ };
+
+ sendMsg(new MsgEnableTUNC(*this, sessionId, enable,
+ tuncConstraint, energyBudget));
+
+ return sessionId;
+}
+
+// Set position assisted clock estimator, use 0 session id to indicate
+// that no callback is needed. Session id 0 is used for calls that are
+// not invoked from the integration api, e.g.: initial configuration
+// from the configure file.
+void
+GnssAdapter::setPositionAssistedClockEstimator(bool enable,
+ uint32_t sessionId) {
+
+ mLocConfigInfo.paceConfigInfo.isValid = true;
+ mLocConfigInfo.paceConfigInfo.enable = enable;
+ LocApiResponse* locApiResponse = nullptr;
+ if (sessionId != 0) {
+ locApiResponse =
+ new LocApiResponse(*getContext(),
+ [this, sessionId] (LocationError err) {
+ reportResponse(err, sessionId);});
+ if (!locApiResponse) {
+ LOC_LOGe("memory alloc failed");
+ }
+ }
+ mLocApi->setPositionAssistedClockEstimatorMode(enable, locApiResponse);
+}
+
+uint32_t
+GnssAdapter::setPositionAssistedClockEstimatorCommand(bool enable) {
+ // generated session id will be none-zero
+ uint32_t sessionId = generateSessionId();
+ LOC_LOGd("session id %u", sessionId);
+
+ struct MsgEnablePACE : public LocMsg {
+ GnssAdapter& mAdapter;
+ uint32_t mSessionId;
+ bool mEnable;
+ inline MsgEnablePACE(GnssAdapter& adapter,
+ uint32_t sessionId, bool enable) :
+ LocMsg(),
+ mAdapter(adapter),
+ mSessionId(sessionId),
+ mEnable(enable){}
+ inline virtual void proc() const {
+ mAdapter.setPositionAssistedClockEstimator(mEnable, mSessionId);
+ }
+ };
+
+ sendMsg(new MsgEnablePACE(*this, sessionId, enable));
+ return sessionId;
+}
+
+void
+GnssAdapter::updateSvConfig(uint32_t sessionId,
+ const GnssSvTypeConfig& svTypeConfig,
+ const GnssSvIdConfig& svIdConfig) {
+
+ // check whether if any constellation is removed from the new config
+ GnssSvTypesMask enabledRemoved = mGnssSvTypeConfig.enabledSvTypesMask &
+ (mGnssSvTypeConfig.enabledSvTypesMask ^ svTypeConfig.enabledSvTypesMask);
+ // Send reset if any constellation is removed from the enabled list
+ if (enabledRemoved != 0) {
+ mLocApi->resetConstellationControl();
+ }
+
+ mGnssSvTypeConfig = svTypeConfig;
+ mGnssSvIdConfig = svIdConfig;
+
+ // Send blacklist info
+ mLocApi->setBlacklistSv(mGnssSvIdConfig);
+
+ // Send only enabled constellation config
+ GnssSvTypeConfig svTypeConfigCopy = {sizeof(GnssSvTypeConfig), 0, 0};
+ svTypeConfigCopy.enabledSvTypesMask = mGnssSvTypeConfig.enabledSvTypesMask;
+ LocApiResponse* locApiResponse = new LocApiResponse(*getContext(),
+ [this, sessionId] (LocationError err) {
+ reportResponse(err, sessionId);});
+ if (!locApiResponse) {
+ LOC_LOGe("memory alloc failed");
+ }
+ mLocApi->setConstellationControl(svTypeConfigCopy, locApiResponse);
+}
+
+uint32_t GnssAdapter::gnssUpdateSvConfigCommand(
+ const GnssSvTypeConfig& svTypeConfig,
+ const GnssSvIdConfig& svIdConfig) {
+
+ // generated session id will be none-zero
+ uint32_t sessionId = generateSessionId();
+ LOC_LOGd("session id %u", sessionId);
+
+ struct MsgUpdateSvConfig : public LocMsg {
+ GnssAdapter& mAdapter;
+ uint32_t mSessionId;
+ GnssSvTypeConfig mSvTypeConfig;
+ GnssSvIdConfig mSvIdConfig;
+
+ inline MsgUpdateSvConfig(GnssAdapter& adapter,
+ uint32_t sessionId,
+ const GnssSvTypeConfig& svTypeConfig,
+ const GnssSvIdConfig& svIdConfig) :
+ LocMsg(),
+ mAdapter(adapter),
+ mSessionId(sessionId),
+ mSvTypeConfig(svTypeConfig),
+ mSvIdConfig(svIdConfig) {}
+ inline virtual void proc() const {
+ mAdapter.updateSvConfig(mSessionId, mSvTypeConfig, mSvIdConfig);
+ }
+ };
+
+ if (sessionId != 0) {
+ sendMsg(new MsgUpdateSvConfig(*this, sessionId,
+ svTypeConfig, svIdConfig));
+ }
+ return sessionId;
+}
+
+void
+GnssAdapter::resetSvConfig(uint32_t sessionId) {
+
+ LocApiResponse* locApiResponse = nullptr;
+ if (sessionId != 0) {
+ locApiResponse =
+ new LocApiResponse(*getContext(),
+ [this, sessionId] (LocationError err) {
+ reportResponse(err, sessionId);});
+ if (!locApiResponse) {
+ LOC_LOGe("memory alloc failed");
+ }
+ }
+ mLocApi->resetConstellationControl(locApiResponse);
+}
+
+uint32_t GnssAdapter::gnssResetSvConfigCommand() {
+
+ // generated session id will be none-zero
+ uint32_t sessionId = generateSessionId();
+ LOC_LOGd("session id %u", sessionId);
+
+ struct MsgResetSvConfig : public LocMsg {
+ GnssAdapter& mAdapter;
+ uint32_t mSessionId;
+
+ inline MsgResetSvConfig(GnssAdapter& adapter,
+ uint32_t sessionId) :
+ LocMsg(),
+ mAdapter(adapter),
+ mSessionId(sessionId) {}
+ inline virtual void proc() const {
+ mAdapter.resetSvConfig(mSessionId);
+ }
+ };
+
+ sendMsg(new MsgResetSvConfig(*this, sessionId));
+ return sessionId;
+}
+
+void
+GnssAdapter::configLeverArm(uint32_t sessionId,
+ const LeverArmConfigInfo& configInfo) {
+
+ LocationError err = LOCATION_ERROR_NOT_SUPPORTED;
+ if (true == mEngHubProxy->configLeverArm(configInfo)) {
+ err = LOCATION_ERROR_SUCCESS;
+ }
+ reportResponse(err, sessionId);
+}
+
+uint32_t
+GnssAdapter::configLeverArmCommand(const LeverArmConfigInfo& configInfo) {
+
+ // generated session id will be none-zero
+ uint32_t sessionId = generateSessionId();
+ LOC_LOGd("session id %u", sessionId);
+
+ struct MsgConfigLeverArm : public LocMsg {
+ GnssAdapter& mAdapter;
+ uint32_t mSessionId;
+ LeverArmConfigInfo mConfigInfo;
+
+ inline MsgConfigLeverArm(GnssAdapter& adapter,
+ uint32_t sessionId,
+ const LeverArmConfigInfo& configInfo) :
+ LocMsg(),
+ mAdapter(adapter),
+ mSessionId(sessionId),
+ mConfigInfo(configInfo) {}
+ inline virtual void proc() const {
+ mAdapter.configLeverArm(mSessionId, mConfigInfo);
+ }
+ };
+
+ sendMsg(new MsgConfigLeverArm(*this, sessionId, configInfo));
+ return sessionId;
+}
+
/* ==== Eng Hub Proxy ================================================================= */
/* ======== UTILITIES ================================================================= */
void
diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h
index 37a4892..ff8131f 100644
--- a/gnss/GnssAdapter.h
+++ b/gnss/GnssAdapter.h
@@ -122,6 +122,23 @@ typedef struct {
double latLonDiffThreshold;
} BlockCPIInfo;
+typedef struct {
+ bool isValid;
+ bool enable;
+ float tuncThresholdMs; // need to be specified if enable is true
+ uint32_t energyBudget; // need to be specified if enable is true
+} TuncConfigInfo;
+
+typedef struct {
+ bool isValid;
+ bool enable;
+} PaceConfigInfo;
+
+typedef struct {
+ TuncConfigInfo tuncConfigInfo;
+ PaceConfigInfo paceConfigInfo;
+} LocIntegrationConfigInfo;
+
using namespace loc_core;
namespace loc_core {
@@ -158,6 +175,7 @@ class GnssAdapter : public LocAdapterBase {
GnssSvTypeConfig mGnssSvTypeConfig;
GnssSvTypeConfigCallback mGnssSvTypeConfigCb;
bool mSupportNfwControl;
+ LocIntegrationConfigInfo mLocConfigInfo;
/* ==== NI ============================================================================= */
NiData mNiData;
@@ -270,6 +288,14 @@ public:
const TrackingOptions& updatedOptions, const TrackingOptions& oldOptions);
bool checkAndSetSPEToRunforNHz(TrackingOptions & out);
+ void setConstrainedTunc(bool enable, float tuncConstraint,
+ uint32_t energyBudget, uint32_t sessionId);
+ void setPositionAssistedClockEstimator(bool enable, uint32_t sessionId);
+ void updateSvConfig(uint32_t sessionId, const GnssSvTypeConfig& svTypeConfig,
+ const GnssSvIdConfig& svIdConfig);
+ void resetSvConfig(uint32_t sessionId);
+ void configLeverArm(uint32_t sessionId, const LeverArmConfigInfo& configInfo);
+
/* ==== NI ============================================================================= */
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
void gnssNiResponseCommand(LocationAPI* client, uint32_t id, GnssNiResponse response);
@@ -329,6 +355,13 @@ public:
void dataConnFailedCommand(AGpsExtType agpsType);
void getGnssEnergyConsumedCommand(GnssEnergyConsumedCallback energyConsumedCb);
void nfwControlCommand(bool enable);
+ uint32_t setConstrainedTuncCommand (bool enable, float tuncConstraint,
+ uint32_t energyBudget);
+ uint32_t setPositionAssistedClockEstimatorCommand (bool enable);
+ uint32_t gnssUpdateSvConfigCommand(const GnssSvTypeConfig& svTypeConfig,
+ const GnssSvIdConfig& svIdConfig);
+ uint32_t gnssResetSvConfigCommand();
+ uint32_t configLeverArmCommand(const LeverArmConfigInfo& configInfo);
/* ========= ODCPI ===================================================================== */
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
diff --git a/gnss/location_gnss.cpp b/gnss/location_gnss.cpp
index 5380f05..97e99e4 100644
--- a/gnss/location_gnss.cpp
+++ b/gnss/location_gnss.cpp
@@ -80,6 +80,13 @@ static void blockCPI(double latitude, double longitude, float accuracy,
int blockDurationMsec, double latLonDiffThreshold);
static void updateBatteryStatus(bool charging);
static void updateSystemPowerState(PowerStateType systemPowerState);
+static uint32_t setConstrainedTunc (bool enable, float tuncConstraint,
+ uint32_t energyBudget);
+static uint32_t setPositionAssistedClockEstimator(bool enable);
+static uint32_t gnssUpdateSvConfig(const GnssSvTypeConfig& svTypeConfig,
+ const GnssSvIdConfig& svIdConfig);
+static uint32_t gnssResetSvConfig();
+static uint32_t configLeverArm(const LeverArmConfigInfo& configInfo);
static const GnssInterface gGnssInterface = {
sizeof(GnssInterface),
@@ -119,7 +126,12 @@ static const GnssInterface gGnssInterface = {
getPowerStateChanges,
injectLocationExt,
updateBatteryStatus,
- updateSystemPowerState
+ updateSystemPowerState,
+ setConstrainedTunc,
+ setPositionAssistedClockEstimator,
+ gnssUpdateSvConfig,
+ gnssResetSvConfig,
+ configLeverArm,
};
#ifndef DEBUG_X86
@@ -398,3 +410,46 @@ static void updateSystemPowerState(PowerStateType systemPowerState) {
gGnssAdapter->updateSystemPowerStateCommand(systemPowerState);
}
}
+
+static uint32_t setConstrainedTunc (bool enable, float tuncConstraint, uint32_t energyBudget) {
+ if (NULL != gGnssAdapter) {
+ return gGnssAdapter->setConstrainedTuncCommand(enable, tuncConstraint, energyBudget);
+ } else {
+ return 0;
+ }
+}
+
+static uint32_t setPositionAssistedClockEstimator(bool enable) {
+ if (NULL != gGnssAdapter) {
+ return gGnssAdapter->setPositionAssistedClockEstimatorCommand(enable);
+ } else {
+ return 0;
+ }
+}
+
+static uint32_t gnssUpdateSvConfig(
+ const GnssSvTypeConfig& svTypeConfig,
+ const GnssSvIdConfig& svIdConfig) {
+ if (NULL != gGnssAdapter) {
+ return gGnssAdapter->gnssUpdateSvConfigCommand(
+ svTypeConfig, svIdConfig);
+ } else {
+ return 0;
+ }
+}
+
+static uint32_t gnssResetSvConfig() {
+ if (NULL != gGnssAdapter) {
+ return gGnssAdapter->gnssResetSvConfigCommand();
+ } else {
+ return 0;
+ }
+}
+
+static uint32_t configLeverArm(const LeverArmConfigInfo& configInfo){
+ if (NULL != gGnssAdapter) {
+ return gGnssAdapter->configLeverArmCommand(configInfo);
+ } else {
+ return 0;
+ }
+}