From 61b7ed6bf0718c2b4a93350f130e8b13f980c823 Mon Sep 17 00:00:00 2001 From: Dante Russo Date: Wed, 15 May 2019 15:08:30 -0700 Subject: Fix few ASAN issues reported - Fix a Use After Free issue in Gnss Update Config If Engine Capabilities are not known yet at the time of the MsgGnssUpdateConfig, the ids arrray will be freed but the ids pointer will be copied into a new MsgGnssUpdateConfig that will access the ids array again - Issue in NetworkInfoDataItemBase which will result in array out of bound access which might result in heap buffer overflow. Change-Id: Ib5a6dc29fef9eb6676d4605f92d60f26a47d1d90 CRs-fixed: 2449980 --- core/data-items/DataItemConcreteTypesBase.h | 2 +- gnss/GnssAdapter.cpp | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/core/data-items/DataItemConcreteTypesBase.h b/core/data-items/DataItemConcreteTypesBase.h index 552d46a..a6e68f1 100644 --- a/core/data-items/DataItemConcreteTypesBase.h +++ b/core/data-items/DataItemConcreteTypesBase.h @@ -249,7 +249,7 @@ public: mId(NETWORKINFO_DATA_ITEM_ID) { memset (&mAllNetworkHandles, NETWORK_HANDLE_UNKNOWN, sizeof (mAllNetworkHandles)); - mAllNetworkHandles[type] = networkHandle; + mAllNetworkHandles[initialType] = networkHandle; } virtual ~NetworkInfoDataItemBase() {} inline virtual DataItemId getId() { return mId; } diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index e1143fd..6558714 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -997,9 +997,18 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config) mConfig(config), mCount(count), mIds(ids) {} + inline MsgGnssUpdateConfig(const MsgGnssUpdateConfig& obj) : + MsgGnssUpdateConfig(obj.mAdapter, obj.mApi, obj.mConfig, + new uint32_t[obj.mCount], obj.mCount) { + if (mIds != nullptr) { + for (int i = 0; i < mCount; ++i) { + mIds[i] = obj.mIds[i]; + } + } + } inline virtual ~MsgGnssUpdateConfig() { - delete [] mIds; + delete[] mIds; } inline virtual void proc() const { @@ -1257,6 +1266,16 @@ GnssAdapter::gnssGetConfigCommand(GnssConfigFlagsMask configMask) { mConfigMask(configMask), mIds(ids), mCount(count) {} + + inline MsgGnssGetConfig(const MsgGnssGetConfig& obj) : + MsgGnssGetConfig(obj.mAdapter, obj.mApi, obj.mConfigMask, + new uint32_t[obj.mCount], obj.mCount) { + if (mIds != nullptr) { + for (int i = 0; i < mCount; ++i) { + mIds[i] = obj.mIds[i]; + } + } + } inline virtual ~MsgGnssGetConfig() { delete[] mIds; -- cgit v1.2.3 From 02e5413b20c3dc0e3cbef6b77e400add6b451d12 Mon Sep 17 00:00:00 2001 From: Mike Cailean Date: Thu, 16 May 2019 15:35:00 -0700 Subject: Send updated GPS lock value to xtra-daemon Send updated (masked) GPS lock value to xtra-daemon CRs-Fixed: 2454370 Change-Id: I17439a2aa10d776cff882a4fb09224489b86c796 --- gnss/XtraSystemStatusObserver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnss/XtraSystemStatusObserver.cpp b/gnss/XtraSystemStatusObserver.cpp index 4cb6f5f..af593fb 100644 --- a/gnss/XtraSystemStatusObserver.cpp +++ b/gnss/XtraSystemStatusObserver.cpp @@ -123,7 +123,7 @@ bool XtraSystemStatusObserver::updateLockStatus(GnssConfigGpsLock lock) { stringstream ss; ss << "gpslock"; - ss << " " << lock; + ss << " " << mGpsLock; string s = ss.str(); return ( LocIpc::send(*mSender, (const uint8_t*)s.data(), s.size()) ); } -- cgit v1.2.3 From 210d3ca227393a46829988577aea95ec2e800c41 Mon Sep 17 00:00:00 2001 From: Nilesh Gharde Date: Thu, 16 May 2019 23:57:46 +0530 Subject: Addressing format related to formating Added formating related issue as genuine errors fixes Change-Id: Ie01e9ce3bf838a37871a4779ae1403b4dca3d87c CRs-Fixed: 2447200 --- android/2.0/GnssConfiguration.cpp | 2 +- android/2.0/location_api/GeofenceAPIClient.cpp | 2 +- android/2.0/location_api/GnssAPIClient.cpp | 6 +++--- android/2.0/location_api/MeasurementAPIClient.cpp | 2 +- build/target_specific_features.mk | 1 - core/LocApiBase.cpp | 2 +- pla/Android.mk | 1 - utils/LocIpc.cpp | 4 ++-- utils/LocIpc.h | 2 +- 9 files changed, 10 insertions(+), 12 deletions(-) diff --git a/android/2.0/GnssConfiguration.cpp b/android/2.0/GnssConfiguration.cpp index 671b6e7..d2a8763 100644 --- a/android/2.0/GnssConfiguration.cpp +++ b/android/2.0/GnssConfiguration.cpp @@ -255,7 +255,7 @@ bool GnssConfiguration::setBlacklistedSource( break; default: copyToSource.constellation = GNSS_SV_TYPE_UNKNOWN; - LOC_LOGe("Invalid constellation %u", copyFromSource.constellation); + LOC_LOGe("Invalid constellation %hhu", copyFromSource.constellation); retVal = false; break; } diff --git a/android/2.0/location_api/GeofenceAPIClient.cpp b/android/2.0/location_api/GeofenceAPIClient.cpp index fabf8bb..a93c988 100644 --- a/android/2.0/location_api/GeofenceAPIClient.cpp +++ b/android/2.0/location_api/GeofenceAPIClient.cpp @@ -141,7 +141,7 @@ void GeofenceAPIClient::geofenceRemoveAll() // callbacks void GeofenceAPIClient::onGeofenceBreachCb(GeofenceBreachNotification geofenceBreachNotification) { - LOC_LOGD("%s]: (%zu)", __FUNCTION__, geofenceBreachNotification.count); + LOC_LOGD("%s]: (%d)", __FUNCTION__, geofenceBreachNotification.count); if (mGnssGeofencingCbIface != nullptr) { for (size_t i = 0; i < geofenceBreachNotification.count; i++) { GnssLocation gnssLocation; diff --git a/android/2.0/location_api/GnssAPIClient.cpp b/android/2.0/location_api/GnssAPIClient.cpp index 68cf395..15245e3 100644 --- a/android/2.0/location_api/GnssAPIClient.cpp +++ b/android/2.0/location_api/GnssAPIClient.cpp @@ -517,7 +517,7 @@ void GnssAPIClient::onGnssNiCb(uint32_t id, GnssNiNotification gnssNiNotificatio void GnssAPIClient::onGnssSvCb(GnssSvNotification gnssSvNotification) { - LOC_LOGD("%s]: (count: %zu)", __FUNCTION__, gnssSvNotification.count); + LOC_LOGD("%s]: (count: %u)", __FUNCTION__, gnssSvNotification.count); mMutex.lock(); auto gnssCbIface(mGnssCbIface); auto gnssCbIface_2_0(mGnssCbIface_2_0); @@ -561,7 +561,7 @@ void GnssAPIClient::onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification) auto r = gnssCbIface_2_0->gnssNmeaCb( static_cast(gnssNmeaNotification.timestamp), nmeaString); if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssCbIface_2_0 nmea=%s length=%zu description=%s", + LOC_LOGE("%s] Error from gnssCbIface_2_0 nmea=%s length=%u description=%s", __func__, gnssNmeaNotification.nmea, gnssNmeaNotification.length, r.description().c_str()); } @@ -569,7 +569,7 @@ void GnssAPIClient::onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification) auto r = gnssCbIface->gnssNmeaCb( static_cast(gnssNmeaNotification.timestamp), nmeaString); if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssNmeaCb nmea=%s length=%zu description=%s", + LOC_LOGE("%s] Error from gnssNmeaCb nmea=%s length=%u description=%s", __func__, gnssNmeaNotification.nmea, gnssNmeaNotification.length, r.description().c_str()); } diff --git a/android/2.0/location_api/MeasurementAPIClient.cpp b/android/2.0/location_api/MeasurementAPIClient.cpp index 23c3b16..eb0c7d1 100644 --- a/android/2.0/location_api/MeasurementAPIClient.cpp +++ b/android/2.0/location_api/MeasurementAPIClient.cpp @@ -170,7 +170,7 @@ void MeasurementAPIClient::measurementClose() { void MeasurementAPIClient::onGnssMeasurementsCb( GnssMeasurementsNotification gnssMeasurementsNotification) { - LOC_LOGD("%s]: (count: %zu active: %d)", + LOC_LOGD("%s]: (count: %u active: %d)", __FUNCTION__, gnssMeasurementsNotification.count, mTracking); if (mTracking) { mMutex.lock(); diff --git a/build/target_specific_features.mk b/build/target_specific_features.mk index ad7f7e1..ca6eb79 100644 --- a/build/target_specific_features.mk +++ b/build/target_specific_features.mk @@ -1,7 +1,6 @@ GNSS_CFLAGS := \ -Werror \ -Wno-error=unused-parameter \ - -Wno-error=format \ -Wno-error=macro-redefined \ -Wno-error=reorder \ -Wno-error=missing-braces \ diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp index c172376..a521ceb 100644 --- a/core/LocApiBase.cpp +++ b/core/LocApiBase.cpp @@ -404,7 +404,7 @@ void LocApiBase::reportSv(GnssSvNotification& svNotify) "QZSS", "BEIDOU", "GALILEO" }; // print the SV info before delivering - LOC_LOGV("num sv: %zu\n" + LOC_LOGV("num sv: %u\n" " sv: constellation svid cN0" " elevation azimuth flags", svNotify.count); diff --git a/pla/Android.mk b/pla/Android.mk index ce062bb..a57861d 100644 --- a/pla/Android.mk +++ b/pla/Android.mk @@ -1,7 +1,6 @@ GNSS_CFLAGS := \ -Werror \ -Wno-error=unused-parameter \ - -Wno-error=format \ -Wno-error=macro-redefined \ -Wno-error=reorder \ -Wno-error=missing-braces \ diff --git a/utils/LocIpc.cpp b/utils/LocIpc.cpp index ecaff01..9496895 100644 --- a/utils/LocIpc.cpp +++ b/utils/LocIpc.cpp @@ -48,7 +48,7 @@ namespace loc_util { #define SOCK_OP_AND_LOG(buf, length, opable, rtv, exe) \ if (nullptr == (buf) || 0 == (length)) { \ - LOC_LOGe("Invalid inputs: buf - %p, length - %d", (buf), (length)); \ + LOC_LOGe("Invalid inputs: buf - %p, length - %u", (buf), (length)); \ } else if (!(opable)) { \ LOC_LOGe("Invalid object: operable - %d", (opable)); \ } else { \ @@ -60,7 +60,7 @@ namespace loc_util { const char Sock::MSG_ABORT[] = "LocIpc::Sock::ABORT"; const char Sock::LOC_IPC_HEAD[] = "$MSGLEN$"; -ssize_t Sock::send(const void *buf, size_t len, int flags, const struct sockaddr *destAddr, +ssize_t Sock::send(const void *buf, uint32_t len, int flags, const struct sockaddr *destAddr, socklen_t addrlen) const { ssize_t rtv = -1; SOCK_OP_AND_LOG(buf, len, isValid(), rtv, sendto(buf, len, flags, destAddr, addrlen)); diff --git a/utils/LocIpc.h b/utils/LocIpc.h index 20a1c8f..c71c4e0 100644 --- a/utils/LocIpc.h +++ b/utils/LocIpc.h @@ -164,7 +164,7 @@ public: inline Sock(int sid, const uint32_t maxTxSize = 8192) : mMaxTxSize(maxTxSize), mSid(sid) {} inline ~Sock() { close(); } inline bool isValid() const { return -1 != mSid; } - ssize_t send(const void *buf, size_t len, int flags, const struct sockaddr *destAddr, + ssize_t send(const void *buf, uint32_t len, int flags, const struct sockaddr *destAddr, socklen_t addrlen) const; ssize_t recv(const shared_ptr& dataCb, int flags, struct sockaddr *srcAddr, socklen_t *addrlen, int sid = -1) const; -- cgit v1.2.3 From 7490804ed9bcf7a2b9c371988466d22b1f659382 Mon Sep 17 00:00:00 2001 From: Kevin Tang Date: Fri, 17 May 2019 18:04:32 -0700 Subject: fixed a potential race condition in managing gps lock gnssConfigRequested in setConfigCommand handling currently gets data into gnssConfigRequested in LocApi thread. This introduces race condition that adapter.getAfwControlId() could be called from a different thread than where adapter.setAfwControlId() is called. CRs-fixed: 2453439 Change-Id: I75ce482a4a87436dff04972ffd82b48db3af62c1 --- gnss/GnssAdapter.cpp | 171 ++++++++++++++++++++++++++------------------------- 1 file changed, 86 insertions(+), 85 deletions(-) diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 7253efe..535f6de 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -714,90 +714,91 @@ GnssAdapter::setConfigCommand() loc_gps_cfg_s gpsConf = ContextBase::mGps_conf; loc_sap_cfg_s_type sapConf = ContextBase::mSap_conf; - mApi.sendMsg(new LocApiMsg( - [&adapter, gpsConf, sapConf, oldServerUrl, oldMoServerUrl] () { - //cache the injected configuration with GnssConfigRequested struct - GnssConfig gnssConfigRequested = {}; - gnssConfigRequested.flags |= GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT | - GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT | - GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT | - GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT; - gnssConfigRequested.gpsLock = GNSS_CONFIG_GPS_LOCK_NONE; - if (0 == adapter.getAfwControlId() || NULL != adapter.mNfwCb) { - gnssConfigRequested.gpsLock = gpsConf.GPS_LOCK; - } - - if (gpsConf.AGPS_CONFIG_INJECT) { - gnssConfigRequested.flags |= GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT | - GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT | - GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT | - GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT; - gnssConfigRequested.suplVersion = - adapter.mLocApi->convertSuplVersion(gpsConf.SUPL_VER); - gnssConfigRequested.lppProfile = - adapter.mLocApi->convertLppProfile(gpsConf.LPP_PROFILE); - gnssConfigRequested.aGlonassPositionProtocolMask = - gpsConf.A_GLONASS_POS_PROTOCOL_SELECT; - } - gnssConfigRequested.lppeControlPlaneMask = - adapter.mLocApi->convertLppeCp(gpsConf.LPPE_CP_TECHNOLOGY); - gnssConfigRequested.lppeUserPlaneMask = - adapter.mLocApi->convertLppeUp(gpsConf.LPPE_UP_TECHNOLOGY); - gnssConfigRequested.blacklistedSvIds.assign(adapter.mBlacklistedSvIds.begin(), - adapter.mBlacklistedSvIds.end()); - adapter.gnssUpdateConfig(oldServerUrl, oldMoServerUrl, gnssConfigRequested, - gnssConfigRequested); - - // set nmea mask type - uint32_t mask = 0; - if (NMEA_PROVIDER_MP == gpsConf.NMEA_PROVIDER) { - mask |= LOC_NMEA_ALL_GENERAL_SUPPORTED_MASK; - } - if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_DEBUG_NMEA_V02)) { - mask |= LOC_NMEA_MASK_DEBUG_V02; - } - - if (mask != 0) { - adapter.mLocApi->setNMEATypesSync(mask); - } - - adapter.mLocApi->setXtraVersionCheckSync(gpsConf.XTRA_VERSION_CHECK); - - adapter.mLocApi->setConstrainedTuncMode( - gpsConf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED == 1, - (float)gpsConf.CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD, - gpsConf.CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET); - adapter.mLocApi->setPositionAssistedClockEstimatorMode( - gpsConf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED == 1); - - if (sapConf.GYRO_BIAS_RANDOM_WALK_VALID || - sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID || - sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID || - sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID || - sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID ) { - adapter.mLocApi->setSensorPropertiesSync( - sapConf.GYRO_BIAS_RANDOM_WALK_VALID, - sapConf.GYRO_BIAS_RANDOM_WALK, - sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID, - sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY, - sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, - sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY, - sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, - sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY, - sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID, - sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY); - } - adapter.mLocApi->setSensorPerfControlConfigSync( - sapConf.SENSOR_CONTROL_MODE, - sapConf.SENSOR_ACCEL_SAMPLES_PER_BATCH, - sapConf.SENSOR_ACCEL_BATCHES_PER_SEC, - sapConf.SENSOR_GYRO_SAMPLES_PER_BATCH, - sapConf.SENSOR_GYRO_BATCHES_PER_SEC, - sapConf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH, - sapConf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH, - sapConf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH, - sapConf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH, - sapConf.SENSOR_ALGORITHM_CONFIG_MASK); + //cache the injected configuration with GnssConfigRequested struct + GnssConfig gnssConfigRequested = {}; + gnssConfigRequested.flags |= GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT | + GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT | + GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT | + GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT; + gnssConfigRequested.gpsLock = GNSS_CONFIG_GPS_LOCK_NONE; + if (0 == adapter.getAfwControlId() || NULL != adapter.mNfwCb) { + gnssConfigRequested.gpsLock = gpsConf.GPS_LOCK; + } + + if (gpsConf.AGPS_CONFIG_INJECT) { + gnssConfigRequested.flags |= GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT | + GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT | + GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT | + GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT; + gnssConfigRequested.suplVersion = + adapter.mLocApi->convertSuplVersion(gpsConf.SUPL_VER); + gnssConfigRequested.lppProfile = + adapter.mLocApi->convertLppProfile(gpsConf.LPP_PROFILE); + gnssConfigRequested.aGlonassPositionProtocolMask = + gpsConf.A_GLONASS_POS_PROTOCOL_SELECT; + } + gnssConfigRequested.lppeControlPlaneMask = + adapter.mLocApi->convertLppeCp(gpsConf.LPPE_CP_TECHNOLOGY); + gnssConfigRequested.lppeUserPlaneMask = + adapter.mLocApi->convertLppeUp(gpsConf.LPPE_UP_TECHNOLOGY); + gnssConfigRequested.blacklistedSvIds.assign(adapter.mBlacklistedSvIds.begin(), + adapter.mBlacklistedSvIds.end()); + mApi.sendMsg(new LocApiMsg( + [&adapter, gpsConf, sapConf, oldServerUrl, + oldMoServerUrl, gnssConfigRequested] () { + adapter.gnssUpdateConfig(oldServerUrl, oldMoServerUrl, gnssConfigRequested, + gnssConfigRequested); + + // set nmea mask type + uint32_t mask = 0; + if (NMEA_PROVIDER_MP == gpsConf.NMEA_PROVIDER) { + mask |= LOC_NMEA_ALL_GENERAL_SUPPORTED_MASK; + } + if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_DEBUG_NMEA_V02)) { + mask |= LOC_NMEA_MASK_DEBUG_V02; + } + + if (mask != 0) { + adapter.mLocApi->setNMEATypesSync(mask); + } + + adapter.mLocApi->setXtraVersionCheckSync(gpsConf.XTRA_VERSION_CHECK); + + adapter.mLocApi->setConstrainedTuncMode( + gpsConf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED == 1, + (float)gpsConf.CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD, + gpsConf.CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET); + adapter.mLocApi->setPositionAssistedClockEstimatorMode( + gpsConf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED == 1); + + if (sapConf.GYRO_BIAS_RANDOM_WALK_VALID || + sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID || + sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID || + sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID || + sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID ) { + adapter.mLocApi->setSensorPropertiesSync( + sapConf.GYRO_BIAS_RANDOM_WALK_VALID, + sapConf.GYRO_BIAS_RANDOM_WALK, + sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID, + sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY, + sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, + sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY, + sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, + sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY, + sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID, + sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY); + } + adapter.mLocApi->setSensorPerfControlConfigSync( + sapConf.SENSOR_CONTROL_MODE, + sapConf.SENSOR_ACCEL_SAMPLES_PER_BATCH, + sapConf.SENSOR_ACCEL_BATCHES_PER_SEC, + sapConf.SENSOR_GYRO_SAMPLES_PER_BATCH, + sapConf.SENSOR_GYRO_BATCHES_PER_SEC, + sapConf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH, + sapConf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH, + sapConf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH, + sapConf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH, + sapConf.SENSOR_ALGORITHM_CONFIG_MASK); } )); } }; @@ -1075,7 +1076,7 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config) newGpsLock = GNSS_CONFIG_GPS_LOCK_MO; } if (newGpsLock == ContextBase::mGps_conf.GPS_LOCK || - 0 != mAdapter.getAfwControlId()) { + 0 != mAdapter.getAfwControlId() || NULL != adapter.mNfwCb) { gnssConfigNeedEngineUpdate.flags &= ~(GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT); } ContextBase::mGps_conf.GPS_LOCK = newGpsLock; -- cgit v1.2.3 From 89583a78f041efb6213044867650e20013500e35 Mon Sep 17 00:00:00 2001 From: Yingjie Wang Date: Thu, 7 Mar 2019 18:08:06 +0800 Subject: Add charger indication receiver in Gnss Hidl Register HEALTH Hal client in all Gnss Hidl impl to acquire charger indication. Change-Id: I3fcc00dd14a95e2375ab27a8c84c260300f9e90d CRs-fixed: 2411445 --- android/1.0/Android.mk | 9 +- android/1.0/Gnss.cpp | 7 + android/1.1/Android.mk | 9 +- android/1.1/Gnss.cpp | 8 ++ android/2.0/Android.mk | 11 +- android/2.0/Gnss.cpp | 7 + android/Android.mk | 9 +- android/utils/Android.mk | 37 ++++++ android/utils/battery_listener.cpp | 266 +++++++++++++++++++++++++++++++++++++ android/utils/battery_listener.h | 32 +++++ 10 files changed, 388 insertions(+), 7 deletions(-) create mode 100644 android/utils/Android.mk create mode 100644 android/utils/battery_listener.cpp create mode 100644 android/utils/battery_listener.h diff --git a/android/1.0/Android.mk b/android/1.0/Android.mk index 5489f86..9337325 100644 --- a/android/1.0/Android.mk +++ b/android/1.0/Android.mk @@ -28,7 +28,8 @@ LOCAL_HEADER_LIBRARIES := \ libgps.utils_headers \ libloc_core_headers \ libloc_pla_headers \ - liblocation_api_headers + liblocation_api_headers \ + liblocbatterylistener_headers LOCAL_SHARED_LIBRARIES := \ liblog \ @@ -38,6 +39,10 @@ LOCAL_SHARED_LIBRARIES := \ libcutils \ libutils \ android.hardware.gnss@1.0 \ + android.hardware.health@1.0 \ + android.hardware.health@2.0 \ + android.hardware.power@1.2 \ + libbase LOCAL_SHARED_LIBRARIES += \ libloc_core \ @@ -46,6 +51,8 @@ LOCAL_SHARED_LIBRARIES += \ liblocation_api \ LOCAL_CFLAGS += $(GNSS_CFLAGS) +LOCAL_STATIC_LIBRARIES := liblocbatterylistener +LOCAL_STATIC_LIBRARIES += libhealthhalutils include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) diff --git a/android/1.0/Gnss.cpp b/android/1.0/Gnss.cpp index 93b320b..873cf37 100644 --- a/android/1.0/Gnss.cpp +++ b/android/1.0/Gnss.cpp @@ -19,6 +19,7 @@ */ #define LOG_TAG "LocSvc_GnssInterface" +#define LOG_NDEBUG 0 #include #include @@ -26,6 +27,7 @@ #include #include "Gnss.h" #include +#include "battery_listener.h" typedef const GnssInterface* (getLocationInterface)(); @@ -44,8 +46,13 @@ void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp& who } } +void location_on_battery_status_changed(bool charging) { + LOC_LOGd("%s: battery status changed to %s charging", __func__, charging ? "" : "not "); +} Gnss::Gnss() { ENTRY_LOG_CALLFLOW(); + // register health client to listen on battery change + loc_extn_battery_properties_listener_init(location_on_battery_status_changed); // clear pending GnssConfig memset(&mPendingConfig, 0, sizeof(GnssConfig)); diff --git a/android/1.1/Android.mk b/android/1.1/Android.mk index 0beaf20..fb72de1 100644 --- a/android/1.1/Android.mk +++ b/android/1.1/Android.mk @@ -28,7 +28,8 @@ LOCAL_HEADER_LIBRARIES := \ libgps.utils_headers \ libloc_core_headers \ libloc_pla_headers \ - liblocation_api_headers + liblocation_api_headers \ + liblocbatterylistener_headers LOCAL_SHARED_LIBRARIES := \ liblog \ @@ -39,6 +40,10 @@ LOCAL_SHARED_LIBRARIES := \ libutils \ android.hardware.gnss@1.0 \ android.hardware.gnss@1.1 \ + android.hardware.health@1.0 \ + android.hardware.health@2.0 \ + android.hardware.power@1.2 \ + libbase LOCAL_SHARED_LIBRARIES += \ libloc_core \ @@ -47,6 +52,8 @@ LOCAL_SHARED_LIBRARIES += \ liblocation_api \ LOCAL_CFLAGS += $(GNSS_CFLAGS) +LOCAL_STATIC_LIBRARIES := liblocbatterylistener +LOCAL_STATIC_LIBRARIES += libhealthhalutils include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) diff --git a/android/1.1/Gnss.cpp b/android/1.1/Gnss.cpp index 8d5d8a8..f0d74da 100644 --- a/android/1.1/Gnss.cpp +++ b/android/1.1/Gnss.cpp @@ -19,6 +19,7 @@ */ #define LOG_TAG "LocSvc_GnssInterface" +#define LOG_NDEBUG 0 #include #include @@ -27,6 +28,8 @@ #include "Gnss.h" #include +#include "battery_listener.h" + typedef const GnssInterface* (getLocationInterface)(); #define IMAGES_INFO_FILE "/sys/devices/soc0/images" @@ -84,8 +87,13 @@ void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp& who } } +void location_on_battery_status_changed(bool charging) { + LOC_LOGd("%s: battery status changed to %s charging", __func__, charging ? "" : "not "); +} Gnss::Gnss() { ENTRY_LOG_CALLFLOW(); + // register health client to listen on battery change + loc_extn_battery_properties_listener_init(location_on_battery_status_changed); // clear pending GnssConfig memset(&mPendingConfig, 0, sizeof(GnssConfig)); diff --git a/android/2.0/Android.mk b/android/2.0/Android.mk index c33a792..7c55504 100644 --- a/android/2.0/Android.mk +++ b/android/2.0/Android.mk @@ -37,7 +37,8 @@ LOCAL_HEADER_LIBRARIES := \ libgps.utils_headers \ libloc_core_headers \ libloc_pla_headers \ - liblocation_api_headers + liblocation_api_headers \ + liblocbatterylistener_headers LOCAL_SHARED_LIBRARIES := \ liblog \ @@ -50,7 +51,11 @@ LOCAL_SHARED_LIBRARIES := \ android.hardware.gnss@1.1 \ android.hardware.gnss@2.0 \ android.hardware.gnss.measurement_corrections@1.0 \ - android.hardware.gnss.visibility_control@1.0 + android.hardware.gnss.visibility_control@1.0 \ + android.hardware.health@1.0 \ + android.hardware.health@2.0 \ + android.hardware.power@1.2 \ + libbase LOCAL_SHARED_LIBRARIES += \ libloc_core \ @@ -59,6 +64,8 @@ LOCAL_SHARED_LIBRARIES += \ liblocation_api \ LOCAL_CFLAGS += $(GNSS_CFLAGS) +LOCAL_STATIC_LIBRARIES := liblocbatterylistener +LOCAL_STATIC_LIBRARIES += libhealthhalutils include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) diff --git a/android/2.0/Gnss.cpp b/android/2.0/Gnss.cpp index 0390af7..be4efac 100644 --- a/android/2.0/Gnss.cpp +++ b/android/2.0/Gnss.cpp @@ -19,6 +19,7 @@ */ #define LOG_TAG "LocSvc_GnssInterface" +#define LOG_NDEBUG 0 #include #include @@ -26,6 +27,7 @@ #include #include "Gnss.h" #include "LocationUtil.h" +#include "battery_listener.h" typedef const GnssInterface* (getLocationInterface)(); @@ -85,8 +87,13 @@ void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp& who } } +void location_on_battery_status_changed(bool charging) { + LOC_LOGd("%s: battery status changed to %s charging", __func__, charging ? "" : "not "); +} Gnss::Gnss() { ENTRY_LOG_CALLFLOW(); + // register health client to listen on battery change + loc_extn_battery_properties_listener_init(location_on_battery_status_changed); // clear pending GnssConfig memset(&mPendingConfig, 0, sizeof(GnssConfig)); mGnssDeathRecipient = new GnssDeathRecipient(this); diff --git a/android/Android.mk b/android/Android.mk index f117def..8233b68 100644 --- a/android/Android.mk +++ b/android/Android.mk @@ -1,12 +1,15 @@ LOCAL_PATH := $(call my-dir) ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),) +include $(CLEAR_VARS) +DIR_LIST := $(LOCAL_PATH) +include $(DIR_LIST)/utils/Android.mk ifeq ($(GNSS_HIDL_VERSION),2.0) -include $(LOCAL_PATH)/2.0/Android.mk +include $(DIR_LIST)/2.0/Android.mk else ifeq ($(GNSS_HIDL_VERSION),1.1) -include $(LOCAL_PATH)/1.1/Android.mk +include $(DIR_LIST)/1.1/Android.mk else -include $(LOCAL_PATH)/1.0/Android.mk +include $(DIR_LIST)/1.0/Android.mk endif #GNSS HIDL 1.1 endif #GNSS HIDL 2.0 else #QMAA flag set, build dummy android.hardware.gnss@1.0-impl-qti diff --git a/android/utils/Android.mk b/android/utils/Android.mk new file mode 100644 index 0000000..47b4081 --- /dev/null +++ b/android/utils/Android.mk @@ -0,0 +1,37 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE := liblocbatterylistener +LOCAL_VENDOR_MODULE := true + +LOCAL_CFLAGS += $(GNSS_CFLAGS) + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH) \ + +LOCAL_SRC_FILES:= \ + battery_listener.cpp +LOCAL_SHARED_LIBRARIES := \ + liblog \ + libhidlbase \ + libhidltransport \ + libhwbinder \ + libcutils \ + libutils \ + android.hardware.health@1.0 \ + android.hardware.health@2.0 \ + android.hardware.power@1.2 \ + libbase + +LOCAL_STATIC_LIBRARIES := libhealthhalutils +LOCAL_CFLAGS += -DBATTERY_LISTENER_ENABLED + +include $(BUILD_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := liblocbatterylistener_headers +LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) + +include $(BUILD_HEADER_LIBRARY) + + diff --git a/android/utils/battery_listener.cpp b/android/utils/battery_listener.cpp new file mode 100644 index 0000000..a790702 --- /dev/null +++ b/android/utils/battery_listener.cpp @@ -0,0 +1,266 @@ +/* +* Copyright (c) 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 +* met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided +* with the distribution. +* * Neither the name of The Linux Foundation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT +* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS +* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include "battery_listener.h" +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "LocSvc_BatteryListener" + +#include +#include +#include +#include +#include +using android::hardware::interfacesEqual; +using android::hardware::Return; +using android::hardware::Void; +using android::hardware::health::V1_0::BatteryStatus; +using android::hardware::health::V1_0::toString; +using android::hardware::health::V2_0::get_health_service; +using android::hardware::health::V2_0::HealthInfo; +using android::hardware::health::V2_0::IHealth; +using android::hardware::health::V2_0::Result; +using android::hidl::manager::V1_0::IServiceManager; +using namespace std::literals::chrono_literals; + +static bool sIsBatteryListened = false; +namespace android { + +#define GET_HEALTH_SVC_RETRY_CNT 5 +#define GET_HEALTH_SVC_WAIT_TIME_MS 500 + +struct BatteryListenerImpl : public hardware::health::V2_0::IHealthInfoCallback, + public hardware::hidl_death_recipient { + typedef std::function cb_fn_t; + BatteryListenerImpl(cb_fn_t cb); + virtual ~BatteryListenerImpl (); + virtual hardware::Return healthInfoChanged( + const hardware::health::V2_0::HealthInfo& info); + virtual void serviceDied(uint64_t cookie, + const wp& who); + bool isCharging() { + std::lock_guard _l(mLock); + return statusToBool(mStatus); + } + private: + sp mHealth; + status_t init(); + BatteryStatus mStatus; + cb_fn_t mCb; + std::mutex mLock; + std::condition_variable mCond; + std::unique_ptr mThread; + bool mDone; + bool statusToBool(const BatteryStatus &s) const { + return (s == BatteryStatus::CHARGING) || + (s == BatteryStatus::FULL); + } +}; + +status_t BatteryListenerImpl::init() +{ + int tries = 0; + + if (mHealth != NULL) + return INVALID_OPERATION; + + do { + mHealth = hardware::health::V2_0::get_health_service(); + if (mHealth != NULL) + break; + usleep(GET_HEALTH_SVC_WAIT_TIME_MS * 1000); + tries++; + } while(tries < GET_HEALTH_SVC_RETRY_CNT); + + if (mHealth == NULL) { + ALOGE("no health service found, retries %d", tries); + return NO_INIT; + } else { + ALOGI("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"); + return; + } + mStatus = status; + }); + if (!ret.isOk()) + ALOGE("batterylistener: get charge status transaction error"); + + if (mStatus == BatteryStatus::UNKNOWN) + ALOGW("batterylistener: init: invalid battery status"); + mDone = false; + mThread = std::make_unique([this]() { + std::unique_lock l(mLock); + BatteryStatus local_status = mStatus; + while (!mDone) { + if (local_status == mStatus) { + mCond.wait(l); + continue; + } + local_status = mStatus; + switch (local_status) { + // NOT_CHARGING is a special event that indicates, a battery is connected, + // but not charging. This is seen for approx a second + // after charger is plugged in. A charging event is eventually received. + // We must try to avoid an unnecessary cb to HAL + // only to call it again shortly. + // An option to deal with this transient event would be to ignore this. + // Or process this event with a slight delay (i.e cancel this event + // if a different event comes in within a timeout + case BatteryStatus::NOT_CHARGING : { + auto mStatusnot_ncharging = + [this, local_status]() { return mStatus != local_status; }; + mCond.wait_for(l, 3s, mStatusnot_ncharging); + if (mStatusnot_ncharging()) // i.e event changed + break; + [[clang::fallthrough]]; //explicit fall-through between switch labels + } + default: + bool c = statusToBool(local_status); + ALOGI("healthInfo cb thread: cb %s", c ? "CHARGING" : "NOT CHARGING"); + l.unlock(); + mCb(c); + l.lock(); + break; + } + } + }); + auto reg = mHealth->registerCallback(this); + if (!reg.isOk()) { + ALOGE("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()); + } + return NO_ERROR; +} + +BatteryListenerImpl::BatteryListenerImpl(cb_fn_t cb) : + mCb(cb) +{ + init(); +} + +BatteryListenerImpl::~BatteryListenerImpl() +{ + { + std::lock_guard _l(mLock); + if (mHealth != NULL) + mHealth->unlinkToDeath(this); + auto r = mHealth->unlinkToDeath(this); + if (!r.isOk() || r == false) { + ALOGE("Transaction error in unregister to HealthHAL death: %s", + r.description().c_str()); + } + } + mDone = true; + mThread->join(); +} + +void BatteryListenerImpl::serviceDied(uint64_t cookie __unused, + const wp& who) +{ + { + std::lock_guard _l(mLock); + if (mHealth == NULL || !interfacesEqual(mHealth, who.promote())) { + ALOGE("health not initialized or unknown interface died"); + return; + } + ALOGI("health service died, reinit"); + mDone = true; + } + mThread->join(); + std::lock_guard _l(mLock); + init(); +} + +// this callback seems to be a SYNC callback and so +// waits for return before next event is issued. +// therefore we need not have a queue to process +// 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); + std::unique_lock l(mLock); + if (info.legacy.batteryStatus != mStatus) { + mStatus = info.legacy.batteryStatus; + mCond.notify_one(); + } + return Void(); +} + +static sp batteryListener; +status_t batteryPropertiesListenerInit(BatteryListenerImpl::cb_fn_t cb) +{ + ALOGV("batteryPropertiesListenerInit entry"); + batteryListener = new BatteryListenerImpl(cb); + return NO_ERROR; +} + +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"); + if (!sIsBatteryListened) { + std::thread t1(android::batteryPropertiesListenerInit, + [=](bool charging) { fn(charging); }); + t1.detach(); + sIsBatteryListened = true; + } +} + +void loc_extn_battery_properties_listener_deinit() +{ + android::batteryPropertiesListenerDeinit(); +} + +bool loc_extn_battery_properties_is_charging() +{ + return android::batteryPropertiesListenerIsCharging(); +} diff --git a/android/utils/battery_listener.h b/android/utils/battery_listener.h new file mode 100644 index 0000000..bb6b715 --- /dev/null +++ b/android/utils/battery_listener.h @@ -0,0 +1,32 @@ +/* +* Copyright (c) 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 +* met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided +* with the distribution. +* * Neither the name of The Linux Foundation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT +* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS +* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +typedef void (* battery_status_change_fn_t)(bool); +void loc_extn_battery_properties_listener_init(battery_status_change_fn_t fn); +void loc_extn_battery_properties_listener_deinit(); +bool loc_extn_battery_properties_is_charging(); -- cgit v1.2.3 From 1e4aefd8b6244ada0238b8fe645345ff297cc32a Mon Sep 17 00:00:00 2001 From: Hoss Zhou Date: Mon, 27 May 2019 16:07:12 +0800 Subject: modify DTM talker id Change-Id: I1844cc64767c0e6b324331f2016091ed1053e360 CRs-Fixed: 2455848 --- utils/loc_nmea.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/loc_nmea.cpp b/utils/loc_nmea.cpp index 45b4f06..abcf5b7 100644 --- a/utils/loc_nmea.cpp +++ b/utils/loc_nmea.cpp @@ -792,6 +792,7 @@ SIDE EFFECTS ===========================================================================*/ static void loc_nmea_generate_DTM(const LocLla &ref_lla, const LocLla &local_lla, + char *talker, char *sentence, int bufSize) { @@ -828,7 +829,7 @@ static void loc_nmea_generate_DTM(const LocLla &ref_lla, default: break; } - length = snprintf(pMarker , lengthRemaining , "$GPDTM,%s,," , local_datum); + length = snprintf(pMarker , lengthRemaining , "$%sDTM,%s,," , talker, local_datum); if (length < 0 || length >= lengthRemaining) { LOC_LOGE("NMEA Error in string formatting"); return; @@ -1226,7 +1227,7 @@ void loc_nmea_generate_pos(const UlpLocation &location, // ------------------- // ------$--DTM------- // ------------------- - loc_nmea_generate_DTM(ref_lla, local_lla, sentence_DTM, sizeof(sentence_DTM)); + loc_nmea_generate_DTM(ref_lla, local_lla, talker, sentence_DTM, sizeof(sentence_DTM)); // ------------------- // ------$--RMC------- -- cgit v1.2.3 From 41a8510ce10241134f4a9b86d9e1182d06f96cde Mon Sep 17 00:00:00 2001 From: Nilesh Gharde Date: Tue, 28 May 2019 12:23:50 +0530 Subject: KW issues on LA.UM.8.12 Addressed KW issue in MeasurementAPIClient.cpp Change-Id: Id35187c9e8eb29a81a86d12423e965fef780d668 CRs-Fixed: 2460424 --- android/2.0/location_api/MeasurementAPIClient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/2.0/location_api/MeasurementAPIClient.cpp b/android/2.0/location_api/MeasurementAPIClient.cpp index eb0c7d1..dc972ec 100644 --- a/android/2.0/location_api/MeasurementAPIClient.cpp +++ b/android/2.0/location_api/MeasurementAPIClient.cpp @@ -217,7 +217,7 @@ void MeasurementAPIClient::onGnssMeasurementsCb( static void convertGnssMeasurement(GnssMeasurementsData& in, V1_0::IGnssMeasurementCallback::GnssMeasurement& out) { - memset(&out, 0, sizeof(IGnssMeasurementCallback::GnssMeasurement)); + memset(&out, 0, sizeof(out)); if (in.flags & GNSS_MEASUREMENTS_DATA_SIGNAL_TO_NOISE_RATIO_BIT) out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_SNR; if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_FREQUENCY_BIT) -- cgit v1.2.3 From c7cbd60fb53693f31384468c180b7d220384c878 Mon Sep 17 00:00:00 2001 From: Saurabh Srivastava Date: Fri, 31 May 2019 00:12:00 +0530 Subject: Removing benign error message Removing error message from GNSS update SV Type config method for onDeviceUp scenario. Change-Id: I7a93f9ea2fd5f8c1182c9ce10d298fc5971bc1e3 CRs-Fixed: 2461765 --- gnss/GnssAdapter.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 535f6de..8e1bf5f 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -1636,9 +1636,10 @@ GnssAdapter::gnssSvTypeConfigUpdate(const GnssSvTypeConfig& config) void GnssAdapter::gnssSvTypeConfigUpdate(bool sendReset) { - LOC_LOGd("constellations blacklisted 0x%" PRIx64 ", enabled 0x%" PRIx64 ", sendReset %d", - mGnssSvTypeConfig.blacklistedSvTypesMask, mGnssSvTypeConfig.enabledSvTypesMask, - sendReset); + LOC_LOGd("size %zu constellations blacklisted 0x%" PRIx64 ", enabled 0x%" PRIx64 + ", sendReset %d", + mGnssSvTypeConfig.size, mGnssSvTypeConfig.blacklistedSvTypesMask, + mGnssSvTypeConfig.enabledSvTypesMask, sendReset); if (mGnssSvTypeConfig.size == sizeof(mGnssSvTypeConfig)) { @@ -1674,8 +1675,6 @@ GnssAdapter::gnssSvTypeConfigUpdate(bool sendReset) svTypeConfig.enabledSvTypesMask = mGnssSvTypeConfig.enabledSvTypesMask; mLocApi->setConstellationControl(svTypeConfig); } - } else { - LOC_LOGE("Invalid GnssSvTypeConfig size"); } } -- cgit v1.2.3 From 04db4be280bef79038482dc37d2972ab2525692c Mon Sep 17 00:00:00 2001 From: Dante Russo Date: Wed, 29 May 2019 17:59:00 -0700 Subject: Downgrade locApiStopTracking print error to debug On cleanup, the locApiStopTracking is called regardless if a session is active or not, where this error would be printed. This is an expected case, so it should not be an error print. Change-Id: Ieb10d159ad61a212821ef897d50d635354557cca CRs-fixed: 2461760 --- location/LocationAPIClientBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/location/LocationAPIClientBase.cpp b/location/LocationAPIClientBase.cpp index 67e559b..5a09712 100644 --- a/location/LocationAPIClientBase.cpp +++ b/location/LocationAPIClientBase.cpp @@ -366,7 +366,7 @@ void LocationAPIClientBase::locAPIStopTracking() mLocationAPI->stopTracking(session); mTracking = false; } else { - LOC_LOGE("%s:%d] invalid session: %d.", __FUNCTION__, __LINE__, session); + LOC_LOGD("%s:%d] invalid session: %d.", __FUNCTION__, __LINE__, session); } } pthread_mutex_unlock(&mMutex); -- cgit v1.2.3 From 4c9b600ed7d558bfb6b929fc588a4764065a978c Mon Sep 17 00:00:00 2001 From: Dante Russo Date: Mon, 3 Jun 2019 18:09:03 -0700 Subject: Report Locations to AFW only when active tracking We want to avoid reporting locations to AFW while measurements is active but tracking is not active. Change-Id: Icbb581199e6f5eba3cfe81cb6ab39337bb7ea51a CRs-fixed: 2441384 --- android/2.0/location_api/GnssAPIClient.cpp | 20 +++++++++++++++++++- android/2.0/location_api/GnssAPIClient.h | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/android/2.0/location_api/GnssAPIClient.cpp b/android/2.0/location_api/GnssAPIClient.cpp index 15245e3..ffe9075 100644 --- a/android/2.0/location_api/GnssAPIClient.cpp +++ b/android/2.0/location_api/GnssAPIClient.cpp @@ -61,6 +61,7 @@ GnssAPIClient::GnssAPIClient(const sp& gpsCb, mControlClient(new LocationAPIControlClient()), mLocationCapabilitiesMask(0), mLocationCapabilitiesCached(false), + mTracking(false), mGnssCbIface_2_0(nullptr) { LOC_LOGD("%s]: (%p %p)", __FUNCTION__, &gpsCb, &niCb); @@ -76,6 +77,7 @@ GnssAPIClient::GnssAPIClient(const sp& gpsCb) : mControlClient(new LocationAPIControlClient()), mLocationCapabilitiesMask(0), mLocationCapabilitiesCached(false), + mTracking(false), mGnssCbIface_2_0(nullptr) { LOC_LOGD("%s]: (%p)", __FUNCTION__, &gpsCb); @@ -179,6 +181,11 @@ void GnssAPIClient::gnssUpdateCallbacks_2_0(const sp& gpsCb bool GnssAPIClient::gnssStart() { LOC_LOGD("%s]: ()", __FUNCTION__); + + mMutex.lock(); + mTracking = true; + mMutex.unlock(); + bool retVal = true; locAPIStartTracking(mTrackingOptions); return retVal; @@ -187,6 +194,11 @@ bool GnssAPIClient::gnssStart() bool GnssAPIClient::gnssStop() { LOC_LOGD("%s]: ()", __FUNCTION__); + + mMutex.lock(); + mTracking = false; + mMutex.unlock(); + bool retVal = true; locAPIStopTracking(); return retVal; @@ -412,12 +424,18 @@ void GnssAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask) void GnssAPIClient::onTrackingCb(Location location) { - LOC_LOGD("%s]: (flags: %02x)", __FUNCTION__, location.flags); mMutex.lock(); auto gnssCbIface(mGnssCbIface); auto gnssCbIface_2_0(mGnssCbIface_2_0); + bool isTracking = mTracking; mMutex.unlock(); + LOC_LOGD("%s]: (flags: %02x isTracking: %d)", __FUNCTION__, location.flags, isTracking); + + if (!isTracking) { + return; + } + if (gnssCbIface_2_0 != nullptr) { V2_0::GnssLocation gnssLocation; convertGnssLocation(location, gnssLocation); diff --git a/android/2.0/location_api/GnssAPIClient.h b/android/2.0/location_api/GnssAPIClient.h index 493f9ca..63b4561 100644 --- a/android/2.0/location_api/GnssAPIClient.h +++ b/android/2.0/location_api/GnssAPIClient.h @@ -102,6 +102,7 @@ private: LocationCapabilitiesMask mLocationCapabilitiesMask; bool mLocationCapabilitiesCached; TrackingOptions mTrackingOptions; + bool mTracking; sp mGnssCbIface_2_0; }; -- cgit v1.2.3 From 2e7c04a82d85a3ddec7a7a024e00f65e1ee0b0c3 Mon Sep 17 00:00:00 2001 From: Yingjie Wang Date: Thu, 11 Apr 2019 08:33:46 +0800 Subject: Update SystemStatus with battery info in HealthHAL Change-Id: Ibc2157f1834eb65da48f9375e497628411a185c9 CRs-fixed: 2433570 --- android/1.0/Gnss.cpp | 8 +++++++- android/1.1/Gnss.cpp | 8 +++++++- android/2.0/Gnss.cpp | 9 +++++++-- core/SystemStatus.cpp | 13 +++++++++++++ core/SystemStatus.h | 1 + gnss/location_gnss.cpp | 10 +++++++++- location/location_interface.h | 1 + 7 files changed, 45 insertions(+), 5 deletions(-) diff --git a/android/1.0/Gnss.cpp b/android/1.0/Gnss.cpp index 873cf37..d85e0a4 100644 --- a/android/1.0/Gnss.cpp +++ b/android/1.0/Gnss.cpp @@ -37,6 +37,7 @@ namespace gnss { namespace V1_0 { namespace implementation { +static sp sGnss; void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp& who) { LOC_LOGE("%s] service died. cookie: %llu, who: %p", __FUNCTION__, static_cast(cookie), &who); @@ -47,10 +48,14 @@ void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp& who } void location_on_battery_status_changed(bool charging) { - LOC_LOGd("%s: battery status changed to %s charging", __func__, charging ? "" : "not "); + LOC_LOGd("battery status changed to %s charging", charging ? "" : "not "); + if (sGnss != nullptr) { + sGnss->getGnssInterface()->updateBatteryStatus(charging); + } } Gnss::Gnss() { ENTRY_LOG_CALLFLOW(); + sGnss = this; // register health client to listen on battery change loc_extn_battery_properties_listener_init(location_on_battery_status_changed); // clear pending GnssConfig @@ -65,6 +70,7 @@ Gnss::~Gnss() { delete mApi; mApi = nullptr; } + sGnss = nullptr; } GnssAPIClient* Gnss::getApi() { diff --git a/android/1.1/Gnss.cpp b/android/1.1/Gnss.cpp index f0d74da..bea556f 100644 --- a/android/1.1/Gnss.cpp +++ b/android/1.1/Gnss.cpp @@ -41,6 +41,7 @@ namespace gnss { namespace V1_1 { namespace implementation { +static sp sGnss; static std::string getVersionString() { static std::string version; if (!version.empty()) @@ -88,10 +89,14 @@ void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp& who } void location_on_battery_status_changed(bool charging) { - LOC_LOGd("%s: battery status changed to %s charging", __func__, charging ? "" : "not "); + LOC_LOGd("battery status changed to %s charging", charging ? "" : "not"); + if (sGnss != nullptr) { + sGnss->getGnssInterface()->updateBatteryStatus(charging); + } } Gnss::Gnss() { ENTRY_LOG_CALLFLOW(); + sGnss = this; // register health client to listen on battery change loc_extn_battery_properties_listener_init(location_on_battery_status_changed); // clear pending GnssConfig @@ -106,6 +111,7 @@ Gnss::~Gnss() { delete mApi; mApi = nullptr; } + sGnss = nullptr; } GnssAPIClient* Gnss::getApi() { diff --git a/android/2.0/Gnss.cpp b/android/2.0/Gnss.cpp index be4efac..4fa5b63 100644 --- a/android/2.0/Gnss.cpp +++ b/android/2.0/Gnss.cpp @@ -41,7 +41,7 @@ namespace V2_0 { namespace implementation { using ::android::hardware::gnss::visibility_control::V1_0::implementation::GnssVisibilityControl; - +static sp sGnss; static std::string getVersionString() { static std::string version; if (!version.empty()) @@ -88,10 +88,14 @@ void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp& who } void location_on_battery_status_changed(bool charging) { - LOC_LOGd("%s: battery status changed to %s charging", __func__, charging ? "" : "not "); + LOC_LOGd("battery status changed to %s charging", charging ? "" : "not"); + if (sGnss != nullptr) { + sGnss->getGnssInterface()->updateBatteryStatus(charging); + } } Gnss::Gnss() { ENTRY_LOG_CALLFLOW(); + sGnss = this; // register health client to listen on battery change loc_extn_battery_properties_listener_init(location_on_battery_status_changed); // clear pending GnssConfig @@ -105,6 +109,7 @@ Gnss::~Gnss() { delete mApi; mApi = nullptr; } + sGnss = nullptr; } GnssAPIClient* Gnss::getApi() { diff --git a/core/SystemStatus.cpp b/core/SystemStatus.cpp index 18cb99c..9ca126f 100644 --- a/core/SystemStatus.cpp +++ b/core/SystemStatus.cpp @@ -1723,5 +1723,18 @@ bool SystemStatus::eventConnectionStatus(bool connected, int8_t type, return true; } +/****************************************************************************** +@brief API to update power connect state + +@param[In] power connect status + +@return true when successfully done +******************************************************************************/ +bool SystemStatus::updatePowerConnectState(bool charging) +{ + SystemStatusPowerConnectState s(charging); + mSysStatusObsvr.notify({&s}); + return true; +} } // namespace loc_core diff --git a/core/SystemStatus.h b/core/SystemStatus.h index f3467e2..94f7f0b 100644 --- a/core/SystemStatus.h +++ b/core/SystemStatus.h @@ -858,6 +858,7 @@ public: bool setDefaultGnssEngineStates(void); bool eventConnectionStatus(bool connected, int8_t type, bool roaming, NetworkHandle networkHandle); + bool updatePowerConnectState(bool charging); }; } // namespace loc_core diff --git a/gnss/location_gnss.cpp b/gnss/location_gnss.cpp index 88fa15d..76839b6 100644 --- a/gnss/location_gnss.cpp +++ b/gnss/location_gnss.cpp @@ -78,6 +78,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 const GnssInterface gGnssInterface = { sizeof(GnssInterface), @@ -115,7 +116,8 @@ static const GnssInterface gGnssInterface = { enableNfwLocationAccess, nfwInit, getPowerStateChanges, - injectLocationExt + injectLocationExt, + updateBatteryStatus }; #ifndef DEBUG_X86 @@ -382,3 +384,9 @@ static void injectLocationExt(const GnssLocationInfoNotification &locationInfo) gGnssAdapter->injectLocationExtCommand(locationInfo); } } + +static void updateBatteryStatus(bool charging) { + if (NULL != gGnssAdapter) { + gGnssAdapter->getSystemStatus()->updatePowerConnectState(charging); + } +} diff --git a/location/location_interface.h b/location/location_interface.h index 80f37c2..fb15bea 100644 --- a/location/location_interface.h +++ b/location/location_interface.h @@ -87,6 +87,7 @@ struct GnssInterface { void (*nfwInit)(const NfwCbInfo& cbInfo); void (*getPowerStateChanges)(void* powerStateCb); void (*injectLocationExt)(const GnssLocationInfoNotification &locationInfo); + void (*updateBatteryStatus)(bool charging); }; struct BatchingInterface { -- cgit v1.2.3 From 071fd823dd949cdbdf81a39a469bee279bac1437 Mon Sep 17 00:00:00 2001 From: Mike Cailean Date: Mon, 3 Jun 2019 15:26:29 -0700 Subject: GPS getting locked after killing LocHIDL Change-Id: Ib6a9ed37f9198b9024042f8ba7ac9e9bf5f05190 CRs-fixed: 2463756 --- gnss/GnssAdapter.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 8e1bf5f..b9a3110 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -720,10 +720,7 @@ GnssAdapter::setConfigCommand() GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT | GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT | GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT; - gnssConfigRequested.gpsLock = GNSS_CONFIG_GPS_LOCK_NONE; - if (0 == adapter.getAfwControlId() || NULL != adapter.mNfwCb) { - gnssConfigRequested.gpsLock = gpsConf.GPS_LOCK; - } + gnssConfigRequested.gpsLock = gpsConf.GPS_LOCK; if (gpsConf.AGPS_CONFIG_INJECT) { gnssConfigRequested.flags |= GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT | @@ -1075,10 +1072,7 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config) if (GNSS_CONFIG_GPS_LOCK_NONE == newGpsLock) { newGpsLock = GNSS_CONFIG_GPS_LOCK_MO; } - if (newGpsLock == ContextBase::mGps_conf.GPS_LOCK || - 0 != mAdapter.getAfwControlId() || NULL != adapter.mNfwCb) { - gnssConfigNeedEngineUpdate.flags &= ~(GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT); - } + gnssConfigNeedEngineUpdate.flags &= ~(GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT); ContextBase::mGps_conf.GPS_LOCK = newGpsLock; index++; } @@ -2976,10 +2970,8 @@ GnssAdapter::enableCommand(LocationTechnologyType techType) mAdapter.setAfwControlId(mSessionId); GnssConfigGpsLock gpsLock = GNSS_CONFIG_GPS_LOCK_NONE; - if (NULL != mAdapter.mNfwCb) { - ContextBase::mGps_conf.GPS_LOCK &= GNSS_CONFIG_GPS_LOCK_NI; - gpsLock = ContextBase::mGps_conf.GPS_LOCK; - } + ContextBase::mGps_conf.GPS_LOCK &= GNSS_CONFIG_GPS_LOCK_NI; + gpsLock = ContextBase::mGps_conf.GPS_LOCK; mApi.sendMsg(new LocApiMsg([&mApi = mApi, gpsLock]() { mApi.setGpsLockSync(gpsLock); })); @@ -3026,10 +3018,8 @@ GnssAdapter::disableCommand(uint32_t id) mContext.modemPowerVote(false); mAdapter.setAfwControlId(0); - if (NULL != mAdapter.mNfwCb) { - /* We need to disable MO (AFW) */ - ContextBase::mGps_conf.GPS_LOCK |= GNSS_CONFIG_GPS_LOCK_MO; - } + /* We need to disable MO (AFW) */ + ContextBase::mGps_conf.GPS_LOCK |= GNSS_CONFIG_GPS_LOCK_MO; GnssConfigGpsLock gpsLock = ContextBase::mGps_conf.GPS_LOCK; mApi.sendMsg(new LocApiMsg([&mApi = mApi,gpsLock] () { mApi.setGpsLockSync(gpsLock); -- cgit v1.2.3 From 980dbf59b6b864d90eee122936a4c8ec484f948d Mon Sep 17 00:00:00 2001 From: Bhavna Sharma Date: Tue, 2 Apr 2019 14:20:36 -0700 Subject: Fix to use explicit sized structures Cross processor communication needs explicit sized structures. Avoid using platform defined values like size_t which may vary from 32-bit to 64-bit. Also use explicitly defined timespec32_t structure that will only use uint32_t fields. CRs-Fixed: 2428163 Change-Id: Ida72f53ac672d9c9b86879bb9861cecefe6f8c6d --- gnss/GnssAdapter.cpp | 2 +- utils/gps_extended_c.h | 43 ++++++++++++++++++++++++------------------- utils/loc_gps.h | 2 +- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 8e1bf5f..0775c2a 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -1636,7 +1636,7 @@ GnssAdapter::gnssSvTypeConfigUpdate(const GnssSvTypeConfig& config) void GnssAdapter::gnssSvTypeConfigUpdate(bool sendReset) { - LOC_LOGd("size %zu constellations blacklisted 0x%" PRIx64 ", enabled 0x%" PRIx64 + LOC_LOGd("size %" PRIu32" constellations blacklisted 0x%" PRIx64 ", enabled 0x%" PRIx64 ", sendReset %d", mGnssSvTypeConfig.size, mGnssSvTypeConfig.blacklistedSvTypesMask, mGnssSvTypeConfig.enabledSvTypesMask, sendReset); diff --git a/utils/gps_extended_c.h b/utils/gps_extended_c.h index 9f4c13c..9c63166 100644 --- a/utils/gps_extended_c.h +++ b/utils/gps_extended_c.h @@ -35,7 +35,12 @@ #include #include #include -#include + +struct timespec32_t { + uint32_t tv_sec; /* seconds */ + uint32_t tv_nsec; /* and nanoseconds */ +}; + /** * @file @@ -132,7 +137,7 @@ typedef enum { typedef struct { /** set to sizeof(UlpLocation) */ - size_t size; + uint32_t size; LocGpsLocation gpsLocation; /* Provider indicator for HYBRID or GPS */ uint16_t position_source; @@ -142,7 +147,7 @@ typedef struct { typedef struct { /** set to sizeof(UlpNmea) */ - size_t size; + uint32_t size; char nmea_str[ULP_MAX_NMEA_STRING_SIZE]; unsigned int len; } UlpNmea; @@ -208,7 +213,7 @@ typedef struct { /** GPS extended callback structure. */ typedef struct { /** set to sizeof(LocGpsCallbacks) */ - size_t size; + uint32_t size; loc_gps_set_capabilities set_capabilities_cb; loc_gps_acquire_wakelock acquire_wakelock_cb; loc_gps_release_wakelock release_wakelock_cb; @@ -232,7 +237,7 @@ typedef struct { /** Represents the status of AGPS. */ typedef struct { /** set to sizeof(AGpsExtStatus) */ - size_t size; + uint32_t size; AGpsExtType type; LocAGpsStatusValue status; @@ -458,7 +463,7 @@ typedef enum { }LocReliability; typedef struct { - struct timespec apTimeStamp; + struct timespec32_t apTimeStamp; /*boottime received from pps-ktimer*/ float apTimeStampUncertaintyMs; /* timestamp uncertainty in milli seconds */ @@ -685,7 +690,7 @@ typedef struct { /** Represents gps location extended. */ typedef struct { /** set to sizeof(GpsLocationExtended) */ - size_t size; + uint32_t size; /** Contains GpsLocationExtendedFlags bits. */ uint64_t flags; /** Contains the Altitude wrt mean sea level */ @@ -1058,7 +1063,7 @@ typedef enum typedef struct { - size_t size; + uint32_t size; float clockDrift; /**< Receiver clock Drift \n - Units: meter per sec \n @@ -1072,7 +1077,7 @@ typedef struct typedef struct { - size_t size; + uint32_t size; uint8_t leapSec; /**< GPS time leap second delta to UTC time \n - Units: sec \n @@ -1093,7 +1098,7 @@ typedef enum typedef struct { - size_t size; + uint32_t size; uint32_t validMask; /* Validity mask as per Gnss_LocInterSystemBiasValidMaskType */ @@ -1110,7 +1115,7 @@ typedef struct typedef struct { - size_t size; + uint32_t size; uint8_t systemRtc_valid; /**< Validity indicator for System RTC */ @@ -1156,7 +1161,7 @@ typedef enum typedef struct { - size_t size; + uint32_t size; uint32_t svMs; /**< Satellite time milisecond.\n For GPS, BDS, GAL range of 0 thru (604800000-1) \n @@ -1216,7 +1221,7 @@ typedef enum typedef struct { - size_t size; + uint32_t size; Gnss_LocSvSystemEnumType gnssSystem; // 0 signal type mask indicates invalid value GnssSignalTypeMask gnssSignalTypeMask; @@ -1389,7 +1394,7 @@ typedef uint64_t GpsSvMeasHeaderFlags; typedef struct { - size_t size; + uint32_t size; // see defines in GNSS_SV_MEAS_HEADER_HAS_XXX_XXX uint64_t flags; @@ -1433,7 +1438,7 @@ typedef struct } GnssSvMeasurementHeader; typedef struct { - size_t size; + uint32_t size; bool isNhz; GnssSvMeasurementHeader svMeasSetHeader; uint32_t svMeasCount; @@ -1473,7 +1478,7 @@ typedef enum typedef struct { - size_t size; + uint32_t size; uint16_t gnssSvId; /* GPS: 1-32, GLO: 65-96, 0: Invalid, SBAS: 120-151, BDS:201-237,GAL:301 to 336 @@ -2034,7 +2039,7 @@ typedef enum { typedef struct { - size_t size; + uint32_t size; Gnss_SrnTech srnTechType; /* SRN Technology type in request */ bool srnRequest; /* scan - start(true) or stop(false) */ bool e911Mode; /* If in E911 emergency */ @@ -2054,7 +2059,7 @@ typedef enum { /* This SV Type config is injected directly to GNSS Adapter * bypassing Location API */ typedef struct { - size_t size; // set to sizeof(GnssSvTypeConfig) + uint32_t size; // set to sizeof(GnssSvTypeConfig) // Enabled Constellations GnssSvTypesMask enabledSvTypesMask; // Disabled Constellations @@ -2141,7 +2146,7 @@ enum OdcpiRequestType { ODCPI_REQUEST_TYPE_STOP }; struct OdcpiRequestInfo { - size_t size; + uint32_t size; OdcpiRequestType type; uint32_t tbfMillis; bool isEmergencyMode; diff --git a/utils/loc_gps.h b/utils/loc_gps.h index b58f20b..eae7383 100644 --- a/utils/loc_gps.h +++ b/utils/loc_gps.h @@ -548,7 +548,7 @@ typedef uint8_t LocGnssConstellationType; /** Represents a location. */ typedef struct { /** set to sizeof(LocGpsLocation) */ - size_t size; + uint32_t size; /** Contains LocGpsLocationFlags bits. */ uint16_t flags; /** The spoof mask */ -- cgit v1.2.3 From 0677be4e4626d05880180f74bc97bbc357ff4663 Mon Sep 17 00:00:00 2001 From: Kevin Tang Date: Thu, 6 Jun 2019 14:01:52 -0700 Subject: Removing LocIpc::createLocIpcQsock* APIs Qrtr and Qsock bot have createLocIpc*Sender and Recver APIs in LocIpc. But Qrtr is really next gen of Qsock. The two will not co-exist. Their existence depends on kernel versions, i.e. 4.9 and earlier is Qsock; while 4.14 and later is Qrtr. Having 2 sets of APIs doesn't make sense, as client would have to know what are the right ones to use, which there is really only one set of backing implementations. Change-Id: Ia473f282bb271ae213d7dc5020b0b8c7b0a8cb8f CRs-Fixed: 2466857 --- utils/LocIpc.cpp | 17 ++++------------- utils/LocIpc.h | 5 ----- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/utils/LocIpc.cpp b/utils/LocIpc.cpp index 9496895..646d2d4 100644 --- a/utils/LocIpc.cpp +++ b/utils/LocIpc.cpp @@ -354,20 +354,11 @@ unique_ptr LocIpc::getLocIpcQrtrRecver(const shared_ptr (*creator_t)(const shared_ptr&, int, int); static creator_t creator = (creator_t)dlGetSymFromLib(sLibQrtrHandle, sLibQrtrName, +#ifdef USE_GLIB + "_ZN8loc_util22createLocIpcQrtrRecverERKSt10shared_ptrINS_15ILocIpcListenerEEii"); +#else "_ZN8loc_util22createLocIpcQrtrRecverERKNSt3__110shared_ptrINS_15ILocIpcListenerEEEii"); - return (nullptr == creator) ? nullptr : creator(listener, service, instance); -} -shared_ptr LocIpc::getLocIpcQsockSender(int service, int instance) { - typedef shared_ptr (*creator_t) (int, int); - static creator_t creator = (creator_t)dlGetSymFromLib(sLibQrtrHandle, sLibQrtrName, - "_ZN8loc_util23createLocIpcQsockSenderEii"); - return (nullptr == creator) ? nullptr : creator(service, instance); -} -unique_ptr LocIpc::getLocIpcQsockRecver(const shared_ptr& listener, - int service, int instance) { - typedef unique_ptr (*creator_t)(const shared_ptr&, int, int); - static creator_t creator = (creator_t)dlGetSymFromLib(sLibQrtrHandle, sLibQrtrName, - "_ZN8loc_util23createLocIpcQsockRecverERKSt10shared_ptrINS_15ILocIpcListenerEEii"); +#endif return (nullptr == creator) ? nullptr : creator(listener, service, instance); } shared_ptr LocIpc::getLocIpcInetTcpSender(const char* serverName, int32_t port) { diff --git a/utils/LocIpc.h b/utils/LocIpc.h index c71c4e0..b91966c 100644 --- a/utils/LocIpc.h +++ b/utils/LocIpc.h @@ -70,8 +70,6 @@ public: getLocIpcInetTcpSender(const char* serverName, int32_t port); static shared_ptr getLocIpcQrtrSender(int service, int instance); - static shared_ptr - getLocIpcQsockSender(int service, int instance); static unique_ptr getLocIpcLocalRecver(const shared_ptr& listener, @@ -82,9 +80,6 @@ public: static unique_ptr getLocIpcQrtrRecver(const shared_ptr& listener, int service, int instance); - static unique_ptr - getLocIpcQsockRecver(const shared_ptr& listener, - int service, int instance); static pair, unique_ptr> getLocIpcQmiLocServiceSenderRecverPair(const shared_ptr& listener, -- cgit v1.2.3