summaryrefslogtreecommitdiff
path: root/android/2.0
diff options
context:
space:
mode:
authorDante Russo <drusso@codeaurora.org>2019-06-03 18:09:03 -0700
committerDante Russo <drusso@codeaurora.org>2019-06-04 14:48:09 -0700
commit4c9b600ed7d558bfb6b929fc588a4764065a978c (patch)
treec064bddca23ecd3283b098580066901a71dac6c5 /android/2.0
parent51426e477b340950d7614ce6b1a7857b6a9b544f (diff)
downloadgps-4c9b600ed7d558bfb6b929fc588a4764065a978c.tar.gz
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
Diffstat (limited to 'android/2.0')
-rw-r--r--android/2.0/location_api/GnssAPIClient.cpp20
-rw-r--r--android/2.0/location_api/GnssAPIClient.h1
2 files changed, 20 insertions, 1 deletions
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<V1_0::IGnssCallback>& 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<V2_0::IGnssCallback>& 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<V2_0::IGnssCallback>& 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<V2_0::IGnssCallback> mGnssCbIface_2_0;
};