summaryrefslogtreecommitdiff
path: root/gnss/GnssAdapter.cpp
diff options
context:
space:
mode:
authorChengYou Ho <chengyouho@google.com>2019-08-15 07:43:28 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-08-15 07:43:28 -0700
commit2e698cd4c3153d00716f2cd482b9bccb3c68e7b3 (patch)
tree58e34b31010a09cd21b5569d3c2bea5bbf4db307 /gnss/GnssAdapter.cpp
parentbb62c4c8a62a290ce7585e50af790ea0f53b0a47 (diff)
parentfe491feff7d601af038ecea1543791fbd375ecfc (diff)
downloadgps-2e698cd4c3153d00716f2cd482b9bccb3c68e7b3.tar.gz
Merge remote-tracking branch 'goog/qcom/release/LA.UM.8.1.R1.09.00.00.529.074' into qt-qpr1-dev am: 0544c20078
am: fe491feff7 Change-Id: I4de6297172421439ccc1315af4986b51e44ac6bd
Diffstat (limited to 'gnss/GnssAdapter.cpp')
-rw-r--r--gnss/GnssAdapter.cpp176
1 files changed, 94 insertions, 82 deletions
diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp
index 532c6b6..026c1ee 100644
--- a/gnss/GnssAdapter.cpp
+++ b/gnss/GnssAdapter.cpp
@@ -97,8 +97,7 @@ GnssAdapter::GnssAdapter() :
mPowerStateCb(nullptr),
mIsE911Session(NULL),
mGnssMbSvIdUsedInPosition{},
- mGnssMbSvIdUsedInPosAvail(false),
- mGnssSignalType()
+ mGnssMbSvIdUsedInPosAvail(false)
{
LOC_LOGD("%s]: Constructor %p", __func__, this);
mLocPositionMode.mode = LOC_POSITION_MODE_INVALID;
@@ -475,6 +474,16 @@ GnssAdapter::convertLocationInfo(GnssLocationInfoNotification& out,
out.flags |= GNSS_LOCATION_INFO_TIME_UNC_BIT;
out.timeUncMs = locationExtended.timeUncMs;
}
+
+ if (GPS_LOCATION_EXTENDED_HAS_CALIBRATION_CONFIDENCE & locationExtended.flags) {
+ out.flags |= GNSS_LOCATION_INFO_CALIBRATION_CONFIDENCE_BIT;
+ out.calibrationConfidence = locationExtended.calibrationConfidence;
+ }
+
+ if (GPS_LOCATION_EXTENDED_HAS_CALIBRATION_STATUS & locationExtended.flags) {
+ out.flags |= GNSS_LOCATION_INFO_CALIBRATION_STATUS_BIT;
+ out.calibrationStatus = locationExtended.calibrationStatus;
+ }
}
@@ -659,7 +668,7 @@ GnssAdapter::setSuplHostServer(const char* server, int port, LocServerType 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) {
+ if (length >= 0 && strncasecmp(url.c_str(), serverUrl, sizeof(serverUrl)) != 0) {
url.assign(serverUrl);
if (LOC_AGPS_SUPL_SERVER == type) {
@@ -837,7 +846,7 @@ std::vector<LocationError> GnssAdapter::gnssUpdateConfig(const std::string& oldS
GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) {
if (gnssConfigNeedEngineUpdate.assistanceServer.type ==
GNSS_ASSISTANCE_TYPE_SUPL) {
- if ((serverUrlLen != 0) && (oldServerUrl.compare(serverUrl) !=0)) {
+ if (0 != oldServerUrl.compare(serverUrl)) {
err = mLocApi->setServerSync(
serverUrl.c_str(), serverUrlLen, LOC_AGPS_SUPL_SERVER);
@@ -845,7 +854,7 @@ std::vector<LocationError> GnssAdapter::gnssUpdateConfig(const std::string& oldS
errsList[index] = err;
}
}
- if ((moServerUrlLen != 0) && (oldMoServerUrl.compare(moServerUrl) != 0)) {
+ if (0 != oldMoServerUrl.compare(moServerUrl)) {
LocationError locErr =
mLocApi->setServerSync(moServerUrl.c_str(),
moServerUrlLen,
@@ -1080,12 +1089,7 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config)
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) {
uint32_t newSuplVersion =
mAdapter.convertSuplVersion(gnssConfigRequested.suplVersion);
- if (newSuplVersion != ContextBase::mGps_conf.SUPL_VER &&
- ContextBase::mGps_conf.AGPS_CONFIG_INJECT) {
- ContextBase::mGps_conf.SUPL_VER = newSuplVersion;
- } else {
- gnssConfigNeedEngineUpdate.flags &= ~(GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT);
- }
+ ContextBase::mGps_conf.SUPL_VER = newSuplVersion;
index++;
}
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) {
@@ -1104,47 +1108,26 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config)
}
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) {
uint32_t newLppProfile = mAdapter.convertLppProfile(gnssConfigRequested.lppProfile);
- if (newLppProfile != ContextBase::mGps_conf.LPP_PROFILE &&
- ContextBase::mGps_conf.AGPS_CONFIG_INJECT) {
- ContextBase::mGps_conf.LPP_PROFILE = newLppProfile;
- } else {
- gnssConfigNeedEngineUpdate.flags &= ~(GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT);
- }
+ ContextBase::mGps_conf.LPP_PROFILE = newLppProfile;
index++;
}
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) {
uint32_t newLppeControlPlaneMask =
- mAdapter.convertLppeCp(gnssConfigRequested.lppeControlPlaneMask);
- if (newLppeControlPlaneMask != ContextBase::mGps_conf.LPPE_CP_TECHNOLOGY) {
- ContextBase::mGps_conf.LPPE_CP_TECHNOLOGY = newLppeControlPlaneMask;
- } else {
- gnssConfigNeedEngineUpdate.flags &=
- ~(GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT);
- }
+ mAdapter.convertLppeCp(gnssConfigRequested.lppeControlPlaneMask);
+ ContextBase::mGps_conf.LPPE_CP_TECHNOLOGY = newLppeControlPlaneMask;
index++;
}
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) {
uint32_t newLppeUserPlaneMask =
- mAdapter.convertLppeUp(gnssConfigRequested.lppeUserPlaneMask);
- if (newLppeUserPlaneMask != ContextBase::mGps_conf.LPPE_UP_TECHNOLOGY) {
- ContextBase::mGps_conf.LPPE_UP_TECHNOLOGY = newLppeUserPlaneMask;
- } else {
- gnssConfigNeedEngineUpdate.flags &=
- ~(GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT);
- }
+ mAdapter.convertLppeUp(gnssConfigRequested.lppeUserPlaneMask);
+ ContextBase::mGps_conf.LPPE_UP_TECHNOLOGY = newLppeUserPlaneMask;
index++;
}
if (gnssConfigRequested.flags &
GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) {
uint32_t newAGloProtMask =
- mAdapter.convertAGloProt(gnssConfigRequested.aGlonassPositionProtocolMask);
- if (newAGloProtMask != ContextBase::mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT &&
- ContextBase::mGps_conf.AGPS_CONFIG_INJECT) {
- ContextBase::mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT = newAGloProtMask;
- } else {
- gnssConfigNeedEngineUpdate.flags &=
- ~(GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT);
- }
+ mAdapter.convertAGloProt(gnssConfigRequested.aGlonassPositionProtocolMask);
+ ContextBase::mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT = newAGloProtMask;
index++;
}
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT) {
@@ -1165,10 +1148,8 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config)
}
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_SUPL_MODE_BIT) {
uint32_t newSuplMode = mAdapter.convertSuplMode(gnssConfigRequested.suplModeMask);
- if (newSuplMode != ContextBase::mGps_conf.SUPL_MODE) {
- ContextBase::mGps_conf.SUPL_MODE = newSuplMode;
- mAdapter.broadcastCapabilities(mAdapter.getCapabilities());
- }
+ ContextBase::mGps_conf.SUPL_MODE = newSuplMode;
+ mAdapter.broadcastCapabilities(mAdapter.getCapabilities());
index++;
}
@@ -3197,9 +3178,6 @@ GnssAdapter::reportPosition(const UlpLocation& ulpLocation,
if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_MULTIBAND) {
mGnssMbSvIdUsedInPosAvail = true;
mGnssMbSvIdUsedInPosition = locationExtended.gnss_mb_sv_used_ids;
- for (int i = 0; i < GNSS_SV_MAX; i++) {
- mGnssSignalType[i] = locationExtended.measUsageInfo[i].gnssSignalType;
- }
}
}
@@ -3268,11 +3246,12 @@ GnssAdapter::reportSv(GnssSvNotification& svNotify)
for (int i=0; i < numSv; i++) {
svUsedIdMask = 0;
gnssSvId = svNotify.gnssSvs[i].svId;
+ GnssSignalTypeMask signalTypeMask = svNotify.gnssSvs[i].gnssSignalTypeMask;
switch (svNotify.gnssSvs[i].type) {
case GNSS_SV_TYPE_GPS:
if (mGnssSvIdUsedInPosAvail) {
if (mGnssMbSvIdUsedInPosAvail) {
- switch (mGnssSignalType[i]) {
+ switch (signalTypeMask) {
case GNSS_SIGNAL_GPS_L1CA:
svUsedIdMask = mGnssMbSvIdUsedInPosition.gps_l1ca_sv_used_ids_mask;
break;
@@ -3294,7 +3273,7 @@ GnssAdapter::reportSv(GnssSvNotification& svNotify)
case GNSS_SV_TYPE_GLONASS:
if (mGnssSvIdUsedInPosAvail) {
if (mGnssMbSvIdUsedInPosAvail) {
- switch (mGnssSignalType[i]) {
+ switch (signalTypeMask) {
case GNSS_SIGNAL_GLONASS_G1:
svUsedIdMask = mGnssMbSvIdUsedInPosition.glo_g1_sv_used_ids_mask;
break;
@@ -3310,7 +3289,7 @@ GnssAdapter::reportSv(GnssSvNotification& svNotify)
case GNSS_SV_TYPE_BEIDOU:
if (mGnssSvIdUsedInPosAvail) {
if (mGnssMbSvIdUsedInPosAvail) {
- switch (mGnssSignalType[i]) {
+ switch (signalTypeMask) {
case GNSS_SIGNAL_BEIDOU_B1I:
svUsedIdMask = mGnssMbSvIdUsedInPosition.bds_b1i_sv_used_ids_mask;
break;
@@ -3323,6 +3302,9 @@ GnssAdapter::reportSv(GnssSvNotification& svNotify)
case GNSS_SIGNAL_BEIDOU_B2AI:
svUsedIdMask = mGnssMbSvIdUsedInPosition.bds_b2ai_sv_used_ids_mask;
break;
+ case GNSS_SIGNAL_BEIDOU_B2AQ:
+ svUsedIdMask = mGnssMbSvIdUsedInPosition.bds_b2aq_sv_used_ids_mask;
+ break;
}
} else {
svUsedIdMask = mGnssSvIdUsedInPosition.bds_sv_used_ids_mask;
@@ -3332,7 +3314,7 @@ GnssAdapter::reportSv(GnssSvNotification& svNotify)
case GNSS_SV_TYPE_GALILEO:
if (mGnssSvIdUsedInPosAvail) {
if (mGnssMbSvIdUsedInPosAvail) {
- switch (mGnssSignalType[i]) {
+ switch (signalTypeMask) {
case GNSS_SIGNAL_GALILEO_E1:
svUsedIdMask = mGnssMbSvIdUsedInPosition.gal_e1_sv_used_ids_mask;
break;
@@ -3351,7 +3333,7 @@ GnssAdapter::reportSv(GnssSvNotification& svNotify)
case GNSS_SV_TYPE_QZSS:
if (mGnssSvIdUsedInPosAvail) {
if (mGnssMbSvIdUsedInPosAvail) {
- switch (mGnssSignalType[i]) {
+ switch (signalTypeMask) {
case GNSS_SIGNAL_QZSS_L1CA:
svUsedIdMask = mGnssMbSvIdUsedInPosition.qzss_l1ca_sv_used_ids_mask;
break;
@@ -3527,7 +3509,8 @@ GnssAdapter::reportData(GnssDataNotification& dataNotify)
}
bool
-GnssAdapter::requestNiNotifyEvent(const GnssNiNotification &notify, const void* data)
+GnssAdapter::requestNiNotifyEvent(const GnssNiNotification &notify, const void* data,
+ const LocInEmergency emergencyState)
{
LOC_LOGI("%s]: notif_type: %d, timeout: %d, default_resp: %d"
"requestor_id: %s (encoding: %d) text: %s text (encoding: %d) extras: %s",
@@ -3540,37 +3523,49 @@ GnssAdapter::requestNiNotifyEvent(const GnssNiNotification &notify, const void*
LocApiBase& mApi;
const GnssNiNotification mNotify;
const void* mData;
+ const LocInEmergency mEmergencyState;
inline MsgReportNiNotify(GnssAdapter& adapter,
LocApiBase& api,
const GnssNiNotification& notify,
- const void* data) :
+ const void* data,
+ const LocInEmergency emergencyState) :
LocMsg(),
mAdapter(adapter),
mApi(api),
mNotify(notify),
- mData(data) {}
+ mData(data),
+ mEmergencyState(emergencyState) {}
inline virtual void proc() const {
+ bool bIsInEmergency = false;
+ bool bInformNiAccept = false;
+
+ bIsInEmergency = ((LOC_IN_EMERGENCY_UNKNOWN == mEmergencyState) &&
+ mAdapter.getE911State()) || // older modems
+ (LOC_IN_EMERGENCY_SET == mEmergencyState); // newer modems
+
if (GNSS_NI_TYPE_EMERGENCY_SUPL == mNotify.type) {
- if (mAdapter.getE911State() ||
- (GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_NO == ContextBase::mGps_conf.SUPL_ES)) {
- mApi.informNiResponse(GNSS_NI_RESPONSE_ACCEPT, mData);
+ bInformNiAccept = bIsInEmergency ||
+ (GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_NO == ContextBase::mGps_conf.SUPL_ES);
+
+ if (bInformNiAccept) {
+ mAdapter.requestNiNotify(mNotify, mData, bInformNiAccept);
} else {
mApi.informNiResponse(GNSS_NI_RESPONSE_DENY, mData);
}
} else if (GNSS_NI_TYPE_CONTROL_PLANE == mNotify.type) {
- if (mAdapter.getE911State() &&
- (1 == ContextBase::mGps_conf.CP_MTLR_ES)) {
+ if (bIsInEmergency && (1 == ContextBase::mGps_conf.CP_MTLR_ES)) {
mApi.informNiResponse(GNSS_NI_RESPONSE_ACCEPT, mData);
- } else {
- mAdapter.requestNiNotify(mNotify, mData);
+ }
+ else {
+ mAdapter.requestNiNotify(mNotify, mData, false);
}
} else {
- mAdapter.requestNiNotify(mNotify, mData);
+ mAdapter.requestNiNotify(mNotify, mData, false);
}
}
};
- sendMsg(new MsgReportNiNotify(*this, *mLocApi, notify, data));
+ sendMsg(new MsgReportNiNotify(*this, *mLocApi, notify, data, emergencyState));
return true;
}
@@ -3693,7 +3688,8 @@ static void* niThreadProc(void *args)
}
bool
-GnssAdapter::requestNiNotify(const GnssNiNotification& notify, const void* data)
+GnssAdapter::requestNiNotify(const GnssNiNotification& notify, const void* data,
+ const bool bInformNiAccept)
{
NiSession* pSession = NULL;
gnssNiCallback gnssNiCb = nullptr;
@@ -3705,6 +3701,20 @@ GnssAdapter::requestNiNotify(const GnssNiNotification& notify, const void* data)
}
}
if (nullptr == gnssNiCb) {
+ if (GNSS_NI_TYPE_EMERGENCY_SUPL == notify.type) {
+ if (bInformNiAccept) {
+ mLocApi->informNiResponse(GNSS_NI_RESPONSE_ACCEPT, data);
+ NiData& niData = getNiData();
+ // ignore any SUPL NI non-Es session if a SUPL NI ES is accepted
+ if (NULL != niData.session.rawRequest) {
+ pthread_mutex_lock(&niData.session.tLock);
+ niData.session.resp = GNSS_NI_RESPONSE_IGNORE;
+ niData.session.respRecvd = true;
+ pthread_cond_signal(&niData.session.tCond);
+ pthread_mutex_unlock(&niData.session.tLock);
+ }
+ }
+ }
EXIT_LOG(%s, "no clients with gnssNiCb.");
return false;
}
@@ -3770,26 +3780,28 @@ GnssAdapter::reportGnssMeasurementsEvent(const GnssMeasurements& gnssMeasurement
{
LOC_LOGD("%s]: msInWeek=%d", __func__, msInWeek);
- struct MsgReportGnssMeasurementData : public LocMsg {
- GnssAdapter& mAdapter;
- GnssMeasurements mGnssMeasurements;
- GnssMeasurementsNotification mMeasurementsNotify;
- inline MsgReportGnssMeasurementData(GnssAdapter& adapter,
- const GnssMeasurements& gnssMeasurements,
- int msInWeek) :
- LocMsg(),
- mAdapter(adapter),
- mMeasurementsNotify(gnssMeasurements.gnssMeasNotification) {
- if (-1 != msInWeek) {
- mAdapter.getAgcInformation(mMeasurementsNotify, msInWeek);
+ if (0 != gnssMeasurements.gnssMeasNotification.count) {
+ struct MsgReportGnssMeasurementData : public LocMsg {
+ GnssAdapter& mAdapter;
+ GnssMeasurements mGnssMeasurements;
+ GnssMeasurementsNotification mMeasurementsNotify;
+ inline MsgReportGnssMeasurementData(GnssAdapter& adapter,
+ const GnssMeasurements& gnssMeasurements,
+ int msInWeek) :
+ LocMsg(),
+ mAdapter(adapter),
+ mMeasurementsNotify(gnssMeasurements.gnssMeasNotification) {
+ if (-1 != msInWeek) {
+ mAdapter.getAgcInformation(mMeasurementsNotify, msInWeek);
+ }
}
- }
- inline virtual void proc() const {
- mAdapter.reportGnssMeasurementData(mMeasurementsNotify);
- }
- };
+ inline virtual void proc() const {
+ mAdapter.reportGnssMeasurementData(mMeasurementsNotify);
+ }
+ };
- sendMsg(new MsgReportGnssMeasurementData(*this, gnssMeasurements, msInWeek));
+ sendMsg(new MsgReportGnssMeasurementData(*this, gnssMeasurements, msInWeek));
+ }
mEngHubProxy->gnssReportSvMeasurement(gnssMeasurements.gnssSvMeasurementSet);
}