From 1a16ef3803aca2b2d8f1468e9aa99961781dfac3 Mon Sep 17 00:00:00 2001 From: Kevin Tang Date: Wed, 17 Jul 2019 12:06:57 -0700 Subject: [PATCH 01/26] Report ErrRecovery only when there is actual event SystemStatus needs to report ErrRecovery events only when they actually happen (value != 0). Change-Id: I282d9c703542ef4bfd61ded78b903017816bd2cb CRs-Fixed: 2491022 --- core/SystemStatus.cpp | 3 +++ core/SystemStatus.h | 32 +++++++++++++++++--------------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/core/SystemStatus.cpp b/core/SystemStatus.cpp index 9ca126f8..1c326c1e 100644 --- a/core/SystemStatus.cpp +++ b/core/SystemStatus.cpp @@ -1338,6 +1338,9 @@ SystemStatus::SystemStatus(const MsgTask* msgTask) : template bool SystemStatus::setIteminReport(TYPE_REPORT& report, TYPE_ITEM&& s) { + if (s.ignore()) { + return false; + } if (!report.empty() && report.back().equals(static_cast(s.collate(report.back())))) { // there is no change - just update reported timestamp report.back().mUtcReported = s.mUtcReported; diff --git a/core/SystemStatus.h b/core/SystemStatus.h index 94f7f0be..8a6fd72d 100644 --- a/core/SystemStatus.h +++ b/core/SystemStatus.h @@ -86,6 +86,7 @@ public: return *this; } virtual void dump(void) {}; + inline virtual bool ignore() { return false; }; }; class SystemStatusLocation : public SystemStatusItemBase @@ -102,7 +103,7 @@ public: mLocation(location), mLocationEx(locationEx) {} bool equals(const SystemStatusLocation& peer); - void dump(void); + void dump(void) override; }; class SystemStatusPQWM1; @@ -132,7 +133,7 @@ public: mTimeUncNs(0ULL) {} inline SystemStatusTimeAndClock(const SystemStatusPQWM1& nmea); bool equals(const SystemStatusTimeAndClock& peer); - void dump(void); + void dump(void) override; }; class SystemStatusXoState : public SystemStatusItemBase @@ -143,7 +144,7 @@ public: mXoState(0) {} inline SystemStatusXoState(const SystemStatusPQWM1& nmea); bool equals(const SystemStatusXoState& peer); - void dump(void); + void dump(void) override; }; class SystemStatusRfAndParams : public SystemStatusItemBase @@ -190,7 +191,7 @@ public: mGalBpAmpQ(0) {} inline SystemStatusRfAndParams(const SystemStatusPQWM1& nmea); bool equals(const SystemStatusRfAndParams& peer); - void dump(void); + void dump(void) override; }; class SystemStatusErrRecovery : public SystemStatusItemBase @@ -201,7 +202,8 @@ public: mRecErrorRecovery(0) {}; inline SystemStatusErrRecovery(const SystemStatusPQWM1& nmea); bool equals(const SystemStatusErrRecovery& peer); - void dump(void); + inline bool ignore() override { return 0 == mRecErrorRecovery; }; + void dump(void) override; }; class SystemStatusPQWP1; @@ -225,7 +227,7 @@ public: mEpiSrc(0) {} inline SystemStatusInjectedPosition(const SystemStatusPQWP1& nmea); bool equals(const SystemStatusInjectedPosition& peer); - void dump(void); + void dump(void) override; }; class SystemStatusPQWP2; @@ -247,7 +249,7 @@ public: mBestAltUnc(0) {} inline SystemStatusBestPosition(const SystemStatusPQWP2& nmea); bool equals(const SystemStatusBestPosition& peer); - void dump(void); + void dump(void) override; }; class SystemStatusPQWP3; @@ -283,7 +285,7 @@ public: mNavicXtraValid(0) {} inline SystemStatusXtra(const SystemStatusPQWP3& nmea); bool equals(const SystemStatusXtra& peer); - void dump(void); + void dump(void) override; }; class SystemStatusPQWP4; @@ -303,7 +305,7 @@ public: mQzssEpheValid(0) {} inline SystemStatusEphemeris(const SystemStatusPQWP4& nmea); bool equals(const SystemStatusEphemeris& peer); - void dump(void); + void dump(void) override; }; class SystemStatusPQWP5; @@ -349,7 +351,7 @@ public: mNavicBadMask(0) {} inline SystemStatusSvHealth(const SystemStatusPQWP5& nmea); bool equals(const SystemStatusSvHealth& peer); - void dump(void); + void dump(void) override; }; class SystemStatusPQWP6; @@ -361,7 +363,7 @@ public: mFixInfoMask(0) {} inline SystemStatusPdr(const SystemStatusPQWP6& nmea); bool equals(const SystemStatusPdr& peer); - void dump(void); + void dump(void) override; }; class SystemStatusPQWP7; @@ -385,7 +387,7 @@ public: } inline SystemStatusNavData(const SystemStatusPQWP7& nmea); bool equals(const SystemStatusNavData& peer); - void dump(void); + void dump(void) override; }; class SystemStatusPQWS1; @@ -399,7 +401,7 @@ public: mHepeLimit(0) {} inline SystemStatusPositionFailure(const SystemStatusPQWS1& nmea); bool equals(const SystemStatusPositionFailure& peer); - void dump(void); + void dump(void) override; }; /****************************************************************************** @@ -710,7 +712,7 @@ public: inline bool equals(const SystemStatusTac& peer) { return (mValue == peer.mValue); } - inline void dump(void) { + inline void dump(void) override { LOC_LOGD("Tac: value=%s", mValue.c_str()); } }; @@ -726,7 +728,7 @@ public: inline bool equals(const SystemStatusMccMnc& peer) { return (mValue == peer.mValue); } - inline void dump(void) { + inline void dump(void) override { LOC_LOGD("TacMccMnc value=%s", mValue.c_str()); } }; From fa7f9e3f087ef2168f716159015ed36decae8450 Mon Sep 17 00:00:00 2001 From: Mike Cailean Date: Fri, 20 Sep 2019 17:15:11 -0700 Subject: [PATCH 02/26] Prevent left shift by a large number CRs-fixed: 2534443 Change-Id: I3c52f6f62620c69bc79bc9bc5343e5d1ec08656d --- gnss/GnssAdapter.cpp | 2 +- utils/loc_nmea.cpp | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index c2e4a091..43fb63bf 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -3484,7 +3484,7 @@ GnssAdapter::reportSv(GnssSvNotification& svNotify) // If SV ID was used in previous position fix, then set USED_IN_FIX // flag, else clear the USED_IN_FIX flag. - if (svUsedIdMask & (1 << (gnssSvId - 1))) { + if ((gnssSvId < 64) && (svUsedIdMask & (1ULL << (gnssSvId - 1)))) { svNotify.gnssSvs[i].gnssSvOptionsMask |= GNSS_SV_OPTIONS_USED_IN_FIX_BIT; } } diff --git a/utils/loc_nmea.cpp b/utils/loc_nmea.cpp index 41a707dc..d5e4b57a 100644 --- a/utils/loc_nmea.cpp +++ b/utils/loc_nmea.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2019, 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 @@ -782,8 +782,13 @@ 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,", - svNotify.gnssSvs[svNumber - 1].svId + svIdOffset, + svId + svIdOffset, (int)(0.5 + svNotify.gnssSvs[svNumber - 1].elevation), //float to int (int)(0.5 + svNotify.gnssSvs[svNumber - 1].azimuth)); //float to int @@ -1901,7 +1906,7 @@ void loc_nmea_generate_sv(const GnssSvNotification &svNotify, (svNotify.gnssSvs[svNumber - 1].gnssSvOptionsMask & GNSS_SV_OPTIONS_USED_IN_FIX_BIT)) { - sv_cache_info.gps_used_mask |= (1 << (svNotify.gnssSvs[svNumber - 1].svId - 1)); + sv_cache_info.gps_used_mask |= (1ULL << (svNotify.gnssSvs[svNumber - 1].svId - 1)); } if (GNSS_SIGNAL_GPS_L5 == svNotify.gnssSvs[svNumber - 1].gnssSignalTypeMask) { sv_cache_info.gps_l5_count++; @@ -1919,7 +1924,7 @@ void loc_nmea_generate_sv(const GnssSvNotification &svNotify, (svNotify.gnssSvs[svNumber - 1].gnssSvOptionsMask & GNSS_SV_OPTIONS_USED_IN_FIX_BIT)) { - sv_cache_info.glo_used_mask |= (1 << (svNotify.gnssSvs[svNumber - 1].svId - 1)); + sv_cache_info.glo_used_mask |= (1ULL << (svNotify.gnssSvs[svNumber - 1].svId - 1)); } if (GNSS_SIGNAL_GLONASS_G2 == svNotify.gnssSvs[svNumber - 1].gnssSignalTypeMask){ sv_cache_info.glo_g2_count++; @@ -1937,7 +1942,7 @@ void loc_nmea_generate_sv(const GnssSvNotification &svNotify, (svNotify.gnssSvs[svNumber - 1].gnssSvOptionsMask & GNSS_SV_OPTIONS_USED_IN_FIX_BIT)) { - sv_cache_info.gal_used_mask |= (1 << (svNotify.gnssSvs[svNumber - 1].svId - 1)); + sv_cache_info.gal_used_mask |= (1ULL << (svNotify.gnssSvs[svNumber - 1].svId - 1)); } if(GNSS_SIGNAL_GALILEO_E5A == svNotify.gnssSvs[svNumber - 1].gnssSignalTypeMask){ sv_cache_info.gal_e5_count++; @@ -1955,7 +1960,9 @@ void loc_nmea_generate_sv(const GnssSvNotification &svNotify, (svNotify.gnssSvs[svNumber - 1].gnssSvOptionsMask & GNSS_SV_OPTIONS_USED_IN_FIX_BIT)) { - sv_cache_info.qzss_used_mask |= (1 << (svNotify.gnssSvs[svNumber - 1].svId - 1)); + // For QZSS we adjusted SV id's in GnssAdapter, we need to re-adjust here + sv_cache_info.qzss_used_mask |= + (1ULL << (svNotify.gnssSvs[svNumber - 1].svId - (QZSS_SV_PRN_MIN - 1) - 1)); } if (GNSS_SIGNAL_QZSS_L5 == svNotify.gnssSvs[svNumber - 1].gnssSignalTypeMask) { sv_cache_info.qzss_l5_count++; @@ -1973,7 +1980,7 @@ void loc_nmea_generate_sv(const GnssSvNotification &svNotify, (svNotify.gnssSvs[svNumber - 1].gnssSvOptionsMask & GNSS_SV_OPTIONS_USED_IN_FIX_BIT)) { - sv_cache_info.bds_used_mask |= (1 << (svNotify.gnssSvs[svNumber - 1].svId - 1)); + sv_cache_info.bds_used_mask |= (1ULL << (svNotify.gnssSvs[svNumber - 1].svId - 1)); } if(GNSS_SIGNAL_BEIDOU_B2AI == svNotify.gnssSvs[svNumber - 1].gnssSignalTypeMask){ sv_cache_info.bds_b2_count++; @@ -1991,7 +1998,8 @@ void loc_nmea_generate_sv(const GnssSvNotification &svNotify, (svNotify.gnssSvs[svNumber - 1].gnssSvOptionsMask & GNSS_SV_OPTIONS_USED_IN_FIX_BIT)) { - sv_cache_info.navic_used_mask |= (1 << (svNotify.gnssSvs[svNumber - 1].svId - 1)); + sv_cache_info.navic_used_mask |= + (1ULL << (svNotify.gnssSvs[svNumber - 1].svId - 1)); } // GNSS_SIGNAL_NAVIC_L5 is the only signal type for NAVIC sv_cache_info.navic_l5_count++; From 73f69ef469c45e329a483a1f39f2757affb34ba3 Mon Sep 17 00:00:00 2001 From: Mike Cailean Date: Tue, 24 Sep 2019 14:15:57 -0700 Subject: [PATCH 03/26] Enable Android sanitizers Change-Id: I6724d0e171e42f779e8eed6aea126f3f69496f6d CRs-fixed: 2534375 --- android/1.0/Android.mk | 6 ++++++ android/1.1/Android.mk | 6 ++++++ android/2.0/Android.mk | 6 ++++++ android/utils/Android.mk | 3 +++ batching/Android.mk | 3 +++ build/target_specific_features.mk | 6 ++++-- core/Android.mk | 3 +++ geofence/Android.mk | 3 +++ gnss/Android.mk | 3 +++ location/Android.mk | 3 +++ utils/Android.mk | 3 +++ 11 files changed, 43 insertions(+), 2 deletions(-) diff --git a/android/1.0/Android.mk b/android/1.0/Android.mk index 9337325f..112ae8bd 100644 --- a/android/1.0/Android.mk +++ b/android/1.0/Android.mk @@ -2,6 +2,9 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := android.hardware.gnss@1.0-impl-qti +LOCAL_SANITIZE += $(GNSS_SANITIZE) +# activate the following line for debug purposes only, comment out for production +#LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG) LOCAL_VENDOR_MODULE := true LOCAL_MODULE_RELATIVE_PATH := hw LOCAL_SRC_FILES := \ @@ -57,6 +60,9 @@ include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := android.hardware.gnss@1.0-service-qti +LOCAL_SANITIZE += $(GNSS_SANITIZE) +# activate the following line for debug purposes only, comment out for production +#LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG) LOCAL_VINTF_FRAGMENTS := android.hardware.gnss@1.0-service-qti.xml LOCAL_VENDOR_MODULE := true LOCAL_MODULE_RELATIVE_PATH := hw diff --git a/android/1.1/Android.mk b/android/1.1/Android.mk index fb72de11..132c1e1e 100644 --- a/android/1.1/Android.mk +++ b/android/1.1/Android.mk @@ -2,6 +2,9 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := android.hardware.gnss@1.1-impl-qti +LOCAL_SANITIZE += $(GNSS_SANITIZE) +# activate the following line for debug purposes only, comment out for production +#LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG) LOCAL_VENDOR_MODULE := true LOCAL_MODULE_RELATIVE_PATH := hw LOCAL_SRC_FILES := \ @@ -58,6 +61,9 @@ include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := android.hardware.gnss@1.1-service-qti +LOCAL_SANITIZE += $(GNSS_SANITIZE) +# activate the following line for debug purposes only, comment out for production +#LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG) LOCAL_VINTF_FRAGMENTS := android.hardware.gnss@1.1-service-qti.xml LOCAL_VENDOR_MODULE := true LOCAL_MODULE_RELATIVE_PATH := hw diff --git a/android/2.0/Android.mk b/android/2.0/Android.mk index 7c555042..d9ac77ca 100644 --- a/android/2.0/Android.mk +++ b/android/2.0/Android.mk @@ -2,6 +2,9 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := android.hardware.gnss@2.0-impl-qti +LOCAL_SANITIZE += $(GNSS_SANITIZE) +# activate the following line for debug purposes only, comment out for production +#LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG) LOCAL_VENDOR_MODULE := true LOCAL_MODULE_RELATIVE_PATH := hw LOCAL_SRC_FILES := \ @@ -70,6 +73,9 @@ include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := android.hardware.gnss@2.0-service-qti +LOCAL_SANITIZE += $(GNSS_SANITIZE) +# activate the following line for debug purposes only, comment out for production +#LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG) LOCAL_VINTF_FRAGMENTS := android.hardware.gnss@2.0-service-qti.xml LOCAL_VENDOR_MODULE := true LOCAL_MODULE_RELATIVE_PATH := hw diff --git a/android/utils/Android.mk b/android/utils/Android.mk index 47b40811..76732c2c 100644 --- a/android/utils/Android.mk +++ b/android/utils/Android.mk @@ -2,6 +2,9 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := liblocbatterylistener +LOCAL_SANITIZE += $(GNSS_SANITIZE) +# activate the following line for debug purposes only, comment out for production +#LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG) LOCAL_VENDOR_MODULE := true LOCAL_CFLAGS += $(GNSS_CFLAGS) diff --git a/batching/Android.mk b/batching/Android.mk index b08d1558..b4876cd5 100644 --- a/batching/Android.mk +++ b/batching/Android.mk @@ -6,6 +6,9 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := libbatching +LOCAL_SANITIZE += $(GNSS_SANITIZE) +# activate the following line for debug purposes only, comment out for production +#LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG) LOCAL_VENDOR_MODULE := true LOCAL_MODULE_TAGS := optional diff --git a/build/target_specific_features.mk b/build/target_specific_features.mk index 6093f4a8..241d67c8 100644 --- a/build/target_specific_features.mk +++ b/build/target_specific_features.mk @@ -15,8 +15,6 @@ GNSS_CFLAGS := \ -Wno-error=switch \ -Wno-error=date-time -LOCAL_SANITIZE := signed-integer-overflow, unsigned-integer-overflow - # GPS-HIDL GNSS_HIDL_1_0_TARGET_LIST := msm8960 GNSS_HIDL_1_0_TARGET_LIST += msm8974 @@ -68,3 +66,7 @@ GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += sdm660 ifneq (,$(filter $(GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST),$(TARGET_BOARD_PLATFORM))) GNSS_HIDL_LEGACY_MEASURMENTS = true endif + +# Activate the following two lines for regression testing +#GNSS_SANITIZE := address cfi alignment bounds null unreachable integer +#GNSS_SANITIZE_DIAG := address cfi alignment bounds null unreachable integer diff --git a/core/Android.mk b/core/Android.mk index bd955c1f..ce5d6a8e 100644 --- a/core/Android.mk +++ b/core/Android.mk @@ -6,6 +6,9 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := libloc_core +LOCAL_SANITIZE += $(GNSS_SANITIZE) +# activate the following line for debug purposes only, comment out for production +#LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG) LOCAL_VENDOR_MODULE := true LOCAL_MODULE_TAGS := optional diff --git a/geofence/Android.mk b/geofence/Android.mk index 6e9e8706..7e0e34e8 100644 --- a/geofence/Android.mk +++ b/geofence/Android.mk @@ -6,6 +6,9 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := libgeofencing +LOCAL_SANITIZE += $(GNSS_SANITIZE) +# activate the following line for debug purposes only, comment out for production +#LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG) LOCAL_VENDOR_MODULE := true LOCAL_MODULE_TAGS := optional diff --git a/gnss/Android.mk b/gnss/Android.mk index d809bc2a..c1b5944a 100644 --- a/gnss/Android.mk +++ b/gnss/Android.mk @@ -6,6 +6,9 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := libgnss +LOCAL_SANITIZE += $(GNSS_SANITIZE) +# activate the following line for debug purposes only, comment out for production +#LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG) LOCAL_VENDOR_MODULE := true LOCAL_MODULE_TAGS := optional diff --git a/location/Android.mk b/location/Android.mk index bbd6fbd8..2a595414 100644 --- a/location/Android.mk +++ b/location/Android.mk @@ -6,6 +6,9 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := liblocation_api +LOCAL_SANITIZE += $(GNSS_SANITIZE) +# activate the following line for debug purposes only, comment out for production +#LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG) LOCAL_VENDOR_MODULE := true LOCAL_MODULE_TAGS := optional diff --git a/utils/Android.mk b/utils/Android.mk index 38876965..88ad487b 100644 --- a/utils/Android.mk +++ b/utils/Android.mk @@ -47,6 +47,9 @@ LOCAL_HEADER_LIBRARIES := \ liblocation_api_headers LOCAL_MODULE := libgps.utils +LOCAL_SANITIZE += $(GNSS_SANITIZE) +# activate the following line for debug purposes only, comment out for production +#LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG) LOCAL_VENDOR_MODULE := true LOCAL_MODULE_TAGS := optional From f80980210e4b9ba5da41bc7f615943e164c68f39 Mon Sep 17 00:00:00 2001 From: Dante Russo Date: Mon, 30 Sep 2019 16:24:03 -0700 Subject: [PATCH 04/26] Assure accurate elapsedRealTimeNanos calculations If a context switch or interrupt happens between getting current time and getting boot time, this can throw off the calculation for the elapsedRealTimeNanos timestamp. Avoid this by retrying if there is a large enough delta between getting current time and getting boot time. Change-Id: I47d7a99b480423a50eaf951a904f21928587eda6 CRs-fixed: 2541719 --- android/2.0/location_api/LocationUtil.cpp | 41 ++++++++++++++++++++--- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/android/2.0/location_api/LocationUtil.cpp b/android/2.0/location_api/LocationUtil.cpp index 38a083af..8a30066f 100644 --- a/android/2.0/location_api/LocationUtil.cpp +++ b/android/2.0/location_api/LocationUtil.cpp @@ -88,10 +88,41 @@ void convertGnssLocation(Location& in, V2_0::GnssLocation& out) struct timespec sinceBootTime; struct timespec currentTime; - if (0 == clock_gettime(CLOCK_BOOTTIME,&sinceBootTime) && - 0 == clock_gettime(CLOCK_REALTIME,¤tTime)) { + struct timespec sinceBootTimeTest; + int64_t sinceBootTimeNanos = 0; + bool clockGetTimeSuccess = false; + const uint32_t MAX_TIME_DELTA_VALUE_NANOS = 10000; + const uint32_t MAX_GET_TIME_COUNT = 20; + /* Attempt to get CLOCK_REALTIME and CLOCK_BOOTIME in succession without an interruption + or context switch (for up to MAX_GET_TIME_COUNT times) to avoid errors in the calculation */ + for (uint32_t i=0; i < MAX_GET_TIME_COUNT; i++) { + if (clock_gettime(CLOCK_BOOTTIME, &sinceBootTime) != 0) { + break; + }; + if (clock_gettime(CLOCK_REALTIME, ¤tTime) != 0) { + break; + } + if (clock_gettime(CLOCK_BOOTTIME, &sinceBootTimeTest) != 0) { + break; + }; + sinceBootTimeNanos = sinceBootTime.tv_sec*1000000000 + sinceBootTime.tv_nsec; + int64_t sinceBootTimeTestNanos = + sinceBootTimeTest.tv_sec*1000000000 + sinceBootTimeTest.tv_nsec; + int64_t sinceBootTimeDeltaNanos = sinceBootTimeTestNanos - sinceBootTimeNanos; - int64_t sinceBootTimeNanos = sinceBootTime.tv_sec*1000000000 + sinceBootTime.tv_nsec; + /* sinceBootTime and sinceBootTimeTest should have a close value if there was no + interruption or context switch between clock_gettime for CLOCK_BOOTIME and + clock_gettime for CLOCK_REALTIME */ + if (sinceBootTimeDeltaNanos < MAX_TIME_DELTA_VALUE_NANOS) { + clockGetTimeSuccess = true; + break; + } else { + LOC_LOGD("%s]: Delta:%" PRIi64 "ns time too large, retry number #%u...", + __FUNCTION__, sinceBootTimeDeltaNanos, i+1); + } + } + + if (clockGetTimeSuccess) { int64_t currentTimeNanos = currentTime.tv_sec*1000000000 + currentTime.tv_nsec; int64_t locationTimeNanos = in.timestamp*1000000; LOC_LOGD("%s]: sinceBootTimeNanos:%" PRIi64 " currentTimeNanos:%" PRIi64 "" @@ -110,8 +141,10 @@ void convertGnssLocation(Location& in, V2_0::GnssLocation& out) __FUNCTION__, out.elapsedRealtime.timestampNs); } } + } else { + LOC_LOGE("%s]: Failed to calculate elapsedRealtimeNanos timestamp after %u tries", + __FUNCTION__, MAX_GET_TIME_COUNT); } - } void convertGnssLocation(const V1_0::GnssLocation& in, Location& out) From 8e7733ba7fa7e307213af81e3447006d8a7a8b1f Mon Sep 17 00:00:00 2001 From: Harikrishnan Hariharan Date: Thu, 3 Oct 2019 23:32:30 +0530 Subject: [PATCH 05/26] Disable few process launch in loc_launcher for low ram targets Use ro.config.low_ram property to identify low ram targets and disable the process in izat.conf whose property value LOW_RAM_TARGETS is set to DISABLED. Change-Id: Idb8b0b91c4ed127b4fa58c41683f9720252dff84 CRs-Fixed: 2542145 --- utils/loc_cfg.cpp | 12 ++++++++++++ utils/loc_target.cpp | 15 +++++++++++++++ utils/loc_target.h | 1 + 3 files changed, 28 insertions(+) diff --git a/utils/loc_cfg.cpp b/utils/loc_cfg.cpp index 9c1f0b35..36482ac0 100644 --- a/utils/loc_cfg.cpp +++ b/utils/loc_cfg.cpp @@ -483,6 +483,7 @@ typedef struct { unsigned int loc_feature_mask; char platform_list[LOC_MAX_PARAM_STRING]; char baseband[LOC_MAX_PARAM_STRING]; + char low_ram_targets[LOC_MAX_PARAM_STRING]; unsigned int sglte_target; char feature_gtp_mode[LOC_MAX_PARAM_STRING]; char feature_gtp_waa[LOC_MAX_PARAM_STRING]; @@ -524,6 +525,7 @@ static const loc_param_s_type loc_process_conf_parameter_table[] = { {"IZAT_FEATURE_MASK", &conf.loc_feature_mask, NULL, 'n'}, {"PLATFORMS", &conf.platform_list, NULL, 's'}, {"BASEBAND", &conf.baseband, NULL, 's'}, + {"LOW_RAM_TARGETS", &conf.low_ram_targets, NULL, 's'}, {"HARDWARE_TYPE", &conf.auto_platform, NULL, 's'}, {"VENDOR_ENHANCED_PROCESS", &conf.vendor_enhanced_process, NULL, 'n'}, }; @@ -565,6 +567,7 @@ int loc_read_process_conf(const char* conf_file_name, uint32_t * process_count_p int group_index=0, nstrings=0, status_length=0; FILE* conf_fp = nullptr; char platform_name[PROPERTY_VALUE_MAX], baseband_name[PROPERTY_VALUE_MAX]; + int low_ram_target=0; char autoplatform_name[PROPERTY_VALUE_MAX]; unsigned int loc_service_mask=0; char config_mask = 0; @@ -597,6 +600,8 @@ int loc_read_process_conf(const char* conf_file_name, uint32_t * process_count_p loc_get_target_baseband(baseband_name, sizeof(baseband_name)); //Identify if this is an automotive platform loc_get_auto_platform_name(autoplatform_name,sizeof(autoplatform_name)); + //Identify if this is a low ram target from ro.config.low_ram property + low_ram_target = loc_identify_low_ram_target(); UTIL_READ_CONF(conf_file_name, loc_feature_conf_table); @@ -894,6 +899,13 @@ int loc_read_process_conf(const char* conf_file_name, uint32_t * process_count_p } } + nstrings = loc_util_split_string(conf.low_ram_targets, split_strings, MAX_NUM_STRINGS, ' '); + if (!strcmp("DISABLED", split_strings[0]) && low_ram_target) { + LOC_LOGd("Disabled for low ram targets\n"); + child_proc[j].proc_status = DISABLED; + continue; + } + if((config_mask & CONFIG_MASK_TARGET_CHECK) && (config_mask & CONFIG_MASK_BASEBAND_CHECK) && (config_mask & CONFIG_MASK_AUTOPLATFORM_CHECK) && diff --git a/utils/loc_target.cpp b/utils/loc_target.cpp index f6fd728a..1cab7b8e 100644 --- a/utils/loc_target.cpp +++ b/utils/loc_target.cpp @@ -130,6 +130,21 @@ void loc_get_auto_platform_name(char *platform_name, int array_length) } } +/*Reads the property ro.config.low_ram to identify if this is a low ram target + Returns: + 0 if not a low ram target + 1 if this is a low ram target +*/ +int loc_identify_low_ram_target() +{ + int ret = 0; + char low_ram_target[PROPERTY_VALUE_MAX]; + property_get("ro.config.low_ram", low_ram_target, ""); + LOC_LOGd("low ram target: %s\n", low_ram_target); + return !(strncmp(low_ram_target, "true", PROPERTY_VALUE_MAX)); +} + + unsigned int loc_get_target(void) { if (gTarget != (unsigned int)-1) diff --git a/utils/loc_target.h b/utils/loc_target.h index 172b4752..e9ff918b 100644 --- a/utils/loc_target.h +++ b/utils/loc_target.h @@ -54,6 +54,7 @@ void loc_get_platform_name(char *platform_name, int array_length); /*The character array passed to this function should have length of atleast PROPERTY_VALUE_MAX*/ void loc_get_auto_platform_name(char *platform_name, int array_length); +int loc_identify_low_ram_target(); /* Please remember to update 'target_name' in loc_log.cpp, if do any changes to this enum. */ From a44fc0383de405ba1527df6df308fcd8990aa8b5 Mon Sep 17 00:00:00 2001 From: Madhanraj Chelladurai Date: Fri, 11 Oct 2019 14:50:06 +0530 Subject: [PATCH 06/26] gps: Add diag permissions for gnss service android interface 2.0 Change-Id: Ib53b8bef8641166c1a7495e9051a092a34830016 CRs-Fixed:2543639 --- android/2.0/android.hardware.gnss@2.0-service-qti.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/2.0/android.hardware.gnss@2.0-service-qti.rc b/android/2.0/android.hardware.gnss@2.0-service-qti.rc index 36ee47c7..ad46d5d2 100644 --- a/android/2.0/android.hardware.gnss@2.0-service-qti.rc +++ b/android/2.0/android.hardware.gnss@2.0-service-qti.rc @@ -1,4 +1,4 @@ service gnss_service /vendor/bin/hw/android.hardware.gnss@2.0-service-qti class hal user gps - group system gps radio + group system gps radio vendor_qti_diag From 201f6120408a47acc37c75ee9029c02f4a71c7b6 Mon Sep 17 00:00:00 2001 From: Harikrishnan Hariharan Date: Fri, 4 Oct 2019 16:54:22 +0530 Subject: [PATCH 07/26] Enable/Disable process launch by loc_launcher based on SOC-Id Add a parameter SOC_IDS for process configuration in izat.conf to include/exclude the process based on SOC-Id. Read the value of this parameter to enable or disable the process launch by loc_launcher. Fixed an issue in read_a_line function to handle newline at the end of line in the file to be read. Change-Id: I66777856ebbb928ce4f49a44dfd9d2f1fbca69b5 CRs-Fixed: 2540349 --- utils/loc_cfg.cpp | 45 ++++++++++++++++++++++++++++++++++++++++---- utils/loc_target.cpp | 38 ++++++++++++++++++++++++++++++------- utils/loc_target.h | 3 +++ 3 files changed, 75 insertions(+), 11 deletions(-) diff --git a/utils/loc_cfg.cpp b/utils/loc_cfg.cpp index 36482ac0..8baf8ca0 100644 --- a/utils/loc_cfg.cpp +++ b/utils/loc_cfg.cpp @@ -460,6 +460,9 @@ void loc_read_conf(const char* conf_file_name, const loc_param_s_type* config_ta #define CONFIG_MASK_AUTOPLATFORM_ALL 0x10 #define CONFIG_MASK_AUTOPLATFORM_FOUND 0x20 #define CONFIG_MASK_AUTOPLATFORM_CHECK 0x30 +#define CONFIG_MASK_SOCID_ALL 0x40 +#define CONFIG_MASK_SOCID_FOUND 0x80 +#define CONFIG_MASK_SOCID_CHECK 0xc0 #define LOC_FEATURE_MASK_GTP_WIFI_BASIC 0x01 #define LOC_FEATURE_MASK_GTP_WIFI_PREMIUM 0X02 @@ -484,6 +487,7 @@ typedef struct { char platform_list[LOC_MAX_PARAM_STRING]; char baseband[LOC_MAX_PARAM_STRING]; char low_ram_targets[LOC_MAX_PARAM_STRING]; + char soc_id_list[LOC_MAX_PARAM_STRING]; unsigned int sglte_target; char feature_gtp_mode[LOC_MAX_PARAM_STRING]; char feature_gtp_waa[LOC_MAX_PARAM_STRING]; @@ -524,6 +528,7 @@ static const loc_param_s_type loc_process_conf_parameter_table[] = { {"PREMIUM_FEATURE", &conf.premium_feature, NULL, 'n'}, {"IZAT_FEATURE_MASK", &conf.loc_feature_mask, NULL, 'n'}, {"PLATFORMS", &conf.platform_list, NULL, 's'}, + {"SOC_IDS", &conf.soc_id_list, NULL, 's'}, {"BASEBAND", &conf.baseband, NULL, 's'}, {"LOW_RAM_TARGETS", &conf.low_ram_targets, NULL, 's'}, {"HARDWARE_TYPE", &conf.auto_platform, NULL, 's'}, @@ -563,14 +568,14 @@ int loc_read_process_conf(const char* conf_file_name, uint32_t * process_count_p gid_t gid_list[LOC_PROCESS_MAX_NUM_GROUPS]; char *split_strings[MAX_NUM_STRINGS]; int name_length=0, group_list_length=0, platform_length=0, baseband_length=0, ngroups=0, ret=0; - int auto_platform_length = 0; + int auto_platform_length = 0, soc_id_list_length=0; int group_index=0, nstrings=0, status_length=0; FILE* conf_fp = nullptr; char platform_name[PROPERTY_VALUE_MAX], baseband_name[PROPERTY_VALUE_MAX]; int low_ram_target=0; - char autoplatform_name[PROPERTY_VALUE_MAX]; + char autoplatform_name[PROPERTY_VALUE_MAX], socid_value[PROPERTY_VALUE_MAX]; unsigned int loc_service_mask=0; - char config_mask = 0; + unsigned char config_mask = 0; unsigned char proc_list_length=0; int gtp_cell_ap_enabled = 0; char arg_gtp_waa[LOC_PROCESS_MAX_ARG_STR_LENGTH] = "--"; @@ -602,6 +607,8 @@ int loc_read_process_conf(const char* conf_file_name, uint32_t * process_count_p loc_get_auto_platform_name(autoplatform_name,sizeof(autoplatform_name)); //Identify if this is a low ram target from ro.config.low_ram property low_ram_target = loc_identify_low_ram_target(); + // Get the soc-id for this device. + loc_get_device_soc_id(socid_value, sizeof(socid_value)); UTIL_READ_CONF(conf_file_name, loc_feature_conf_table); @@ -774,9 +781,10 @@ int loc_read_process_conf(const char* conf_file_name, uint32_t * process_count_p baseband_length = (int)strlen(conf.baseband); status_length = (int)strlen(conf.proc_status); auto_platform_length = (int)strlen(conf.auto_platform); + soc_id_list_length = (int)strlen(conf.soc_id_list); if(!name_length || !group_list_length || !platform_length || - !baseband_length || !status_length || !auto_platform_length) { + !baseband_length || !status_length || !auto_platform_length || !soc_id_list_length) { LOC_LOGE("%s:%d]: Error: i: %d; One of the parameters not specified in conf file", __func__, __LINE__, i); continue; @@ -847,6 +855,34 @@ int loc_read_process_conf(const char* conf_file_name, uint32_t * process_count_p } } + // SOC Id's check + nstrings = loc_util_split_string(conf.soc_id_list, split_strings, MAX_NUM_STRINGS, ' '); + if (strcmp("all", split_strings[0]) == 0) { + if (nstrings == 1 || (nstrings == 2 && (strcmp("exclude", split_strings[1]) == 0))) { + LOC_LOGd("Enabled for all SOC ids\n"); + config_mask |= CONFIG_MASK_SOCID_ALL; + } + else if (nstrings > 2 && (strcmp("exclude", split_strings[1]) == 0)) { + config_mask |= CONFIG_MASK_SOCID_FOUND; + for (i = 2; i < nstrings; i++) { + if (strcmp(socid_value, split_strings[i]) == 0) { + LOC_LOGd("Disabled for SOC id %s\n", socid_value); + config_mask &= ~CONFIG_MASK_SOCID_FOUND; + break; + } + } + } + } + else { + for (i = 0; i < nstrings; i++) { + if (strcmp(socid_value, split_strings[i]) == 0) { + LOC_LOGd("Matched SOC id : %s\n", split_strings[i]); + config_mask |= CONFIG_MASK_SOCID_FOUND; + break; + } + } + } + nstrings = loc_util_split_string(conf.baseband, split_strings, MAX_NUM_STRINGS, ' '); if(strcmp("all", split_strings[0]) == 0) { if (nstrings == 1 || (nstrings == 2 && (strcmp("exclude", split_strings[1]) == 0))) { @@ -909,6 +945,7 @@ int loc_read_process_conf(const char* conf_file_name, uint32_t * process_count_p if((config_mask & CONFIG_MASK_TARGET_CHECK) && (config_mask & CONFIG_MASK_BASEBAND_CHECK) && (config_mask & CONFIG_MASK_AUTOPLATFORM_CHECK) && + (config_mask & CONFIG_MASK_SOCID_CHECK) && (child_proc[j].proc_status != DISABLED_FROM_CONF) && (child_proc[j].proc_status != DISABLED_VIA_VENDOR_ENHANCED_CHECK)) { diff --git a/utils/loc_target.cpp b/utils/loc_target.cpp index 1cab7b8e..3ee42e62 100644 --- a/utils/loc_target.cpp +++ b/utils/loc_target.cpp @@ -80,6 +80,11 @@ static int read_a_line(const char * file_path, char * line, int line_size) int len; fgets(line, line_size, fp); len = strlen(line); + while ('\n' == line[len-1]) { + // If there is a new line at end of string, replace it with NULL + line[len-1] = '\0'; + len--; + } len = len < line_size - 1? len : line_size - 1; line[len] = '\0'; LOC_LOGD("cat %s: %s", file_path, line); @@ -144,6 +149,30 @@ int loc_identify_low_ram_target() return !(strncmp(low_ram_target, "true", PROPERTY_VALUE_MAX)); } +/*The character array passed to this function should have length + of atleast PROPERTY_VALUE_MAX*/ +/* Reads the soc_id node and return the soc_id value */ +void loc_get_device_soc_id(char *soc_id_value, int array_length) +{ + static const char soc_id[] = "/sys/devices/soc0/soc_id"; + static const char soc_id_dep[] = "/sys/devices/system/soc/soc0/id"; + int return_val = 0; + + if (soc_id_value && (array_length >= PROPERTY_VALUE_MAX)) { + if (!access(soc_id, F_OK)) { + return_val = read_a_line(soc_id, soc_id_value, array_length); + } else { + return_val = read_a_line(soc_id_dep, soc_id_value, array_length); + } + if (0 == return_val) { + LOC_LOGd("SOC Id value: %s\n", soc_id_value); + } else { + LOC_LOGe("Unable to read the soc_id value\n"); + } + } else { + LOC_LOGe("Null parameter or array length less than PROPERTY_VALUE_MAX\n"); + } +} unsigned int loc_get_target(void) { @@ -151,10 +180,8 @@ unsigned int loc_get_target(void) return gTarget; static const char hw_platform[] = "/sys/devices/soc0/hw_platform"; - static const char id[] = "/sys/devices/soc0/soc_id"; static const char hw_platform_dep[] = "/sys/devices/system/soc/soc0/hw_platform"; - static const char id_dep[] = "/sys/devices/system/soc/soc0/id"; static const char mdm[] = "/target"; // mdm target we are using char rd_hw_platform[LINE_LEN]; @@ -170,11 +197,8 @@ unsigned int loc_get_target(void) } else { read_a_line(hw_platform_dep, rd_hw_platform, LINE_LEN); } - if (!access(id, F_OK)) { - read_a_line(id, rd_id, LINE_LEN); - } else { - read_a_line(id_dep, rd_id, LINE_LEN); - } + // Get the soc-id for this device. + loc_get_device_soc_id(rd_id, sizeof(rd_id)); /*check automotive platform*/ loc_get_auto_platform_name(rd_auto_platform, sizeof(rd_auto_platform)); diff --git a/utils/loc_target.h b/utils/loc_target.h index e9ff918b..2dcd895e 100644 --- a/utils/loc_target.h +++ b/utils/loc_target.h @@ -55,6 +55,9 @@ void loc_get_platform_name(char *platform_name, int array_length); of atleast PROPERTY_VALUE_MAX*/ void loc_get_auto_platform_name(char *platform_name, int array_length); int loc_identify_low_ram_target(); +/*The character array passed to this function should have length + of atleast PROPERTY_VALUE_MAX*/ +void loc_get_device_soc_id(char *soc_id_value, int array_length); /* Please remember to update 'target_name' in loc_log.cpp, if do any changes to this enum. */ From 87923e48c1b0ad158c0ca92bd049524d7ff672fd Mon Sep 17 00:00:00 2001 From: Wei Chen Date: Mon, 16 Sep 2019 13:30:54 -0700 Subject: [PATCH 08/26] GPS: enable tunc constrained feature by default for auto PL Enable TUNC feature by default if DISTRO is set to "auto" Change-Id: I5d05a40fd6c6fb5c9f37cf2a7478f66b9384f5df CRs-fixed: 2528781 --- core/ContextBase.cpp | 5 +++++ core/Makefile.am | 4 ++++ core/configure.ac | 12 ++++++++++++ 3 files changed, 21 insertions(+) diff --git a/core/ContextBase.cpp b/core/ContextBase.cpp index d5c3108f..22ac849c 100644 --- a/core/ContextBase.cpp +++ b/core/ContextBase.cpp @@ -171,9 +171,14 @@ void ContextBase::readConfig() /* default configuration value of constrained time uncertainty mode: feature disabled, time uncertainty threshold defined by modem, and unlimited power budget */ +#ifdef FEATURE_AUTOMOTIVE + mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED = 1; +#else mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED = 0; +#endif mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD = 0.0; mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET = 0; + /* default configuration value of position assisted clock estimator mode */ mGps_conf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED = 0; /* default configuration QTI GNSS H/W */ diff --git a/core/Makefile.am b/core/Makefile.am index ffd93579..1199a523 100644 --- a/core/Makefile.am +++ b/core/Makefile.am @@ -56,6 +56,10 @@ libloc_core_la_LDFLAGS = -Wl,-z,defs -lpthread -shared -version-info 1:0:0 libloc_core_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) endif +if USE_FEATURE_AUTOMOTIVE +AM_CFLAGS += -DFEATURE_AUTOMOTIVE +endif + libloc_core_la_LIBADD = -ldl $(GPSUTILS_LIBS) #Create and Install libraries diff --git a/core/configure.ac b/core/configure.ac index c3e062b6..548c5e59 100644 --- a/core/configure.ac +++ b/core/configure.ac @@ -74,6 +74,18 @@ fi AM_CONDITIONAL(USE_GLIB, test "x${with_glib}" = "xyes") +AC_ARG_WITH([auto_feature], + AC_HELP_STRING([--with-auto_feature=@<:@dir@:>@], + [Using Automotive feature]), + [], + with_auto_feature=no) + +if test "x$with_auto_feature" != "xno"; then + CPPFLAGS="${CPPFLAGS} -DFEATURE_AUTOMOTIVE" +fi + +AM_CONDITIONAL(USE_FEATURE_AUTOMOTIVE, test "x${with_auto_feature}" = "xyes") + AC_CONFIG_FILES([ \ Makefile \ loc-core.pc \ From ba93fa33fb1a98e0cfd1f536512083c63b69fdb9 Mon Sep 17 00:00:00 2001 From: Wei Chen Date: Fri, 27 Sep 2019 13:16:13 -0700 Subject: [PATCH 09/26] GPS log util: add capability to log modem callflow with debug level Add debug level to log high frequency modem calls so those high frequency modem calls do not get outputted with default gps.conf Change-Id: I2c34471ae97f5cdfebf99c3d7edcdaff7ff63018 CRs-fixed: 2537163 --- utils/log_util.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils/log_util.h b/utils/log_util.h index ed7e19e1..192baebb 100644 --- a/utils/log_util.h +++ b/utils/log_util.h @@ -176,6 +176,7 @@ extern char* get_timestamp(char* str, unsigned long buf_size); #define LOG_I(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGI, ID, WHAT, SPEC, VAL) #define LOG_V(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGV, ID, WHAT, SPEC, VAL) #define LOG_E(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGE, ID, WHAT, SPEC, VAL) +#define LOG_D(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGD, ID, WHAT, SPEC, VAL) #define ENTRY_LOG() LOG_V(ENTRY_TAG, __FUNCTION__, %s, "") #define EXIT_LOG(SPEC, VAL) LOG_V(EXIT_TAG, __FUNCTION__, SPEC, VAL) @@ -193,6 +194,8 @@ extern char* get_timestamp(char* str, unsigned long buf_size); #define EXIT_LOG_CALLFLOW(SPEC, VAL) LOG_I(TO_MODEM, __FUNCTION__, SPEC, VAL) // Used for logging callflow from Modem(TO_MODEM, __FUNCTION__, %s, "") #define MODEM_LOG_CALLFLOW(SPEC, VAL) LOG_I(FROM_MODEM, __FUNCTION__, SPEC, VAL) +// Used for logging high frequency callflow from Modem(TO_MODEM, __FUNCTION__, %s, "") +#define MODEM_LOG_CALLFLOW_DEBUG(SPEC, VAL) LOG_D(FROM_MODEM, __FUNCTION__, SPEC, VAL) // Used for logging callflow to Android Framework #define CALLBACK_LOG_CALLFLOW(CB, SPEC, VAL) LOG_I(TO_AFW, CB, SPEC, VAL) From 3a84bfac176e1e52ddb010ab61f67d70b67f9fd5 Mon Sep 17 00:00:00 2001 From: Wei Chen Date: Mon, 30 Sep 2019 11:46:56 -0700 Subject: [PATCH 10/26] GPS NMEA: enhance gga fix qualtiy for sensor contributed fix This enhancement will be enabled if CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED is set to 1 in gps.conf. PPP fix w/o sensor: fix quality will now be 59 PPP fix w sensor: fix quality will now be 69 RTK fixed fix w/ sensor: fix quality will now be 64 RTK float fix w/ sensor: 65 DGNSS and/or SBAS correction fix and w/ sensor: 62 GPS fix without correction but and w/ sensor: 61 Change-Id: I7bc1bb5504e023de40f271d97d31c602f27bd94e CRs-fixed: 2537211 --- core/ContextBase.cpp | 18 ++++++--- core/ContextBase.h | 1 + etc/gps.conf | 25 ++++++++++++ gnss/GnssAdapter.cpp | 3 +- utils/loc_nmea.cpp | 95 +++++++++++++++++++++++++++++++++++--------- utils/loc_nmea.h | 1 + 6 files changed, 118 insertions(+), 25 deletions(-) diff --git a/core/ContextBase.cpp b/core/ContextBase.cpp index 22ac849c..74345909 100644 --- a/core/ContextBase.cpp +++ b/core/ContextBase.cpp @@ -70,7 +70,8 @@ const loc_param_s_type ContextBase::mGps_conf_table[] = {"XTRA_SERVER_1", &mGps_conf.XTRA_SERVER_1, NULL, 's'}, {"XTRA_SERVER_2", &mGps_conf.XTRA_SERVER_2, NULL, 's'}, {"XTRA_SERVER_3", &mGps_conf.XTRA_SERVER_3, NULL, 's'}, - {"USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL", &mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL, NULL, 'n'}, + {"USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL", + &mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL, NULL, 'n'}, {"AGPS_CONFIG_INJECT", &mGps_conf.AGPS_CONFIG_INJECT, NULL, 'n'}, {"EXTERNAL_DR_ENABLED", &mGps_conf.EXTERNAL_DR_ENABLED, NULL, 'n'}, {"SUPL_HOST", &mGps_conf.SUPL_HOST, NULL, 's'}, @@ -78,13 +79,19 @@ const loc_param_s_type ContextBase::mGps_conf_table[] = {"MODEM_TYPE", &mGps_conf.MODEM_TYPE, NULL, 'n' }, {"MO_SUPL_HOST", &mGps_conf.MO_SUPL_HOST, NULL, 's' }, {"MO_SUPL_PORT", &mGps_conf.MO_SUPL_PORT, NULL, 'n' }, - {"CONSTRAINED_TIME_UNCERTAINTY_ENABLED", &mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED, NULL, 'n'}, - {"CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD", &mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD, NULL, 'f'}, - {"CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET", &mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET, NULL, 'n'}, - {"POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED", &mGps_conf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED, NULL, 'n'}, + {"CONSTRAINED_TIME_UNCERTAINTY_ENABLED", + &mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED, NULL, 'n'}, + {"CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD", + &mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD, NULL, 'f'}, + {"CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET", + &mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET, NULL, 'n'}, + {"POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED", + &mGps_conf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED, NULL, 'n'}, {"PROXY_APP_PACKAGE_NAME", &mGps_conf.PROXY_APP_PACKAGE_NAME, NULL, 's' }, {"CP_MTLR_ES", &mGps_conf.CP_MTLR_ES, NULL, 'n' }, {"GNSS_DEPLOYMENT", &mGps_conf.GNSS_DEPLOYMENT, NULL, 'n'}, + {"CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED", + &mGps_conf.CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED, NULL, 'n'}, }; const loc_param_s_type ContextBase::mSap_conf_table[] = @@ -183,6 +190,7 @@ void ContextBase::readConfig() mGps_conf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED = 0; /* default configuration QTI GNSS H/W */ mGps_conf.GNSS_DEPLOYMENT = 0; + mGps_conf.CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED = 0; UTIL_READ_CONF(LOC_PATH_GPS_CONF, mGps_conf_table); UTIL_READ_CONF(LOC_PATH_SAP_CONF, mSap_conf_table); diff --git a/core/ContextBase.h b/core/ContextBase.h index 5da76e26..6701600e 100644 --- a/core/ContextBase.h +++ b/core/ContextBase.h @@ -74,6 +74,7 @@ typedef struct loc_gps_cfg_s char PROXY_APP_PACKAGE_NAME[LOC_MAX_PARAM_STRING]; uint32_t CP_MTLR_ES; uint32_t GNSS_DEPLOYMENT; + uint32_t CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED; } loc_gps_cfg_s_type; /* NOTE: the implementaiton of the parser casts number diff --git a/etc/gps.conf b/etc/gps.conf index 63547653..47aa8efb 100644 --- a/etc/gps.conf +++ b/etc/gps.conf @@ -99,6 +99,31 @@ DATUM_TYPE = 0 ################################ # NMEA provider (1=Modem Processor, 0=Application Processor) NMEA_PROVIDER=0 + +# Customized NMEA GGA fix quality that can be used to tell +# whether SENSOR contributed to the fix. +# +# When this configuration item is not enabled (set to any value that is not 1), +# GGA fix quality conforms to NMEA standard spec as below: +# PPP/DGNSS/SBAS correction fix w/ or w/o sensor: 2 +# RTK fixed fix w/ or w/o sensor: 4 +# RTK float fix w/ or w/o sensor: 5 +# SPE fix w/ or w/o sensor: 1 +# Sensor dead reckoning fix: 6 +# +# When this configuration is enabled (set to 1), GGA fix quality +# will be output as below: +# PPP fix w/o sensor: 59, w/ sensor: 69 +# DGNSS/SBAS correction fix w/o sensor: 2, w/ sensor: 62 +# RTK fixed fix w/o sensor: 4, w/ sensor: 64 +# RTK float fix w/o sensor: 5, w/ sensor: 65, +# SPE fix w/o sensor: 1, and w/ sensor: 61 +# Sensor dead reckoning fix: 6 +# +# any value that is not 1 - disabled +# 1 - enabled +CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED = 0 + # Mark if it is a SGLTE target (1=SGLTE, 0=nonSGLTE) SGLTE_TARGET=0 diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 43fb63bf..980d4895 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -3272,9 +3272,10 @@ GnssAdapter::reportPosition(const UlpLocation& ulpLocation, (0 == ulpLocation.gpsLocation.longitude) && (LOC_RELIABILITY_NOT_SET == locationExtended.horizontal_reliability)); uint8_t generate_nmea = (reportToGnssClient && status != LOC_SESS_FAILURE && !blank_fix); + bool custom_nmea_gga = (1 == ContextBase::mGps_conf.CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED); std::vector nmeaArraystr; loc_nmea_generate_pos(ulpLocation, locationExtended, mLocSystemInfo, - generate_nmea, nmeaArraystr); + generate_nmea, custom_nmea_gga, nmeaArraystr); stringstream ss; for (auto itor = nmeaArraystr.begin(); itor != nmeaArraystr.end(); ++itor) { ss << *itor; diff --git a/utils/loc_nmea.cpp b/utils/loc_nmea.cpp index d5e4b57a..24197ff0 100644 --- a/utils/loc_nmea.cpp +++ b/utils/loc_nmea.cpp @@ -1033,47 +1033,56 @@ SIDE EFFECTS ===========================================================================*/ static void loc_nmea_get_fix_quality(const UlpLocation & location, const GpsLocationExtended & locationExtended, - char & ggaGpsQuality, + bool custom_gga_fix_quality, + char ggaGpsQuality[3], char & rmcModeIndicator, char & vtgModeIndicator) { - ggaGpsQuality = '0'; - rmcModeIndicator = 'N'; - vtgModeIndicator = 'N'; + ggaGpsQuality[0] = '0'; // 0 means no fix + rmcModeIndicator = 'N'; // N means no fix + vtgModeIndicator = 'N'; // N means no fix do { + // GGA fix quality is defined in NMEA spec as below: + // https://www.trimble.com/OEM_ReceiverHelp/V4.44/en/NMEA-0183messages_GGA.html + // Fix quality: 0 = invalid + // 1 = GPS fix (SPS) + // 2 = DGPS fix + // 3 = PPS fix + // 4 = Real Time Kinematic + // 5 = Float RTK + // 6 = estimated (dead reckoning) (2.3 feature) + // 7 = Manual input mode + // 8 = Simulation mode if (!(location.gpsLocation.flags & LOC_GPS_LOCATION_HAS_LAT_LONG)){ - ggaGpsQuality = '0'; // 0 means no fix - rmcModeIndicator = 'N'; - vtgModeIndicator = 'N'; break; } // NOTE: Order of the check is important if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_NAV_SOLUTION_MASK) { if (LOC_NAV_MASK_PPP_CORRECTION & locationExtended.navSolutionMask) { - ggaGpsQuality = '2'; // 2 means DGPS fix + ggaGpsQuality[0] = '2'; // 2 means DGPS fix rmcModeIndicator = 'P'; // P means precise vtgModeIndicator = 'P'; // P means precise break; } else if (LOC_NAV_MASK_RTK_FIXED_CORRECTION & locationExtended.navSolutionMask){ - ggaGpsQuality = '4'; // 4 means RTK Fixed fix + ggaGpsQuality[0] = '4'; // 4 means RTK Fixed fix rmcModeIndicator = 'R'; // use R (RTK fixed) vtgModeIndicator = 'D'; // use D (differential) as // no RTK fixed defined for VTG in NMEA 183 spec break; } else if (LOC_NAV_MASK_RTK_CORRECTION & locationExtended.navSolutionMask){ - ggaGpsQuality = '5'; // 5 means RTK float fix + ggaGpsQuality[0] = '5'; // 5 means RTK float fix rmcModeIndicator = 'F'; // F means RTK float fix vtgModeIndicator = 'D'; // use D (differential) as // no RTK float defined for VTG in NMEA 183 spec break; } else if (LOC_NAV_MASK_DGNSS_CORRECTION & locationExtended.navSolutionMask){ - ggaGpsQuality = '2'; // 2 means DGPS fix + ggaGpsQuality[0] = '2'; // 2 means DGPS fix rmcModeIndicator = 'D'; // D means differential vtgModeIndicator = 'D'; // D means differential break; } else if (LOC_NAV_MASK_SBAS_CORRECTION_IONO & locationExtended.navSolutionMask){ - ggaGpsQuality = '2'; // 2 means DGPS fix + ggaGpsQuality[0] = '2'; // 2 means DGPS fix rmcModeIndicator = 'D'; // D means differential vtgModeIndicator = 'D'; // D means differential break; @@ -1082,12 +1091,12 @@ static void loc_nmea_get_fix_quality(const UlpLocation & location, // NOTE: Order of the check is important if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_POS_TECH_MASK) { if (LOC_POS_TECH_MASK_SATELLITE & locationExtended.tech_mask){ - ggaGpsQuality = '1'; // 1 means GPS + ggaGpsQuality[0] = '1'; // 1 means GPS rmcModeIndicator = 'A'; // A means autonomous vtgModeIndicator = 'A'; // A means autonomous break; } else if (LOC_POS_TECH_MASK_SENSORS & locationExtended.tech_mask){ - ggaGpsQuality = '6'; // 6 means estimated (dead reckoning) + ggaGpsQuality[0] = '6'; // 6 means estimated (dead reckoning) rmcModeIndicator = 'E'; // E means estimated (dead reckoning) vtgModeIndicator = 'E'; // E means estimated (dead reckoning) break; @@ -1095,7 +1104,54 @@ static void loc_nmea_get_fix_quality(const UlpLocation & location, } } while (0); - LOC_LOGv("gps quality: %c, rmc mode indicator: %c, vtg mode indicator: %c", + do { + // check for customized nmea enabled or not + // with customized GGA quality enabled + // PPP fix w/o sensor: 59, PPP fix w/ sensor: 69 + // DGNSS/SBAS correction fix w/o sensor: 2, w/ sensor: 62 + // RTK fixed fix w/o sensor: 4, w/ sensor: 64 + // RTK float fix w/o sensor: 5, w/ sensor: 65 + // SPE fix w/o sensor: 1, and w/ sensor: 61 + // Sensor dead reckoning fix: 6 + if (true == custom_gga_fix_quality) { + if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_NAV_SOLUTION_MASK) { + // PPP fix w/o sensor: fix quality will now be 59 + // PPP fix w sensor: fix quality will now be 69 + if (LOC_NAV_MASK_PPP_CORRECTION & locationExtended.navSolutionMask) { + if ((locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_POS_TECH_MASK) && + (LOC_POS_TECH_MASK_SENSORS & locationExtended.tech_mask)) { + ggaGpsQuality[0] = '6'; + ggaGpsQuality[1] = '9'; + } else { + ggaGpsQuality[0] = '5'; + ggaGpsQuality[1] = '9'; + } + break; + } + } + + if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_POS_TECH_MASK) { + if (LOC_POS_TECH_MASK_SENSORS & locationExtended.tech_mask){ + char ggaQuality_copy = ggaGpsQuality[0]; + ggaGpsQuality[0] = '6'; // 6 sensor assisted + // RTK fixed fix w/ sensor: fix quality will now be 64 + // RTK float fix w/ sensor: 65 + // DGNSS and/or SBAS correction fix and w/ sensor: 62 + // GPS fix without correction and w/ sensor: 61 + if ((LOC_NAV_MASK_RTK_FIXED_CORRECTION & locationExtended.navSolutionMask)|| + (LOC_NAV_MASK_RTK_CORRECTION & locationExtended.navSolutionMask)|| + (LOC_NAV_MASK_DGNSS_CORRECTION & locationExtended.navSolutionMask)|| + (LOC_NAV_MASK_SBAS_CORRECTION_IONO & locationExtended.navSolutionMask)|| + (LOC_POS_TECH_MASK_SATELLITE & locationExtended.tech_mask)) { + ggaGpsQuality[1] = ggaQuality_copy; + break; + } + } + } + } + } while (0); + + LOC_LOGv("gps quality: %s, rmc mode indicator: %c, vtg mode indicator: %c", ggaGpsQuality, rmcModeIndicator, vtgModeIndicator); } @@ -1127,6 +1183,7 @@ void loc_nmea_generate_pos(const UlpLocation &location, const GpsLocationExtended &locationExtended, const LocationSystemInfo &systemInfo, unsigned char generate_nmea, + bool custom_gga_fix_quality, std::vector &nmeaArraystr) { ENTRY_LOG(); @@ -1270,10 +1327,10 @@ void loc_nmea_generate_pos(const UlpLocation &location, talker[1] = sv_meta.talker[1]; } - char ggaGpsQuality = '0'; + char ggaGpsQuality[3] = {'0', '\0', '\0'}; char rmcModeIndicator = 'N'; char vtgModeIndicator = 'N'; - loc_nmea_get_fix_quality(location, locationExtended, + loc_nmea_get_fix_quality(location, locationExtended, custom_gga_fix_quality, ggaGpsQuality, rmcModeIndicator, vtgModeIndicator); // ------------------- @@ -1772,12 +1829,12 @@ void loc_nmea_generate_pos(const UlpLocation &location, svUsedCount = MAX_SATELLITES_IN_USE; if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP) { - length = snprintf(pMarker, lengthRemaining, "%c,%02d,%.1f,", + length = snprintf(pMarker, lengthRemaining, "%s,%02d,%.1f,", ggaGpsQuality, svUsedCount, locationExtended.hdop); } else { // no hdop - length = snprintf(pMarker, lengthRemaining, "%c,%02d,,", + length = snprintf(pMarker, lengthRemaining, "%s,%02d,,", ggaGpsQuality, svUsedCount); } diff --git a/utils/loc_nmea.h b/utils/loc_nmea.h index c6c83db4..a9cafb76 100644 --- a/utils/loc_nmea.h +++ b/utils/loc_nmea.h @@ -79,6 +79,7 @@ void loc_nmea_generate_pos(const UlpLocation &location, const GpsLocationExtended &locationExtended, const LocationSystemInfo &systemInfo, unsigned char generate_nmea, + bool custom_gga_fix_quality, std::vector &nmeaArraystr); #define DEBUG_NMEA_MINSIZE 6 From 5c568ca1bdd64c4de4a29695457db6bd81d0f5d8 Mon Sep 17 00:00:00 2001 From: Wei Chen Date: Tue, 1 Oct 2019 14:18:29 -0700 Subject: [PATCH 11/26] GNSS adapter: fix a race condition Fix the race condition that handleEngineUp gets called before GNSS adapter constructor finishes CRs-fixed: 2538904 Change-Id: I0946dd44ce3a4b03f2c8a45a855bbfbd4b7b8468 --- core/LocAdapterBase.cpp | 11 +++++++++-- core/LocAdapterBase.h | 24 ++++++++++++++++++++++-- gnss/GnssAdapter.cpp | 11 ++++++++--- 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/core/LocAdapterBase.cpp b/core/LocAdapterBase.cpp index 1b844e57..1e91cf83 100644 --- a/core/LocAdapterBase.cpp +++ b/core/LocAdapterBase.cpp @@ -43,13 +43,20 @@ namespace loc_core { // the right locApi should get created. LocAdapterBase::LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask, ContextBase* context, bool isMaster, - LocAdapterProxyBase *adapterProxyBase) : + LocAdapterProxyBase *adapterProxyBase, + bool waitForDoneInit) : mIsMaster(isMaster), mEvtMask(mask), mContext(context), mLocApi(context->getLocApi()), mLocAdapterProxyBase(adapterProxyBase), mMsgTask(context->getMsgTask()), mIsEngineCapabilitiesKnown(ContextBase::sIsEngineCapabilitiesKnown) { - mLocApi->addAdapter(this); + LOC_LOGd("waitForDoneInit: %d", waitForDoneInit); + if (!waitForDoneInit) { + mLocApi->addAdapter(this); + mAdapterAdded = true; + } else { + mAdapterAdded = false; + } } uint32_t LocAdapterBase::mSessionIdCounter(1); diff --git a/core/LocAdapterBase.h b/core/LocAdapterBase.h index 909b6fea..7ca3ecda 100644 --- a/core/LocAdapterBase.h +++ b/core/LocAdapterBase.h @@ -70,9 +70,11 @@ protected: LocApiBase* mLocApi; LocAdapterProxyBase* mLocAdapterProxyBase; const MsgTask* mMsgTask; + bool mAdapterAdded; + inline LocAdapterBase(const MsgTask* msgTask) : mIsMaster(false), mEvtMask(0), mContext(NULL), mLocApi(NULL), - mLocAdapterProxyBase(NULL), mMsgTask(msgTask) {} + mLocAdapterProxyBase(NULL), mMsgTask(msgTask), mAdapterAdded(false) {} /* ==== CLIENT ========================================================================= */ typedef std::map ClientDataMap; @@ -89,9 +91,27 @@ protected: public: inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); } + // When waitForDoneInit is not specified or specified as false, + // handleEngineUpEvent may be called on the child adapter object from + // a different thread before the constructor of the child + // object finishes. + // + // If the handleEngineUpEvent relies on member variables of the constructor + // of the child adapter to be initialized first, we need to specify the + // waitForDoneInit to *TRUE* to delay handleEngineUpEvent to get called + // until when the child adapter finishes its initialization and notify + // LocAdapterBase via doneInit method. LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask, ContextBase* context, bool isMaster = false, - LocAdapterProxyBase *adapterProxyBase = NULL); + LocAdapterProxyBase *adapterProxyBase = NULL, + bool waitForDoneInit = false); + + inline void doneInit() { + if (!mAdapterAdded) { + mLocApi->addAdapter(this); + mAdapterAdded = true; + } + } inline LOC_API_ADAPTER_EVENT_MASK_T checkMask(LOC_API_ADAPTER_EVENT_MASK_T mask) const { diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 980d4895..11f6777e 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -65,9 +65,10 @@ static void agpsCloseResultCb (bool isSuccess, AGpsExtType agpsType, void* userD GnssAdapter::GnssAdapter() : LocAdapterBase(0, LocContext::getLocContext(NULL, - NULL, - LocContext::mLocationHalName, - false), true, nullptr), + NULL, + LocContext::mLocationHalName, + false), + true, nullptr, true), mEngHubProxy(new EngineHubProxyBase()), mLocPositionMode(), mGnssSvIdUsedInPosition(), @@ -127,6 +128,10 @@ GnssAdapter::GnssAdapter() : readConfigCommand(); initDefaultAgpsCommand(); initEngHubProxyCommand(); + + // at last step, let us inform adapater base that we are done + // with initialization, e.g.: ready to process handleEngineUpEvent + doneInit(); } void From f195c219e601fd1c99e65353371a571e77043622 Mon Sep 17 00:00:00 2001 From: Madhanraj Chelladurai Date: Mon, 30 Sep 2019 17:27:36 +0530 Subject: [PATCH 12/26] nmea: fix status and mode indicator fields of RMC Fix status and mode indicator fields to proper values as per NMEA standard for GPRMC string. Change-Id: I7fe0e292079c0f71bb37f6a1462f669e14f54b81 CRs-Fixed: 2537924 --- utils/loc_nmea.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/utils/loc_nmea.cpp b/utils/loc_nmea.cpp index 24197ff0..61db2beb 100644 --- a/utils/loc_nmea.cpp +++ b/utils/loc_nmea.cpp @@ -1439,8 +1439,19 @@ void loc_nmea_generate_pos(const UlpLocation &location, pMarker = sentence_RMC; lengthRemaining = sizeof(sentence_RMC); - length = snprintf(pMarker, lengthRemaining, "$%sRMC,%02d%02d%02d.%02d,A," , - talker, utcHours, utcMinutes, utcSeconds,utcMSeconds/10); + bool validFix = ((0 != sv_cache_info.gps_used_mask) || + (0 != sv_cache_info.glo_used_mask) || + (0 != sv_cache_info.gal_used_mask) || + (0 != sv_cache_info.qzss_used_mask) || + (0 != sv_cache_info.bds_used_mask)); + + if (validFix) { + length = snprintf(pMarker, lengthRemaining, "$%sRMC,%02d%02d%02d.%02d,A,", + talker, utcHours, utcMinutes, utcSeconds, utcMSeconds/10); + } else { + length = snprintf(pMarker, lengthRemaining, "$%sRMC,%02d%02d%02d.%02d,V,", + talker, utcHours, utcMinutes, utcSeconds, utcMSeconds/10); + } if (length < 0 || length >= lengthRemaining) { @@ -1581,8 +1592,6 @@ void loc_nmea_generate_pos(const UlpLocation &location, // hardcode Navigation Status field to 'V' length = snprintf(pMarker, lengthRemaining, ",%c", 'V'); - pMarker += length; - lengthRemaining -= length; length = loc_nmea_put_checksum(sentence_RMC, sizeof(sentence_RMC)); From ae1d9031eff622838da1596737d871c16dcc9e2e Mon Sep 17 00:00:00 2001 From: Yingjie Wang Date: Mon, 14 Oct 2019 18:21:15 +0800 Subject: [PATCH 13/26] Add listener for the initial battery status Listen to the initial charging status as DPO mode depends on it; Change ALOG to LOC_LOG. Change-Id: Ic61f76038f0e464b18ade8c9b20c058de35748c8 CRs-fixed: 2544828 --- android/1.0/Gnss.cpp | 2 + android/1.1/Gnss.cpp | 2 + android/2.0/Gnss.cpp | 2 + android/utils/Android.mk | 3 ++ android/utils/battery_listener.cpp | 70 +++++++++++++++--------------- 5 files changed, 45 insertions(+), 34 deletions(-) diff --git a/android/1.0/Gnss.cpp b/android/1.0/Gnss.cpp index d85e0a40..4aac432f 100644 --- a/android/1.0/Gnss.cpp +++ b/android/1.0/Gnss.cpp @@ -56,6 +56,8 @@ void location_on_battery_status_changed(bool charging) { Gnss::Gnss() { ENTRY_LOG_CALLFLOW(); sGnss = this; + // initilize gnss interface at first in case needing notify battery status + sGnss->getGnssInterface()->initialize(); // register health client to listen on battery change loc_extn_battery_properties_listener_init(location_on_battery_status_changed); // clear pending GnssConfig diff --git a/android/1.1/Gnss.cpp b/android/1.1/Gnss.cpp index bea556fe..277dbc16 100644 --- a/android/1.1/Gnss.cpp +++ b/android/1.1/Gnss.cpp @@ -97,6 +97,8 @@ void location_on_battery_status_changed(bool charging) { Gnss::Gnss() { ENTRY_LOG_CALLFLOW(); sGnss = this; + // initilize gnss interface at first in case needing notify battery status + sGnss->getGnssInterface()->initialize(); // register health client to listen on battery change loc_extn_battery_properties_listener_init(location_on_battery_status_changed); // clear pending GnssConfig diff --git a/android/2.0/Gnss.cpp b/android/2.0/Gnss.cpp index af76b727..2276c148 100644 --- a/android/2.0/Gnss.cpp +++ b/android/2.0/Gnss.cpp @@ -96,6 +96,8 @@ void location_on_battery_status_changed(bool charging) { Gnss::Gnss() { ENTRY_LOG_CALLFLOW(); sGnss = this; + // initilize gnss interface at first in case needing notify battery status + sGnss->getGnssInterface()->initialize(); // register health client to listen on battery change loc_extn_battery_properties_listener_init(location_on_battery_status_changed); // clear pending GnssConfig diff --git a/android/utils/Android.mk b/android/utils/Android.mk index 76732c2c..0e4c9536 100644 --- a/android/utils/Android.mk +++ b/android/utils/Android.mk @@ -26,6 +26,9 @@ LOCAL_SHARED_LIBRARIES := \ android.hardware.power@1.2 \ libbase +LOCAL_HEADER_LIBRARIES := \ + libgps.utils_headers \ + LOCAL_STATIC_LIBRARIES := libhealthhalutils LOCAL_CFLAGS += -DBATTERY_LISTENER_ENABLED diff --git a/android/utils/battery_listener.cpp b/android/utils/battery_listener.cpp index a790702b..8547e41e 100644 --- a/android/utils/battery_listener.cpp +++ b/android/utils/battery_listener.cpp @@ -31,12 +31,15 @@ #undef LOG_TAG #endif #define LOG_TAG "LocSvc_BatteryListener" +#define LOG_NDEBUG 0 #include #include #include #include #include +#include + using android::hardware::interfacesEqual; using android::hardware::Return; using android::hardware::Void; @@ -99,24 +102,25 @@ status_t BatteryListenerImpl::init() } while(tries < GET_HEALTH_SVC_RETRY_CNT); if (mHealth == NULL) { - ALOGE("no health service found, retries %d", tries); + LOC_LOGe("no health service found, retries %d", tries); return NO_INIT; } else { - ALOGI("Get health service in %d tries", tries); + LOC_LOGi("Get health service in %d tries", tries); } mStatus = BatteryStatus::UNKNOWN; auto ret = mHealth->getChargeStatus([&](Result r, BatteryStatus status) { if (r != Result::SUCCESS) { - ALOGE("batterylistener: cannot get battery status"); + LOC_LOGe("batterylistener: cannot get battery status"); return; } mStatus = status; }); - if (!ret.isOk()) - ALOGE("batterylistener: get charge status transaction error"); - - if (mStatus == BatteryStatus::UNKNOWN) - ALOGW("batterylistener: init: invalid battery status"); + if (!ret.isOk()) { + LOC_LOGe("batterylistener: get charge status transaction error"); + } + if (mStatus == BatteryStatus::UNKNOWN) { + LOC_LOGw("batterylistener: init: invalid battery status"); + } mDone = false; mThread = std::make_unique([this]() { std::unique_lock l(mLock); @@ -146,7 +150,7 @@ status_t BatteryListenerImpl::init() } default: bool c = statusToBool(local_status); - ALOGI("healthInfo cb thread: cb %s", c ? "CHARGING" : "NOT CHARGING"); + LOC_LOGi("healthInfo cb thread: cb %s", c ? "CHARGING" : "NOT CHARGING"); l.unlock(); mCb(c); l.lock(); @@ -156,13 +160,14 @@ status_t BatteryListenerImpl::init() }); auto reg = mHealth->registerCallback(this); if (!reg.isOk()) { - ALOGE("Transaction error in registeringCb to HealthHAL death: %s", + LOC_LOGe("Transaction error in registeringCb to HealthHAL death: %s", reg.description().c_str()); } auto linked = mHealth->linkToDeath(this, 0 /* cookie */); if (!linked.isOk() || linked == false) { - ALOGE("Transaction error in linking to HealthHAL death: %s", linked.description().c_str()); + LOC_LOGe("Transaction error in linking to HealthHAL death: %s", + linked.description().c_str()); } return NO_ERROR; } @@ -181,7 +186,7 @@ BatteryListenerImpl::~BatteryListenerImpl() mHealth->unlinkToDeath(this); auto r = mHealth->unlinkToDeath(this); if (!r.isOk() || r == false) { - ALOGE("Transaction error in unregister to HealthHAL death: %s", + LOC_LOGe("Transaction error in unregister to HealthHAL death: %s", r.description().c_str()); } } @@ -195,10 +200,10 @@ void BatteryListenerImpl::serviceDied(uint64_t cookie __unused, { std::lock_guard _l(mLock); if (mHealth == NULL || !interfacesEqual(mHealth, who.promote())) { - ALOGE("health not initialized or unknown interface died"); + LOC_LOGe("health not initialized or unknown interface died"); return; } - ALOGI("health service died, reinit"); + LOC_LOGi("health service died, reinit"); mDone = true; } mThread->join(); @@ -212,9 +217,8 @@ void BatteryListenerImpl::serviceDied(uint64_t cookie __unused, // NOT_CHARGING and CHARGING concurrencies. // Replace single var by a list if this assumption is broken Return BatteryListenerImpl::healthInfoChanged( - const hardware::health::V2_0::HealthInfo& info) -{ - ALOGV("healthInfoChanged: %d", info.legacy.batteryStatus); + const hardware::health::V2_0::HealthInfo& info) { + LOC_LOGv("healthInfoChanged: %d", info.legacy.batteryStatus); std::unique_lock l(mLock); if (info.legacy.batteryStatus != mStatus) { mStatus = info.legacy.batteryStatus; @@ -224,29 +228,29 @@ Return BatteryListenerImpl::healthInfoChanged( } static sp batteryListener; -status_t batteryPropertiesListenerInit(BatteryListenerImpl::cb_fn_t cb) -{ - ALOGV("batteryPropertiesListenerInit entry"); + +bool batteryPropertiesListenerIsCharging() { + return batteryListener->isCharging(); +} + +status_t batteryPropertiesListenerInit(BatteryListenerImpl::cb_fn_t cb) { batteryListener = new BatteryListenerImpl(cb); + bool isCharging = batteryPropertiesListenerIsCharging(); + LOC_LOGv("charging status: %s charging", isCharging ? "" : "not");; + if (isCharging) { + cb(isCharging); + } return NO_ERROR; } -status_t batteryPropertiesListenerDeinit() -{ +status_t batteryPropertiesListenerDeinit() { batteryListener.clear(); return OK; } -bool batteryPropertiesListenerIsCharging() -{ - return batteryListener->isCharging(); -} - } // namespace android -void loc_extn_battery_properties_listener_init(battery_status_change_fn_t fn) -{ - ALOGV("loc_extn_battery_properties_listener_init entry"); +void loc_extn_battery_properties_listener_init(battery_status_change_fn_t fn) { if (!sIsBatteryListened) { std::thread t1(android::batteryPropertiesListenerInit, [=](bool charging) { fn(charging); }); @@ -255,12 +259,10 @@ void loc_extn_battery_properties_listener_init(battery_status_change_fn_t fn) } } -void loc_extn_battery_properties_listener_deinit() -{ +void loc_extn_battery_properties_listener_deinit() { android::batteryPropertiesListenerDeinit(); } -bool loc_extn_battery_properties_is_charging() -{ +bool loc_extn_battery_properties_is_charging() { return android::batteryPropertiesListenerIsCharging(); } From 755bba2813a8acda140ead88debbed8dd6b78bef Mon Sep 17 00:00:00 2001 From: Wei Chen Date: Tue, 8 Oct 2019 14:28:08 -0700 Subject: [PATCH 14/26] GnssSv struct: make it in sync between 3.0.c5, 4.0 and 5.0 Make GnssSv struct in sync between 3.0.c5, 4.0 and 5.0 to allow 3.0.C5 hal daemon to work with 4.0/5.0 location client API app Change-Id: I421fc3a36055fa278ef42bca4816d07f18c75d68 CRs-fixed: 2541020 --- location/LocationDataTypes.h | 34 +++++++++++++++------------- utils/gps_extended_c.h | 43 ------------------------------------ 2 files changed, 19 insertions(+), 58 deletions(-) diff --git a/location/LocationDataTypes.h b/location/LocationDataTypes.h index 17094ab5..956754ad 100644 --- a/location/LocationDataTypes.h +++ b/location/LocationDataTypes.h @@ -567,28 +567,32 @@ typedef enum { GNSS_SIGNAL_GALILEO_E5A = (1<<7), /** GALILEO E5B RF Band */ GNSS_SIGNAL_GALILEO_E5B = (1<<8), - /** BEIDOU B1_I RF Band */ - GNSS_SIGNAL_BEIDOU_B1I = (1<<9), - /** BEIDOU B1C RF Band */ - GNSS_SIGNAL_BEIDOU_B1C = (1<<10), - /** BEIDOU B2_I RF Band */ - GNSS_SIGNAL_BEIDOU_B2I = (1<<11), - /** BEIDOU B2A_I RF Band */ - GNSS_SIGNAL_BEIDOU_B2AI = (1<<12), + /** BEIDOU B1 RF Band */ + GNSS_SIGNAL_BEIDOU_B1 = (1<<9), + /** BEIDOU B2 RF Band */ + GNSS_SIGNAL_BEIDOU_B2 = (1<<10), /** QZSS L1CA RF Band */ - GNSS_SIGNAL_QZSS_L1CA = (1<<13), + GNSS_SIGNAL_QZSS_L1CA = (1<<11), /** QZSS L1S RF Band */ - GNSS_SIGNAL_QZSS_L1S = (1<<14), + GNSS_SIGNAL_QZSS_L1S = (1<<12), /** QZSS L2 RF Band */ - GNSS_SIGNAL_QZSS_L2 = (1<<15), + GNSS_SIGNAL_QZSS_L2 = (1<<13), /** QZSS L5 RF Band */ - GNSS_SIGNAL_QZSS_L5 = (1<<16), + GNSS_SIGNAL_QZSS_L5 = (1<<14), /** SBAS L1 RF Band */ - GNSS_SIGNAL_SBAS_L1 = (1<<17), + GNSS_SIGNAL_SBAS_L1 = (1<<15), + /** BEIDOU B1I RF Band */ + GNSS_SIGNAL_BEIDOU_B1I = (1<<16), + /** BEIDOU B1C RF Band */ + GNSS_SIGNAL_BEIDOU_B1C = (1<<17), + /** BEIDOU B2I RF Band */ + GNSS_SIGNAL_BEIDOU_B2I = (1<<18), + /** BEIDOU B2AI RF Band */ + GNSS_SIGNAL_BEIDOU_B2AI = (1<<19), /** NAVIC L5 RF Band */ - GNSS_SIGNAL_NAVIC_L5 = (1<<18), + GNSS_SIGNAL_NAVIC_L5 = (1<<20), /** BEIDOU B2A_Q RF Band */ - GNSS_SIGNAL_BEIDOU_B2AQ = (1<<19) + GNSS_SIGNAL_BEIDOU_B2AQ = (1<<21), } GnssSignalTypeBits; #define GNSS_SIGNAL_TYPE_MASK_ALL\ diff --git a/utils/gps_extended_c.h b/utils/gps_extended_c.h index 69a659ee..3ef49e3d 100644 --- a/utils/gps_extended_c.h +++ b/utils/gps_extended_c.h @@ -573,49 +573,6 @@ typedef uint8_t CarrierPhaseAmbiguityType; #define CARRIER_PHASE_AMBIGUITY_RESOLUTION_FLOAT ((CarrierPhaseAmbiguityType)1) #define CARRIER_PHASE_AMBIGUITY_RESOLUTION_FIXED ((CarrierPhaseAmbiguityType)2) -/** GNSS Signal Type and RF Band */ -typedef uint32_t GnssSignalTypeMask; -/** GPS L1CA Signal */ -#define GNSS_SIGNAL_GPS_L1CA ((GnssSignalTypeMask)0x00000001ul) -/** GPS L1C Signal */ -#define GNSS_SIGNAL_GPS_L1C ((GnssSignalTypeMask)0x00000002ul) -/** GPS L2 RF Band */ -#define GNSS_SIGNAL_GPS_L2 ((GnssSignalTypeMask)0x00000004ul) -/** GPS L5 RF Band */ -#define GNSS_SIGNAL_GPS_L5 ((GnssSignalTypeMask)0x00000008ul) -/** GLONASS G1 (L1OF) RF Band */ -#define GNSS_SIGNAL_GLONASS_G1 ((GnssSignalTypeMask)0x00000010ul) -/** GLONASS G2 (L2OF) RF Band */ -#define GNSS_SIGNAL_GLONASS_G2 ((GnssSignalTypeMask)0x00000020ul) -/** GALILEO E1 RF Band */ -#define GNSS_SIGNAL_GALILEO_E1 ((GnssSignalTypeMask)0x00000040ul) -/** GALILEO E5A RF Band */ -#define GNSS_SIGNAL_GALILEO_E5A ((GnssSignalTypeMask)0x00000080ul) -/** GALILEO E5B RF Band */ -#define GNSS_SIGNAL_GALILIEO_E5B ((GnssSignalTypeMask)0x00000100ul) -/** BEIDOU B1_I RF Band */ -#define GNSS_SIGNAL_BEIDOU_B1I ((GnssSignalTypeMask)0x00000200ul) -/** BEIDOU B1C RF Band */ -#define GNSS_SIGNAL_BEIDOU_B1C ((GnssSignalTypeMask)0x00000400ul) -/** BEIDOU B2_I RF Band */ -#define GNSS_SIGNAL_BEIDOU_B2I ((GnssSignalTypeMask)0x00000800ul) -/** BEIDOU B2A_I RF Band */ -#define GNSS_SIGNAL_BEIDOU_B2AI ((GnssSignalTypeMask)0x00001000ul) -/** QZSS L1CA RF Band */ -#define GNSS_SIGNAL_QZSS_L1CA ((GnssSignalTypeMask)0x00002000ul) -/** QZSS L1S RF Band */ -#define GNSS_SIGNAL_QZSS_L1S ((GnssSignalTypeMask)0x00004000ul) -/** QZSS L2 RF Band */ -#define GNSS_SIGNAL_QZSS_L2 ((GnssSignalTypeMask)0x00008000ul) -/** QZSS L5 RF Band */ -#define GNSS_SIGNAL_QZSS_L5 ((GnssSignalTypeMask)0x00010000ul) -/** SBAS L1 RF Band */ -#define GNSS_SIGNAL_SBAS_L1 ((GnssSignalTypeMask)0x00020000ul) -/** NAVIC L5 RF Band */ -#define GNSS_SIGNAL_NAVIC_L5 ((GnssSignalTypeMask)0x00040000ul) -/** BEIDOU B2A_Q RF Band */ -#define GNSS_SIGNAL_BEIDOU_B2AQ ((GnssSignalTypeMask)0x00080000ul) - typedef uint16_t GnssMeasUsageStatusBitMask; /** Used in fix */ #define GNSS_MEAS_USED_IN_PVT ((GnssMeasUsageStatusBitMask)0x00000001ul) From 7eb1dcf0c743c27dde4814ad6ce22ee50876bbec Mon Sep 17 00:00:00 2001 From: Wei Chen Date: Thu, 3 Oct 2019 13:29:47 -0700 Subject: [PATCH 15/26] GPS NMEA: generate empty GSA sentence for dead reckoning fixes For dead reckoning fixes when number of SV used in fix is 0, we need to generate an empty GSA sentence CRs-fixed: 2542163 Change-Id: Icb89981d04ecdfeb81fbdc16b2a8d3676319b18d --- utils/loc_nmea.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/utils/loc_nmea.cpp b/utils/loc_nmea.cpp index 24197ff0..64a35250 100644 --- a/utils/loc_nmea.cpp +++ b/utils/loc_nmea.cpp @@ -1327,6 +1327,14 @@ void loc_nmea_generate_pos(const UlpLocation &location, talker[1] = sv_meta.talker[1]; } + // if svUsedCount is 0, it means we do not generate any GSA sentence yet. + // in this case, generate an empty GSA sentence + if (svUsedCount == 0) { + strlcpy(sentence, "$GPGSA,A,1,,,,,,,,,,,,,,,,", sizeof(sentence)); + length = loc_nmea_put_checksum(sentence, sizeof(sentence)); + nmeaArraystr.push_back(sentence); + } + char ggaGpsQuality[3] = {'0', '\0', '\0'}; char rmcModeIndicator = 'N'; char vtgModeIndicator = 'N'; From 386a7413091314c2ba33ef06f7444cdbeaba7bf1 Mon Sep 17 00:00:00 2001 From: Dante Russo Date: Tue, 22 Oct 2019 08:18:52 -0700 Subject: [PATCH 16/26] Add NI_SUPL_DENY_ON_NFW_LOCKED configuration If an NI SUPL Request that does not have Privacy Override option comes when NFW is locked and config item NI_SUPL_DENY_ON_NFW_LOCKED = 1, then deny it Change-Id: I0a769c4696751069d5a034dde8569ecfcf63b41a CRs-fixed: 2550126 --- core/ContextBase.cpp | 3 +++ core/ContextBase.h | 1 + gnss/GnssAdapter.cpp | 9 +++++++++ 3 files changed, 13 insertions(+) diff --git a/core/ContextBase.cpp b/core/ContextBase.cpp index 74345909..3b8ffc6e 100644 --- a/core/ContextBase.cpp +++ b/core/ContextBase.cpp @@ -92,6 +92,7 @@ const loc_param_s_type ContextBase::mGps_conf_table[] = {"GNSS_DEPLOYMENT", &mGps_conf.GNSS_DEPLOYMENT, NULL, 'n'}, {"CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED", &mGps_conf.CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED, NULL, 'n'}, + {"NI_SUPL_DENY_ON_NFW_LOCKED", &mGps_conf.NI_SUPL_DENY_ON_NFW_LOCKED, NULL, 'n'}, }; const loc_param_s_type ContextBase::mSap_conf_table[] = @@ -191,6 +192,8 @@ void ContextBase::readConfig() /* default configuration QTI GNSS H/W */ mGps_conf.GNSS_DEPLOYMENT = 0; mGps_conf.CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED = 0; + /* default configuration for NI_SUPL_DENY_ON_NFW_LOCKED */ + mGps_conf.NI_SUPL_DENY_ON_NFW_LOCKED = 0; UTIL_READ_CONF(LOC_PATH_GPS_CONF, mGps_conf_table); UTIL_READ_CONF(LOC_PATH_SAP_CONF, mSap_conf_table); diff --git a/core/ContextBase.h b/core/ContextBase.h index 6701600e..e63450ff 100644 --- a/core/ContextBase.h +++ b/core/ContextBase.h @@ -75,6 +75,7 @@ typedef struct loc_gps_cfg_s uint32_t CP_MTLR_ES; uint32_t GNSS_DEPLOYMENT; uint32_t CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED; + uint32_t NI_SUPL_DENY_ON_NFW_LOCKED; } loc_gps_cfg_s_type; /* NOTE: the implementaiton of the parser casts number diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 980d4895..b4630468 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -3676,6 +3676,15 @@ GnssAdapter::requestNiNotifyEvent(const GnssNiNotification ¬ify, const void* else { mAdapter.requestNiNotify(mNotify, mData, false); } + } else if ((mAdapter.mSupportNfwControl || 0 == mAdapter.getAfwControlId()) && + GNSS_NI_TYPE_SUPL == mNotify.type && !bIsInEmergency && + !(GNSS_NI_OPTIONS_PRIVACY_OVERRIDE_BIT & mNotify.options) && + (GNSS_CONFIG_GPS_LOCK_NI & ContextBase::mGps_conf.GPS_LOCK) && + 1 == ContextBase::mGps_conf.NI_SUPL_DENY_ON_NFW_LOCKED) { + // If 'Q' Lock behavior OR 'P' Lock behavior and GNSS is Locked + // If an NI SUPL Request that does not have Privacy Override option comes when + // NFW is locked and config item NI_SUPL_DENY_ON_NFW_LOCKED = 1, then deny it + mApi.informNiResponse(GNSS_NI_RESPONSE_DENY, mData); } else { mAdapter.requestNiNotify(mNotify, mData, false); } From 52d928e06956bad27f03c78d67cbaadd80cef74d Mon Sep 17 00:00:00 2001 From: Wei Chen Date: Fri, 13 Sep 2019 15:43:27 -0700 Subject: [PATCH 17/26] GPS HAL: send platform power state event to modem Send platform power state event, suspend/resume/shutdown to modem Change-Id: I19960f5fb4935de9e4f5513abd95aed6241a2fd9 CRs-fixed: 2527622 --- core/LocApiBase.cpp | 2 ++ core/LocApiBase.h | 1 + gnss/GnssAdapter.cpp | 35 +++++++++++++++++++++++++++++++++-- gnss/GnssAdapter.h | 6 ++++++ gnss/location_gnss.cpp | 10 +++++++++- location/location_interface.h | 1 + utils/gps_extended_c.h | 7 +++++++ 7 files changed, 59 insertions(+), 3 deletions(-) diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp index 8c79cf74..595fa49f 100644 --- a/core/LocApiBase.cpp +++ b/core/LocApiBase.cpp @@ -873,5 +873,7 @@ DEFAULT_IMPL() void LocApiBase::addToCallQueue(LocApiResponse* /*adapterResponse*/) DEFAULT_IMPL() +void LocApiBase::updateSystemPowerState(PowerStateType /*powerState*/) +DEFAULT_IMPL() } // namespace loc_core diff --git a/core/LocApiBase.h b/core/LocApiBase.h index 6dac585b..3c85b099 100644 --- a/core/LocApiBase.h +++ b/core/LocApiBase.h @@ -312,6 +312,7 @@ public: void updateEvtMask(); void updateNmeaMask(uint32_t mask); + virtual void updateSystemPowerState(PowerStateType systemPowerState); }; typedef LocApiBase* (getLocApi_t)(LOC_API_ADAPTER_EVENT_MASK_T exMask, diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 11f6777e..7d42106b 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -98,7 +98,8 @@ GnssAdapter::GnssAdapter() : mIsE911Session(NULL), mGnssMbSvIdUsedInPosition{}, mGnssMbSvIdUsedInPosAvail(false), - mSupportNfwControl(true) + mSupportNfwControl(true), + mSystemPowerState(POWER_STATE_UNKNOWN) { LOC_LOGD("%s]: Constructor %p", __func__, this); mLocPositionMode.mode = LOC_POSITION_MODE_INVALID; @@ -1997,6 +1998,35 @@ GnssAdapter::blockCPICommand(double latitude, double longitude, sendMsg(new MsgBlockCPI(mBlockCPIInfo, blockCPIInfo)); } +void +GnssAdapter::updateSystemPowerState(PowerStateType systemPowerState) { + if (POWER_STATE_UNKNOWN != systemPowerState) { + mSystemPowerState = systemPowerState; + mLocApi->updateSystemPowerState(mSystemPowerState); + } +} + +void +GnssAdapter::updateSystemPowerStateCommand(PowerStateType systemPowerState) { + LOC_LOGd("power event %d", systemPowerState); + + struct MsgUpdatePowerState : public LocMsg { + GnssAdapter& mAdapter; + PowerStateType mSystemPowerState; + + inline MsgUpdatePowerState(GnssAdapter& adapter, + PowerStateType systemPowerState) : + LocMsg(), + mAdapter(adapter), + mSystemPowerState(systemPowerState) {} + inline virtual void proc() const { + mAdapter.updateSystemPowerState(mSystemPowerState); + } + }; + + sendMsg(new MsgUpdatePowerState(*this, systemPowerState)); +} + void GnssAdapter::addClientCommand(LocationAPI* client, const LocationCallbacks& callbacks) { @@ -2133,9 +2163,10 @@ GnssAdapter::handleEngineUpEvent() mAdapter.broadcastCapabilities(mAdapter.getCapabilities()); // must be called only after capabilities are known mAdapter.setConfig(); - mAdapter.restartSessions(); mAdapter.gnssSvIdConfigUpdate(); mAdapter.gnssSvTypeConfigUpdate(); + mAdapter.updateSystemPowerState(mAdapter.getSystemPowerState()); + mAdapter.restartSessions(); for (auto msg: mAdapter.mPendingMsgs) { mAdapter.sendMsg(msg); } diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h index 3ccdd96d..b3ffeaf8 100644 --- a/gnss/GnssAdapter.h +++ b/gnss/GnssAdapter.h @@ -187,6 +187,7 @@ class GnssAdapter : public LocAdapterBase { XtraSystemStatusObserver mXtraObserver; LocationSystemInfo mLocSystemInfo; std::vector mBlacklistedSvIds; + PowerStateType mSystemPowerState; /* === Misc ===================================================================== */ BlockCPIInfo mBlockCPIInfo; @@ -413,6 +414,8 @@ public: return false; } + void updateSystemPowerState(PowerStateType systemPowerState); + /*======== GNSSDEBUG ================================================================*/ bool getDebugReport(GnssDebugReport& report); /* get AGC information from system status and fill it */ @@ -459,11 +462,14 @@ public: void reportPowerStateIfChanged(); void savePowerStateCallback(powerStateCallback powerStateCb){ mPowerStateCb = powerStateCb; } bool getPowerState() { return mPowerOn; } + inline PowerStateType getSystemPowerState() { return mSystemPowerState; } + void setAllowFlpNetworkFixes(uint32_t allow) { mAllowFlpNetworkFixes = allow; } uint32_t getAllowFlpNetworkFixes() { return mAllowFlpNetworkFixes; } void setSuplHostServer(const char* server, int port, LocServerType type); void notifyClientOfCachedLocationSystemInfo(LocationAPI* client, const LocationCallbacks& callbacks); + void updateSystemPowerStateCommand(PowerStateType systemPowerState); }; #endif //GNSS_ADAPTER_H diff --git a/gnss/location_gnss.cpp b/gnss/location_gnss.cpp index 76839b62..5380f05a 100644 --- a/gnss/location_gnss.cpp +++ b/gnss/location_gnss.cpp @@ -79,6 +79,7 @@ static void odcpiInject(const Location& location); static void blockCPI(double latitude, double longitude, float accuracy, int blockDurationMsec, double latLonDiffThreshold); static void updateBatteryStatus(bool charging); +static void updateSystemPowerState(PowerStateType systemPowerState); static const GnssInterface gGnssInterface = { sizeof(GnssInterface), @@ -117,7 +118,8 @@ static const GnssInterface gGnssInterface = { nfwInit, getPowerStateChanges, injectLocationExt, - updateBatteryStatus + updateBatteryStatus, + updateSystemPowerState }; #ifndef DEBUG_X86 @@ -390,3 +392,9 @@ static void updateBatteryStatus(bool charging) { gGnssAdapter->getSystemStatus()->updatePowerConnectState(charging); } } + +static void updateSystemPowerState(PowerStateType systemPowerState) { + if (NULL != gGnssAdapter) { + gGnssAdapter->updateSystemPowerStateCommand(systemPowerState); + } +} diff --git a/location/location_interface.h b/location/location_interface.h index fb15bea6..d08dfb3c 100644 --- a/location/location_interface.h +++ b/location/location_interface.h @@ -88,6 +88,7 @@ struct GnssInterface { void (*getPowerStateChanges)(void* powerStateCb); void (*injectLocationExt)(const GnssLocationInfoNotification &locationInfo); void (*updateBatteryStatus)(bool charging); + void (*updateSystemPowerState)(PowerStateType systemPowerState); }; struct BatchingInterface { diff --git a/utils/gps_extended_c.h b/utils/gps_extended_c.h index 3ef49e3d..cd7c2358 100644 --- a/utils/gps_extended_c.h +++ b/utils/gps_extended_c.h @@ -2223,6 +2223,13 @@ typedef void (*LocAgpsOpenResultCb)(bool isSuccess, AGpsExtType agpsType, const typedef void (*LocAgpsCloseResultCb)(bool isSuccess, AGpsExtType agpsType, void* userDataPtr); +enum PowerStateType { + POWER_STATE_UNKNOWN = 0, + POWER_STATE_SUSPEND = 1, + POWER_STATE_RESUME = 2, + POWER_STATE_SHUTDOWN = 3 +}; + /* Shared resources of LocIpc */ #define LOC_IPC_HAL "/dev/socket/location/socket_hal" #define LOC_IPC_XTRA "/dev/socket/location/xtra/socket_xtra" From 6bfa690c483ed3f58a28062dbafc2843e0502a52 Mon Sep 17 00:00:00 2001 From: Bhavna Sharma Date: Wed, 2 Oct 2019 16:29:38 -0700 Subject: [PATCH 18/26] Handle SPE session TBF and nHz subscription for automotive 1. Requirement is to run SPE session only at 100ms TBF if any nHz capable engine subscribes for nHz measurement or nHz position reports. 2. Second requirement is to subscribe for nHz measurement only if an an actual nHz engine subscribes for nHz measurement CRs-Fixed: 2540001 Change-Id: I5a2c93a9d880967ab59ce6cd12cd415c98f29e6c --- core/EngineHubProxyBase.h | 6 +- gnss/GnssAdapter.cpp | 138 ++++++++++++++++++++++++++++++-------- gnss/GnssAdapter.h | 4 ++ 3 files changed, 118 insertions(+), 30 deletions(-) diff --git a/core/EngineHubProxyBase.h b/core/EngineHubProxyBase.h index ec881f69..2d30c5bc 100644 --- a/core/EngineHubProxyBase.h +++ b/core/EngineHubProxyBase.h @@ -113,6 +113,9 @@ typedef std::function GnssAdapterReqAidingDataCb; +typedef std::function + GnssAdapterUpdateNHzRequirementCb; + // potential parameters: message queue: MsgTask * msgTask; // callback function to report back dr and ppe position and sv report typedef EngineHubProxyBase* (getEngHubProxyFn)( @@ -120,7 +123,8 @@ typedef EngineHubProxyBase* (getEngHubProxyFn)( IOsObserver* osObserver, GnssAdapterReportEnginePositionsEventCb positionEventCb, GnssAdapterReportSvEventCb svEventCb, - GnssAdapterReqAidingDataCb reqAidingDataCb); + GnssAdapterReqAidingDataCb reqAidingDataCb, + GnssAdapterUpdateNHzRequirementCb updateNHzRequirementCb); } // namespace loc_core diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 11f6777e..dee969ab 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -45,7 +45,6 @@ #include #include #include - #include #define RAD2DEG (180.0 / M_PI) @@ -71,6 +70,8 @@ GnssAdapter::GnssAdapter() : true, nullptr, true), mEngHubProxy(new EngineHubProxyBase()), mLocPositionMode(), + mNHzNeeded(false), + mSPEAlreadyRunningAtHighestInterval(false), mGnssSvIdUsedInPosition(), mGnssSvIdUsedInPosAvail(false), mControlCallbacks(), @@ -173,6 +174,30 @@ GnssAdapter::convertOptions(LocPosMode& out, const TrackingOptions& trackingOpti out.timeBetweenMeasurements = trackingOptions.tbm; } +bool +GnssAdapter::checkAndSetSPEToRunforNHz(TrackingOptions & out) { + // first check if NHz meas is needed at all, if not, just return false + // if a NHz capable engine is subscribed for NHz measurement or NHz positions, + // always run the SPE only session at 100ms TBF. + // If SPE session is already set to highest interval, no need to start it again. + + bool isSPERunningAtHighestInterval = false; + + if (!mNHzNeeded) { + LOC_LOGd("No nHz session needed."); + } else if (mSPEAlreadyRunningAtHighestInterval) { + LOC_LOGd("SPE is already running at highest interval."); + isSPERunningAtHighestInterval = true; + } else if (out.minInterval > MIN_TRACKING_INTERVAL) { + out.minInterval = MIN_TRACKING_INTERVAL; + LOC_LOGd("nHz session is needed, starting SPE only session at 100ms TBF."); + mSPEAlreadyRunningAtHighestInterval = true; + } + + return isSPERunningAtHighestInterval; +} + + void GnssAdapter::convertLocation(Location& out, const UlpLocation& ulpLocation, const GpsLocationExtended& locationExtended, @@ -2089,13 +2114,16 @@ GnssAdapter::updateClientsEventMask() if((1 == ContextBase::mGps_conf.EXTERNAL_DR_ENABLED) || (true == initEngHubProxy())) { mask |= LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT; - mask |= LOC_API_ADAPTER_BIT_GNSS_NHZ_MEASUREMENT; mask |= LOC_API_ADAPTER_BIT_GNSS_SV_POLYNOMIAL_REPORT; mask |= LOC_API_ADAPTER_BIT_PARSED_UNPROPAGATED_POSITION_REPORT; mask |= LOC_API_ADAPTER_BIT_GNSS_SV_EPHEMERIS_REPORT; mask |= LOC_API_ADAPTER_BIT_LOC_SYSTEM_INFO; mask |= LOC_API_ADAPTER_BIT_EVENT_REPORT_INFO; + // Nhz measurement bit is set based on callback from loc eng hub + // for Nhz engines. + mask |= checkMask(LOC_API_ADAPTER_BIT_GNSS_NHZ_MEASUREMENT); + LOC_LOGd("Auto usecase, Enable MEAS/POLY/EPHEMERIS - mask 0x%" PRIx64 "", mask); } @@ -2155,13 +2183,31 @@ GnssAdapter::restartSessions() // odcpi session is no longer active after restart mOdcpiRequestActive = false; + // SPE will be restarted now, so set this variable to false. + mSPEAlreadyRunningAtHighestInterval = false; + + checkAndRestartTimeBasedSession(); + + for (auto it = mDistanceBasedTrackingSessions.begin(); + it != mDistanceBasedTrackingSessions.end(); ++it) { + mLocApi->startDistanceBasedTracking(it->first.id, it->second, + new LocApiResponse(*getContext(), + [] (LocationError /*err*/) {})); + } +} + +void GnssAdapter::checkAndRestartTimeBasedSession() +{ + LOC_LOGD("%s]: ", __func__); + if (!mTimeBasedTrackingSessions.empty()) { // get the LocationOptions that has the smallest interval, which should be the active one TrackingOptions smallestIntervalOptions; // size is zero until set for the first time TrackingOptions highestPowerTrackingOptions; memset(&smallestIntervalOptions, 0, sizeof(smallestIntervalOptions)); memset(&highestPowerTrackingOptions, 0, sizeof(highestPowerTrackingOptions)); - for (auto it = mTimeBasedTrackingSessions.begin(); it != mTimeBasedTrackingSessions.end(); ++it) { + for (auto it = mTimeBasedTrackingSessions.begin(); + it != mTimeBasedTrackingSessions.end(); ++it) { // size of zero means we havent set it yet if (0 == smallestIntervalOptions.size || it->second.minInterval < smallestIntervalOptions.minInterval) { @@ -2177,14 +2223,10 @@ GnssAdapter::restartSessions() } highestPowerTrackingOptions.setLocationOptions(smallestIntervalOptions); - mLocApi->startTimeBasedTracking(highestPowerTrackingOptions, nullptr); - } - - for (auto it = mDistanceBasedTrackingSessions.begin(); - it != mDistanceBasedTrackingSessions.end(); ++it) { - mLocApi->startDistanceBasedTracking(it->first.id, it->second, - new LocApiResponse(*getContext(), - [] (LocationError /*err*/) {})); + // want to run SPE session at a fixed min interval in some automotive scenarios + if(!checkAndSetSPEToRunforNHz(highestPowerTrackingOptions)) { + mLocApi->startTimeBasedTracking(highestPowerTrackingOptions, nullptr); + } } } @@ -2491,6 +2533,7 @@ GnssAdapter::startTimeBasedTrackingMultiplex(LocationAPI* client, uint32_t sessi multiplexedOptions.minInterval = options.minInterval; updateOptions = true; } + // if session we are starting has smaller powerMode then next smallest if (options.powerMode < multiplexedPowerMode) { multiplexedOptions.powerMode = options.powerMode; @@ -2524,15 +2567,24 @@ GnssAdapter::startTimeBasedTracking(LocationAPI* client, uint32_t sessionId, mEngHubProxy->gnssSetFixMode(locPosMode); mEngHubProxy->gnssStartFix(); - mLocApi->startTimeBasedTracking(trackingOptions, new LocApiResponse(*getContext(), - [this, client, sessionId] (LocationError err) { - if (LOCATION_ERROR_SUCCESS != err) { - eraseTrackingSession(client, sessionId); - } + // want to run SPE session at a fixed min interval in some automotive scenarios + // use a local copy of TrackingOptions as the TBF may get modified in the + // checkAndSetSPEToRunforNHz function + TrackingOptions tempOptions(trackingOptions); + if (!checkAndSetSPEToRunforNHz(tempOptions)) { + mLocApi->startTimeBasedTracking(tempOptions, new LocApiResponse(*getContext(), + [this, client, sessionId] (LocationError err) { + if (LOCATION_ERROR_SUCCESS != err) { + eraseTrackingSession(client, sessionId); + } + + reportResponse(client, err, sessionId); + } + )); + } else { + reportResponse(client, LOCATION_ERROR_SUCCESS, sessionId); + } - reportResponse(client, err, sessionId); - } - )); } void @@ -2546,16 +2598,23 @@ GnssAdapter::updateTracking(LocationAPI* client, uint32_t sessionId, mEngHubProxy->gnssSetFixMode(locPosMode); mEngHubProxy->gnssStartFix(); - mLocApi->startTimeBasedTracking(updatedOptions, new LocApiResponse(*getContext(), - [this, client, sessionId, oldOptions] (LocationError err) { - if (LOCATION_ERROR_SUCCESS != err) { - // restore the old LocationOptions - saveTrackingSession(client, sessionId, oldOptions); + // want to run SPE session at a fixed min interval in some automotive scenarios + // use a local copy of TrackingOptions as the TBF may get modified in the + // checkAndSetSPEToRunforNHz function + TrackingOptions tempOptions(updatedOptions); + if(!checkAndSetSPEToRunforNHz(tempOptions)) { + mLocApi->startTimeBasedTracking(tempOptions, new LocApiResponse(*getContext(), + [this, client, sessionId, oldOptions] (LocationError err) { + if (LOCATION_ERROR_SUCCESS != err) { + // restore the old LocationOptions + saveTrackingSession(client, sessionId, oldOptions); + } + reportResponse(client, err, sessionId); } - - reportResponse(client, err, sessionId); - } - )); + )); + } else { + reportResponse(client, LOCATION_ERROR_SUCCESS, sessionId); + } } void @@ -2856,6 +2915,8 @@ GnssAdapter::stopTracking(LocationAPI* client, uint32_t id) [this, client, id] (LocationError err) { reportResponse(client, err, id); })); + + mSPEAlreadyRunningAtHighestInterval = false; } bool @@ -5023,11 +5084,30 @@ GnssAdapter::initEngHubProxy() { mLocApi->requestForAidingData(svDataMask); }; + GnssAdapterUpdateNHzRequirementCb updateNHzRequirementCb = + [this] (bool nHzNeeded, bool nHzMeasNeeded) { + + if (nHzMeasNeeded && + (!checkMask(LOC_API_ADAPTER_BIT_GNSS_NHZ_MEASUREMENT))) { + updateEvtMask(LOC_API_ADAPTER_BIT_GNSS_NHZ_MEASUREMENT, + LOC_REGISTRATION_MASK_ENABLED); + } else if (checkMask(LOC_API_ADAPTER_BIT_GNSS_NHZ_MEASUREMENT)) { + updateEvtMask(LOC_API_ADAPTER_BIT_GNSS_NHZ_MEASUREMENT, + LOC_REGISTRATION_MASK_DISABLED); + } + + if (mNHzNeeded != nHzNeeded) { + mNHzNeeded = nHzNeeded; + checkAndRestartTimeBasedSession(); + } + }; + getEngHubProxyFn* getter = (getEngHubProxyFn*) dlsym(handle, "getEngHubProxy"); if(getter != nullptr) { EngineHubProxyBase* hubProxy = (*getter) (mMsgTask, mSystemStatus->getOsObserver(), reportPositionEventCb, - reportSvEventCb, reqAidingDataCb); + reportSvEventCb, reqAidingDataCb, + updateNHzRequirementCb); if (hubProxy != nullptr) { mEngHubProxy = hubProxy; engHubLoadSuccessful = true; diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h index 3ccdd96d..1bcf4b7a 100644 --- a/gnss/GnssAdapter.h +++ b/gnss/GnssAdapter.h @@ -138,6 +138,8 @@ class GnssAdapter : public LocAdapterBase { /* ==== Engine Hub ===================================================================== */ EngineHubProxyBase* mEngHubProxy; + bool mNHzNeeded; + bool mSPEAlreadyRunningAtHighestInterval; /* ==== TRACKING ======================================================================= */ TrackingOptionsMap mTimeBasedTrackingSessions; @@ -228,6 +230,7 @@ public: virtual void handleEngineUpEvent(); /* ======== UTILITIES ================================================================== */ void restartSessions(); + void checkAndRestartTimeBasedSession(); /* ==== CLIENT ========================================================================= */ /* ======== COMMANDS ====(Called from Client Thread)==================================== */ @@ -265,6 +268,7 @@ public: const TrackingOptions& trackingOptions); void updateTracking(LocationAPI* client, uint32_t sessionId, const TrackingOptions& updatedOptions, const TrackingOptions& oldOptions); + bool checkAndSetSPEToRunforNHz(TrackingOptions & out); /* ==== NI ============================================================================= */ /* ======== COMMANDS ====(Called from Client Thread)==================================== */ From 569517b808735f514f6d2e9fadb7922af4610960 Mon Sep 17 00:00:00 2001 From: Wei Chen Date: Fri, 1 Nov 2019 11:31:41 -0700 Subject: [PATCH 19/26] GPS HW module: fix << overflow issue Fix shift overflow when the number of bits shifted can exceed 31 bits Change-Id: Ib4334fd9b3bf574b8d8143a5f706ca9e963a6053 CRs-fixed: 2557855 --- gnss/GnssAdapter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index dee969ab..f7e1c0d2 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -1518,7 +1518,7 @@ GnssAdapter::convertToGnssSvIdConfig( LOC_LOGe("Invalid sv id %d for sv type %d", source.svId, source.constellation); } else { - *svMaskPtr |= (1 << (source.svId - initialSvId)); + *svMaskPtr |= (1ULL << (source.svId - initialSvId)); } } } From e14cbf37981a9c86c387590d85e627e6405d819a Mon Sep 17 00:00:00 2001 From: Wei Chen Date: Mon, 4 Nov 2019 12:55:24 -0800 Subject: [PATCH 20/26] GNSS BDS max SV ID: update to 237 from 235 Change-Id: I0c373c91f9763c67d1b877f77216ae0efc7a6273 CRs-fixed: 2558927 --- utils/gps_extended_c.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/gps_extended_c.h b/utils/gps_extended_c.h index 3ef49e3d..3c6a0a4e 100644 --- a/utils/gps_extended_c.h +++ b/utils/gps_extended_c.h @@ -449,7 +449,7 @@ typedef uint32_t GnssAdditionalSystemInfoMask; #define QZSS_SV_PRN_MIN 193 #define QZSS_SV_PRN_MAX 197 #define BDS_SV_PRN_MIN 201 -#define BDS_SV_PRN_MAX 235 +#define BDS_SV_PRN_MAX 237 #define GAL_SV_PRN_MIN 301 #define GAL_SV_PRN_MAX 336 #define NAVIC_SV_PRN_MIN 401 From 61c8aaca033ea9c883a71edc741361d2fbc5cdc3 Mon Sep 17 00:00:00 2001 From: Wei Chen Date: Tue, 15 Oct 2019 15:36:46 -0700 Subject: [PATCH 21/26] Concurrent position report: report out SPE fix promptly For concurrent position report, we need to report SPE fix promptly Change-Id: Iba7807ccb158dc4092abd9bbf540cbf0a6c7345b CRs-fixed: 2546089 --- gnss/GnssAdapter.cpp | 53 ++++++++++++++++++++++++++++++-------------- gnss/GnssAdapter.h | 3 +-- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index dee969ab..f06deb06 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -2086,7 +2086,9 @@ GnssAdapter::updateClientsEventMask() { LOC_API_ADAPTER_EVENT_MASK_T mask = 0; for (auto it=mClientData.begin(); it != mClientData.end(); ++it) { - if (it->second.trackingCb != nullptr || it->second.gnssLocationInfoCb != nullptr) { + if (it->second.trackingCb != nullptr || + it->second.gnssLocationInfoCb != nullptr || + it->second.engineLocationsInfoCb != nullptr) { mask |= LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT; } if (it->second.gnssSvCb != nullptr) { @@ -2259,13 +2261,6 @@ GnssAdapter::notifyClientOfCachedLocationSystemInfo( } } -bool -GnssAdapter::hasTrackingCallback(LocationAPI* client) -{ - auto it = mClientData.find(client); - return (it != mClientData.end() && (it->second.trackingCb || it->second.gnssLocationInfoCb)); -} - bool GnssAdapter::isTimeBasedTrackingSession(LocationAPI* client, uint32_t sessionId) { @@ -2281,10 +2276,21 @@ GnssAdapter::isDistanceBasedTrackingSession(LocationAPI* client, uint32_t sessio } bool -GnssAdapter::hasMeasurementsCallback(LocationAPI* client) +GnssAdapter::hasCallbacksToStartTracking(LocationAPI* client) { + bool allowed = false; auto it = mClientData.find(client); - return (it != mClientData.end() && it->second.gnssMeasurementsCb); + if (it != mClientData.end()) { + if (it->second.trackingCb || it->second.gnssLocationInfoCb || + it->second.engineLocationsInfoCb || it->second.gnssMeasurementsCb) { + allowed = true; + } else { + LOC_LOGi("missing right callback to start tracking") + } + } else { + LOC_LOGi("client %p not found", client) + } + return allowed; } bool @@ -2452,8 +2458,7 @@ GnssAdapter::startTrackingCommand(LocationAPI* client, TrackingOptions& options) return; } LocationError err = LOCATION_ERROR_SUCCESS; - if (!mAdapter.hasTrackingCallback(mClient) && - !mAdapter.hasMeasurementsCallback(mClient)) { + if (!mAdapter.hasCallbacksToStartTracking(mClient)) { err = LOCATION_ERROR_CALLBACK_MISSING; } else if (0 == mOptions.size) { err = LOCATION_ERROR_INVALID_PARAMETER; @@ -3137,21 +3142,35 @@ GnssAdapter::reportPositionEvent(const UlpLocation& ulpLocation, int msInWeek) { // this position is from QMI LOC API, then send report to engine hub - // if sending is successful, we return as we will wait for final report from engine hub - // if the position is called from engine hub, then send it out directly + // also, send out SPE fix promptly to the clients that have registered + // with SPE report + LOC_LOGd("reportPositionEvent, eng type: %d, unpro %d, sess status %d", + locationExtended.locOutputEngType, ulpLocation.unpropagatedPosition, + status); if (true == initEngHubProxy()){ + // send the SPE fix to engine hub mEngHubProxy->gnssReportPosition(ulpLocation, locationExtended, status); + // report out all SPE fix if it is not propagated, even for failed fix + if (false == ulpLocation.unpropagatedPosition) { + EngineLocationInfo engLocationInfo = {}; + engLocationInfo.location = ulpLocation; + engLocationInfo.locationExtended = locationExtended; + engLocationInfo.sessionStatus = status; + reportEnginePositionsEvent(1, &engLocationInfo); + } return; } + // unpropagated report: is only for engine hub to consume and no need + // to send out to the clients if (true == ulpLocation.unpropagatedPosition) { return; } - // Fix is from QMI, and it is not an - // unpropagated position and engine hub is not loaded, queue the msg - // when message is queued, the position can be dispatched to requesting client + // Fix is from QMI, and it is not an unpropagated position and engine hub + // is not loaded, queue the message when message is processed, the position + // can be dispatched to requesting client that registers for SPE report struct MsgReportPosition : public LocMsg { GnssAdapter& mAdapter; const UlpLocation mUlpLocation; diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h index 1bcf4b7a..1feb985f 100644 --- a/gnss/GnssAdapter.h +++ b/gnss/GnssAdapter.h @@ -246,10 +246,9 @@ public: /* ======== RESPONSES ================================================================== */ void reportResponse(LocationAPI* client, LocationError err, uint32_t sessionId); /* ======== UTILITIES ================================================================== */ - bool hasTrackingCallback(LocationAPI* client); bool isTimeBasedTrackingSession(LocationAPI* client, uint32_t sessionId); bool isDistanceBasedTrackingSession(LocationAPI* client, uint32_t sessionId); - bool hasMeasurementsCallback(LocationAPI* client); + bool hasCallbacksToStartTracking(LocationAPI* client); bool isTrackingSession(LocationAPI* client, uint32_t sessionId); void saveTrackingSession(LocationAPI* client, uint32_t sessionId, const TrackingOptions& trackingOptions); From 62042a27ebbbdd230ada2693d4a90fadde0d6c6e Mon Sep 17 00:00:00 2001 From: Hoss Zhou Date: Wed, 6 Nov 2019 16:26:30 +0800 Subject: [PATCH 22/26] fix nmea B2AQ issues Change-Id: I07e17eac2eb663155d138fc67881f9926dea2f5e CRs-Fixed: 2560784 --- utils/loc_nmea.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/loc_nmea.cpp b/utils/loc_nmea.cpp index cf738ba6..876620f4 100644 --- a/utils/loc_nmea.cpp +++ b/utils/loc_nmea.cpp @@ -2056,7 +2056,8 @@ void loc_nmea_generate_sv(const GnssSvNotification &svNotify, { sv_cache_info.bds_used_mask |= (1ULL << (svNotify.gnssSvs[svNumber - 1].svId - 1)); } - if(GNSS_SIGNAL_BEIDOU_B2AI == svNotify.gnssSvs[svNumber - 1].gnssSignalTypeMask){ + if ((GNSS_SIGNAL_BEIDOU_B2AI == svNotify.gnssSvs[svNumber - 1].gnssSignalTypeMask) || + (GNSS_SIGNAL_BEIDOU_B2AQ == svNotify.gnssSvs[svNumber - 1].gnssSignalTypeMask)) { sv_cache_info.bds_b2_count++; } else { // GNSS_SIGNAL_BEIDOU_B1I or default From 31f3995e14c4b2d61903a2b6dbda47b155c6f6a6 Mon Sep 17 00:00:00 2001 From: haohuang Date: Thu, 14 Nov 2019 10:26:10 +0800 Subject: [PATCH 23/26] Remove assigning preferredAccuracyMeters to minDistance Remove this assigning in gnssSetPositionMode. We shouldn't assign preferredAccuracyMeters to minDistance, because if preferredAccuracyMeters is larger than 0, GnssAdapter will start distance based tracking which is not expected. Change-Id: I2c2acedd121e02bf9da1136540cc34b9257197fd CRs-fixed: 2566229 --- android/1.0/location_api/GnssAPIClient.cpp | 1 - android/1.1/location_api/GnssAPIClient.cpp | 1 - android/2.0/location_api/GnssAPIClient.cpp | 1 - 3 files changed, 3 deletions(-) diff --git a/android/1.0/location_api/GnssAPIClient.cpp b/android/1.0/location_api/GnssAPIClient.cpp index b9fe2b25..eb785915 100644 --- a/android/1.0/location_api/GnssAPIClient.cpp +++ b/android/1.0/location_api/GnssAPIClient.cpp @@ -174,7 +174,6 @@ bool GnssAPIClient::gnssSetPositionMode(IGnss::GnssPositionMode mode, // For MSA, we always treat it as SINGLE mode. mTrackingOptions.minInterval = SINGLE_SHOT_MIN_TRACKING_INTERVAL_MSEC; } - mTrackingOptions.minDistance = preferredAccuracyMeters; if (mode == IGnss::GnssPositionMode::STANDALONE) mTrackingOptions.mode = GNSS_SUPL_MODE_STANDALONE; else if (mode == IGnss::GnssPositionMode::MS_BASED) diff --git a/android/1.1/location_api/GnssAPIClient.cpp b/android/1.1/location_api/GnssAPIClient.cpp index 9a95fdfe..be4d6596 100644 --- a/android/1.1/location_api/GnssAPIClient.cpp +++ b/android/1.1/location_api/GnssAPIClient.cpp @@ -174,7 +174,6 @@ bool GnssAPIClient::gnssSetPositionMode(IGnss::GnssPositionMode mode, // For MSA, we always treat it as SINGLE mode. mTrackingOptions.minInterval = SINGLE_SHOT_MIN_TRACKING_INTERVAL_MSEC; } - mTrackingOptions.minDistance = preferredAccuracyMeters; if (mode == IGnss::GnssPositionMode::STANDALONE) mTrackingOptions.mode = GNSS_SUPL_MODE_STANDALONE; else if (mode == IGnss::GnssPositionMode::MS_BASED) diff --git a/android/2.0/location_api/GnssAPIClient.cpp b/android/2.0/location_api/GnssAPIClient.cpp index a3cdd278..d505241c 100644 --- a/android/2.0/location_api/GnssAPIClient.cpp +++ b/android/2.0/location_api/GnssAPIClient.cpp @@ -223,7 +223,6 @@ bool GnssAPIClient::gnssSetPositionMode(IGnss::GnssPositionMode mode, // For MSA, we always treat it as SINGLE mode. mTrackingOptions.minInterval = SINGLE_SHOT_MIN_TRACKING_INTERVAL_MSEC; } - mTrackingOptions.minDistance = preferredAccuracyMeters; if (mode == IGnss::GnssPositionMode::STANDALONE) mTrackingOptions.mode = GNSS_SUPL_MODE_STANDALONE; else if (mode == IGnss::GnssPositionMode::MS_BASED) From c7b6382ede2ada8cbe6d94a58fc27d91bf8da398 Mon Sep 17 00:00:00 2001 From: Nilesh Gharde Date: Wed, 20 Nov 2019 17:59:43 +0530 Subject: [PATCH 24/26] SUPL Version for 5G and LPP Rel 15 Change-Id: Id00ea3bfb72c88c7c68425aa8c8829579ebd6237 CRs-fixed: 2570450 --- android/1.0/GnssConfiguration.cpp | 3 +++ android/1.1/GnssConfiguration.cpp | 3 +++ android/2.0/GnssConfiguration.cpp | 3 +++ gnss/GnssAdapter.cpp | 2 ++ location/LocationDataTypes.h | 1 + 5 files changed, 12 insertions(+) diff --git a/android/1.0/GnssConfiguration.cpp b/android/1.0/GnssConfiguration.cpp index 0b622494..73c9d5c2 100644 --- a/android/1.0/GnssConfiguration.cpp +++ b/android/1.0/GnssConfiguration.cpp @@ -65,6 +65,9 @@ Return GnssConfiguration::setSuplVersion(uint32_t version) { config.size = sizeof(GnssConfig); config.flags = GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT; switch (version) { + case 0x00020004: + config.suplVersion = GNSS_CONFIG_SUPL_VERSION_2_0_4; + break; case 0x00020002: config.suplVersion = GNSS_CONFIG_SUPL_VERSION_2_0_2; break; diff --git a/android/1.1/GnssConfiguration.cpp b/android/1.1/GnssConfiguration.cpp index 93f96457..708e2c1a 100644 --- a/android/1.1/GnssConfiguration.cpp +++ b/android/1.1/GnssConfiguration.cpp @@ -65,6 +65,9 @@ Return GnssConfiguration::setSuplVersion(uint32_t version) { config.size = sizeof(GnssConfig); config.flags = GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT; switch (version) { + case 0x00020004: + config.suplVersion = GNSS_CONFIG_SUPL_VERSION_2_0_4; + break; case 0x00020002: config.suplVersion = GNSS_CONFIG_SUPL_VERSION_2_0_2; break; diff --git a/android/2.0/GnssConfiguration.cpp b/android/2.0/GnssConfiguration.cpp index 363d2b1e..069c0365 100644 --- a/android/2.0/GnssConfiguration.cpp +++ b/android/2.0/GnssConfiguration.cpp @@ -55,6 +55,9 @@ Return GnssConfiguration::setSuplVersion(uint32_t version) { config.size = sizeof(GnssConfig); config.flags = GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT; switch (version) { + case 0x00020004: + config.suplVersion = GNSS_CONFIG_SUPL_VERSION_2_0_4; + break; case 0x00020002: config.suplVersion = GNSS_CONFIG_SUPL_VERSION_2_0_2; break; diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 19dcb6de..0382f19f 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -533,6 +533,8 @@ inline uint32_t GnssAdapter::convertSuplVersion(const GnssConfigSuplVersion suplVersion) { switch (suplVersion) { + case GNSS_CONFIG_SUPL_VERSION_2_0_4: + return 0x00020004; case GNSS_CONFIG_SUPL_VERSION_2_0_0: return 0x00020000; case GNSS_CONFIG_SUPL_VERSION_2_0_2: diff --git a/location/LocationDataTypes.h b/location/LocationDataTypes.h index 956754ad..2fb35bf8 100644 --- a/location/LocationDataTypes.h +++ b/location/LocationDataTypes.h @@ -248,6 +248,7 @@ typedef enum { GNSS_CONFIG_SUPL_VERSION_1_0_0 = 1, GNSS_CONFIG_SUPL_VERSION_2_0_0, GNSS_CONFIG_SUPL_VERSION_2_0_2, + GNSS_CONFIG_SUPL_VERSION_2_0_4, } GnssConfigSuplVersion; // LTE Positioning Profile From 97c612b5a0153169e29bf28ef8098ca4bb104786 Mon Sep 17 00:00:00 2001 From: Santoshkumar Zalake Date: Thu, 21 Nov 2019 10:49:19 +0530 Subject: [PATCH 25/26] Use gmtime_r function to avoid UTC time corruption. The gmtime library function is outputting corrupted UTC time as this function is not thread safer. CRs-Fixed: 2571035 Change-Id: Ieed088392e3094eb20fa9b526931a3a89d4f231c --- utils/loc_nmea.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/loc_nmea.cpp b/utils/loc_nmea.cpp index 876620f4..9ee27164 100644 --- a/utils/loc_nmea.cpp +++ b/utils/loc_nmea.cpp @@ -1195,7 +1195,8 @@ void loc_nmea_generate_pos(const UlpLocation &location, (location, locationExtended, systemInfo, utcPosTimestamp); time_t utcTime(utcPosTimestamp/1000); - tm * pTm = gmtime(&utcTime); + struct tm result; + tm * pTm = gmtime_r(&utcTime, &result); if (NULL == pTm) { LOC_LOGE("gmtime failed"); return; From 6c35439ef28c99928ae26360bdc4952f97d8d66e Mon Sep 17 00:00:00 2001 From: Wei Chen Date: Fri, 16 Aug 2019 14:59:23 -0700 Subject: [PATCH 26/26] FR 57252: GPS hal changes to allow configuration for LE target (1) runtime enable/disable TUNC (2) runtime enable/disable PACE (3) runtime enable/disable constellations (4) delete all aiding data (5) config lever arm Change-Id: I6cffd08e4c6fa45ff8d62bfef2da1156f3b61956 CRs-fixed: 2497326 --- core/EngineHubProxyBase.h | 5 + core/LocApiBase.cpp | 19 ++- core/LocApiBase.h | 15 +- gnss/GnssAdapter.cpp | 295 +++++++++++++++++++++++++++++++++- gnss/GnssAdapter.h | 33 ++++ gnss/location_gnss.cpp | 57 ++++++- location/ILocationAPI.h | 113 +++++++++++++ location/LocationAPI.cpp | 76 +++++++++ location/LocationAPI.h | 113 +++++++++++++ location/LocationDataTypes.h | 69 ++++++++ location/location_interface.h | 6 + utils/gps_extended_c.h | 21 +-- 12 files changed, 780 insertions(+), 42 deletions(-) diff --git a/core/EngineHubProxyBase.h b/core/EngineHubProxyBase.h index 2d30c5bc..d46bca25 100644 --- a/core/EngineHubProxyBase.h +++ b/core/EngineHubProxyBase.h @@ -101,6 +101,11 @@ public: (void) additionalSystemInfo; return false; } + + inline virtual bool configLeverArm(const LeverArmConfigInfo& configInfo) { + (void) configInfo; + return false; + } }; typedef std::function diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp index 595fa49f..71abdf9f 100644 --- a/core/LocApiBase.cpp +++ b/core/LocApiBase.cpp @@ -756,24 +756,27 @@ DEFAULT_IMPL() void LocApiBase::getBlacklistSv() DEFAULT_IMPL() -void LocApiBase::setConstellationControl(const GnssSvTypeConfig& /*config*/) +void LocApiBase::setConstellationControl(const GnssSvTypeConfig& /*config*/, + LocApiResponse* /*adapterResponse*/) DEFAULT_IMPL() void LocApiBase::getConstellationControl() DEFAULT_IMPL() -void LocApiBase::resetConstellationControl() +void LocApiBase::resetConstellationControl(LocApiResponse* /*adapterResponse*/) DEFAULT_IMPL() -LocationError LocApiBase:: +void LocApiBase:: setConstrainedTuncMode(bool /*enabled*/, float /*tuncConstraint*/, - uint32_t /*energyBudget*/) -DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) + uint32_t /*energyBudget*/, + LocApiResponse* /*adapterResponse*/) +DEFAULT_IMPL() -LocationError LocApiBase:: - setPositionAssistedClockEstimatorMode(bool /*enabled*/) -DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) +void LocApiBase:: + setPositionAssistedClockEstimatorMode(bool /*enabled*/, + LocApiResponse* /*adapterResponse*/) +DEFAULT_IMPL() LocationError LocApiBase::getGnssEnergyConsumed() DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) diff --git a/core/LocApiBase.h b/core/LocApiBase.h index 3c85b099..9c76bab2 100644 --- a/core/LocApiBase.h +++ b/core/LocApiBase.h @@ -260,12 +260,17 @@ public: virtual LocationError setBlacklistSvSync(const GnssSvIdConfig& config); virtual void setBlacklistSv(const GnssSvIdConfig& config); virtual void getBlacklistSv(); - virtual void setConstellationControl(const GnssSvTypeConfig& config); + virtual void setConstellationControl(const GnssSvTypeConfig& config, + LocApiResponse *adapterResponse=nullptr); virtual void getConstellationControl(); - virtual void resetConstellationControl(); - virtual LocationError setConstrainedTuncMode(bool enabled, float tuncConstraint, - uint32_t energyBudget); - virtual LocationError setPositionAssistedClockEstimatorMode(bool enabled); + virtual void resetConstellationControl(LocApiResponse *adapterResponse=nullptr); + + virtual void setConstrainedTuncMode(bool enabled, + float tuncConstraint, + uint32_t energyBudget, + LocApiResponse* adapterResponse=nullptr); + virtual void setPositionAssistedClockEstimatorMode(bool enabled, + LocApiResponse* adapterResponse=nullptr); virtual LocationError getGnssEnergyConsumed(); virtual void addGeofence(uint32_t clientId, const GeofenceOption& options, diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 19dcb6de..38818897 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -80,6 +80,7 @@ GnssAdapter::GnssAdapter() : mGnssSvIdConfig(), mGnssSvTypeConfig(), mGnssSvTypeConfigCb(nullptr), + mLocConfigInfo{}, mNiData(), mAgpsManager(), mOdcpiRequestCb(nullptr), @@ -826,12 +827,32 @@ GnssAdapter::setConfig() mLocApi->setXtraVersionCheckSync(gpsConf.XTRA_VERSION_CHECK); + // load tunc configuration from config file on first boot-up, + // e.g.: adapter.mLocConfigInfo.tuncConfigInfo.isValid is false + if (mLocConfigInfo.tuncConfigInfo.isValid == false) { + mLocConfigInfo.tuncConfigInfo.isValid = true; + mLocConfigInfo.tuncConfigInfo.enable = + (gpsConf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED == 1); + mLocConfigInfo.tuncConfigInfo.tuncThresholdMs = + (float)gpsConf.CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD; + mLocConfigInfo.tuncConfigInfo.energyBudget = + gpsConf.CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET; + } + mLocApi->setConstrainedTuncMode( - gpsConf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED == 1, - (float)gpsConf.CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD, - gpsConf.CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET); + mLocConfigInfo.tuncConfigInfo.enable, + mLocConfigInfo.tuncConfigInfo.tuncThresholdMs, + mLocConfigInfo.tuncConfigInfo.energyBudget); + + // load pace configuration from config file on first boot-up, + // e.g.: adapter.mLocConfigInfo.paceConfigInfo.isValid is false + if (mLocConfigInfo.paceConfigInfo.isValid == false) { + mLocConfigInfo.paceConfigInfo.isValid = true; + mLocConfigInfo.paceConfigInfo.enable = + (gpsConf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED==1); + } mLocApi->setPositionAssistedClockEstimatorMode( - gpsConf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED == 1); + mLocConfigInfo.paceConfigInfo.enable); if (sapConf.GYRO_BIAS_RANDOM_WALK_VALID || sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID || @@ -3371,10 +3392,11 @@ GnssAdapter::reportPosition(const UlpLocation& ulpLocation, } } - // if engine hub is running and the fix is from sensor, e.g.: DRE, - // inject DRE fix to modem - if ((1 == ContextBase::mGps_conf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED) && - (true == initEngHubProxy()) && (LOC_POS_TECH_MASK_SENSORS & techMask)) { + // if PACE is enabled and engine hub is running and the fix is from sensor, + // e.g.: DRE, inject DRE fix to modem + if ((true == mLocConfigInfo.paceConfigInfo.isValid && + true == mLocConfigInfo.paceConfigInfo.enable) && + (true == initEngHubProxy()) && (LOC_POS_TECH_MASK_SENSORS & techMask)) { mLocApi->injectPosition(locationInfo, false); } } @@ -5056,6 +5078,263 @@ GnssAdapter::nfwControlCommand(bool enable) { } } +// Set tunc constrained mode, use 0 session id to indicate +// that no callback is needed. Session id 0 is used for calls that +// are not invoked from the integration api, e.g.: initial configuration +// from the configure file +void +GnssAdapter::setConstrainedTunc(bool enable, float tuncConstraint, + uint32_t energyBudget, uint32_t sessionId) { + + mLocConfigInfo.tuncConfigInfo.isValid = true; + mLocConfigInfo.tuncConfigInfo.enable = enable; + mLocConfigInfo.tuncConfigInfo.tuncThresholdMs = tuncConstraint; + mLocConfigInfo.tuncConfigInfo.energyBudget = energyBudget; + + LocApiResponse* locApiResponse = nullptr; + if (sessionId != 0) { + locApiResponse = + new LocApiResponse(*getContext(), + [this, sessionId] (LocationError err) { + reportResponse(err, sessionId);}); + if (!locApiResponse) { + LOC_LOGe("memory alloc failed"); + } + } + mLocApi->setConstrainedTuncMode( + enable, tuncConstraint, energyBudget, locApiResponse); +} + +uint32_t +GnssAdapter::setConstrainedTuncCommand (bool enable, float tuncConstraint, + uint32_t energyBudget) { + // generated session id will be none-zero + uint32_t sessionId = generateSessionId(); + LOC_LOGd("session id %u", sessionId); + + struct MsgEnableTUNC : public LocMsg { + GnssAdapter& mAdapter; + uint32_t mSessionId; + bool mEnable; + float mTuncConstraint; + uint32_t mEnergyBudget; + + inline MsgEnableTUNC(GnssAdapter& adapter, + uint32_t sessionId, + bool enable, + float tuncConstraint, + uint32_t energyBudget) : + LocMsg(), + mAdapter(adapter), + mSessionId(sessionId), + mEnable(enable), + mTuncConstraint(tuncConstraint), + mEnergyBudget(energyBudget) {} + inline virtual void proc() const { + mAdapter.setConstrainedTunc(mEnable, mTuncConstraint, + mEnergyBudget, mSessionId); + } + }; + + sendMsg(new MsgEnableTUNC(*this, sessionId, enable, + tuncConstraint, energyBudget)); + + return sessionId; +} + +// Set position assisted clock estimator, use 0 session id to indicate +// that no callback is needed. Session id 0 is used for calls that are +// not invoked from the integration api, e.g.: initial configuration +// from the configure file. +void +GnssAdapter::setPositionAssistedClockEstimator(bool enable, + uint32_t sessionId) { + + mLocConfigInfo.paceConfigInfo.isValid = true; + mLocConfigInfo.paceConfigInfo.enable = enable; + LocApiResponse* locApiResponse = nullptr; + if (sessionId != 0) { + locApiResponse = + new LocApiResponse(*getContext(), + [this, sessionId] (LocationError err) { + reportResponse(err, sessionId);}); + if (!locApiResponse) { + LOC_LOGe("memory alloc failed"); + } + } + mLocApi->setPositionAssistedClockEstimatorMode(enable, locApiResponse); +} + +uint32_t +GnssAdapter::setPositionAssistedClockEstimatorCommand(bool enable) { + // generated session id will be none-zero + uint32_t sessionId = generateSessionId(); + LOC_LOGd("session id %u", sessionId); + + struct MsgEnablePACE : public LocMsg { + GnssAdapter& mAdapter; + uint32_t mSessionId; + bool mEnable; + inline MsgEnablePACE(GnssAdapter& adapter, + uint32_t sessionId, bool enable) : + LocMsg(), + mAdapter(adapter), + mSessionId(sessionId), + mEnable(enable){} + inline virtual void proc() const { + mAdapter.setPositionAssistedClockEstimator(mEnable, mSessionId); + } + }; + + sendMsg(new MsgEnablePACE(*this, sessionId, enable)); + return sessionId; +} + +void +GnssAdapter::updateSvConfig(uint32_t sessionId, + const GnssSvTypeConfig& svTypeConfig, + const GnssSvIdConfig& svIdConfig) { + + // check whether if any constellation is removed from the new config + GnssSvTypesMask enabledRemoved = mGnssSvTypeConfig.enabledSvTypesMask & + (mGnssSvTypeConfig.enabledSvTypesMask ^ svTypeConfig.enabledSvTypesMask); + // Send reset if any constellation is removed from the enabled list + if (enabledRemoved != 0) { + mLocApi->resetConstellationControl(); + } + + mGnssSvTypeConfig = svTypeConfig; + mGnssSvIdConfig = svIdConfig; + + // Send blacklist info + mLocApi->setBlacklistSv(mGnssSvIdConfig); + + // Send only enabled constellation config + GnssSvTypeConfig svTypeConfigCopy = {sizeof(GnssSvTypeConfig), 0, 0}; + svTypeConfigCopy.enabledSvTypesMask = mGnssSvTypeConfig.enabledSvTypesMask; + LocApiResponse* locApiResponse = new LocApiResponse(*getContext(), + [this, sessionId] (LocationError err) { + reportResponse(err, sessionId);}); + if (!locApiResponse) { + LOC_LOGe("memory alloc failed"); + } + mLocApi->setConstellationControl(svTypeConfigCopy, locApiResponse); +} + +uint32_t GnssAdapter::gnssUpdateSvConfigCommand( + const GnssSvTypeConfig& svTypeConfig, + const GnssSvIdConfig& svIdConfig) { + + // generated session id will be none-zero + uint32_t sessionId = generateSessionId(); + LOC_LOGd("session id %u", sessionId); + + struct MsgUpdateSvConfig : public LocMsg { + GnssAdapter& mAdapter; + uint32_t mSessionId; + GnssSvTypeConfig mSvTypeConfig; + GnssSvIdConfig mSvIdConfig; + + inline MsgUpdateSvConfig(GnssAdapter& adapter, + uint32_t sessionId, + const GnssSvTypeConfig& svTypeConfig, + const GnssSvIdConfig& svIdConfig) : + LocMsg(), + mAdapter(adapter), + mSessionId(sessionId), + mSvTypeConfig(svTypeConfig), + mSvIdConfig(svIdConfig) {} + inline virtual void proc() const { + mAdapter.updateSvConfig(mSessionId, mSvTypeConfig, mSvIdConfig); + } + }; + + if (sessionId != 0) { + sendMsg(new MsgUpdateSvConfig(*this, sessionId, + svTypeConfig, svIdConfig)); + } + return sessionId; +} + +void +GnssAdapter::resetSvConfig(uint32_t sessionId) { + + LocApiResponse* locApiResponse = nullptr; + if (sessionId != 0) { + locApiResponse = + new LocApiResponse(*getContext(), + [this, sessionId] (LocationError err) { + reportResponse(err, sessionId);}); + if (!locApiResponse) { + LOC_LOGe("memory alloc failed"); + } + } + mLocApi->resetConstellationControl(locApiResponse); +} + +uint32_t GnssAdapter::gnssResetSvConfigCommand() { + + // generated session id will be none-zero + uint32_t sessionId = generateSessionId(); + LOC_LOGd("session id %u", sessionId); + + struct MsgResetSvConfig : public LocMsg { + GnssAdapter& mAdapter; + uint32_t mSessionId; + + inline MsgResetSvConfig(GnssAdapter& adapter, + uint32_t sessionId) : + LocMsg(), + mAdapter(adapter), + mSessionId(sessionId) {} + inline virtual void proc() const { + mAdapter.resetSvConfig(mSessionId); + } + }; + + sendMsg(new MsgResetSvConfig(*this, sessionId)); + return sessionId; +} + +void +GnssAdapter::configLeverArm(uint32_t sessionId, + const LeverArmConfigInfo& configInfo) { + + LocationError err = LOCATION_ERROR_NOT_SUPPORTED; + if (true == mEngHubProxy->configLeverArm(configInfo)) { + err = LOCATION_ERROR_SUCCESS; + } + reportResponse(err, sessionId); +} + +uint32_t +GnssAdapter::configLeverArmCommand(const LeverArmConfigInfo& configInfo) { + + // generated session id will be none-zero + uint32_t sessionId = generateSessionId(); + LOC_LOGd("session id %u", sessionId); + + struct MsgConfigLeverArm : public LocMsg { + GnssAdapter& mAdapter; + uint32_t mSessionId; + LeverArmConfigInfo mConfigInfo; + + inline MsgConfigLeverArm(GnssAdapter& adapter, + uint32_t sessionId, + const LeverArmConfigInfo& configInfo) : + LocMsg(), + mAdapter(adapter), + mSessionId(sessionId), + mConfigInfo(configInfo) {} + inline virtual void proc() const { + mAdapter.configLeverArm(mSessionId, mConfigInfo); + } + }; + + sendMsg(new MsgConfigLeverArm(*this, sessionId, configInfo)); + return sessionId; +} + /* ==== Eng Hub Proxy ================================================================= */ /* ======== UTILITIES ================================================================= */ void diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h index 37a4892d..ff8131ff 100644 --- a/gnss/GnssAdapter.h +++ b/gnss/GnssAdapter.h @@ -122,6 +122,23 @@ typedef struct { double latLonDiffThreshold; } BlockCPIInfo; +typedef struct { + bool isValid; + bool enable; + float tuncThresholdMs; // need to be specified if enable is true + uint32_t energyBudget; // need to be specified if enable is true +} TuncConfigInfo; + +typedef struct { + bool isValid; + bool enable; +} PaceConfigInfo; + +typedef struct { + TuncConfigInfo tuncConfigInfo; + PaceConfigInfo paceConfigInfo; +} LocIntegrationConfigInfo; + using namespace loc_core; namespace loc_core { @@ -158,6 +175,7 @@ class GnssAdapter : public LocAdapterBase { GnssSvTypeConfig mGnssSvTypeConfig; GnssSvTypeConfigCallback mGnssSvTypeConfigCb; bool mSupportNfwControl; + LocIntegrationConfigInfo mLocConfigInfo; /* ==== NI ============================================================================= */ NiData mNiData; @@ -270,6 +288,14 @@ public: const TrackingOptions& updatedOptions, const TrackingOptions& oldOptions); bool checkAndSetSPEToRunforNHz(TrackingOptions & out); + void setConstrainedTunc(bool enable, float tuncConstraint, + uint32_t energyBudget, uint32_t sessionId); + void setPositionAssistedClockEstimator(bool enable, uint32_t sessionId); + void updateSvConfig(uint32_t sessionId, const GnssSvTypeConfig& svTypeConfig, + const GnssSvIdConfig& svIdConfig); + void resetSvConfig(uint32_t sessionId); + void configLeverArm(uint32_t sessionId, const LeverArmConfigInfo& configInfo); + /* ==== NI ============================================================================= */ /* ======== COMMANDS ====(Called from Client Thread)==================================== */ void gnssNiResponseCommand(LocationAPI* client, uint32_t id, GnssNiResponse response); @@ -329,6 +355,13 @@ public: void dataConnFailedCommand(AGpsExtType agpsType); void getGnssEnergyConsumedCommand(GnssEnergyConsumedCallback energyConsumedCb); void nfwControlCommand(bool enable); + uint32_t setConstrainedTuncCommand (bool enable, float tuncConstraint, + uint32_t energyBudget); + uint32_t setPositionAssistedClockEstimatorCommand (bool enable); + uint32_t gnssUpdateSvConfigCommand(const GnssSvTypeConfig& svTypeConfig, + const GnssSvIdConfig& svIdConfig); + uint32_t gnssResetSvConfigCommand(); + uint32_t configLeverArmCommand(const LeverArmConfigInfo& configInfo); /* ========= ODCPI ===================================================================== */ /* ======== COMMANDS ====(Called from Client Thread)==================================== */ diff --git a/gnss/location_gnss.cpp b/gnss/location_gnss.cpp index 5380f05a..97e99e42 100644 --- a/gnss/location_gnss.cpp +++ b/gnss/location_gnss.cpp @@ -80,6 +80,13 @@ static void blockCPI(double latitude, double longitude, float accuracy, int blockDurationMsec, double latLonDiffThreshold); static void updateBatteryStatus(bool charging); static void updateSystemPowerState(PowerStateType systemPowerState); +static uint32_t setConstrainedTunc (bool enable, float tuncConstraint, + uint32_t energyBudget); +static uint32_t setPositionAssistedClockEstimator(bool enable); +static uint32_t gnssUpdateSvConfig(const GnssSvTypeConfig& svTypeConfig, + const GnssSvIdConfig& svIdConfig); +static uint32_t gnssResetSvConfig(); +static uint32_t configLeverArm(const LeverArmConfigInfo& configInfo); static const GnssInterface gGnssInterface = { sizeof(GnssInterface), @@ -119,7 +126,12 @@ static const GnssInterface gGnssInterface = { getPowerStateChanges, injectLocationExt, updateBatteryStatus, - updateSystemPowerState + updateSystemPowerState, + setConstrainedTunc, + setPositionAssistedClockEstimator, + gnssUpdateSvConfig, + gnssResetSvConfig, + configLeverArm, }; #ifndef DEBUG_X86 @@ -398,3 +410,46 @@ static void updateSystemPowerState(PowerStateType systemPowerState) { gGnssAdapter->updateSystemPowerStateCommand(systemPowerState); } } + +static uint32_t setConstrainedTunc (bool enable, float tuncConstraint, uint32_t energyBudget) { + if (NULL != gGnssAdapter) { + return gGnssAdapter->setConstrainedTuncCommand(enable, tuncConstraint, energyBudget); + } else { + return 0; + } +} + +static uint32_t setPositionAssistedClockEstimator(bool enable) { + if (NULL != gGnssAdapter) { + return gGnssAdapter->setPositionAssistedClockEstimatorCommand(enable); + } else { + return 0; + } +} + +static uint32_t gnssUpdateSvConfig( + const GnssSvTypeConfig& svTypeConfig, + const GnssSvIdConfig& svIdConfig) { + if (NULL != gGnssAdapter) { + return gGnssAdapter->gnssUpdateSvConfigCommand( + svTypeConfig, svIdConfig); + } else { + return 0; + } +} + +static uint32_t gnssResetSvConfig() { + if (NULL != gGnssAdapter) { + return gGnssAdapter->gnssResetSvConfigCommand(); + } else { + return 0; + } +} + +static uint32_t configLeverArm(const LeverArmConfigInfo& configInfo){ + if (NULL != gGnssAdapter) { + return gGnssAdapter->configLeverArmCommand(configInfo); + } else { + return 0; + } +} diff --git a/location/ILocationAPI.h b/location/ILocationAPI.h index 3df6f799..87aa99bd 100644 --- a/location/ILocationAPI.h +++ b/location/ILocationAPI.h @@ -189,6 +189,119 @@ public: LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid LOCATION_ERROR_NOT_SUPPORTED if build is not userdebug */ virtual uint32_t gnssDeleteAidingData(GnssAidingData& data) = 0; + + /** @brief + Reset the constellation settings to modem default. + + @param + None + + @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 resetConstellationConfig() = 0; + + /** @brief + Configure the constellation to be used by the GNSS engine on + modem. + + @param + constellationConfig: specify the constellation configuration + used by GNSS engine. + + @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 configConstellations( + const GnssSvTypeConfig& svTypeConfig, + const GnssSvIdConfig& svIdConfig) = 0; + + /** @brief + Enable or disable the constrained time uncertainty feature. + + @param + enable: true to enable the constrained time uncertainty + feature and false to disable the constrainted time + uncertainty feature. + + @param + tuncThreshold: this specifies the time uncertainty threshold + that gps engine need to maintain, in units of milli-seconds. + Default is 0.0 meaning that modem default value of time + uncertainty threshold will be used. This parameter is + ignored when requesting to disable this feature. + + @param + energyBudget: this specifies the power budget that gps + engine is allowed to spend to maintain the time uncertainty. + Default is 0 meaning that GPS engine is not constained by + power budget and can spend as much power as needed. The + parameter need to be specified in units of 0.1 milli watt + second. This parameter is ignored requesting to disable this + feature. + + @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 configConstrainedTimeUncertainty( + bool enable, float tuncThreshold = 0.0, + uint32_t energyBudget = 0) = 0; + + /** @brief + Enable or disable position assisted clock estimator feature. + + @param + enable: true to enable position assisted clock estimator and + false to disable the position assisted clock estimator + feature. + + @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 configPositionAssistedClockEstimator(bool enable) = 0; + + /** @brief + Sets the lever arm parameters for the vehicle. + + @param + configInfo: lever arm configuration info regarding below two + types of lever arm info: + a: GNSS Antenna w.r.t the origin at the IMU e.g.: inertial + measurement unit. + b: lever arm parameters regarding the OPF (output frame) + w.r.t the origin (at the GPS Antenna). Vehicle manufacturers + prefer the position output to be tied to a specific point in + the vehicle rather than where the antenna is placed + (midpoint of the rear axle is typical). + + Caller can choose types of lever arm info to configure via the + leverMarkTypeMask. + + @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 configLeverArm(const LeverArmConfigInfo& configInfo) = 0; }; #endif /* ILOCATIONAPI_H */ diff --git a/location/LocationAPI.cpp b/location/LocationAPI.cpp index 4348c276..7c125b81 100644 --- a/location/LocationAPI.cpp +++ b/location/LocationAPI.cpp @@ -723,3 +723,79 @@ LocationControlAPI::gnssDeleteAidingData(GnssAidingData& data) pthread_mutex_unlock(&gDataMutex); return id; } + +uint32_t LocationControlAPI::resetConstellationConfig() { + uint32_t id = 0; + pthread_mutex_lock(&gDataMutex); + + if (gData.gnssInterface != NULL) { + id = gData.gnssInterface->gnssResetSvConfig(); + } else { + LOC_LOGe("No gnss interface available for Location Control API"); + } + + pthread_mutex_unlock(&gDataMutex); + return id; +} + +uint32_t LocationControlAPI::configConstellations( + const GnssSvTypeConfig& svTypeConfig, + const GnssSvIdConfig& svIdConfig) { + uint32_t id = 0; + pthread_mutex_lock(&gDataMutex); + + if (gData.gnssInterface != NULL) { + id = gData.gnssInterface->gnssUpdateSvConfig( + svTypeConfig, svIdConfig); + } else { + LOC_LOGe("No gnss interface available for Location Control API"); + } + + pthread_mutex_unlock(&gDataMutex); + return id; +} + +uint32_t LocationControlAPI::configConstrainedTimeUncertainty( + bool enable, float tuncThreshold, uint32_t energyBudget) { + uint32_t id = 0; + pthread_mutex_lock(&gDataMutex); + + if (gData.gnssInterface != NULL) { + id = gData.gnssInterface->setConstrainedTunc(enable, + tuncThreshold, + energyBudget); + } else { + LOC_LOGe("No gnss interface available for Location Control API"); + } + + pthread_mutex_unlock(&gDataMutex); + return id; +} + +uint32_t LocationControlAPI::configPositionAssistedClockEstimator(bool enable) { + uint32_t id = 0; + pthread_mutex_lock(&gDataMutex); + + if (gData.gnssInterface != NULL) { + id = gData.gnssInterface->setPositionAssistedClockEstimator(enable); + } else { + LOC_LOGe("No gnss interface available for Location Control API"); + } + + pthread_mutex_unlock(&gDataMutex); + return id; +} + +uint32_t LocationControlAPI::configLeverArm(const LeverArmConfigInfo& configInfo) { + uint32_t id = 0; + pthread_mutex_lock(&gDataMutex); + + if (gData.gnssInterface != NULL) { + id = gData.gnssInterface->configLeverArm(configInfo); + } else { + LOC_LOGe("No gnss interface available for Location Control API"); + } + + pthread_mutex_unlock(&gDataMutex); + return id; +} diff --git a/location/LocationAPI.h b/location/LocationAPI.h index 6f5987ca..f70fc2f8 100644 --- a/location/LocationAPI.h +++ b/location/LocationAPI.h @@ -261,6 +261,119 @@ public: LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid LOCATION_ERROR_NOT_SUPPORTED if build is not userdebug */ virtual uint32_t gnssDeleteAidingData(GnssAidingData& data) override; + + /** @brief + Reset the constellation settings to modem default. + + @param + None + + @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 resetConstellationConfig() override; + + /** @brief + Configure the constellation to be used by the GNSS engine on + modem. + + @param + constellationConfig: specify the constellation configuration + used by GNSS engine. + + @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 configConstellations( + const GnssSvTypeConfig& svTypeConfig, + const GnssSvIdConfig& svIdConfig) override; + + /** @brief + Enable or disable the constrained time uncertainty feature. + + @param + enable: true to enable the constrained time uncertainty + feature and false to disable the constrainted time + uncertainty feature. + + @param + tuncThreshold: this specifies the time uncertainty threshold + that gps engine need to maintain, in units of milli-seconds. + Default is 0.0 meaning that modem default value of time + uncertainty threshold will be used. This parameter is + ignored when requesting to disable this feature. + + @param + energyBudget: this specifies the power budget that gps + engine is allowed to spend to maintain the time uncertainty. + Default is 0 meaning that GPS engine is not constained by + power budget and can spend as much power as needed. The + parameter need to be specified in units of 0.1 milli watt + second. This parameter is ignored requesting to disable this + feature. + + @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 configConstrainedTimeUncertainty( + bool enable, float tuncThreshold = 0.0, + uint32_t energyBudget = 0) override; + + /** @brief + Enable or disable position assisted clock estimator feature. + + @param + enable: true to enable position assisted clock estimator and + false to disable the position assisted clock estimator + feature. + + @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 configPositionAssistedClockEstimator(bool enable) override; + + /** @brief + Sets the lever arm parameters for the vehicle. + + @param + configInfo: lever arm configuration info regarding below two + types of lever arm info: + a: GNSS Antenna w.r.t the origin at the IMU e.g.: inertial + measurement unit. + b: lever arm parameters regarding the OPF (output frame) + w.r.t the origin (at the GPS Antenna). Vehicle manufacturers + prefer the position output to be tied to a specific point in + the vehicle rather than where the antenna is placed + (midpoint of the rear axle is typical). + + Caller can choose types of lever arm info to configure via the + leverMarkTypeMask. + + @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 configLeverArm(const LeverArmConfigInfo& configInfo) override; }; #endif /* LOCATIONAPI_H */ diff --git a/location/LocationDataTypes.h b/location/LocationDataTypes.h index 956754ad..f36d9c19 100644 --- a/location/LocationDataTypes.h +++ b/location/LocationDataTypes.h @@ -658,6 +658,8 @@ typedef enum { DEAD_RECKONING_ENGINE = (1 << 1), PRECISE_POSITIONING_ENGINE = (1 << 2) } PositioningEngineBits; +#define POSITION_ENGINE_MASK_ALL \ + (STANDARD_POSITIONING_ENGINE|DEAD_RECKONING_ENGINE|PRECISE_POSITIONING_ENGINE) typedef uint64_t GnssDataMask; typedef enum { @@ -1186,6 +1188,13 @@ typedef struct { // GAL - SV 301 maps to bit 0 #define GNSS_SV_CONFIG_GAL_INITIAL_SV_ID 301 uint64_t galBlacklistSvMask; + + // 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 + uint64_t sbasBlacklistSvMask; } GnssSvIdConfig; struct GnssConfig{ @@ -1313,6 +1322,66 @@ struct LocationSystemInfo { LeapSecondSystemInfo leapSecondSysInfo; }; +/* Mask indicating enabled or disabled constellations */ +typedef uint64_t GnssSvTypesMask; +typedef enum { + GNSS_SV_TYPES_MASK_GLO_BIT = (1<<0), + GNSS_SV_TYPES_MASK_BDS_BIT = (1<<1), + GNSS_SV_TYPES_MASK_QZSS_BIT = (1<<2), + GNSS_SV_TYPES_MASK_GAL_BIT = (1<<3), + GNSS_SV_TYPES_MASK_NAVIC_BIT = (1<<4), +} GnssSvTypesMaskBits; + +/* This SV Type config is injected directly to GNSS Adapter + * bypassing Location API */ +typedef struct { + uint32_t size; // set to sizeof(GnssSvTypeConfig) + // Enabled Constellations + GnssSvTypesMask enabledSvTypesMask; + // Disabled Constellations + GnssSvTypesMask blacklistedSvTypesMask; +} GnssSvTypeConfig; + +// Specify parameters related to lever arm +struct LeverArmParams { + // Offset along the vehicle forward axis + float forwardOffsetMeters; + // Offset along the vehicle starboard axis + float sidewaysOffsetMeters; + // Offset along the vehicle up axis + float upOffsetMeters; +}; + +typedef uint32_t LeverArmTypeMask; + +enum LeverArmTypeBits { + // Lever arm regarding the VRP (Vehicle Reference Point) w.r.t + // the origin (at the GPS Antenna) + LEVER_ARM_TYPE_GNSS_TO_VRP_BIT = (1<<0), + // Lever arm regarding GNSS Antenna w.r.t the origin at the IMU + // e.g.: inertial measurement unit for DR (dead reckoning + // engine) + LEVER_ARM_TYPE_DR_IMU_TO_GNSS_BIT = (1<<1), + // Lever arm regarding GNSS Antenna w.r.t the origin at the + // IMU (inertial measurement unit) for VEPP (vision enhanced + // precise positioning engine) + LEVER_ARM_TYPE_VEPP_IMU_TO_GNSS_BIT = (1<<2) +}; + +struct LeverArmConfigInfo { + // Valid mask for the types of lever arm parameters provided + LeverArmTypeMask leverArmValidMask; + // Lever arm regarding the VRP (Vehicle Reference Point) w.r.t the origin + // (at the GPS Antenna) + LeverArmParams gnssToVRP; + // Lever arm parameters regarding GNSS Antenna w.r.t the origin at the IMU + // (inertial measurement unit) for DR (dead reckoning engine) + LeverArmParams drImuToGnss; + // Lever arm regarding GNSS Antenna w.r.t the origin at the IMU + // (inertial measurement unit) for VEPP (vision enhanced precise position engine) + LeverArmParams veppImuToGnss; +}; + /* Provides the capabilities of the system capabilities callback is called once soon after createInstance is called */ typedef std::function