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(-) (limited to 'android/2.0') 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