diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2022-01-23 04:51:00 -0800 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2022-01-23 04:51:00 -0800 |
commit | 42065cba5f58cffa1ca15943d333e458908ae810 (patch) | |
tree | c5e8d42e04a07215fb75cdeb2ead75d7484312aa | |
parent | 82cc0d1b132e6200e49ddef23ff28d00f3baea4a (diff) | |
parent | cf77e9a0c916925290533269894490c3aa1902be (diff) |
Merge cf77e9a0c916925290533269894490c3aa1902be on remote branch
Change-Id: I24c7563e91329fbced10b1dcfab17b85d0e3ecaa
-rw-r--r-- | android/1.0/Android.mk | 4 | ||||
-rw-r--r-- | android/1.0/service.cpp | 16 | ||||
-rw-r--r-- | android/1.1/Android.mk | 4 | ||||
-rw-r--r-- | android/1.1/service.cpp | 16 | ||||
-rw-r--r-- | android/2.0/Android.mk | 4 | ||||
-rw-r--r-- | android/2.0/location_api/LocationUtil.cpp | 2 | ||||
-rw-r--r-- | android/2.0/service.cpp | 12 | ||||
-rw-r--r-- | android/2.1/Android.mk | 4 | ||||
-rw-r--r-- | android/2.1/location_api/LocationUtil.cpp | 2 | ||||
-rw-r--r-- | android/2.1/service.cpp | 12 | ||||
-rw-r--r-- | android/aidl-impl/Android.mk | 5 | ||||
-rw-r--r-- | android/aidl-impl/Gnss.h | 2 | ||||
-rw-r--r-- | android/aidl-impl/service.cpp | 14 | ||||
-rw-r--r-- | android/utils/battery_listener.cpp | 11 | ||||
-rw-r--r-- | core/ContextBase.cpp | 6 | ||||
-rw-r--r-- | core/LocApiBase.cpp | 106 | ||||
-rw-r--r-- | core/LocApiBase.h | 27 | ||||
-rw-r--r-- | gnss/GnssAdapter.cpp | 63 | ||||
-rw-r--r-- | gnss/GnssAdapter.h | 3 | ||||
-rw-r--r-- | gps_vendor_board.mk | 22 | ||||
-rw-r--r-- | location/LocationAPIClientBase.cpp | 24 | ||||
-rw-r--r-- | location/LocationAPIClientBase.h | 1 | ||||
-rw-r--r-- | location/LocationDataTypes.h | 4 | ||||
-rw-r--r-- | utils/gps_extended_c.h | 9 | ||||
-rw-r--r-- | utils/loc_gps.h | 4 |
25 files changed, 224 insertions, 153 deletions
diff --git a/android/1.0/Android.mk b/android/1.0/Android.mk index 9d05878..667576c 100644 --- a/android/1.0/Android.mk +++ b/android/1.0/Android.mk @@ -93,8 +93,4 @@ LOCAL_SHARED_LIBRARIES += \ LOCAL_CFLAGS += $(GNSS_CFLAGS) -ifneq ($(LOC_HIDL_VERSION),) -LOCAL_CFLAGS += -DLOC_HIDL_VERSION='"$(LOC_HIDL_VERSION)"' -endif - include $(BUILD_EXECUTABLE) diff --git a/android/1.0/service.cpp b/android/1.0/service.cpp index 2a6f60f..90ae802 100644 --- a/android/1.0/service.cpp +++ b/android/1.0/service.cpp @@ -60,23 +60,7 @@ int main() { status = registerPassthroughServiceImplementation<IGnss>(); if (status == OK) { - if (vendorEnhanced) { - #ifdef LOC_HIDL_VERSION - #define VENDOR_ENHANCED_LIB "vendor.qti.gnss@" LOC_HIDL_VERSION "-service.so" - - void* libHandle = NULL; - vendorEnhancedServiceMain* vendorEnhancedMainMethod = (vendorEnhancedServiceMain*) - dlGetSymFromLib(libHandle, VENDOR_ENHANCED_LIB, "main"); - if (NULL != vendorEnhancedMainMethod) { - (*vendorEnhancedMainMethod)(0, NULL); - } - #else - ALOGE("LOC_HIDL_VERSION not defined."); - #endif - } - joinRpcThreadpool(); - } else { ALOGE("Error while registering IGnss 1.0 service: %d", status); } diff --git a/android/1.1/Android.mk b/android/1.1/Android.mk index 8ed6e5e..5a4319d 100644 --- a/android/1.1/Android.mk +++ b/android/1.1/Android.mk @@ -95,8 +95,4 @@ LOCAL_SHARED_LIBRARIES += \ LOCAL_CFLAGS += $(GNSS_CFLAGS) -ifneq ($(LOC_HIDL_VERSION),) -LOCAL_CFLAGS += -DLOC_HIDL_VERSION='"$(LOC_HIDL_VERSION)"' -endif - include $(BUILD_EXECUTABLE) diff --git a/android/1.1/service.cpp b/android/1.1/service.cpp index 0cb91f7..86d168e 100644 --- a/android/1.1/service.cpp +++ b/android/1.1/service.cpp @@ -60,23 +60,7 @@ int main() { status = registerPassthroughServiceImplementation<IGnss>(); if (status == OK) { - if (vendorEnhanced) { - #ifdef LOC_HIDL_VERSION - #define VENDOR_ENHANCED_LIB "vendor.qti.gnss@" LOC_HIDL_VERSION "-service.so" - - void* libHandle = NULL; - vendorEnhancedServiceMain* vendorEnhancedMainMethod = (vendorEnhancedServiceMain*) - dlGetSymFromLib(libHandle, VENDOR_ENHANCED_LIB, "main"); - if (NULL != vendorEnhancedMainMethod) { - (*vendorEnhancedMainMethod)(0, NULL); - } - #else - ALOGE("LOC_HIDL_VERSION not defined."); - #endif - } - joinRpcThreadpool(); - } else { ALOGE("Error while registering IGnss 1.1 service: %d", status); } diff --git a/android/2.0/Android.mk b/android/2.0/Android.mk index daeaad7..543a137 100644 --- a/android/2.0/Android.mk +++ b/android/2.0/Android.mk @@ -105,8 +105,4 @@ LOCAL_SHARED_LIBRARIES += \ LOCAL_CFLAGS += $(GNSS_CFLAGS) -ifneq ($(LOC_HIDL_VERSION),) -LOCAL_CFLAGS += -DLOC_HIDL_VERSION='"$(LOC_HIDL_VERSION)"' -endif - include $(BUILD_EXECUTABLE) diff --git a/android/2.0/location_api/LocationUtil.cpp b/android/2.0/location_api/LocationUtil.cpp index 961b7b1..f55a5f9 100644 --- a/android/2.0/location_api/LocationUtil.cpp +++ b/android/2.0/location_api/LocationUtil.cpp @@ -89,7 +89,7 @@ void convertGnssLocation(Location& in, V2_0::GnssLocation& out) memset(&out, 0, sizeof(V2_0::GnssLocation)); convertGnssLocation(in, out.v1_0); - if (in.flags & LOCATION_HAS_ELAPSED_REAL_TIME) { + if (in.flags & LOCATION_HAS_ELAPSED_REAL_TIME_BIT) { out.elapsedRealtime.flags |= ElapsedRealtimeFlags::HAS_TIMESTAMP_NS; out.elapsedRealtime.timestampNs = in.elapsedRealTime; out.elapsedRealtime.flags |= ElapsedRealtimeFlags::HAS_TIME_UNCERTAINTY_NS; diff --git a/android/2.0/service.cpp b/android/2.0/service.cpp index 3c9af95..c37d44c 100644 --- a/android/2.0/service.cpp +++ b/android/2.0/service.cpp @@ -84,18 +84,6 @@ int main() { status = registerPassthroughServiceImplementation<IGnss>(); if (status == OK) { - #ifdef LOC_HIDL_VERSION - #define VENDOR_ENHANCED_LIB "vendor.qti.gnss@" LOC_HIDL_VERSION "-service.so" - - void* libHandle = NULL; - vendorEnhancedServiceMain* vendorEnhancedMainMethod = (vendorEnhancedServiceMain*) - dlGetSymFromLib(libHandle, VENDOR_ENHANCED_LIB, "main"); - if (NULL != vendorEnhancedMainMethod) { - (*vendorEnhancedMainMethod)(0, NULL); - } - #else - ALOGI("LOC_HIDL_VERSION not defined."); - #endif initializeGnssPowerHandler(); joinRpcThreadpool(); } else { diff --git a/android/2.1/Android.mk b/android/2.1/Android.mk index c45017c..4202005 100644 --- a/android/2.1/Android.mk +++ b/android/2.1/Android.mk @@ -108,8 +108,4 @@ LOCAL_SHARED_LIBRARIES += \ LOCAL_CFLAGS += $(GNSS_CFLAGS) -ifneq ($(LOC_HIDL_VERSION),) -LOCAL_CFLAGS += -DLOC_HIDL_VERSION='"$(LOC_HIDL_VERSION)"' -endif - include $(BUILD_EXECUTABLE) diff --git a/android/2.1/location_api/LocationUtil.cpp b/android/2.1/location_api/LocationUtil.cpp index 5154e70..690b820 100644 --- a/android/2.1/location_api/LocationUtil.cpp +++ b/android/2.1/location_api/LocationUtil.cpp @@ -90,7 +90,7 @@ void convertGnssLocation(Location& in, V2_0::GnssLocation& out) memset(&out, 0, sizeof(V2_0::GnssLocation)); convertGnssLocation(in, out.v1_0); - if (in.flags & LOCATION_HAS_ELAPSED_REAL_TIME) { + if (in.flags & LOCATION_HAS_ELAPSED_REAL_TIME_BIT) { out.elapsedRealtime.flags |= ElapsedRealtimeFlags::HAS_TIMESTAMP_NS; out.elapsedRealtime.timestampNs = in.elapsedRealTime; out.elapsedRealtime.flags |= ElapsedRealtimeFlags::HAS_TIME_UNCERTAINTY_NS; diff --git a/android/2.1/service.cpp b/android/2.1/service.cpp index b42e681..22cc0f2 100644 --- a/android/2.1/service.cpp +++ b/android/2.1/service.cpp @@ -87,18 +87,6 @@ int main() { status = registerPassthroughServiceImplementation<IGnss>(); if (status == OK) { - #ifdef LOC_HIDL_VERSION - #define VENDOR_ENHANCED_LIB "vendor.qti.gnss@" LOC_HIDL_VERSION "-service.so" - - void* libHandle = NULL; - vendorEnhancedServiceMain* vendorEnhancedMainMethod = (vendorEnhancedServiceMain*) - dlGetSymFromLib(libHandle, VENDOR_ENHANCED_LIB, "main"); - if (NULL != vendorEnhancedMainMethod) { - (*vendorEnhancedMainMethod)(0, NULL); - } - #else - ALOGI("LOC_HIDL_VERSION not defined."); - #endif initializeGnssPowerHandler(); joinRpcThreadpool(); } else { diff --git a/android/aidl-impl/Android.mk b/android/aidl-impl/Android.mk index 11aaf10..57f102e 100644 --- a/android/aidl-impl/Android.mk +++ b/android/aidl-impl/Android.mk @@ -25,7 +25,6 @@ LOCAL_HEADER_LIBRARIES := \ LOCAL_SHARED_LIBRARIES := \ libbase \ - libhidlbase \ libbinder_ndk \ android.hardware.gnss-V1-ndk_platform \ liblog \ @@ -80,8 +79,4 @@ LOCAL_SHARED_LIBRARIES += \ LOCAL_CFLAGS += $(GNSS_CFLAGS) -ifneq ($(LOC_HIDL_VERSION),) -LOCAL_CFLAGS += -DLOC_HIDL_VERSION='"$(LOC_HIDL_VERSION)"' -endif - include $(BUILD_EXECUTABLE) diff --git a/android/aidl-impl/Gnss.h b/android/aidl-impl/Gnss.h index 4063180..c0ad168 100644 --- a/android/aidl-impl/Gnss.h +++ b/android/aidl-impl/Gnss.h @@ -32,8 +32,6 @@ #include "GnssConfiguration.h" #include "GnssPowerIndication.h" #include "GnssMeasurementInterface.h" -#include <hidl/MQDescriptor.h> -#include <hidl/Status.h> namespace android { namespace hardware { diff --git a/android/aidl-impl/service.cpp b/android/aidl-impl/service.cpp index e893dfe..4edd9f9 100644 --- a/android/aidl-impl/service.cpp +++ b/android/aidl-impl/service.cpp @@ -26,8 +26,6 @@ #include <android/binder_manager.h> #include <android/binder_process.h> #include "Gnss.h" -#include <hidl/HidlSupport.h> -#include <hidl/HidlTransportSupport.h> #include <pthread.h> #include <log_util.h> @@ -54,7 +52,6 @@ using android::OK; typedef int vendorEnhancedServiceMain(int /* argc */, char* /* argv */ []); using GnssAidl = ::android::hardware::gnss::aidl::implementation::Gnss; -using android::hardware::configureRpcThreadpool; using ::android::hardware::gnss::V1_0::GnssLocation; using android::hardware::gnss::V2_1::IGnss; @@ -98,17 +95,6 @@ int main() { if (NULL != aidlMainMethod) { ALOGI("start LocAidl service"); (*aidlMainMethod)(0, NULL); - } else { - #ifdef LOC_HIDL_VERSION - #define VENDOR_ENHANCED_LIB "vendor.qti.gnss@" LOC_HIDL_VERSION "-service.so" - void* libHandle = NULL; - vendorEnhancedServiceMain* vendorEnhancedMainMethod = (vendorEnhancedServiceMain*) - dlGetSymFromLib(libHandle, VENDOR_ENHANCED_LIB, "main"); - if (NULL != vendorEnhancedMainMethod) { - (*vendorEnhancedMainMethod)(0, NULL); - } - #endif - } // Loc AIDL service end joinRpcThreadpool(); diff --git a/android/utils/battery_listener.cpp b/android/utils/battery_listener.cpp index 0d5cd03..b144966 100644 --- a/android/utils/battery_listener.cpp +++ b/android/utils/battery_listener.cpp @@ -180,16 +180,19 @@ BatteryListenerImpl::~BatteryListenerImpl() { { std::lock_guard<std::mutex> _l(mLock); - if (mHealth != NULL) + if (mHealth != NULL) { mHealth->unregisterCallback(this); auto r = mHealth->unlinkToDeath(this); if (!r.isOk() || r == false) { LOC_LOGe("Transaction error in unregister to HealthHAL death: %s", r.description().c_str()); } + } } mDone = true; - mThread->join(); + if (NULL != mThread) { + mThread->join(); + } } void BatteryListenerImpl::serviceDied(uint64_t cookie __unused, @@ -206,7 +209,9 @@ void BatteryListenerImpl::serviceDied(uint64_t cookie __unused, } mHealth = NULL; mCond.notify_one(); - mThread->join(); + if (NULL != mThread) { + mThread->join(); + } std::lock_guard<std::mutex> _l(mLock); init(); } diff --git a/core/ContextBase.cpp b/core/ContextBase.cpp index cf4229c..842efaa 100644 --- a/core/ContextBase.cpp +++ b/core/ContextBase.cpp @@ -193,6 +193,12 @@ void ContextBase::readConfig() /* default configuration QTI GNSS H/W */ mGps_conf.GNSS_DEPLOYMENT = 0; mGps_conf.CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED = 0; + /* default NMEA Tag Block Grouping is disabled */ + mGps_conf.NMEA_TAG_BLOCK_GROUPING_ENABLED = 0; + /* default configuration for NI_SUPL_DENY_ON_NFW_LOCKED */ + mGps_conf.NI_SUPL_DENY_ON_NFW_LOCKED = 1; + /* By default NMEA Printing is disabled */ + mGps_conf.ENABLE_NMEA_PRINT = 0; #ifdef USE_GLIB // For LE target, disable by default diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp index 52e5174..9d92810 100644 --- a/core/LocApiBase.cpp +++ b/core/LocApiBase.cpp @@ -934,7 +934,7 @@ void LocApiBase:: DEFAULT_IMPL() int64_t ElapsedRealtimeEstimator::getElapsedRealtimeEstimateNanos(int64_t curDataTimeNanos, - bool isCurDataTimeTrustable, int64_t tbf) { + bool isCurDataTimeTrustable, int64_t tbfNanos) { //The algorithm works follow below steps: //When isCurDataTimeTrustable is meet (means Modem timestamp is already stable), //1, Wait for mFixTimeStablizationThreshold fixes; While waiting for modem time @@ -957,7 +957,7 @@ int64_t ElapsedRealtimeEstimator::getElapsedRealtimeEstimateNanos(int64_t curDat int64_t sinceBootTimeNanos = 0; if (getCurrentTime(currentTime, sinceBootTimeNanos)) { if (isCurDataTimeTrustable) { - if (tbf > 0 && tbf != curDataTimeNanos - mPrevDataTimeNanos) { + if (tbfNanos > 0 && tbfNanos != curDataTimeNanos - mPrevDataTimeNanos) { mFixTimeStablizationThreshold = 5; } int64_t currentTimeNanos = (int64_t)currentTime.tv_sec*1000000000 + currentTime.tv_nsec; @@ -991,6 +991,8 @@ void ElapsedRealtimeEstimator::reset() { mPrevUtcTimeNanos = 0; mPrevBootTimeNanos = 0; mFixTimeStablizationThreshold = 5; + memset(&mTimePairPVTReport, 0, sizeof(mTimePairPVTReport)); + memset(&mTimePairMeasReport, 0, sizeof(mTimePairMeasReport)); } int64_t ElapsedRealtimeEstimator::getElapsedRealtimeQtimer(int64_t qtimerTicksAtOrigin) { @@ -1032,6 +1034,106 @@ int64_t ElapsedRealtimeEstimator::getElapsedRealtimeQtimer(int64_t qtimerTicksAt return elapsedRealTimeNanos; } +void ElapsedRealtimeEstimator::saveGpsTimeAndQtimerPairInPvtReport( + const GpsLocationExtended& locationExtended) { + + // Use GPS timestamp and qtimer tick for 1Hz PVT report for association + if ((locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_GPS_TIME) && + (locationExtended.gpsTime.gpsTimeOfWeekMs % 1000 == 0) && + (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_SYSTEM_TICK) && + (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_SYSTEM_TICK_UNC)) { + mTimePairPVTReport.gpsTime.gpsWeek = locationExtended.gpsTime.gpsWeek; + mTimePairPVTReport.gpsTime.gpsTimeOfWeekMs = + locationExtended.gpsTime.gpsTimeOfWeekMs; + mTimePairPVTReport.qtimerTick = locationExtended.systemTick; + mTimePairPVTReport.timeUncMsec = locationExtended.systemTickUnc; + + LOC_LOGv("gps time (%d, %d), qtimer tick %" PRIi64 ", qtime unc %f", + mTimePairPVTReport.gpsTime.gpsWeek, mTimePairPVTReport.gpsTime.gpsTimeOfWeekMs, + mTimePairPVTReport.qtimerTick, mTimePairPVTReport.timeUncMsec); + } +} + +void ElapsedRealtimeEstimator::saveGpsTimeAndQtimerPairInMeasReport( + const GnssSvMeasurementSet& svMeasurementSet) { + + const GnssSvMeasurementHeader& svMeasSetHeader = svMeasurementSet.svMeasSetHeader; + // Use 1Hz measurement report timestamp and qtimer tick for association + if ((svMeasurementSet.isNhz == false) && + (svMeasSetHeader.gpsSystemTime.validityMask & GNSS_SYSTEM_TIME_WEEK_VALID) && + (svMeasSetHeader.gpsSystemTime.validityMask & GNSS_SYSTEM_TIME_WEEK_MS_VALID)) { + + LOC_LOGv("gps time %d %d, meas unc %f, ref cnt tick %" PRIi64 "," + "system rtc ms %" PRIi64 ", systemClkTimeUncMs %f", + svMeasurementSet.svMeasSetHeader.gpsSystemTime.systemWeek, + svMeasurementSet.svMeasSetHeader.gpsSystemTime.systemMsec, + svMeasurementSet.svMeasSetHeader.gpsSystemTime.systemClkTimeUncMs, + svMeasurementSet.svMeasSetHeader.refCountTicks, + svMeasurementSet.svMeasSetHeader.gpsSystemTimeExt.systemRtcMs, + svMeasurementSet.svMeasSetHeader.gpsSystemTime.systemClkTimeUncMs); + if ((svMeasSetHeader.flags & GNSS_SV_MEAS_HEADER_HAS_REF_COUNT_TICKS) && + (svMeasSetHeader.flags & GNSS_SV_MEAS_HEADER_HAS_REF_COUNT_TICKS_UNC)) { + mTimePairMeasReport.gpsTime.gpsWeek = svMeasSetHeader.gpsSystemTime.systemWeek; + mTimePairMeasReport.gpsTime.gpsTimeOfWeekMs = svMeasSetHeader.gpsSystemTime.systemMsec; + mTimePairMeasReport.qtimerTick = svMeasurementSet.svMeasSetHeader.refCountTicks; + mTimePairMeasReport.timeUncMsec = svMeasurementSet.svMeasSetHeader.refCountTicksUnc; + } + + LOC_LOGv("gps time (%d, %d), qtimer tick %" PRIi64 ", unc %f", + mTimePairMeasReport.gpsTime.gpsWeek, mTimePairMeasReport.gpsTime.gpsTimeOfWeekMs, + mTimePairMeasReport.qtimerTick, mTimePairMeasReport.timeUncMsec); + } +} + +#define MSEC_IN_ONE_WEEK 604800000LL +bool ElapsedRealtimeEstimator::getElapsedRealtimeForGpsTime( + const GPSTimeStruct& gpsTimeAtOrigin, int64_t &bootTimeNsAtOrigin, float & bootTimeUnc) { + struct timespec curBootTime = {}; + int64_t curBootTimeNs = 0; + int64_t curQTimerNSec = 0; + int64_t qtimerNsecAtOrigin = 0; + int64_t gpsTimeDiffMsec = 0; + GpsTimeQtimerTickPair timePair; + + // We have valid association + if (mTimePairMeasReport.gpsTime.gpsWeek != 0) { + timePair = mTimePairMeasReport; + LOC_LOGv("use meas time association"); + } else if (mTimePairPVTReport.gpsTime.gpsWeek != 0) { + LOC_LOGv("use PVT time association"); + timePair = mTimePairPVTReport; + } else { + return false; + } + + int64_t originMsec = (int64_t)gpsTimeAtOrigin.gpsWeek * (int64_t)MSEC_IN_ONE_WEEK + + (int64_t)gpsTimeAtOrigin.gpsTimeOfWeekMs; + int64_t timePairMsec = (int64_t)timePair.gpsTime.gpsWeek * (int64_t)MSEC_IN_ONE_WEEK + + (int64_t)timePair.gpsTime.gpsTimeOfWeekMs; + gpsTimeDiffMsec = originMsec - timePairMsec; + + qtimerNsecAtOrigin = timePair.qtimerTick * 10000/192 + gpsTimeDiffMsec * 1000000; + + clock_gettime(CLOCK_BOOTTIME, &curBootTime); + curBootTimeNs = ((int64_t)curBootTime.tv_sec) * 1000000000 + (int64_t)curBootTime.tv_nsec; + // qtimer freq: 19200000, so + // so 1 tick equals 1000,000,000/19,200,000 ns = 10000/192 + curQTimerNSec = getQTimerTickCount() * 10000/192; + bootTimeNsAtOrigin = curBootTimeNs - (curQTimerNSec - qtimerNsecAtOrigin); + + bootTimeUnc = timePair.timeUncMsec; + LOC_LOGv("gpsTimeAtOrigin (%d, %d), timepair: gps (%d, %d), " + "qtimer nsec =%" PRIi64 ", curQTimerNSec=%" PRIi64 " qtimerNsecAtOrigin=%" PRIi64 "" + " curBoottimeNSec=%" PRIi64 " bootimeNsecAtOrigin=%" PRIi64 ", boottime unc =%f", + gpsTimeAtOrigin.gpsWeek, gpsTimeAtOrigin.gpsTimeOfWeekMs, + timePair.gpsTime.gpsWeek, timePair.gpsTime.gpsTimeOfWeekMs, + timePair.qtimerTick * 100000 / 192, + curQTimerNSec, qtimerNsecAtOrigin, curBootTimeNs, bootTimeNsAtOrigin, bootTimeUnc); + + return true; +} + + bool ElapsedRealtimeEstimator::getCurrentTime( struct timespec& currentTime, int64_t& sinceBootTimeNanos) { diff --git a/core/LocApiBase.h b/core/LocApiBase.h index 1a573a1..e26c00a 100644 --- a/core/LocApiBase.h +++ b/core/LocApiBase.h @@ -106,6 +106,7 @@ public: inline virtual bool getSatellitePVT(GnssSvPolynomial& svPolynomial, GnssSvMeasurementHeader& svMeasSetHeader, GnssMeasurementsData& measurementData) { return false; } + inline virtual float getGeoidalSeparation(double latitude, double longitude) { return 0.0; } }; class LocApiBase { @@ -355,6 +356,12 @@ public: }; class ElapsedRealtimeEstimator { + typedef struct { + GPSTimeStruct gpsTime; + int64_t qtimerTick; + float timeUncMsec; // in milli-seconds + } GpsTimeQtimerTickPair; + private: int64_t mCurrentClockDiff; int64_t mPrevUtcTimeNanos; @@ -362,16 +369,26 @@ private: int64_t mFixTimeStablizationThreshold; int64_t mInitialTravelTime; int64_t mPrevDataTimeNanos; -public: + // association between gps time and qtimer value + // the two variable saves a pair of gps time and qtimer time + // read at the same point + GpsTimeQtimerTickPair mTimePairPVTReport; + GpsTimeQtimerTickPair mTimePairMeasReport; - ElapsedRealtimeEstimator(int64_t travelTimeNanosEstimate): - mInitialTravelTime(travelTimeNanosEstimate) {reset();} +public: + inline ElapsedRealtimeEstimator(int64_t travelTimeNanosEstimate) : + mInitialTravelTime(travelTimeNanosEstimate) { + reset(); + } int64_t getElapsedRealtimeEstimateNanos(int64_t curDataTimeNanos, - bool isCurDataTimeTrustable, int64_t tbf); + bool isCurDataTimeTrustable, int64_t tbfNanos); inline int64_t getElapsedRealtimeUncNanos() { return 5000000;} void reset(); - static int64_t getElapsedRealtimeQtimer(int64_t qtimerTicksAtOrigin); + bool getElapsedRealtimeForGpsTime(const GPSTimeStruct& gpsTimeAtOrigin, + int64_t &elapsedTime, float & elpasedTimeUnc); + void saveGpsTimeAndQtimerPairInPvtReport(const GpsLocationExtended& locationExtended); + void saveGpsTimeAndQtimerPairInMeasReport(const GnssSvMeasurementSet& svMeasurementSet); static bool getCurrentTime(struct timespec& currentTime, int64_t& sinceBootTimeNanos); }; diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 2f8e95e..d07f5d9 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -165,7 +165,8 @@ GnssAdapter::GnssAdapter() : mGnssPowerStatisticsInit(false), mBootReferenceEnergy(0), mPowerElapsedRealTimeCal(30000000), - mAddressRequestCb(nullptr) + mAddressRequestCb(nullptr), + mPositionElapsedRealTimeCal(30000000) { LOC_LOGD("%s]: Constructor %p", __func__, this); mLocPositionMode.mode = LOC_POSITION_MODE_INVALID; @@ -352,14 +353,9 @@ GnssAdapter::convertLocation(Location& out, const UlpLocation& ulpLocation, } if (LOC_GPS_LOCATION_HAS_SPOOF_MASK & ulpLocation.gpsLocation.flags) { - out.flags |= LOCATION_HAS_SPOOF_MASK; + out.flags |= LOCATION_HAS_SPOOF_MASK_BIT; out.spoofMask = ulpLocation.gpsLocation.spoof_mask; } - if (LOC_GPS_LOCATION_HAS_ELAPSED_REAL_TIME & ulpLocation.gpsLocation.flags) { - out.flags |= LOCATION_HAS_ELAPSED_REAL_TIME; - out.elapsedRealTime = ulpLocation.gpsLocation.elapsedRealTime; - out.elapsedRealTimeUnc = ulpLocation.gpsLocation.elapsedRealTimeUnc; - } out.qualityType = LOCATION_STANDALONE_QUALITY_TYPE; if (GPS_LOCATION_EXTENDED_HAS_NAV_SOLUTION_MASK & locationExtended.flags) { out.flags |= LOCATION_HAS_QUALITY_TYPE_BIT; @@ -381,6 +377,31 @@ GnssAdapter::convertLocation(Location& out, const UlpLocation& ulpLocation, } } +void GnssAdapter::fillElapsedRealTime(const GpsLocationExtended& locationExtended, + Location& out) { + if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_GPS_TIME) { + int64_t elapsedTimeNs = 0; + float elapsedTimeUncMsec = 0.0; + if (mPositionElapsedRealTimeCal.getElapsedRealtimeForGpsTime( + locationExtended.gpsTime, elapsedTimeNs, elapsedTimeUncMsec)) { + out.flags |= LOCATION_HAS_ELAPSED_REAL_TIME_BIT; + out.elapsedRealTime = elapsedTimeNs; + out.elapsedRealTimeUnc = (int64_t) (elapsedTimeUncMsec * 1000000); + } +#ifndef FEATURE_AUTOMOTIVE + else if (out.timestamp > 0) { + int64_t locationTimeNanos = (int64_t)out.timestamp * 1000000; + bool isCurDataTimeTrustable = (out.timestamp % mLocPositionMode.min_interval == 0); + out.flags |= LOCATION_HAS_ELAPSED_REAL_TIME_BIT; + out.elapsedRealTime = mPositionElapsedRealTimeCal.getElapsedRealtimeEstimateNanos( + locationTimeNanos, isCurDataTimeTrustable, + (int64_t)mLocPositionMode.min_interval * 1000000); + out.elapsedRealTimeUnc = mPositionElapsedRealTimeCal.getElapsedRealtimeUncNanos(); + } +#endif //FEATURE_AUTOMOTIVE + } +} + /* This is utility routine that computes number of SV used in the fix from the svUsedIdsMask. */ @@ -2806,6 +2827,7 @@ GnssAdapter::suspendSessions() mDgnssState &= ~DGNSS_STATE_NO_NMEA_PENDING; } stopDgnssNtrip(); + mPositionElapsedRealTimeCal.reset(); mSPEAlreadyRunningAtHighestInterval = false; } } @@ -3587,6 +3609,7 @@ GnssAdapter::stopTracking(LocationAPI* client, uint32_t id) mDgnssState &= ~DGNSS_STATE_NO_NMEA_PENDING; } stopDgnssNtrip(); + mPositionElapsedRealTimeCal.reset(); mSPEAlreadyRunningAtHighestInterval = false; } @@ -3911,6 +3934,10 @@ GnssAdapter::reportPositionEvent(const UlpLocation& ulpLocation, mAdapter.reportData(mDataNotify); } + // save the association of GPS timestamp and qtimer tick cnt in PVT report + mAdapter.mPositionElapsedRealTimeCal + .saveGpsTimeAndQtimerPairInPvtReport(mLocationExtended); + if (true == mAdapter.initEngHubProxy()){ // send the SPE fix to engine hub mAdapter.mEngHubProxy->gnssReportPosition(mUlpLocation, mLocationExtended, mStatus); @@ -4131,7 +4158,9 @@ GnssAdapter::reportPosition(const UlpLocation& ulpLocation, GnssLocationInfoNotification locationInfo = {}; convertLocationInfo(locationInfo, locationExtended, status); convertLocation(locationInfo.location, ulpLocation, locationExtended); + fillElapsedRealTime(locationExtended, locationInfo.location); logLatencyInfo(); + for (auto it=mClientData.begin(); it != mClientData.end(); ++it) { if (reportToAllClients || needReportForClient(it->first, status)) { if (nullptr != it->second.gnssLocationInfoCb) { @@ -4263,6 +4292,8 @@ GnssAdapter::reportEnginePositions(unsigned int count, convertLocation(locationInfo[i].location, engLocation->location, engLocation->locationExtended); + fillElapsedRealTime(engLocation->locationExtended, + locationInfo[i].location); } } @@ -4646,6 +4677,10 @@ GnssAdapter::requestNiNotifyEvent(const GnssNiNotification ¬ify, const void* -NOT Privacy Override option -NFW is locked and config item NI_SUPL_DENY_ON_NFW_LOCKED = 1 */ mApi.informNiResponse(GNSS_NI_RESPONSE_DENY, mData); + } else if ((GNSS_NI_TYPE_SUPL == mNotify.type || + GNSS_NI_TYPE_EMERGENCY_SUPL == mNotify.type) + && (GNSS_NI_OPTIONS_PRIVACY_OVERRIDE_BIT & mNotify.options)) { + mApi.informNiResponse(GNSS_NI_RESPONSE_ACCEPT, mData); } else if (GNSS_NI_TYPE_EMERGENCY_SUPL == mNotify.type) { bInformNiAccept = bIsInEmergency || (GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_NO == ContextBase::mGps_conf.SUPL_ES); @@ -4661,10 +4696,6 @@ GnssAdapter::requestNiNotifyEvent(const GnssNiNotification ¬ify, const void* } else { mAdapter.requestNiNotify(mNotify, mData, false); } - } else if ((GNSS_NI_TYPE_SUPL == mNotify.type || - GNSS_NI_TYPE_EMERGENCY_SUPL == mNotify.type) - && (GNSS_NI_OPTIONS_PRIVACY_OVERRIDE_BIT & mNotify.options)) { - mApi.informNiResponse(GNSS_NI_RESPONSE_ACCEPT, mData); } else { mAdapter.requestNiNotify(mNotify, mData, false); } @@ -4892,19 +4923,21 @@ GnssAdapter::reportGnssMeasurementsEvent(const GnssMeasurements& gnssMeasurement 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) { + mGnssMeasurements(gnssMeasurements) { if (-1 != msInWeek) { - mAdapter.getAgcInformation(mMeasurementsNotify, msInWeek); + mAdapter.getAgcInformation(mGnssMeasurements.gnssMeasNotification, msInWeek); } } + inline virtual void proc() const { - mAdapter.reportGnssMeasurementData(mMeasurementsNotify); + mAdapter.mPositionElapsedRealTimeCal.saveGpsTimeAndQtimerPairInMeasReport( + mGnssMeasurements.gnssSvMeasurementSet); + mAdapter.reportGnssMeasurementData(mGnssMeasurements.gnssMeasNotification); } }; diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h index f7c1739..9c47d08 100644 --- a/gnss/GnssAdapter.h +++ b/gnss/GnssAdapter.h @@ -288,6 +288,7 @@ class GnssAdapter : public LocAdapterBase { std::queue<GnssLatencyInfo> mGnssLatencyInfoQueue; GnssReportLoggerUtil mLogger; bool mDreIntEnabled; + ElapsedRealtimeEstimator mPositionElapsedRealTimeCal; /* === NativeAgpsHandler ======================================================== */ NativeAgpsHandler mNativeAgpsHandler; @@ -314,6 +315,8 @@ class GnssAdapter : public LocAdapterBase { inline void injectLocationAndAddr(const Location& location, const GnssCivicAddress& addr) { mLocApi->injectPositionAndCivicAddress(location, addr);} static bool isFlpClient(LocationCallbacks& locationCallbacks); + void fillElapsedRealTime(const GpsLocationExtended& locationExtended, + Location& out); /*==== DGnss Ntrip Source ==========================================================*/ StartDgnssNtripParams mStartDgnssNtripParams; diff --git a/gps_vendor_board.mk b/gps_vendor_board.mk index 6f44bfd..e891ff7 100644 --- a/gps_vendor_board.mk +++ b/gps_vendor_board.mk @@ -4,16 +4,16 @@ LOC_BOARD_PLATFORM_EXCLUDE_LIST := # Define BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE if: +# EXCLUDE_LOCATION_FEATURES is not true AND +# TARGET_BOARD_PLATFORM is not in LOC_BOARD_PLATFORM_EXCLUDE_LIST AND # (TARRGET_USES_QMMA is not true OR -# TARGET_USES_QMAA_OVERRIDE_GPS is not false) AND -# TARGET_BOARD_PLATFORM is not in LOC_BOARD_PLATFORM_EXCLUDE_LIST -ifneq ($(TARGET_USES_QMAA),true) +# TARGET_USES_QMAA_OVERRIDE_GPS is not false +ifneq ($(EXCLUDE_LOCATION_FEATURES),true) ifeq (,$(filter $(LOC_BOARD_PLATFORM_EXCLUDE_LIST),$(TARGET_BOARD_PLATFORM))) - BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE := default - endif -else ifneq ($(TARGET_USES_QMAA_OVERRIDE_GPS),false) - ifeq (,$(filter $(LOC_BOARD_PLATFORM_EXCLUDE_LIST),$(TARGET_BOARD_PLATFORM))) - BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE := default - endif -endif - + ifneq ($(TARGET_USES_QMAA),true) + BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE := default + else ifneq ($(TARGET_USES_QMAA_OVERRIDE_GPS),false) + BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE := default + endif + endif #LOC_BOARD_PLATFORM_EXCLUDE_LIST check +endif #EXCLUDE_LOCATION_FEATURES check diff --git a/location/LocationAPIClientBase.cpp b/location/LocationAPIClientBase.cpp index 642226d..b7c8e05 100644 --- a/location/LocationAPIClientBase.cpp +++ b/location/LocationAPIClientBase.cpp @@ -48,8 +48,6 @@ LocationAPIControlClient::LocationAPIControlClient() : mRequestQueues[i].reset((uint32_t)0); } - memset(&mConfig, 0, sizeof(GnssConfig)); - LocationControlCallbacks locationControlCallbacks; locationControlCallbacks.size = sizeof(LocationControlCallbacks); @@ -145,21 +143,15 @@ uint32_t LocationAPIControlClient::locAPIGnssUpdateConfig(GnssConfig config) pthread_mutex_lock(&mMutex); if (mLocationControlAPI) { - if (mConfig.equals(config)) { - LOC_LOGv("GnssConfig is identical to previous call"); - retVal = LOCATION_ERROR_SUCCESS; - } else { - mConfig = config; - uint32_t* idArray = mLocationControlAPI->gnssUpdateConfig(config); - LOC_LOGv("gnssUpdateConfig return array: %p", idArray); - if (nullptr != idArray) { - if (nullptr != mRequestQueues[CTRL_REQUEST_CONFIG_UPDATE].getSessionArrayPtr()) { - mRequestQueues[CTRL_REQUEST_CONFIG_UPDATE].reset(idArray); - } - mRequestQueues[CTRL_REQUEST_CONFIG_UPDATE].push(new GnssUpdateConfigRequest(*this)); - retVal = LOCATION_ERROR_SUCCESS; - delete [] idArray; + uint32_t* idArray = mLocationControlAPI->gnssUpdateConfig(config); + LOC_LOGv("gnssUpdateConfig return array: %p", idArray); + if (nullptr != idArray) { + if (nullptr != mRequestQueues[CTRL_REQUEST_CONFIG_UPDATE].getSessionArrayPtr()) { + mRequestQueues[CTRL_REQUEST_CONFIG_UPDATE].reset(idArray); } + mRequestQueues[CTRL_REQUEST_CONFIG_UPDATE].push(new GnssUpdateConfigRequest(*this)); + retVal = LOCATION_ERROR_SUCCESS; + delete [] idArray; } } pthread_mutex_unlock(&mMutex); diff --git a/location/LocationAPIClientBase.h b/location/LocationAPIClientBase.h index 3675671..0038e9a 100644 --- a/location/LocationAPIClientBase.h +++ b/location/LocationAPIClientBase.h @@ -194,7 +194,6 @@ private: LocationControlAPI* mLocationControlAPI; RequestQueue mRequestQueues[CTRL_REQUEST_MAX]; bool mEnabled; - GnssConfig mConfig; }; class LocationAPIClientBase { diff --git a/location/LocationDataTypes.h b/location/LocationDataTypes.h index 347393d..06dcb85 100644 --- a/location/LocationDataTypes.h +++ b/location/LocationDataTypes.h @@ -76,8 +76,8 @@ typedef enum { LOCATION_HAS_VERTICAL_ACCURACY_BIT = (1<<5), // location has valid vertical accuracy LOCATION_HAS_SPEED_ACCURACY_BIT = (1<<6), // location has valid speed accuracy LOCATION_HAS_BEARING_ACCURACY_BIT = (1<<7), // location has valid bearing accuracy - LOCATION_HAS_SPOOF_MASK = (1<<8), // location has valid spoof mask - LOCATION_HAS_ELAPSED_REAL_TIME = (1<<9), // location has valid elapsed real time + LOCATION_HAS_SPOOF_MASK_BIT = (1<<8), // location has valid spoof mask + LOCATION_HAS_ELAPSED_REAL_TIME_BIT = (1<<9), // location has valid elapsed real time LOCATION_HAS_CONFORMITY_INDEX_BIT = (1<<10), // location has valid conformity index LOCATION_HAS_QUALITY_TYPE_BIT = (1<<11), // location has valid quality type LOCATION_HAS_TECH_MASK_BIT = (1<<12), // location has valid tech mask diff --git a/utils/gps_extended_c.h b/utils/gps_extended_c.h index d84b894..5400720 100644 --- a/utils/gps_extended_c.h +++ b/utils/gps_extended_c.h @@ -429,6 +429,9 @@ typedef uint64_t GpsLocationExtendedFlags; #define GPS_LOCATION_EXTENDED_HAS_DR_SOLUTION_STATUS_MASK 0x800000000000 /** GpsLocationExtended has altitudeAssumed. */ #define GPS_LOCATION_EXTENDED_HAS_ALTITUDE_ASSUMED 0x1000000000000 +#define GPS_LOCATION_EXTENDED_HAS_SYSTEM_TICK 0x2000000000000 +/** GpsLocationExtended has system tick unc. */ +#define GPS_LOCATION_EXTENDED_HAS_SYSTEM_TICK_UNC 0x4000000000000 typedef uint32_t LocNavSolutionMask; /* Bitmask to specify whether SBAS ionospheric correction is used */ @@ -875,6 +878,10 @@ typedef struct { * true: Altitude is assumed; there may not be enough * satellites to determine the precise altitude. */ bool altitudeAssumed; + /** System Tick at GPS Time */ + uint64_t systemTick; + /** Uncertainty for System Tick at GPS Time in milliseconds */ + float systemTickUnc; } GpsLocationExtended; // struct that contains complete position info from engine @@ -1518,6 +1525,7 @@ typedef uint64_t GpsSvMeasHeaderFlags; #define GNSS_SV_MEAS_HEADER_HAS_GLOG1G2_TIME_BIAS 0x200000000 #define GNSS_SV_MEAS_HEADER_HAS_BDSB1IB1C_TIME_BIAS 0x400000000 #define GNSS_SV_MEAS_HEADER_HAS_GALE1E5B_TIME_BIAS 0x800000000 +#define GNSS_SV_MEAS_HEADER_HAS_REF_COUNT_TICKS_UNC 0x1000000000 typedef struct { @@ -1571,6 +1579,7 @@ typedef struct /** Receiver tick at frame count */ uint64_t refCountTicks; + float refCountTicksUnc; /** DGNSS corrections source type RTCM, 3GPP etc, if DGNSS was * used for these measurements. */ diff --git a/utils/loc_gps.h b/utils/loc_gps.h index faa897b..0c122fb 100644 --- a/utils/loc_gps.h +++ b/utils/loc_gps.h @@ -106,10 +106,8 @@ typedef uint16_t LocGpsLocationFlags; #define LOC_GPS_LOCATION_HAS_BEARING_ACCURACY 0x0080 /** LocGpsLocation has valid spoof mask */ #define LOC_GPS_LOCATION_HAS_SPOOF_MASK 0x0100 -/** LocGpsLocation has valid Real Time and Real Time Uncertainty */ -#define LOC_GPS_LOCATION_HAS_ELAPSED_REAL_TIME 0x0200 /** Location has valid source information. */ -#define LOC_GPS_LOCATION_HAS_SOURCE_INFO 0x0400 +#define LOC_GPS_LOCATION_HAS_SOURCE_INFO 0x0200 /** Spoof mask in LocGpsLocation */ typedef uint32_t LocGpsSpoofMask; |