diff --git a/gps/android/1.0/location_api/GnssAPIClient.cpp b/gps/android/1.0/location_api/GnssAPIClient.cpp index eb785915..c474d453 100644 --- a/gps/android/1.0/location_api/GnssAPIClient.cpp +++ b/gps/android/1.0/location_api/GnssAPIClient.cpp @@ -540,7 +540,7 @@ static void convertGnssSvStatus(GnssSvNotification& in, IGnssCallback::GnssSvSta } for (size_t i = 0; i < out.numSvs; i++) { IGnssCallback::GnssSvInfo& info = out.gnssSvList[i]; - info.svid = in.gnssSvs[i].svId; + convertGnssSvid(in.gnssSvs[i], info.svid); convertGnssConstellationType(in.gnssSvs[i].type, info.constellation); info.cN0Dbhz = in.gnssSvs[i].cN0Dbhz; info.elevationDegrees = in.gnssSvs[i].elevation; diff --git a/gps/android/1.0/location_api/LocationUtil.cpp b/gps/android/1.0/location_api/LocationUtil.cpp index 102593bc..d14cdac5 100644 --- a/gps/android/1.0/location_api/LocationUtil.cpp +++ b/gps/android/1.0/location_api/LocationUtil.cpp @@ -147,6 +147,64 @@ void convertGnssConstellationType(GnssSvType& in, GnssConstellationType& out) } } +void convertGnssSvid(GnssSv& in, int16_t& out) +{ + switch(in.type){ + case GNSS_SV_TYPE_GPS: + out = in.svId; + break; + case GNSS_SV_TYPE_SBAS: + out = in.svId; + break; + case GNSS_SV_TYPE_GLONASS: + out = in.svId - GLO_SV_PRN_MIN + 1; + break; + case GNSS_SV_TYPE_QZSS: + out = in.svId; + break; + case GNSS_SV_TYPE_BEIDOU: + out = in.svId - BDS_SV_PRN_MIN + 1; + break; + case GNSS_SV_TYPE_GALILEO: + out = in.svId - GAL_SV_PRN_MIN + 1; + break; + default: + out = in.svId; + break; + } +} + +void convertGnssSvid(GnssMeasurementsData& in, int16_t& out) +{ + switch (in.svType) { + case GNSS_SV_TYPE_GPS: + out = in.svId; + break; + case GNSS_SV_TYPE_SBAS: + out = in.svId; + break; + case GNSS_SV_TYPE_GLONASS: + if (in.svId != 255) { // OSN is known + out = in.svId - GLO_SV_PRN_MIN + 1; + } else { // OSN is not known, report FCN + out = in.gloFrequency + 92; + } + break; + case GNSS_SV_TYPE_QZSS: + out = in.svId; + break; + case GNSS_SV_TYPE_BEIDOU: + out = in.svId - BDS_SV_PRN_MIN + 1; + break; + case GNSS_SV_TYPE_GALILEO: + out = in.svId - GAL_SV_PRN_MIN + 1; + break; + default: + out = in.svId; + break; + } +} + void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out) { switch(in) { diff --git a/gps/android/1.0/location_api/LocationUtil.h b/gps/android/1.0/location_api/LocationUtil.h index 9e0cd369..f6760e5f 100644 --- a/gps/android/1.0/location_api/LocationUtil.h +++ b/gps/android/1.0/location_api/LocationUtil.h @@ -43,6 +43,8 @@ namespace implementation { void convertGnssLocation(Location& in, V1_0::GnssLocation& out); void convertGnssLocation(const V1_0::GnssLocation& in, Location& out); void convertGnssConstellationType(GnssSvType& in, V1_0::GnssConstellationType& out); +void convertGnssSvid(GnssSv& in, int16_t& out); +void convertGnssSvid(GnssMeasurementsData& in, int16_t& out); void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out); void convertGnssEphemerisSource(GnssEphemerisSource& in, GnssDebug::SatelliteEphemerisSource& out); void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEphemerisHealth& out); diff --git a/gps/android/1.0/location_api/MeasurementAPIClient.cpp b/gps/android/1.0/location_api/MeasurementAPIClient.cpp index 73709e3a..9b23308b 100644 --- a/gps/android/1.0/location_api/MeasurementAPIClient.cpp +++ b/gps/android/1.0/location_api/MeasurementAPIClient.cpp @@ -163,7 +163,7 @@ static void convertGnssMeasurement(GnssMeasurementsData& in, out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_PHASE_UNCERTAINTY; if (in.flags & GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT) out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_AUTOMATIC_GAIN_CONTROL; - out.svid = in.svId; + convertGnssSvid(in, out.svid); convertGnssConstellationType(in.svType, out.constellation); out.timeOffsetNs = in.timeOffsetNs; if (in.stateMask & GNSS_MEASUREMENTS_STATE_CODE_LOCK_BIT) diff --git a/gps/android/1.1/Gnss.cpp b/gps/android/1.1/Gnss.cpp index b6f29650..2e2a52ad 100644 --- a/gps/android/1.1/Gnss.cpp +++ b/gps/android/1.1/Gnss.cpp @@ -379,7 +379,7 @@ Return Gnss::setCallback_1_1(const sp& callback) { OdcpiRequestCallback cb = [this](const OdcpiRequestInfo& odcpiRequest) { odcpiRequestCb(odcpiRequest); }; - gnssInterface->odcpiInit(cb); + gnssInterface->odcpiInit(cb, OdcpiPrioritytype::ODCPI_HANDLER_PRIORITY_LOW); } return setCallback(callback); } @@ -429,6 +429,9 @@ Return Gnss::injectBestLocation(const GnssLocation& gnssLocation) { void Gnss::odcpiRequestCb(const OdcpiRequestInfo& request) { ENTRY_LOG_CALLFLOW(); + if (ODCPI_REQUEST_TYPE_STOP == request.type) { + return; + } if (mGnssCbIface_1_1 != nullptr) { // For emergency mode, request DBH (Device based hybrid) location // Mark Independent from GNSS flag to false. diff --git a/gps/android/1.1/location_api/GnssAPIClient.cpp b/gps/android/1.1/location_api/GnssAPIClient.cpp index be4d6596..80710898 100644 --- a/gps/android/1.1/location_api/GnssAPIClient.cpp +++ b/gps/android/1.1/location_api/GnssAPIClient.cpp @@ -540,7 +540,7 @@ static void convertGnssSvStatus(GnssSvNotification& in, IGnssCallback::GnssSvSta } for (size_t i = 0; i < out.numSvs; i++) { IGnssCallback::GnssSvInfo& info = out.gnssSvList[i]; - info.svid = in.gnssSvs[i].svId; + convertGnssSvid(in.gnssSvs[i], info.svid); convertGnssConstellationType(in.gnssSvs[i].type, info.constellation); info.cN0Dbhz = in.gnssSvs[i].cN0Dbhz; info.elevationDegrees = in.gnssSvs[i].elevation; diff --git a/gps/android/1.1/location_api/LocationUtil.cpp b/gps/android/1.1/location_api/LocationUtil.cpp index f1d051c1..459150fd 100644 --- a/gps/android/1.1/location_api/LocationUtil.cpp +++ b/gps/android/1.1/location_api/LocationUtil.cpp @@ -147,6 +147,64 @@ void convertGnssConstellationType(GnssSvType& in, GnssConstellationType& out) } } +void convertGnssSvid(GnssSv& in, int16_t& out) +{ + switch(in.type){ + case GNSS_SV_TYPE_GPS: + out = in.svId; + break; + case GNSS_SV_TYPE_SBAS: + out = in.svId; + break; + case GNSS_SV_TYPE_GLONASS: + out = in.svId - GLO_SV_PRN_MIN + 1; + break; + case GNSS_SV_TYPE_QZSS: + out = in.svId; + break; + case GNSS_SV_TYPE_BEIDOU: + out = in.svId - BDS_SV_PRN_MIN + 1; + break; + case GNSS_SV_TYPE_GALILEO: + out = in.svId - GAL_SV_PRN_MIN + 1; + break; + default: + out = in.svId; + break; + } +} + +void convertGnssSvid(GnssMeasurementsData& in, int16_t& out) +{ + switch (in.svType) { + case GNSS_SV_TYPE_GPS: + out = in.svId; + break; + case GNSS_SV_TYPE_SBAS: + out = in.svId; + break; + case GNSS_SV_TYPE_GLONASS: + if (in.svId != 255) { // OSN is known + out = in.svId - GLO_SV_PRN_MIN + 1; + } else { // OSN is not known, report FCN + out = in.gloFrequency + 92; + } + break; + case GNSS_SV_TYPE_QZSS: + out = in.svId; + break; + case GNSS_SV_TYPE_BEIDOU: + out = in.svId - BDS_SV_PRN_MIN + 1; + break; + case GNSS_SV_TYPE_GALILEO: + out = in.svId - GAL_SV_PRN_MIN + 1; + break; + default: + out = in.svId; + break; + } +} + void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out) { switch(in) { diff --git a/gps/android/1.1/location_api/LocationUtil.h b/gps/android/1.1/location_api/LocationUtil.h index 63f4f6f0..af3c93f3 100644 --- a/gps/android/1.1/location_api/LocationUtil.h +++ b/gps/android/1.1/location_api/LocationUtil.h @@ -43,6 +43,8 @@ namespace implementation { void convertGnssLocation(Location& in, V1_0::GnssLocation& out); void convertGnssLocation(const V1_0::GnssLocation& in, Location& out); void convertGnssConstellationType(GnssSvType& in, V1_0::GnssConstellationType& out); +void convertGnssSvid(GnssSv& in, int16_t& out); +void convertGnssSvid(GnssMeasurementsData& in, int16_t& out); void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out); void convertGnssEphemerisSource(GnssEphemerisSource& in, GnssDebug::SatelliteEphemerisSource& out); void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEphemerisHealth& out); diff --git a/gps/android/1.1/location_api/MeasurementAPIClient.cpp b/gps/android/1.1/location_api/MeasurementAPIClient.cpp index 6f250676..a87ae6d5 100644 --- a/gps/android/1.1/location_api/MeasurementAPIClient.cpp +++ b/gps/android/1.1/location_api/MeasurementAPIClient.cpp @@ -197,7 +197,7 @@ static void convertGnssMeasurement(GnssMeasurementsData& in, out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_PHASE_UNCERTAINTY; if (in.flags & GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT) out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_AUTOMATIC_GAIN_CONTROL; - out.svid = in.svId; + convertGnssSvid(in, out.svid); convertGnssConstellationType(in.svType, out.constellation); out.timeOffsetNs = in.timeOffsetNs; if (in.stateMask & GNSS_MEASUREMENTS_STATE_CODE_LOCK_BIT) diff --git a/gps/android/2.0/Gnss.cpp b/gps/android/2.0/Gnss.cpp index 0e53a34a..e3c8b093 100644 --- a/gps/android/2.0/Gnss.cpp +++ b/gps/android/2.0/Gnss.cpp @@ -445,7 +445,7 @@ Return Gnss::setCallback_1_1(const sp& callback) { OdcpiRequestCallback cb = [this](const OdcpiRequestInfo& odcpiRequest) { odcpiRequestCb(odcpiRequest); }; - gnssInterface->odcpiInit(cb); + gnssInterface->odcpiInit(cb, OdcpiPrioritytype::ODCPI_HANDLER_PRIORITY_LOW); } GnssAPIClient* api = getApi(); @@ -508,6 +508,9 @@ Return Gnss::injectBestLocation(const GnssLocation& gnssLocation) { void Gnss::odcpiRequestCb(const OdcpiRequestInfo& request) { ENTRY_LOG_CALLFLOW(); + if (ODCPI_REQUEST_TYPE_STOP == request.type) { + return; + } if (mGnssCbIface_2_0 != nullptr) { // For emergency mode, request DBH (Device based hybrid) location // Mark Independent from GNSS flag to false. @@ -575,7 +578,7 @@ Return Gnss::setCallback_2_0(const sp& callback) { OdcpiRequestCallback cb = [this](const OdcpiRequestInfo& odcpiRequest) { odcpiRequestCb(odcpiRequest); }; - gnssInterface->odcpiInit(cb); + gnssInterface->odcpiInit(cb, OdcpiPrioritytype::ODCPI_HANDLER_PRIORITY_LOW); } GnssAPIClient* api = getApi(); diff --git a/gps/android/2.0/android.hardware.gnss@2.0-service-qti.xml b/gps/android/2.0/android.hardware.gnss@2.0-service-qti.xml index ff9fb2c9..de82c60e 100644 --- a/gps/android/2.0/android.hardware.gnss@2.0-service-qti.xml +++ b/gps/android/2.0/android.hardware.gnss@2.0-service-qti.xml @@ -29,6 +29,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. android.hardware.gnss hwbinder + @1.0::IGnss/gnss_vendor @1.1::IGnss/default @2.0::IGnss/default diff --git a/gps/android/2.0/location_api/GnssAPIClient.cpp b/gps/android/2.0/location_api/GnssAPIClient.cpp index d505241c..1fcf5300 100644 --- a/gps/android/2.0/location_api/GnssAPIClient.cpp +++ b/gps/android/2.0/location_api/GnssAPIClient.cpp @@ -678,7 +678,7 @@ static void convertGnssSvStatus(GnssSvNotification& in, V1_0::IGnssCallback::Gns out.numSvs = static_cast(V1_0::GnssMax::SVS_COUNT); } for (size_t i = 0; i < out.numSvs; i++) { - out.gnssSvList[i].svid = in.gnssSvs[i].svId; + convertGnssSvid(in.gnssSvs[i], out.gnssSvList[i].svid); convertGnssConstellationType(in.gnssSvs[i].type, out.gnssSvList[i].constellation); out.gnssSvList[i].cN0Dbhz = in.gnssSvs[i].cN0Dbhz; out.gnssSvList[i].elevationDegrees = in.gnssSvs[i].elevation; @@ -701,7 +701,7 @@ static void convertGnssSvStatus(GnssSvNotification& in, { out.resize(in.count); for (size_t i = 0; i < in.count; i++) { - out[i].v1_0.svid = in.gnssSvs[i].svId; + convertGnssSvid(in.gnssSvs[i], out[i].v1_0.svid); out[i].v1_0.cN0Dbhz = in.gnssSvs[i].cN0Dbhz; out[i].v1_0.elevationDegrees = in.gnssSvs[i].elevation; out[i].v1_0.azimuthDegrees = in.gnssSvs[i].azimuth; diff --git a/gps/android/2.0/location_api/LocationUtil.cpp b/gps/android/2.0/location_api/LocationUtil.cpp index 7e6810c6..c2a75576 100644 --- a/gps/android/2.0/location_api/LocationUtil.cpp +++ b/gps/android/2.0/location_api/LocationUtil.cpp @@ -30,6 +30,7 @@ #include #include #include +#include namespace android { namespace hardware { @@ -136,12 +137,17 @@ void convertGnssLocation(Location& in, V2_0::GnssLocation& out) if (currentTimeNanos >= locationTimeNanos) { int64_t ageTimeNanos = currentTimeNanos - locationTimeNanos; LOC_LOGD("%s]: ageTimeNanos:%" PRIi64 ")", __FUNCTION__, ageTimeNanos); - if (ageTimeNanos >= 0 && ageTimeNanos <= sinceBootTimeNanos) { + // the max trusted propagation time 30s for ageTimeNanos to avoid user setting + //wrong time, it will affect elapsedRealtimeNanos + if (ageTimeNanos >= 0 && ageTimeNanos <= 30000000000) { out.elapsedRealtime.flags |= ElapsedRealtimeFlags::HAS_TIMESTAMP_NS; out.elapsedRealtime.timestampNs = sinceBootTimeNanos - ageTimeNanos; out.elapsedRealtime.flags |= ElapsedRealtimeFlags::HAS_TIME_UNCERTAINTY_NS; - // time uncertainty is 1 ms since it is calculated from utc time that is in ms - out.elapsedRealtime.timeUncertaintyNs = 1000000; + // time uncertainty is the max value between abs(AP_UTC - MP_UTC) and 100ms, to + //verify if user change the sys time + out.elapsedRealtime.timeUncertaintyNs = + std::max((int64_t)abs(currentTimeNanos - locationTimeNanos), + (int64_t)100000000); LOC_LOGD("%s]: timestampNs:%" PRIi64 ")", __FUNCTION__, out.elapsedRealtime.timestampNs); } @@ -256,6 +262,64 @@ void convertGnssConstellationType(GnssSvType& in, V2_0::GnssConstellationType& o } } +void convertGnssSvid(GnssSv& in, int16_t& out) +{ + switch (in.type) { + case GNSS_SV_TYPE_GPS: + out = in.svId; + break; + case GNSS_SV_TYPE_SBAS: + out = in.svId; + break; + case GNSS_SV_TYPE_GLONASS: + out = in.svId - GLO_SV_PRN_MIN + 1; + break; + case GNSS_SV_TYPE_QZSS: + out = in.svId; + break; + case GNSS_SV_TYPE_BEIDOU: + out = in.svId - BDS_SV_PRN_MIN + 1; + break; + case GNSS_SV_TYPE_GALILEO: + out = in.svId - GAL_SV_PRN_MIN + 1; + break; + default: + out = in.svId; + break; + } +} + +void convertGnssSvid(GnssMeasurementsData& in, int16_t& out) +{ + switch (in.svType) { + case GNSS_SV_TYPE_GPS: + out = in.svId; + break; + case GNSS_SV_TYPE_SBAS: + out = in.svId; + break; + case GNSS_SV_TYPE_GLONASS: + if (in.svId != 255) { // OSN is known + out = in.svId - GLO_SV_PRN_MIN + 1; + } else { // OSN is not known, report FCN + out = in.gloFrequency + 92; + } + break; + case GNSS_SV_TYPE_QZSS: + out = in.svId; + break; + case GNSS_SV_TYPE_BEIDOU: + out = in.svId - BDS_SV_PRN_MIN + 1; + break; + case GNSS_SV_TYPE_GALILEO: + out = in.svId - GAL_SV_PRN_MIN + 1; + break; + default: + out = in.svId; + break; + } +} + void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out) { switch(in) { diff --git a/gps/android/2.0/location_api/LocationUtil.h b/gps/android/2.0/location_api/LocationUtil.h index d3dce23c..3c345149 100644 --- a/gps/android/2.0/location_api/LocationUtil.h +++ b/gps/android/2.0/location_api/LocationUtil.h @@ -46,6 +46,8 @@ void convertGnssLocation(const V1_0::GnssLocation& in, Location& out); void convertGnssLocation(const V2_0::GnssLocation& in, Location& out); void convertGnssConstellationType(GnssSvType& in, V1_0::GnssConstellationType& out); void convertGnssConstellationType(GnssSvType& in, V2_0::GnssConstellationType& out); +void convertGnssSvid(GnssSv& in, int16_t& out); +void convertGnssSvid(GnssMeasurementsData& in, int16_t& out); void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out); void convertGnssEphemerisSource(GnssEphemerisSource& in, GnssDebug::SatelliteEphemerisSource& out); void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEphemerisHealth& out); diff --git a/gps/android/2.0/location_api/MeasurementAPIClient.cpp b/gps/android/2.0/location_api/MeasurementAPIClient.cpp index b87e5082..5894e46e 100644 --- a/gps/android/2.0/location_api/MeasurementAPIClient.cpp +++ b/gps/android/2.0/location_api/MeasurementAPIClient.cpp @@ -231,7 +231,7 @@ static void convertGnssMeasurement(GnssMeasurementsData& in, out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_PHASE_UNCERTAINTY; if (in.flags & GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT) out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_AUTOMATIC_GAIN_CONTROL; - out.svid = in.svId; + convertGnssSvid(in, out.svid); convertGnssConstellationType(in.svType, out.constellation); out.timeOffsetNs = in.timeOffsetNs; if (in.stateMask & GNSS_MEASUREMENTS_STATE_CODE_LOCK_BIT) diff --git a/gps/android/2.0/service.cpp b/gps/android/2.0/service.cpp index 664c661f..e484a16d 100644 --- a/gps/android/2.0/service.cpp +++ b/gps/android/2.0/service.cpp @@ -73,6 +73,11 @@ int main() { #else ALOGE("LOC_HIDL_VERSION not defined."); #endif + } else { + status = registerPassthroughServiceImplementation("gnss_vendor"); + if (status != OK) { + ALOGE("Error while registering gnss_vendor service: %d", status); + } } joinRpcThreadpool(); diff --git a/gps/android/utils/battery_listener.cpp b/gps/android/utils/battery_listener.cpp index 8547e41e..170159a7 100644 --- a/gps/android/utils/battery_listener.cpp +++ b/gps/android/utils/battery_listener.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2019, The Linux Foundation. All rights reserved. +* Copyright (c) 2019-2020, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -183,7 +183,7 @@ BatteryListenerImpl::~BatteryListenerImpl() { std::lock_guard _l(mLock); if (mHealth != NULL) - mHealth->unlinkToDeath(this); + mHealth->unregisterCallback(this); auto r = mHealth->unlinkToDeath(this); if (!r.isOk() || r == false) { LOC_LOGe("Transaction error in unregister to HealthHAL death: %s", @@ -206,6 +206,8 @@ void BatteryListenerImpl::serviceDied(uint64_t cookie __unused, LOC_LOGi("health service died, reinit"); mDone = true; } + mHealth = NULL; + mCond.notify_one(); mThread->join(); std::lock_guard _l(mLock); init(); diff --git a/gps/core/ContextBase.cpp b/gps/core/ContextBase.cpp index 3eb49739..8e568eae 100644 --- a/gps/core/ContextBase.cpp +++ b/gps/core/ContextBase.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2014,2016-2017 The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014,2016-2017,2020 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -30,7 +30,6 @@ #define LOG_TAG "LocSvc_CtxBase" #include -#include #include #include #include diff --git a/gps/core/LocAdapterBase.cpp b/gps/core/LocAdapterBase.cpp index 1e91cf83..8df7198a 100644 --- a/gps/core/LocAdapterBase.cpp +++ b/gps/core/LocAdapterBase.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2014, 2016-2019 The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014, 2016-2020 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -185,6 +185,10 @@ DEFAULT_IMPL() void LocAdapterBase::reportGnssSvTypeConfigEvent(const GnssSvTypeConfig& /*config*/) DEFAULT_IMPL() +void LocAdapterBase::reportGnssConfigEvent(uint32_t, /* session id*/ + const GnssConfig& /*gnssConfig*/) +DEFAULT_IMPL() + bool LocAdapterBase:: requestOdcpiEvent(OdcpiRequestInfo& /*request*/) DEFAULT_IMPL(false) diff --git a/gps/core/LocAdapterBase.h b/gps/core/LocAdapterBase.h index 7ca3ecda..4a5d1abc 100644 --- a/gps/core/LocAdapterBase.h +++ b/gps/core/LocAdapterBase.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2014, 2016-2019 The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014, 2016-2020 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -206,6 +206,7 @@ public: GpsLocationExtended &location_extended, LocPosTechMask tech_mask); virtual void reportGnssSvIdConfigEvent(const GnssSvIdConfig& config); virtual void reportGnssSvTypeConfigEvent(const GnssSvTypeConfig& config); + virtual void reportGnssConfigEvent(uint32_t sessionId, const GnssConfig& gnssConfig); virtual bool requestOdcpiEvent(OdcpiRequestInfo& request); virtual bool reportGnssEngEnergyConsumedEvent(uint64_t energyConsumedSinceFirstBoot); virtual bool reportDeleteAidingDataEvent(GnssAidingData &aidingData); diff --git a/gps/core/LocApiBase.cpp b/gps/core/LocApiBase.cpp index 71abdf9f..60bfdd21 100644 --- a/gps/core/LocApiBase.cpp +++ b/gps/core/LocApiBase.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2014, 2016-2019 The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014, 2016-2020 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -415,19 +415,17 @@ void LocApiBase::reportSv(GnssSvNotification& svNotify) svNotify.gnssSvs[i].type = GNSS_SV_TYPE_UNKNOWN; } // Display what we report to clients - uint16_t displaySvId = GNSS_SV_TYPE_QZSS == svNotify.gnssSvs[i].type ? - svNotify.gnssSvs[i].svId + QZSS_SV_PRN_MIN - 1 : - svNotify.gnssSvs[i].svId; - LOC_LOGV(" %03zu: %*s %02d %f %f %f %f 0x%02X", + LOC_LOGV(" %03zu: %*s %02d %f %f %f %f 0x%02X 0x%2X", i, 13, constellationString[svNotify.gnssSvs[i].type], - displaySvId, + svNotify.gnssSvs[i].svId, svNotify.gnssSvs[i].cN0Dbhz, svNotify.gnssSvs[i].elevation, svNotify.gnssSvs[i].azimuth, svNotify.gnssSvs[i].carrierFrequencyHz, - svNotify.gnssSvs[i].gnssSvOptionsMask); + svNotify.gnssSvs[i].gnssSvOptionsMask, + svNotify.gnssSvs[i].gnssSignalTypeMask); } // loop through adapters, and deliver to all adapters. TO_ALL_LOCADAPTERS( @@ -593,6 +591,11 @@ void LocApiBase::handleBatchStatusEvent(BatchingStatus batchStatus) TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportBatchStatusChangeEvent(batchStatus)); } +void LocApiBase::reportGnssConfig(uint32_t sessionId, const GnssConfig& gnssConfig) +{ + // loop through adapters, and deliver to the first handling adapter. + TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssConfigEvent(sessionId, gnssConfig)); +} enum loc_api_adapter_err LocApiBase:: open(LOC_API_ADAPTER_EVENT_MASK_T /*mask*/) @@ -879,4 +882,14 @@ DEFAULT_IMPL() void LocApiBase::updateSystemPowerState(PowerStateType /*powerState*/) DEFAULT_IMPL() +void LocApiBase:: + configRobustLocation(bool /*enabled*/, + bool /*enableForE911*/, + LocApiResponse* /*adapterResponse*/) +DEFAULT_IMPL() + +void LocApiBase:: + getRobustLocationConfig(uint32_t sessionId, LocApiResponse* /*adapterResponse*/) +DEFAULT_IMPL() + } // namespace loc_core diff --git a/gps/core/LocApiBase.h b/gps/core/LocApiBase.h index 9c76bab2..1e8337c5 100644 --- a/gps/core/LocApiBase.h +++ b/gps/core/LocApiBase.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2014, 2016-2019 The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014, 2016-2020 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -195,6 +195,7 @@ public: void reportDeleteAidingDataEvent(GnssAidingData& aidingData); void reportKlobucharIonoModel(GnssKlobucharIonoModel& ionoModel); void reportGnssAdditionalSystemInfo(GnssAdditionalSystemInfo& additionalSystemInfo); + void reportGnssConfig(uint32_t sessionId, const GnssConfig& gnssConfig); void sendNfwNotification(GnssNfwNotification& notification); void geofenceBreach(size_t count, uint32_t* hwIds, Location& location, @@ -318,6 +319,9 @@ public: void updateNmeaMask(uint32_t mask); virtual void updateSystemPowerState(PowerStateType systemPowerState); + virtual void configRobustLocation(bool enable, bool enableForE911, + LocApiResponse* adapterResponse=nullptr); + virtual void getRobustLocationConfig(uint32_t sessionId, LocApiResponse* adapterResponse); }; typedef LocApiBase* (getLocApi_t)(LOC_API_ADAPTER_EVENT_MASK_T exMask, diff --git a/gps/core/Makefile.am b/gps/core/Makefile.am index 1199a523..291dbb53 100644 --- a/gps/core/Makefile.am +++ b/gps/core/Makefile.am @@ -40,6 +40,10 @@ libloc_core_la_c_sources = \ SystemStatusOsObserver.cpp \ SystemStatus.cpp +if USE_EXTERNAL_AP +AM_CFLAGS += -DFEATURE_EXTERNAL_AP +endif + library_includedir = $(pkgincludedir) library_include_HEADERS = $(libloc_core_la_h_sources) diff --git a/gps/core/SystemStatusOsObserver.cpp b/gps/core/SystemStatusOsObserver.cpp index b51a564d..98f5f742 100644 --- a/gps/core/SystemStatusOsObserver.cpp +++ b/gps/core/SystemStatusOsObserver.cpp @@ -38,7 +38,7 @@ namespace loc_core { template COUT SystemStatusOsObserver::containerTransfer(CINT& inContainer) { - COUT outContainer(0); + COUT outContainer = {}; for (auto item : inContainer) { outContainer.insert(outContainer.begin(), item); } @@ -67,6 +67,7 @@ void SystemStatusOsObserver::setSubscriptionObj(IDataItemSubscription* subscript inline SetSubsObj(ObserverContext& context, IDataItemSubscription* subscriptionObj) : mContext(context), mSubsObj(subscriptionObj) {} void proc() const { + LOC_LOGi("SetSubsObj::enter"); mContext.mSubscriptionObj = mSubsObj; if (!mContext.mSSObserver->mDataItemToClients.empty()) { @@ -76,6 +77,7 @@ void SystemStatusOsObserver::setSubscriptionObj(IDataItemSubscription* subscript mContext.mSubscriptionObj->subscribe(dis, mContext.mSSObserver); mContext.mSubscriptionObj->requestData(dis, mContext.mSSObserver); } + LOC_LOGi("SetSubsObj::exit"); } }; @@ -101,7 +103,7 @@ void SystemStatusOsObserver::subscribe(const list& l, IDataItemObser mToRequestData(requestData) {} void proc() const { - unordered_set dataItemsToSubscribe(0); + unordered_set dataItemsToSubscribe = {}; mParent->mDataItemToClients.add(mDataItemSet, {mClient}, &dataItemsToSubscribe); mParent->mClientToDataItems.add(mClient, mDataItemSet); @@ -147,8 +149,8 @@ void SystemStatusOsObserver::updateSubscription( mDataItemSet(containerTransfer, unordered_set>(l)) {} void proc() const { - unordered_set dataItemsToSubscribe(0); - unordered_set dataItemsToUnsubscribe(0); + unordered_set dataItemsToSubscribe = {}; + unordered_set dataItemsToUnsubscribe = {}; unordered_set clients({mClient}); // below removes clients from all entries keyed with the return of the // mClientToDataItems.update() call. If leaving an empty set of clients as the @@ -219,11 +221,11 @@ void SystemStatusOsObserver::unsubscribe( mDataItemSet(containerTransfer, unordered_set>(l)) {} void proc() const { - unordered_set dataItemsUnusedByClient(0); - unordered_set clientToRemove(0); + unordered_set dataItemsUnusedByClient = {}; + unordered_set clientToRemove = {}; + unordered_set dataItemsToUnsubscribe = {}; mParent->mClientToDataItems.trimOrRemove({mClient}, mDataItemSet, &clientToRemove, &dataItemsUnusedByClient); - unordered_set dataItemsToUnsubscribe(0); mParent->mDataItemToClients.trimOrRemove(dataItemsUnusedByClient, {mClient}, &dataItemsToUnsubscribe, nullptr); @@ -259,6 +261,7 @@ void SystemStatusOsObserver::unsubscribeAll(IDataItemObserver* client) void proc() const { unordered_set diByClient = mParent->mClientToDataItems.getValSet(mClient); + if (!diByClient.empty()) { unordered_set dataItemsToUnsubscribe; mParent->mClientToDataItems.remove(mClient); @@ -308,7 +311,7 @@ void SystemStatusOsObserver::notify(const list& dlist) void proc() const { // Update Cache with received data items and prepare // list of data items to be sent. - unordered_set dataItemIdsToBeSent(0); + unordered_set dataItemIdsToBeSent = {}; for (auto item : mDiVec) { if (mParent->updateCache(item)) { dataItemIdsToBeSent.insert(item->getId()); @@ -316,7 +319,7 @@ void SystemStatusOsObserver::notify(const list& dlist) } // Send data item to all subscribed clients - unordered_set clientSet(0); + unordered_set clientSet = {}; for (auto each : dataItemIdsToBeSent) { auto clients = mParent->mDataItemToClients.getValSetPtr(each); if (nullptr != clients) { @@ -459,8 +462,9 @@ bool SystemStatusOsObserver::connectBackhaul() mFwkActionReqObj(fwkActReq) {} virtual ~HandleConnectBackhaul() {} void proc() const { - LOC_LOGD("HandleConnectBackhaul"); + LOC_LOGi("HandleConnectBackhaul::enter"); mFwkActionReqObj->connectBackhaul(); + LOC_LOGi("HandleConnectBackhaul::exit"); } IFrameworkActionReq* mFwkActionReqObj; }; @@ -488,8 +492,9 @@ bool SystemStatusOsObserver::disconnectBackhaul() mFwkActionReqObj(fwkActReq) {} virtual ~HandleDisconnectBackhaul() {} void proc() const { - LOC_LOGD("HandleDisconnectBackhaul"); + LOC_LOGi("HandleDisconnectBackhaul::enter"); mFwkActionReqObj->disconnectBackhaul(); + LOC_LOGi("HandleDisconnectBackhaul::exit"); } IFrameworkActionReq* mFwkActionReqObj; }; @@ -518,7 +523,7 @@ void SystemStatusOsObserver::sendCachedDataItems( } else { string clientName; to->getName(clientName); - list dataItems(0); + list dataItems = {}; for (auto each : s) { auto citer = mDataItemCache.find(each); diff --git a/gps/core/configure.ac b/gps/core/configure.ac index 548c5e59..19db9cfb 100644 --- a/gps/core/configure.ac +++ b/gps/core/configure.ac @@ -86,6 +86,19 @@ fi AM_CONDITIONAL(USE_FEATURE_AUTOMOTIVE, test "x${with_auto_feature}" = "xyes") +# External AP +AC_ARG_WITH([external_ap], + AC_HELP_STRING([--with-external_ap=@<:@dir@:>@], + [Using External Application Processor]), + [], + with_external_ap=no) + +if test "x$with_external_ap" != "xno"; then + CPPFLAGS="${CPPFLAGS} -DFEATURE_EXTERNAL_AP" +fi + +AM_CONDITIONAL(USE_EXTERNAL_AP, test "x${with_external_ap}" = "xyes") + AC_CONFIG_FILES([ \ Makefile \ loc-core.pc \ diff --git a/gps/gnss/GnssAdapter.cpp b/gps/gnss/GnssAdapter.cpp index 7b9880cc..85d51f62 100644 --- a/gps/gnss/GnssAdapter.cpp +++ b/gps/gnss/GnssAdapter.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. +/* Copyright (c) 2017-2020 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -87,6 +87,7 @@ GnssAdapter::GnssAdapter() : mOdcpiRequestActive(false), mOdcpiTimer(this), mOdcpiRequest(), + mCallbackPriority(OdcpiPrioritytype::ODCPI_HANDLER_PRIORITY_LOW), mSystemStatus(SystemStatus::getInstance(mMsgTask)), mServerUrl(":"), mXtraObserver(mSystemStatus->getOsObserver(), mMsgTask), @@ -526,6 +527,11 @@ GnssAdapter::convertLocationInfo(GnssLocationInfoNotification& out, out.flags |= GNSS_LOCATION_INFO_OUTPUT_ENG_MASK_BIT; out.locOutputEngMask = locationExtended.locOutputEngMask; } + + if (GPS_LOCATION_EXTENDED_HAS_CONFORMITY_INDEX & locationExtended.flags) { + out.flags |= GNSS_LOCATION_INFO_CONFORMITY_INDEX_BIT; + out.conformityIndex = locationExtended.conformityIndex; + } } @@ -853,6 +859,13 @@ GnssAdapter::setConfig() mLocApi->setPositionAssistedClockEstimatorMode( mLocConfigInfo.paceConfigInfo.enable); + // we do not support control robust location from gps.conf + if (mLocConfigInfo.robustLocationConfigInfo.isValid == true) { + mLocApi->configRobustLocation( + mLocConfigInfo.robustLocationConfigInfo.enable, + mLocConfigInfo.robustLocationConfigInfo.enableFor911); + } + if (sapConf.GYRO_BIAS_RANDOM_WALK_VALID || sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID || sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID || @@ -1298,9 +1311,10 @@ void GnssAdapter::gnssSvIdConfigUpdate() { LOC_LOGd("blacklist bds 0x%" PRIx64 ", glo 0x%" PRIx64 - ", qzss 0x%" PRIx64 ", gal 0x%" PRIx64, + ", qzss 0x%" PRIx64 ", gal 0x%" PRIx64 ", sbas 0x%" PRIx64, mGnssSvIdConfig.bdsBlacklistSvMask, mGnssSvIdConfig.gloBlacklistSvMask, - mGnssSvIdConfig.qzssBlacklistSvMask, mGnssSvIdConfig.galBlacklistSvMask); + mGnssSvIdConfig.qzssBlacklistSvMask, mGnssSvIdConfig.galBlacklistSvMask, + mGnssSvIdConfig.sbasBlacklistSvMask); // Now set required blacklisted SVs mLocApi->setBlacklistSv(mGnssSvIdConfig); @@ -1323,9 +1337,10 @@ LocationError GnssAdapter::gnssSvIdConfigUpdateSync() { LOC_LOGd("blacklist bds 0x%" PRIx64 ", glo 0x%" PRIx64 - ", qzss 0x%" PRIx64 ", gal 0x%" PRIx64, + ", qzss 0x%" PRIx64 ", gal 0x%" PRIx64 ", sbas 0x%" PRIx64, mGnssSvIdConfig.bdsBlacklistSvMask, mGnssSvIdConfig.gloBlacklistSvMask, - mGnssSvIdConfig.qzssBlacklistSvMask, mGnssSvIdConfig.galBlacklistSvMask); + mGnssSvIdConfig.qzssBlacklistSvMask, mGnssSvIdConfig.galBlacklistSvMask, + mGnssSvIdConfig.sbasBlacklistSvMask); // Now set required blacklisted SVs return mLocApi->setBlacklistSvSync(mGnssSvIdConfig); @@ -1479,6 +1494,19 @@ GnssAdapter::gnssGetConfigCommand(GnssConfigFlagsMask configMask) { errs[index++] = LOCATION_ERROR_NOT_SUPPORTED; } } + if (mConfigMask & GNSS_CONFIG_FLAGS_ROBUST_LOCATION_BIT) { + uint32_t sessionId = *(mIds+index); + LocApiResponse* locApiResponse = + new LocApiResponse(*mAdapter.getContext(), + [this, sessionId] (LocationError err) { + mAdapter.reportResponse(err, sessionId);}); + if (!locApiResponse) { + LOC_LOGe("memory alloc failed"); + mAdapter.reportResponse(LOCATION_ERROR_GENERAL_FAILURE, sessionId); + } else { + mApi.getRobustLocationConfig(sessionId, locApiResponse); + } + } mAdapter.reportResponse(index, errs, mIds); delete[] errs; @@ -1508,12 +1536,14 @@ GnssAdapter::convertToGnssSvIdConfig( config.bdsBlacklistSvMask = 0; config.qzssBlacklistSvMask = 0; config.galBlacklistSvMask = 0; + config.sbasBlacklistSvMask = 0; retVal = true; } else { // Parse the vector and convert SV IDs to mask values for (GnssSvIdSource source : blacklistedSvIds) { uint64_t* svMaskPtr = NULL; GnssSvId initialSvId = 0; + uint16_t svIndexOffset = 0; switch(source.constellation) { case GNSS_SV_TYPE_GLONASS: svMaskPtr = &config.gloBlacklistSvMask; @@ -1531,6 +1561,28 @@ GnssAdapter::convertToGnssSvIdConfig( svMaskPtr = &config.galBlacklistSvMask; initialSvId = GNSS_SV_CONFIG_GAL_INITIAL_SV_ID; break; + case GNSS_SV_TYPE_SBAS: + // SBAS does not support enable/disable whole constellation + // so do not set up svTypeMask for SBAS + svMaskPtr = &config.sbasBlacklistSvMask; + // SBAS currently has two ranges + // range of SV id: 120 to 158 and 183 to 191 + if (0 == source.svId) { + LOC_LOGd("blacklist all SBAS SV"); + } else if (source.svId >= GNSS_SV_CONFIG_SBAS_INITIAL2_SV_ID) { + // handle SV id in range of 183 to 191 + initialSvId = GNSS_SV_CONFIG_SBAS_INITIAL2_SV_ID; + svIndexOffset = GNSS_SV_CONFIG_SBAS_INITIAL_SV_LENGTH; + } else if ((source.svId >= GNSS_SV_CONFIG_SBAS_INITIAL_SV_ID) && + (source.svId < (GNSS_SV_CONFIG_SBAS_INITIAL_SV_ID + + GNSS_SV_CONFIG_SBAS_INITIAL_SV_LENGTH))){ + // handle SV id in range of 120 to 158 + initialSvId = GNSS_SV_CONFIG_SBAS_INITIAL_SV_ID; + } else { + LOC_LOGe("invalid SBAS sv id %d", source.svId); + svMaskPtr = nullptr; + } + break; default: break; } @@ -1545,7 +1597,8 @@ GnssAdapter::convertToGnssSvIdConfig( LOC_LOGe("Invalid sv id %d for sv type %d", source.svId, source.constellation); } else { - *svMaskPtr |= (1ULL << (source.svId - initialSvId)); + uint32_t shiftCnt = source.svId + svIndexOffset - initialSvId; + *svMaskPtr |= (1ULL << shiftCnt); } } } @@ -1554,41 +1607,49 @@ GnssAdapter::convertToGnssSvIdConfig( if (0 != config.gloBlacklistSvMask || 0 != config.bdsBlacklistSvMask || 0 != config.galBlacklistSvMask || - 0 != config.qzssBlacklistSvMask) { + 0 != config.qzssBlacklistSvMask || + 0 != config.sbasBlacklistSvMask) { retVal = true; } } + LOC_LOGd("blacklist bds 0x%" PRIx64 ", glo 0x%" PRIx64 + ", qzss 0x%" PRIx64 ", gal 0x%" PRIx64 ", sbas 0x%" PRIx64, + config.bdsBlacklistSvMask, config.gloBlacklistSvMask, + config.qzssBlacklistSvMask, config.galBlacklistSvMask, + config.sbasBlacklistSvMask); + return retVal; } void GnssAdapter::convertFromGnssSvIdConfig( - const GnssSvIdConfig& svConfig, GnssConfig& config) + const GnssSvIdConfig& svConfig, std::vector& blacklistedSvIds) { // Convert blacklisted SV mask values to vectors if (svConfig.bdsBlacklistSvMask) { convertGnssSvIdMaskToList( - svConfig.bdsBlacklistSvMask, config.blacklistedSvIds, + svConfig.bdsBlacklistSvMask, blacklistedSvIds, GNSS_SV_CONFIG_BDS_INITIAL_SV_ID, GNSS_SV_TYPE_BEIDOU); - config.flags |= GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT; } if (svConfig.galBlacklistSvMask) { convertGnssSvIdMaskToList( - svConfig.galBlacklistSvMask, config.blacklistedSvIds, + svConfig.galBlacklistSvMask, blacklistedSvIds, GNSS_SV_CONFIG_GAL_INITIAL_SV_ID, GNSS_SV_TYPE_GALILEO); - config.flags |= GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT; } if (svConfig.gloBlacklistSvMask) { convertGnssSvIdMaskToList( - svConfig.gloBlacklistSvMask, config.blacklistedSvIds, + svConfig.gloBlacklistSvMask, blacklistedSvIds, GNSS_SV_CONFIG_GLO_INITIAL_SV_ID, GNSS_SV_TYPE_GLONASS); - config.flags |= GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT; } if (svConfig.qzssBlacklistSvMask) { convertGnssSvIdMaskToList( - svConfig.qzssBlacklistSvMask, config.blacklistedSvIds, + svConfig.qzssBlacklistSvMask, blacklistedSvIds, GNSS_SV_CONFIG_QZSS_INITIAL_SV_ID, GNSS_SV_TYPE_QZSS); - config.flags |= GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT; + } + if (svConfig.sbasBlacklistSvMask) { + convertGnssSvIdMaskToList( + svConfig.sbasBlacklistSvMask, blacklistedSvIds, + GNSS_SV_CONFIG_SBAS_INITIAL_SV_ID, GNSS_SV_TYPE_SBAS); } } @@ -1602,6 +1663,7 @@ void GnssAdapter::convertGnssSvIdMaskToList( // SV ID 0 => All SV IDs in mask if (GNSS_SV_CONFIG_ALL_BITS_ENABLED_MASK == svIdMask) { + LOC_LOGd("blacklist all SVs in constellation %d", source.constellation); source.svId = 0; svIds.push_back(source); return; @@ -1612,6 +1674,18 @@ void GnssAdapter::convertGnssSvIdMaskToList( while (svIdMask > 0) { if (svIdMask & 0x1) { source.svId = bitNumber + initialSvId; + // SBAS has two ranges: + // SBAS - SV 120 to 158, maps to 0 to 38 + // SV 183 to 191, maps to 39 to 47 + // #define GNSS_SV_CONFIG_SBAS_INITIAL_SV_ID 120 + // #define GNSS_SV_CONFIG_SBAS_INITIAL_SV_LENGTH 39 + // #define GNSS_SV_CONFIG_SBAS_INITIAL2_SV_ID 183 + if (svType == GNSS_SV_TYPE_SBAS) { + if (bitNumber >= GNSS_SV_CONFIG_SBAS_INITIAL_SV_LENGTH) { + source.svId = bitNumber - GNSS_SV_CONFIG_SBAS_INITIAL_SV_LENGTH + + GNSS_SV_CONFIG_SBAS_INITIAL2_SV_ID; + } + } svIds.push_back(source); } bitNumber++; @@ -1645,12 +1719,18 @@ void GnssAdapter::reportGnssSvIdConfig(const GnssSvIdConfig& svIdConfig) // Invoke control clients config callback if (nullptr != mControlCallbacks.gnssConfigCb && svIdConfig.size == sizeof(GnssSvIdConfig)) { - convertFromGnssSvIdConfig(svIdConfig, config); - LOC_LOGd("blacklist bds 0x%" PRIx64 ", glo 0x%" PRIx64 - ", qzss 0x%" PRIx64 ", gal 0x%" PRIx64, - svIdConfig.bdsBlacklistSvMask, svIdConfig.gloBlacklistSvMask, - svIdConfig.qzssBlacklistSvMask, svIdConfig.galBlacklistSvMask); - mControlCallbacks.gnssConfigCb(config); + + convertFromGnssSvIdConfig(svIdConfig, config.blacklistedSvIds); + if (config.blacklistedSvIds.size() > 0) { + config.flags |= GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT; + } + LOC_LOGd("blacklist bds 0x%" PRIx64 ", glo 0x%" PRIx64 ", " + "qzss 0x%" PRIx64 ", gal 0x%" PRIx64 ", sbas 0x%" PRIx64, + svIdConfig.bdsBlacklistSvMask, svIdConfig.gloBlacklistSvMask, + svIdConfig.qzssBlacklistSvMask, svIdConfig.galBlacklistSvMask, + svIdConfig.sbasBlacklistSvMask); + // use 0 session id to indicate that receiver does not yet care about session id + mControlCallbacks.gnssConfigCb(0, config); } else { LOC_LOGe("Failed to report, size %d", (uint32_t)config.size); } @@ -1711,6 +1791,12 @@ GnssAdapter::gnssSvTypeConfigUpdate(bool sendReset) mGnssSvTypeConfig.size, mGnssSvTypeConfig.blacklistedSvTypesMask, mGnssSvTypeConfig.enabledSvTypesMask, sendReset); + LOC_LOGd("blacklist bds 0x%" PRIx64 ", glo 0x%" PRIx64 + ", qzss 0x%" PRIx64 ", gal 0x%" PRIx64 ", sbas 0x%" PRIx64, + mGnssSvIdConfig.bdsBlacklistSvMask, mGnssSvIdConfig.gloBlacklistSvMask, + mGnssSvIdConfig.qzssBlacklistSvMask, mGnssSvIdConfig.galBlacklistSvMask, + mGnssSvIdConfig.sbasBlacklistSvMask); + if (mGnssSvTypeConfig.size == sizeof(mGnssSvTypeConfig)) { if (sendReset) { @@ -2097,8 +2183,6 @@ GnssAdapter::addClientCommand(LocationAPI* client, const LocationCallbacks& call inline virtual void proc() const { // check whether we need to notify client of cached location system info mAdapter.notifyClientOfCachedLocationSystemInfo(mClient, mCallbacks); - // check whether we need to request sv poly for the registered client - mAdapter.requestSvPolyForClient(mClient, mCallbacks); mAdapter.saveClient(mClient, mCallbacks); } }; @@ -2159,9 +2243,6 @@ GnssAdapter::updateClientsEventMask() if (it->second.gnssMeasurementsCb != nullptr) { mask |= LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT; } - if (it->second.gnssSvPolynomialCb != nullptr) { - mask |= LOC_API_ADAPTER_BIT_GNSS_SV_POLYNOMIAL_REPORT; - } if (it->second.gnssDataCb != nullptr) { mask |= LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT; mask |= LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT; @@ -2228,7 +2309,8 @@ GnssAdapter::handleEngineUpEvent() mAdapter.gnssSvIdConfigUpdate(); mAdapter.gnssSvTypeConfigUpdate(); mAdapter.updateSystemPowerState(mAdapter.getSystemPowerState()); - mAdapter.restartSessions(); + // restart sessions + mAdapter.restartSessions(true); for (auto msg: mAdapter.mPendingMsgs) { mAdapter.sendMsg(msg); } @@ -2241,12 +2323,14 @@ GnssAdapter::handleEngineUpEvent() } void -GnssAdapter::restartSessions() +GnssAdapter::restartSessions(bool modemSSR) { - LOC_LOGD("%s]: ", __func__); + LOC_LOGi(":enter"); - // odcpi session is no longer active after restart - mOdcpiRequestActive = false; + if (modemSSR) { + // odcpi session is no longer active after restart + mOdcpiRequestActive = false; + } // SPE will be restarted now, so set this variable to false. mSPEAlreadyRunningAtHighestInterval = false; @@ -2261,6 +2345,20 @@ GnssAdapter::restartSessions() } } +// suspend all on-going sessions +void +GnssAdapter::suspendSessions() +{ + LOC_LOGi(":enter"); + + if (!mTimeBasedTrackingSessions.empty()) { + // inform engine hub that GNSS session has stopped + mEngHubProxy->gnssStopFix(); + mLocApi->stopFix(nullptr); + mSPEAlreadyRunningAtHighestInterval = false; + } +} + void GnssAdapter::checkAndRestartTimeBasedSession() { LOC_LOGD("%s]: ", __func__); @@ -2345,8 +2443,7 @@ GnssAdapter::hasCallbacksToStartTracking(LocationAPI* client) auto it = mClientData.find(client); if (it != mClientData.end()) { if (it->second.trackingCb || it->second.gnssLocationInfoCb || - it->second.engineLocationsInfoCb || it->second.gnssMeasurementsCb || - it->second.gnssSvPolynomialCb) { + it->second.engineLocationsInfoCb || it->second.gnssMeasurementsCb) { allowed = true; } else { LOC_LOGi("missing right callback to start tracking") @@ -3404,12 +3501,18 @@ GnssAdapter::reportPosition(const UlpLocation& ulpLocation, } } - // 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); + // if PACE is enabled + if ((true == mLocConfigInfo.paceConfigInfo.isValid) && + (true == mLocConfigInfo.paceConfigInfo.enable)) { + // If fix has sensor contribution, and it is fused fix with DRE engine + // contributing to the fix, inject to modem + if ((LOC_POS_TECH_MASK_SENSORS & techMask) && + (locationInfo.flags & GNSS_LOCATION_INFO_OUTPUT_ENG_TYPE_BIT) && + (locationInfo.locOutputEngType == LOC_OUTPUT_ENGINE_FUSED) && + (locationInfo.flags & GNSS_LOCATION_INFO_OUTPUT_ENG_MASK_BIT) && + (locationInfo.locOutputEngMask & DEAD_RECKONING_ENGINE)) { + mLocApi->injectPosition(locationInfo, false); + } } } } @@ -3618,10 +3721,6 @@ GnssAdapter::reportSv(GnssSvNotification& svNotify) svUsedIdMask = mGnssSvIdUsedInPosition.qzss_sv_used_ids_mask; } } - // QZSS SV id's need to reported as it is to framework, since - // framework expects it as it is. See GnssStatus.java. - // SV id passed to here by LocApi is 1-based. - svNotify.gnssSvs[i].svId += (QZSS_SV_PRN_MIN - 1); break; case GNSS_SV_TYPE_NAVIC: if (mGnssSvIdUsedInPosAvail) { @@ -4095,53 +4194,11 @@ GnssAdapter::reportGnssMeasurementData(const GnssMeasurementsNotification& measu } } -void -GnssAdapter::requestSvPolyForClient(LocationAPI* client, const LocationCallbacks& callbacks) { - if (callbacks.gnssSvPolynomialCb) { - LocationCallbacks oldCallbacks = getClientCallbacks(client); - if (!oldCallbacks.gnssSvPolynomialCb) { - LOC_LOGd("request sv poly"); - GnssAidingDataSvMask svDataMask = GNSS_AIDING_DATA_SV_POLY_BIT; - mLocApi->requestForAidingData(svDataMask); - } - } -} - -void -GnssAdapter::reportSvPolynomial(const GnssSvPolynomial &svPolynomial) -{ - for (auto it=mClientData.begin(); it != mClientData.end(); ++it) { - if (nullptr != it->second.gnssSvPolynomialCb) { - it->second.gnssSvPolynomialCb(svPolynomial); - } - } -} - void GnssAdapter::reportSvPolynomialEvent(GnssSvPolynomial &svPolynomial) { LOC_LOGD("%s]: ", __func__); - - // report SV poly to engine hub to dispatch to engine plugins mEngHubProxy->gnssReportSvPolynomial(svPolynomial); - - // report SV poly to registered client - struct MsgReportGnssSvPolynomial : public LocMsg { - GnssAdapter& mAdapter; - GnssSvPolynomial mGnssSvPolynomialNotify; - inline MsgReportGnssSvPolynomial(GnssAdapter& adapter, - const GnssSvPolynomial& svPoly) : - LocMsg(), - mAdapter(adapter), - mGnssSvPolynomialNotify(svPoly) { - } - - inline virtual void proc() const { - mAdapter.reportSvPolynomial(mGnssSvPolynomialNotify); - } - }; - - sendMsg(new MsgReportGnssSvPolynomial(*this, svPolynomial)); } void @@ -4208,8 +4265,12 @@ void GnssAdapter::requestOdcpi(const OdcpiRequestInfo& request) // the request is being stopped, but allow timer to expire first // before stopping the timer just in case more ODCPI requests come // to avoid spamming more odcpi requests to the framework - } else { + } else if (ODCPI_REQUEST_TYPE_STOP == request.type) { + LOC_LOGd("request: type %d, isEmergency %d", request.type, request.isEmergencyMode); + mOdcpiRequestCb(request); mOdcpiRequestActive = false; + } else { + LOC_LOGE("Invalid ODCPI request type.."); } } else { LOC_LOGw("ODCPI request not supported"); @@ -4238,31 +4299,38 @@ bool GnssAdapter::reportGnssAdditionalSystemInfoEvent( return true; } -void GnssAdapter::initOdcpiCommand(const OdcpiRequestCallback& callback) +void GnssAdapter::initOdcpiCommand(const OdcpiRequestCallback& callback, + OdcpiPrioritytype priority) { struct MsgInitOdcpi : public LocMsg { GnssAdapter& mAdapter; OdcpiRequestCallback mOdcpiCb; + OdcpiPrioritytype mPriority; inline MsgInitOdcpi(GnssAdapter& adapter, - const OdcpiRequestCallback& callback) : + const OdcpiRequestCallback& callback, + OdcpiPrioritytype priority) : LocMsg(), mAdapter(adapter), - mOdcpiCb(callback) {} + mOdcpiCb(callback), mPriority(priority){} inline virtual void proc() const { - mAdapter.initOdcpi(mOdcpiCb); + mAdapter.initOdcpi(mOdcpiCb, mPriority); } }; - sendMsg(new MsgInitOdcpi(*this, callback)); + sendMsg(new MsgInitOdcpi(*this, callback, priority)); } -void GnssAdapter::initOdcpi(const OdcpiRequestCallback& callback) +void GnssAdapter::initOdcpi(const OdcpiRequestCallback& callback, + OdcpiPrioritytype priority) { - mOdcpiRequestCb = callback; - - /* Register for WIFI request */ - updateEvtMask(LOC_API_ADAPTER_BIT_REQUEST_WIFI, - LOC_REGISTRATION_MASK_ENABLED); + LOC_LOGd("In priority: %d, Curr priority: %d", priority, mCallbackPriority); + if (priority >= mCallbackPriority) { + mOdcpiRequestCb = callback; + mCallbackPriority = priority; + /* Register for WIFI request */ + updateEvtMask(LOC_API_ADAPTER_BIT_REQUEST_WIFI, + LOC_REGISTRATION_MASK_ENABLED); + } } void GnssAdapter::injectOdcpiCommand(const Location& location) @@ -5263,6 +5331,8 @@ GnssAdapter::updateSvConfig(uint32_t sessionId, mGnssSvTypeConfig = svTypeConfig; mGnssSvIdConfig = svIdConfig; + mBlacklistedSvIds.clear(); + convertFromGnssSvIdConfig(svIdConfig, mBlacklistedSvIds); // Send blacklist info mLocApi->setBlacklistSv(mGnssSvIdConfig); @@ -5317,6 +5387,17 @@ uint32_t GnssAdapter::gnssUpdateSvConfigCommand( void GnssAdapter::resetSvConfig(uint32_t sessionId) { + // Clear blacklisting + memset(&mGnssSvIdConfig, 0, sizeof(GnssSvIdConfig)); + mGnssSvIdConfig.size = sizeof(mGnssSvIdConfig); + mBlacklistedSvIds.clear(); + gnssSvIdConfigUpdate(); + + // Reset constellation config, including mGnssSvTypeConfig + // when size is set to 0, upon subsequent modem restart, sv type + // config will not be sent down to modem + gnssSetSvTypeConfig({sizeof(GnssSvTypeConfig), 0, 0}); + LocApiResponse* locApiResponse = nullptr; if (sessionId != 0) { locApiResponse = @@ -5393,6 +5474,91 @@ GnssAdapter::configLeverArmCommand(const LeverArmConfigInfo& configInfo) { return sessionId; } + +void +GnssAdapter::configRobustLocation(uint32_t sessionId, + bool enable, bool enableForE911) { + + mLocConfigInfo.robustLocationConfigInfo.isValid = true; + mLocConfigInfo.robustLocationConfigInfo.enable = enable; + mLocConfigInfo.robustLocationConfigInfo.enableFor911 = enableForE911; + + // suspend all tracking sessions so modem can take the E911 configure + suspendSessions(); + + 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->configRobustLocation(enable, enableForE911, locApiResponse); + + // resume all tracking sessions after the E911 configure + restartSessions(false); +} + +uint32_t GnssAdapter::configRobustLocationCommand( + bool enable, bool enableForE911) { + + // generated session id will be none-zero + uint32_t sessionId = generateSessionId(); + LOC_LOGd("session id %u", sessionId); + + struct MsgConfigRobustLocation : public LocMsg { + GnssAdapter& mAdapter; + uint32_t mSessionId; + bool mEnable; + bool mEnableForE911; + + inline MsgConfigRobustLocation(GnssAdapter& adapter, + uint32_t sessionId, + bool enable, + bool enableForE911) : + LocMsg(), + mAdapter(adapter), + mSessionId(sessionId), + mEnable(enable), + mEnableForE911(enableForE911) {} + inline virtual void proc() const { + mAdapter.configRobustLocation(mSessionId, mEnable, mEnableForE911); + } + }; + + sendMsg(new MsgConfigRobustLocation(*this, sessionId, enable, enableForE911)); + return sessionId; +} + +void GnssAdapter::reportGnssConfigEvent(uint32_t sessionId, const GnssConfig& gnssConfig) +{ + struct MsgReportGnssConfig : public LocMsg { + GnssAdapter& mAdapter; + uint32_t mSessionId; + mutable GnssConfig mGnssConfig; + inline MsgReportGnssConfig(GnssAdapter& adapter, + uint32_t sessionId, + const GnssConfig& gnssConfig) : + LocMsg(), + mAdapter(adapter), + mSessionId(sessionId), + mGnssConfig(gnssConfig) {} + inline virtual void proc() const { + // Invoke control clients config callback + if (nullptr != mAdapter.mControlCallbacks.gnssConfigCb) { + mAdapter.mControlCallbacks.gnssConfigCb(mSessionId, mGnssConfig); + } else { + LOC_LOGe("Failed to report, callback not registered"); + } + } + }; + + sendMsg(new MsgReportGnssConfig(*this, sessionId, gnssConfig)); +} + /* ==== Eng Hub Proxy ================================================================= */ /* ======== UTILITIES ================================================================= */ void diff --git a/gps/gnss/GnssAdapter.h b/gps/gnss/GnssAdapter.h index 32bd84e0..b197247f 100644 --- a/gps/gnss/GnssAdapter.h +++ b/gps/gnss/GnssAdapter.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. +/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -134,9 +134,16 @@ typedef struct { bool enable; } PaceConfigInfo; +typedef struct { + bool isValid; + bool enable; + bool enableFor911; +} RobustLocationConfigInfo; + typedef struct { TuncConfigInfo tuncConfigInfo; PaceConfigInfo paceConfigInfo; + RobustLocationConfigInfo robustLocationConfigInfo; } LocIntegrationConfigInfo; using namespace loc_core; @@ -196,6 +203,7 @@ class GnssAdapter : public LocAdapterBase { /* ==== ODCPI ========================================================================== */ OdcpiRequestCallback mOdcpiRequestCb; bool mOdcpiRequestActive; + OdcpiPrioritytype mCallbackPriority; OdcpiTimer mOdcpiTimer; OdcpiRequestInfo mOdcpiRequest; void odcpiTimerExpire(); @@ -229,7 +237,7 @@ class GnssAdapter : public LocAdapterBase { int totalSvCntInThisConstellation); /* ======== UTILITIES ================================================================== */ - inline void initOdcpi(const OdcpiRequestCallback& callback); + inline void initOdcpi(const OdcpiRequestCallback& callback, OdcpiPrioritytype priority); inline void injectOdcpi(const Location& location); static bool isFlpClient(LocationCallbacks& locationCallbacks); @@ -248,8 +256,9 @@ public: /* ======== EVENTS ====(Called from QMI Thread)========================================= */ virtual void handleEngineUpEvent(); /* ======== UTILITIES ================================================================== */ - void restartSessions(); + void restartSessions(bool modemSSR = false); void checkAndRestartTimeBasedSession(); + void suspendSessions(); /* ==== CLIENT ========================================================================= */ /* ======== COMMANDS ====(Called from Client Thread)==================================== */ @@ -295,6 +304,7 @@ public: const GnssSvIdConfig& svIdConfig); void resetSvConfig(uint32_t sessionId); void configLeverArm(uint32_t sessionId, const LeverArmConfigInfo& configInfo); + void configRobustLocation(uint32_t sessionId, bool enable, bool enableForE911); /* ==== NI ============================================================================= */ /* ======== COMMANDS ====(Called from Client Thread)==================================== */ @@ -362,10 +372,11 @@ public: const GnssSvIdConfig& svIdConfig); uint32_t gnssResetSvConfigCommand(); uint32_t configLeverArmCommand(const LeverArmConfigInfo& configInfo); + uint32_t configRobustLocationCommand(bool enable, bool enableForE911); /* ========= ODCPI ===================================================================== */ /* ======== COMMANDS ====(Called from Client Thread)==================================== */ - void initOdcpiCommand(const OdcpiRequestCallback& callback); + void initOdcpiCommand(const OdcpiRequestCallback& callback, OdcpiPrioritytype priority); void injectOdcpiCommand(const Location& location); /* ======== RESPONSES ================================================================== */ void reportResponse(LocationError err, uint32_t sessionId); @@ -404,6 +415,7 @@ public: virtual void reportSvEphemerisEvent(GnssSvEphemerisReport & svEphemeris); virtual void reportGnssSvIdConfigEvent(const GnssSvIdConfig& config); virtual void reportGnssSvTypeConfigEvent(const GnssSvTypeConfig& config); + virtual void reportGnssConfigEvent(uint32_t sessionId, const GnssConfig& gnssConfig); virtual bool reportGnssEngEnergyConsumedEvent(uint64_t energyConsumedSinceFirstBoot); virtual void reportLocationSystemInfoEvent(const LocationSystemInfo& locationSystemInfo); @@ -452,8 +464,7 @@ public: void updateSystemPowerState(PowerStateType systemPowerState); void reportSvPolynomial(const GnssSvPolynomial &svPolynomial); - void requestSvPolyForClient(LocationAPI* client, - const LocationCallbacks& callbacks); + /*======== GNSSDEBUG ================================================================*/ @@ -483,7 +494,7 @@ public: static bool convertToGnssSvIdConfig( const std::vector& blacklistedSvIds, GnssSvIdConfig& config); static void convertFromGnssSvIdConfig( - const GnssSvIdConfig& svConfig, GnssConfig& config); + const GnssSvIdConfig& svConfig, std::vector& blacklistedSvIds); static void convertGnssSvIdMaskToList( uint64_t svIdMask, std::vector& svIds, GnssSvId initialSvId, GnssSvType svType); diff --git a/gps/gnss/location_gnss.cpp b/gps/gnss/location_gnss.cpp index 97e99e42..50e8872f 100644 --- a/gps/gnss/location_gnss.cpp +++ b/gps/gnss/location_gnss.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. +/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -73,7 +73,7 @@ static void enableNfwLocationAccess(bool enable); static void nfwInit(const NfwCbInfo& cbInfo); static void getPowerStateChanges(void* powerStateCb); -static void odcpiInit(const OdcpiRequestCallback& callback); +static void odcpiInit(const OdcpiRequestCallback& callback, OdcpiPrioritytype priority); static void odcpiInject(const Location& location); static void blockCPI(double latitude, double longitude, float accuracy, @@ -87,6 +87,7 @@ static uint32_t gnssUpdateSvConfig(const GnssSvTypeConfig& svTypeConfig, const GnssSvIdConfig& svIdConfig); static uint32_t gnssResetSvConfig(); static uint32_t configLeverArm(const LeverArmConfigInfo& configInfo); +static uint32_t configRobustLocation(bool enable, bool enableForE911); static const GnssInterface gGnssInterface = { sizeof(GnssInterface), @@ -132,6 +133,7 @@ static const GnssInterface gGnssInterface = { gnssUpdateSvConfig, gnssResetSvConfig, configLeverArm, + configRobustLocation, }; #ifndef DEBUG_X86 @@ -140,6 +142,7 @@ extern "C" const GnssInterface* getGnssInterface() const GnssInterface* getGnssInterface() #endif // DEBUG_X86 { + gGnssInterface.initialize(); return &gGnssInterface; } @@ -346,10 +349,10 @@ static void updateConnectionStatus(bool connected, int8_t type, } } -static void odcpiInit(const OdcpiRequestCallback& callback) +static void odcpiInit(const OdcpiRequestCallback& callback, OdcpiPrioritytype priority) { if (NULL != gGnssAdapter) { - gGnssAdapter->initOdcpiCommand(callback); + gGnssAdapter->initOdcpiCommand(callback, priority); } } @@ -453,3 +456,11 @@ static uint32_t configLeverArm(const LeverArmConfigInfo& configInfo){ return 0; } } + +static uint32_t configRobustLocation(bool enable, bool enableForE911){ + if (NULL != gGnssAdapter) { + return gGnssAdapter->configRobustLocationCommand(enable, enableForE911); + } else { + return 0; + } +} diff --git a/gps/location/ILocationAPI.h b/gps/location/ILocationAPI.h index 87aa99bd..b53e41ea 100644 --- a/gps/location/ILocationAPI.h +++ b/gps/location/ILocationAPI.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2018 The Linux Foundation. All rights reserved. +/* Copyright (c) 2018-2020 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -302,6 +302,27 @@ public: LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid */ virtual uint32_t configLeverArm(const LeverArmConfigInfo& configInfo) = 0; + + /** @brief + Configure the robust location setting. + + @param + enable: true to enable robust location and false to disable + robust location. + + @param + enableForE911: true to enable robust location when device is on + E911 session and false to disable on E911 session. + This parameter is only valid if robust location is enabled. + + @return + A session id that will be returned in responseCallback to + match command with response. This effect is global for all + clients of LocationAPI responseCallback returns: + LOCATION_ERROR_SUCCESS if successful + LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid + */ + virtual uint32_t configRobustLocation(bool enable, bool enableForE911) = 0; }; #endif /* ILOCATIONAPI_H */ diff --git a/gps/location/LocationAPI.cpp b/gps/location/LocationAPI.cpp index d0a560d1..dd0b002f 100644 --- a/gps/location/LocationAPI.cpp +++ b/gps/location/LocationAPI.cpp @@ -87,7 +87,7 @@ static bool isGnssClient(LocationCallbacks& locationCallbacks) locationCallbacks.gnssLocationInfoCb != nullptr || locationCallbacks.engineLocationsInfoCb != nullptr || locationCallbacks.gnssMeasurementsCb != nullptr || - locationCallbacks.gnssSvPolynomialCb != nullptr); + locationCallbacks.locationSystemInfoCb != nullptr); } static bool isBatchingClient(LocationCallbacks& locationCallbacks) @@ -796,3 +796,17 @@ uint32_t LocationControlAPI::configLeverArm(const LeverArmConfigInfo& configInfo pthread_mutex_unlock(&gDataMutex); return id; } + +uint32_t LocationControlAPI::configRobustLocation(bool enable, bool enableForE911) { + uint32_t id = 0; + pthread_mutex_lock(&gDataMutex); + + if (gData.gnssInterface != NULL) { + id = gData.gnssInterface->configRobustLocation(enable, enableForE911); + } else { + LOC_LOGe("No gnss interface available for Location Control API"); + } + + pthread_mutex_unlock(&gDataMutex); + return id; +} diff --git a/gps/location/LocationAPI.h b/gps/location/LocationAPI.h index f70fc2f8..c949fcc7 100644 --- a/gps/location/LocationAPI.h +++ b/gps/location/LocationAPI.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. +/* Copyright (c) 2017-2020 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -374,6 +374,27 @@ public: LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid */ virtual uint32_t configLeverArm(const LeverArmConfigInfo& configInfo) override; + + /** @brief + Configure the robust location setting. + + @param + enable: true to enable robust location and false to disable + robust location. + + @param + enableForE911: true to enable robust location when device is + on E911 session and false to disable on E911 session. + This parameter is only valid if robust location is enabled. + + @return + A session id that will be returned in responseCallback to + match command with response. This effect is global for all + clients of LocationAPI responseCallback returns: + LOCATION_ERROR_SUCCESS if successful + LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid + */ + virtual uint32_t configRobustLocation(bool enable, bool enableForE911) override; }; #endif /* LOCATIONAPI_H */ diff --git a/gps/location/LocationDataTypes.h b/gps/location/LocationDataTypes.h index 3ff3e4a2..f987c75f 100644 --- a/gps/location/LocationDataTypes.h +++ b/gps/location/LocationDataTypes.h @@ -177,6 +177,7 @@ typedef enum { GNSS_LOCATION_INFO_CALIBRATION_STATUS_BIT = (1<<26), // valid sensor cal status GNSS_LOCATION_INFO_OUTPUT_ENG_TYPE_BIT = (1<<27), // valid output engine type GNSS_LOCATION_INFO_OUTPUT_ENG_MASK_BIT = (1<<28), // valid output engine mask + GNSS_LOCATION_INFO_CONFORMITY_INDEX_BIT = (1<<29), // valid conformity index } GnssLocationInfoFlagBits; typedef enum { @@ -318,6 +319,7 @@ typedef enum { GNSS_CONFIG_FLAGS_SUPL_MODE_BIT = (1<<9), GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT = (1<<10), GNSS_CONFIG_FLAGS_EMERGENCY_EXTENSION_SECONDS_BIT = (1<<11), + GNSS_CONFIG_FLAGS_ROBUST_LOCATION_BIT = (1<<12), } GnssConfigFlagsBits; typedef enum { @@ -1044,6 +1046,11 @@ typedef struct { // when loc output eng type is set to fused, this field // indicates the set of engines contribute to the fix. PositioningEngineMask locOutputEngMask; + /* When robust location is enabled, this field + * will how well the various input data considered for + * navigation solution conform to expectations. + * Range: 0 (least conforming) to 1 (most conforming) */ + float conformityIndex; } GnssLocationInfoNotification; typedef struct { @@ -1148,6 +1155,7 @@ typedef struct { double agcLevelDb; GnssMeasurementsCodeType codeType; char otherCodeTypeName[GNSS_MAX_NAME_LENGTH]; + int16_t gloFrequency; } GnssMeasurementsData; typedef struct { @@ -1192,80 +1200,6 @@ typedef struct { GnssMeasurementsClock clock; // clock } GnssMeasurementsNotification; -#define GNSS_SV_POLY_VELOCITY_COEF_MAX_SIZE 12 -#define GNSS_SV_POLY_XYZ_0_TH_ORDER_COEFF_MAX_SIZE 3 -#define GNSS_SV_POLY_XYZ_N_TH_ORDER_COEFF_MAX_SIZE 9 -#define GNSS_SV_POLY_SV_CLKBIAS_COEFF_MAX_SIZE 4 - -typedef uint16_t GnssSvPolyStatusMask; -#define GNSS_SV_POLY_SRC_ALM_CORR_V02 ((GnssSvPolyStatusMask)0x01) -#define GNSS_SV_POLY_GLO_STR4_V02 ((GnssSvPolyStatusMask)0x02) -#define GNSS_SV_POLY_DELETE_V02 ((GnssSvPolyStatusMask)0x04) -#define GNSS_SV_POLY_SRC_GAL_FNAV_OR_INAV_V02 ((GnssSvPolyStatusMask)0x08) -typedef uint16_t GnssSvPolyStatusMaskValidity; -#define GNSS_SV_POLY_SRC_ALM_CORR_VALID_V02 ((GnssSvPolyStatusMaskValidity)0x01) -#define GNSS_SV_POLY_GLO_STR4_VALID_V02 ((GnssSvPolyStatusMaskValidity)0x02) -#define GNSS_SV_POLY_DELETE_VALID_V02 ((GnssSvPolyStatusMaskValidity)0x04) -#define GNSS_SV_POLY_SRC_GAL_FNAV_OR_INAV_VALID_V02 ((GnssSvPolyStatusMaskValidity)0x08) - -typedef struct { - uint32_t size; - uint16_t gnssSvId; - /* GPS: 1-32, GLO: 65-96, 0: Invalid, - SBAS: 120-151, BDS:201-237,GAL:301 to 336 - All others are reserved - */ - int8_t freqNum; - /* Freq index, only valid if u_SysInd is GLO */ - - GnssSvPolyStatusMaskValidity svPolyStatusMaskValidity; - GnssSvPolyStatusMask svPolyStatusMask; - - uint32_t is_valid; - - uint16_t iode; - /* Ephemeris reference time - GPS:Issue of Data Ephemeris used [unitless]. - GLO: Tb 7-bit, refer to ICD02 - */ - double T0; - /* Reference time for polynominal calculations - GPS: Secs in week. - GLO: Full secs since Jan/01/96 - */ - double polyCoeffXYZ0[GNSS_SV_POLY_XYZ_0_TH_ORDER_COEFF_MAX_SIZE]; - /* C0X, C0Y, C0Z */ - double polyCoefXYZN[GNSS_SV_POLY_XYZ_N_TH_ORDER_COEFF_MAX_SIZE]; - /* C1X, C2X ... C2Z, C3Z */ - float polyCoefOther[GNSS_SV_POLY_SV_CLKBIAS_COEFF_MAX_SIZE]; - /* C0T, C1T, C2T, C3T */ - float svPosUnc; /* SV position uncertainty [m]. */ - float ionoDelay; /* Ionospheric delay at d_T0 [m]. */ - float ionoDot; /* Iono delay rate [m/s]. */ - float sbasIonoDelay;/* SBAS Ionospheric delay at d_T0 [m]. */ - float sbasIonoDot; /* SBAS Iono delay rate [m/s]. */ - float tropoDelay; /* Tropospheric delay [m]. */ - float elevation; /* Elevation [rad] at d_T0 */ - float elevationDot; /* Elevation rate [rad/s] */ - float elevationUnc; /* SV elevation [rad] uncertainty */ - double velCoef[GNSS_SV_POLY_VELOCITY_COEF_MAX_SIZE]; - /* Coefficients of velocity poly */ - uint32_t enhancedIOD; /* Enhanced Reference Time */ - float gpsIscL1ca; - float gpsIscL2c; - float gpsIscL5I5; - float gpsIscL5Q5; - float gpsTgd; - float gloTgdG1G2; - float bdsTgdB1; - float bdsTgdB2; - float bdsTgdB2a; - float bdsIscB2a; - float galBgdE1E5a; - float galBgdE1E5b; - float navicTgdL5; -} GnssSvPolynomial; - typedef uint32_t GnssSvId; struct GnssSvIdSource{ @@ -1308,6 +1242,32 @@ typedef struct { uint64_t sbasBlacklistSvMask; } GnssSvIdConfig; +// Specify the valid mask for robust location configure that +// will be returned via LocConfigGetMinGpsWeekCb when invoking +// getRobustLocationConfig. */ +enum GnssConfigRobustLocationValidMask { + // GnssConfigRobustLocation has valid enabled field. + GNSS_CONFIG_ROBUST_LOCATION_ENABLED_VALID_BIT = (1<<0), + // GnssConfigRobustLocation has valid enabledForE911 field. + GNSS_CONFIG_ROBUST_LOCATION_ENABLED_FOR_E911_VALID_BIT = (1<<1), +}; + +// specify the robust location configuration used by modem GNSS engine +struct GnssConfigRobustLocation { + GnssConfigRobustLocationValidMask validMask; + bool enabled; + bool enabledForE911; + + inline bool equals(const GnssConfigRobustLocation& config) const { + if (config.validMask == validMask && + config.enabled == enabled && + config.enabledForE911 == enabledForE911) { + return true; + } + return false; + } +}; + struct GnssConfig{ uint32_t size; // set to sizeof(GnssConfig) GnssConfigFlagsMask flags; // bitwise OR of GnssConfigFlagsBits to mark which params are valid @@ -1323,6 +1283,7 @@ struct GnssConfig{ GnssConfigSuplModeMask suplModeMask; //bitwise OR of GnssConfigSuplModeBits std::vector blacklistedSvIds; uint32_t emergencyExtensionSeconds; + GnssConfigRobustLocation robustLocationConfig; inline bool equals(const GnssConfig& config) { if (flags == config.flags && @@ -1337,7 +1298,8 @@ struct GnssConfig{ suplEmergencyServices == config.suplEmergencyServices && suplModeMask == config.suplModeMask && blacklistedSvIds == config.blacklistedSvIds && - emergencyExtensionSeconds == config.emergencyExtensionSeconds) { + emergencyExtensionSeconds == config.emergencyExtensionSeconds && + robustLocationConfig.equals(config.robustLocationConfig)) { return true; } return false; @@ -1608,17 +1570,10 @@ typedef std::function gnssMeasurementsCallback; -/* Gives GNSS SV poly information, optional can be NULL - gnssSvPolyCallback is called only during a tracking session - broadcasted to all clients that registers for the poly */ -typedef std::function gnssSvPolynomialCallback; - - /* Provides the current GNSS configuration to the client */ typedef std::function gnssConfigCallback; /* LocationSystemInfoCb is for receiving rare occuring location @@ -1656,7 +1611,6 @@ typedef struct { batchingStatusCallback batchingStatusCb; // optional locationSystemInfoCallback locationSystemInfoCb; // optional engineLocationsInfoCallback engineLocationsInfoCb; // optional - gnssSvPolynomialCallback gnssSvPolynomialCb; // optional } LocationCallbacks; #endif /* LOCATIONDATATYPES_H */ diff --git a/gps/location/Makefile.am b/gps/location/Makefile.am index fccdf94d..6a5a7502 100644 --- a/gps/location/Makefile.am +++ b/gps/location/Makefile.am @@ -11,6 +11,10 @@ liblocation_api_la_SOURCES = \ LocationAPI.cpp \ LocationAPIClientBase.cpp +if USE_EXTERNAL_AP +AM_CFLAGS += -DFEATURE_EXTERNAL_AP +endif + if USE_GLIB liblocation_api_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@ liblocation_api_la_LDFLAGS = -lstdc++ -Wl,-z,defs -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 diff --git a/gps/location/configure.ac b/gps/location/configure.ac index 39abb69f..f8376f56 100644 --- a/gps/location/configure.ac +++ b/gps/location/configure.ac @@ -74,6 +74,19 @@ fi AM_CONDITIONAL(USE_GLIB, test "x${with_glib}" = "xyes") +# External AP +AC_ARG_WITH([external_ap], + AC_HELP_STRING([--with-external_ap=@<:@dir@:>@], + [Using External Application Processor]), + [], + with_external_ap=no) + +if test "x$with_external_ap" != "xno"; then + CPPFLAGS="${CPPFLAGS} -DFEATURE_EXTERNAL_AP" +fi + +AM_CONDITIONAL(USE_EXTERNAL_AP, test "x${with_external_ap}" = "xyes") + AC_CONFIG_FILES([ \ Makefile \ location-api.pc \ diff --git a/gps/location/location_interface.h b/gps/location/location_interface.h index 6edb9116..4eb0549e 100644 --- a/gps/location/location_interface.h +++ b/gps/location/location_interface.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2017-2019 The Linux Foundation. All rights reserved. +/* Copyright (c) 2017-2020 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -78,7 +78,7 @@ struct GnssInterface { void (*getDebugReport)(GnssDebugReport& report); void (*updateConnectionStatus)(bool connected, int8_t type, bool roaming, NetworkHandle networkHandle); - void (*odcpiInit)(const OdcpiRequestCallback& callback); + void (*odcpiInit)(const OdcpiRequestCallback& callback, OdcpiPrioritytype priority); void (*odcpiInject)(const Location& location); void (*blockCPI)(double latitude, double longitude, float accuracy, int blockDurationMsec, double latLonDiffThreshold); @@ -95,6 +95,7 @@ struct GnssInterface { const GnssSvIdConfig& svIdConfig); uint32_t (*gnssResetSvConfig)(); uint32_t (*configLeverArm)(const LeverArmConfigInfo& configInfo); + uint32_t (*configRobustLocation)(bool enable, bool enableForE911); }; struct BatchingInterface { diff --git a/gps/pla/oe/loc_pla.h b/gps/pla/oe/loc_pla.h index bbdb0bd3..2ab0aaa4 100644 --- a/gps/pla/oe/loc_pla.h +++ b/gps/pla/oe/loc_pla.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2014, The Linux Foundation. All rights reserved. +/* Copyright (c) 2014, 2020 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -37,6 +37,22 @@ #include #include +#if defined(__GNUC__) && defined(__GNUC_PREREQ) +#if __GNUC_PREREQ(6,0) + #pragma message "GNU C version is above 6" +#else + #pragma message "GNU C version is less than 6" + #define NO_UNORDERED_SET_OR_MAP +#endif +#endif + +// use set/map instead of unordered_set/unordered_map for +// older GCC versions +#ifdef NO_UNORDERED_SET_OR_MAP +#define unordered_set set +#define unordered_map map +#endif + inline int64_t sysTimeMillis(int clock) { struct timespec ts; @@ -61,6 +77,8 @@ extern "C" { #include #include #include +#else +#define set_sched_policy(a, b) #endif /* FEATURE_EXTERNAL_AP */ #include #include diff --git a/gps/utils/LocUnorderedSetMap.h b/gps/utils/LocUnorderedSetMap.h index 87481348..7b25ad0f 100644 --- a/gps/utils/LocUnorderedSetMap.h +++ b/gps/utils/LocUnorderedSetMap.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved. +/* Copyright (c) 2015, 2017, 2020 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -30,8 +30,15 @@ #define __LOC_UNORDERDED_SETMAP_H__ #include -#include -#include +#include + +#ifdef NO_UNORDERED_SET_OR_MAP + #include + #include +#else + #include + #include +#endif using std::unordered_set; using std::unordered_map; @@ -55,7 +62,7 @@ inline static void trimSet(unordered_set& fromSet, const unordered_set& rV // *s1* and *s2* will be left with the intersect removed from them. template static unordered_set removeAndReturnInterset(unordered_set& s1, unordered_set& s2) { - unordered_set common(0); + unordered_set common = {}; for (auto b = s2.begin(); b != s2.end(); b++) { auto a = find(s1.begin(), s1.end(), *b); if (a != s1.end()) { @@ -73,7 +80,6 @@ template class LocUnorderedSetMap { unordered_map> mMap; - // Trim the VALs pointed to by *iter*, with everything that also exist in *rVals*. // If the set becomes empty, remove the map entry. *goneVals*, if not null, records // the trimmed VALs. @@ -89,7 +95,9 @@ class LocUnorderedSetMap { public: inline LocUnorderedSetMap() {} - inline LocUnorderedSetMap(size_t size) : mMap(size) {} + inline LocUnorderedSetMap(size_t size) : LocUnorderedSetMap() { + mMap.get_allocator().allocate(size); + } inline bool empty() { return mMap.empty(); } @@ -104,12 +112,12 @@ public: // If the entry is not in the map, an empty set will be returned. inline unordered_set getValSet(const KEY& key) { auto entry = mMap.find(key); - return (entry != mMap.end()) ? entry->second : unordered_set(0); + return (entry != mMap.end()) ? entry->second : unordered_set{}; } // This gets all the KEYs from the map inline unordered_set getKeys() { - unordered_set keys(0); + unordered_set keys = {}; for (auto entry : mMap) { keys.insert(entry.first); } @@ -128,6 +136,7 @@ public: unordered_set* goneKeys, unordered_set* goneVals) { trimOrRemove(keys, rVals, goneKeys, goneVals); } + inline void trimOrRemove(unordered_set& keys, const unordered_set& rVals, unordered_set* goneKeys, unordered_set* goneVals) { for (auto key : keys) { @@ -161,6 +170,7 @@ public: unordered_set* newKeys) { add(keys, newVals, newKeys); } + inline void add(const unordered_set& keys, const unordered_set& newVals, unordered_set* newKeys) { for (auto key : keys) { @@ -174,8 +184,7 @@ public: // in effect removed from the keyed VAL set in the map entry. // This call would also remove those same VALs from *newVals*. inline unordered_set update(const KEY& key, unordered_set& newVals) { - unordered_set goneVals(0); - + unordered_set goneVals = {}; if (newVals.empty()) { mMap.erase(key); } else { diff --git a/gps/utils/MsgTask.cpp b/gps/utils/MsgTask.cpp index 73a77fdb..0a978ed0 100644 --- a/gps/utils/MsgTask.cpp +++ b/gps/utils/MsgTask.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2013, 2015, 2017The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2013, 2015, 2017, 2020 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -83,10 +83,8 @@ void MsgTask::sendMsg(const LocMsg* msg) const { } void MsgTask::prerun() { -#ifndef FEATURE_EXTERNAL_AP // make sure we do not run in background scheduling group set_sched_policy(gettid(), SP_FOREGROUND); -#endif /* FEATURE_EXTERNAL_AP */ } bool MsgTask::run() { diff --git a/gps/utils/gps_extended_c.h b/gps/utils/gps_extended_c.h index d6e50a20..8eb11523 100644 --- a/gps/utils/gps_extended_c.h +++ b/gps/utils/gps_extended_c.h @@ -401,6 +401,9 @@ typedef uint64_t GpsLocationExtendedFlags; #define GPS_LOCATION_EXTENDED_HAS_DGNSS_REF_STATION_ID 0x40000000000 /** GpsLocationExtended has dgnss data age */ #define GPS_LOCATION_EXTENDED_HAS_DGNSS_DATA_AGE 0x80000000000 + /** GpsLocationExtended has the conformityIndex computed from + * robust location feature. */ +#define GPS_LOCATION_EXTENDED_HAS_CONFORMITY_INDEX 0x100000000000 typedef uint32_t LocNavSolutionMask; /* Bitmask to specify whether SBAS ionospheric correction is used */ @@ -619,6 +622,17 @@ typedef uint16_t GnssMeasUsageInfoValidityMask; #define GNSS_CARRIER_PHASE_RESIDUAL_VALID ((GnssMeasUsageInfoValidityMask)0x00000004ul) #define GNSS_CARRIER_PHASE_AMBIGUITY_TYPE_VALID ((GnssMeasUsageInfoValidityMask)0x00000008ul) +typedef uint16_t GnssSvPolyStatusMask; +#define GNSS_SV_POLY_SRC_ALM_CORR_V02 ((GnssSvPolyStatusMask)0x01) +#define GNSS_SV_POLY_GLO_STR4_V02 ((GnssSvPolyStatusMask)0x02) +#define GNSS_SV_POLY_DELETE_V02 ((GnssSvPolyStatusMask)0x04) +#define GNSS_SV_POLY_SRC_GAL_FNAV_OR_INAV_V02 ((GnssSvPolyStatusMask)0x08) +typedef uint16_t GnssSvPolyStatusMaskValidity; +#define GNSS_SV_POLY_SRC_ALM_CORR_VALID_V02 ((GnssSvPolyStatusMaskValidity)0x01) +#define GNSS_SV_POLY_GLO_STR4_VALID_V02 ((GnssSvPolyStatusMaskValidity)0x02) +#define GNSS_SV_POLY_DELETE_VALID_V02 ((GnssSvPolyStatusMaskValidity)0x04) +#define GNSS_SV_POLY_SRC_GAL_FNAV_OR_INAV_VALID_V02 ((GnssSvPolyStatusMaskValidity)0x08) + typedef struct { /** Specifies GNSS signal type @@ -797,6 +811,12 @@ typedef struct { /** If DGNSS is used, DGNSS data age in milli-seconds */ uint32_t dgnssDataAgeMsec; + + /* When robust location is enabled, this field + * will how well the various input data considered for + * navigation solution conform to expectations. + * Range: 0 (least conforming) to 1 (most conforming) */ + float conformityIndex; } GpsLocationExtended; enum loc_sess_status { @@ -1005,9 +1025,14 @@ typedef uint32_t LOC_GPS_LOCK_MASK; #define isGpsLockAll(lock) (((lock) & ((LOC_GPS_LOCK_MASK)3)) == 3) /*++ *********************************************** -** Satellite Measurement Structure definitions +** Satellite Measurement and Satellite Polynomial +** structure definitions ** *********************************************** --*/ +#define GNSS_SV_POLY_VELOCITY_COEF_MAX_SIZE 12 +#define GNSS_SV_POLY_XYZ_0_TH_ORDER_COEFF_MAX_SIZE 3 +#define GNSS_SV_POLY_XYZ_N_TH_ORDER_COEFF_MAX_SIZE 9 +#define GNSS_SV_POLY_SV_CLKBIAS_COEFF_MAX_SIZE 4 /** Max number of GNSS SV measurement */ #define GNSS_LOC_SV_MEAS_LIST_MAX_SIZE 128 @@ -1564,7 +1589,66 @@ typedef enum GNSS_SV_POLY_GLO_STR4 = 0x40 /**< GLONASS String 4 has been received */ -}Gnss_SvPolyStatusMaskType; +} Gnss_SvPolyStatusMaskType; + + +typedef struct { + uint32_t size; + uint16_t gnssSvId; + /** Unique SV Identifier. + * For SV Range of supported constellation, please refer to the + * comment section of gnssSvId in GpsMeasUsageInfo. + */ + int8_t freqNum; + /** Freq index, only valid if u_SysInd is GLO */ + + GnssSvPolyStatusMaskValidity svPolyStatusMaskValidity; + GnssSvPolyStatusMask svPolyStatusMask; + + uint32_t is_valid; + + uint16_t iode; + /* Ephemeris reference time + GPS:Issue of Data Ephemeris used [unitless]. + GLO: Tb 7-bit, refer to ICD02 + */ + double T0; + /* Reference time for polynominal calculations + GPS: Secs in week. + GLO: Full secs since Jan/01/96 + */ + double polyCoeffXYZ0[GNSS_SV_POLY_XYZ_0_TH_ORDER_COEFF_MAX_SIZE]; + /* C0X, C0Y, C0Z */ + double polyCoefXYZN[GNSS_SV_POLY_XYZ_N_TH_ORDER_COEFF_MAX_SIZE]; + /* C1X, C2X ... C2Z, C3Z */ + float polyCoefOther[GNSS_SV_POLY_SV_CLKBIAS_COEFF_MAX_SIZE]; + /* C0T, C1T, C2T, C3T */ + float svPosUnc; /* SV position uncertainty [m]. */ + float ionoDelay; /* Ionospheric delay at d_T0 [m]. */ + float ionoDot; /* Iono delay rate [m/s]. */ + float sbasIonoDelay;/* SBAS Ionospheric delay at d_T0 [m]. */ + float sbasIonoDot; /* SBAS Iono delay rate [m/s]. */ + float tropoDelay; /* Tropospheric delay [m]. */ + float elevation; /* Elevation [rad] at d_T0 */ + float elevationDot; /* Elevation rate [rad/s] */ + float elevationUnc; /* SV elevation [rad] uncertainty */ + double velCoef[GNSS_SV_POLY_VELOCITY_COEF_MAX_SIZE]; + /* Coefficients of velocity poly */ + uint32_t enhancedIOD; /* Enhanced Reference Time */ + float gpsIscL1ca; + float gpsIscL2c; + float gpsIscL5I5; + float gpsIscL5Q5; + float gpsTgd; + float gloTgdG1G2; + float bdsTgdB1; + float bdsTgdB2; + float bdsTgdB2a; + float bdsIscB2a; + float galBgdE1E5a; + float galBgdE1E5b; + float navicTgdL5; +} GnssSvPolynomial; typedef enum { GNSS_EPH_ACTION_UPDATE_SRC_UNKNOWN_V02 = 0, /** OdcpiRequestCallback; +/* ODCPI callback priorities*/ +enum OdcpiPrioritytype { + ODCPI_HANDLER_PRIORITY_LOW, + ODCPI_HANDLER_PRIORITY_HIGH +}; + /* * Callback with AGNSS(IpV4) status information. * diff --git a/gps/utils/loc_nmea.cpp b/gps/utils/loc_nmea.cpp index 5295f6a6..cc850a87 100644 --- a/gps/utils/loc_nmea.cpp +++ b/gps/utils/loc_nmea.cpp @@ -36,7 +36,9 @@ #include #define GLONASS_SV_ID_OFFSET 64 -#define QZSS_SV_ID_OFFSET (-192) +#define QZSS_SV_ID_OFFSET (192) +#define BDS_SV_ID_OFFSET (200) +#define GALILEO_SV_ID_OFFSET (300) #define MAX_SV_COUNT_SUPPORTED_IN_ONE_CONSTELLATION 64 #define MAX_SATELLITES_IN_USE 12 #define MSEC_IN_ONE_WEEK 604800000ULL @@ -429,6 +431,8 @@ static loc_nmea_sv_meta* loc_nmea_sv_meta_init(loc_nmea_sv_meta& sv_meta, sv_meta.talker[0] = 'G'; sv_meta.talker[1] = 'A'; sv_meta.mask = sv_cache_info.gal_used_mask; + // GALILEO SV ids are from 301-336, So keep svIdOffset 300 + sv_meta.svIdOffset = GALILEO_SV_ID_OFFSET; sv_meta.systemId = SYSTEM_ID_GALILEO; if (GNSS_SIGNAL_GALILEO_E1 == signalType) { sv_meta.svCount = sv_cache_info.gal_e1_count; @@ -440,7 +444,7 @@ static loc_nmea_sv_meta* loc_nmea_sv_meta_init(loc_nmea_sv_meta& sv_meta, sv_meta.talker[0] = 'G'; sv_meta.talker[1] = 'Q'; sv_meta.mask = sv_cache_info.qzss_used_mask; - // QZSS SV ids are from 193-199. So keep svIdOffset -192 + // QZSS SV ids are from 193-197. So keep svIdOffset 192 sv_meta.svIdOffset = QZSS_SV_ID_OFFSET; sv_meta.systemId = SYSTEM_ID_QZSS; if (GNSS_SIGNAL_QZSS_L1CA == signalType) { @@ -453,7 +457,8 @@ static loc_nmea_sv_meta* loc_nmea_sv_meta_init(loc_nmea_sv_meta& sv_meta, sv_meta.talker[0] = 'G'; sv_meta.talker[1] = 'B'; sv_meta.mask = sv_cache_info.bds_used_mask; - // BDS SV ids are from 201-235. So keep svIdOffset 0 + // BDS SV ids are from 201-237. So keep svIdOffset 200 + sv_meta.svIdOffset = BDS_SV_ID_OFFSET; sv_meta.systemId = SYSTEM_ID_BDS; if (GNSS_SIGNAL_BEIDOU_B1I == signalType) { sv_meta.svCount = sv_cache_info.bds_b1_count; @@ -724,6 +729,9 @@ static void loc_nmea_generate_GSV(const GnssSvNotification &svNotify, return; } + if (GNSS_SV_TYPE_GLONASS == sv_meta_p->svType) { + svIdOffset = 0; + } svNumber = 1; sentenceNumber = 1; sentenceCount = svCount / 4 + (svCount % 4 != 0); @@ -782,13 +790,8 @@ static void loc_nmea_generate_GSV(const GnssSvNotification &svNotify, if (sv_meta_p->svType == svNotify.gnssSvs[svNumber - 1].type && sv_meta_p->signalId == convert_signalType_to_signalId(signalType)) { - uint16_t svId = svNotify.gnssSvs[svNumber - 1].svId; - // For QZSS we adjusted SV id's in GnssAdapter, we need to re-adjust here - if (GNSS_SV_TYPE_QZSS == svNotify.gnssSvs[svNumber - 1].type) { - svId = svId - (QZSS_SV_PRN_MIN - 1); - } - length = snprintf(pMarker, lengthRemaining,",%02d,%02d,%03d,", - svId + svIdOffset, + length = snprintf(pMarker, lengthRemaining, ",%02d,%02d,%03d,", + svNotify.gnssSvs[svNumber - 1].svId - svIdOffset, (int)(0.5 + svNotify.gnssSvs[svNumber - 1].elevation), //float to int (int)(0.5 + svNotify.gnssSvs[svNumber - 1].azimuth)); //float to int diff --git a/sdm660.mk b/sdm660.mk index 9f0dbcb7..42ad16c5 100644 --- a/sdm660.mk +++ b/sdm660.mk @@ -250,6 +250,7 @@ PRODUCT_PACKAGES += \ # GPS Config PRODUCT_COPY_FILES += \ + $(COMMON_PATH)/gps/etc/apdr.conf:$(TARGET_COPY_OUT_VENDOR)/etc/apdr.conf \ $(COMMON_PATH)/gps/etc/flp.conf:$(TARGET_COPY_OUT_VENDOR)/etc/flp.conf \ $(COMMON_PATH)/gps/etc/gps.conf:$(TARGET_COPY_OUT_VENDOR)/etc/gps.conf \ $(COMMON_PATH)/gps/etc/izat.conf:$(TARGET_COPY_OUT_VENDOR)/etc/izat.conf \