summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorqctecmdr <qctecmdr@localhost>2019-06-05 15:37:26 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2019-06-05 15:37:26 -0700
commit22e008e8d1a85c90056dd528ed12061afb3b538a (patch)
tree2a7324195455c1a4cfcfdb46f03262b63dd6bc85 /android
parent04db4be280bef79038482dc37d2972ab2525692c (diff)
parent4c9b600ed7d558bfb6b929fc588a4764065a978c (diff)
downloadgps-22e008e8d1a85c90056dd528ed12061afb3b538a.tar.gz
Merge "Report Locations to AFW only when active tracking"
Diffstat (limited to 'android')
-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;
};