[automerger skipped] Skip ab/6749736 in stage. am: 3018c2dacf -s ours am: 269e84fa60 -s ours
am skip reason: Change-Id I566e3e0fcc74b4e5706d804f48dd9cd31467933c with SHA-1 5568245489 is in history
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/qcom/sdm845/gps/+/12796470
Change-Id: I10991419d18fa9db7172e7dd099a03e99049a3ca
diff --git a/sdm845/android/location_api/GnssAPIClient.cpp b/sdm845/android/location_api/GnssAPIClient.cpp
index 61b8b38..b799981 100644
--- a/sdm845/android/location_api/GnssAPIClient.cpp
+++ b/sdm845/android/location_api/GnssAPIClient.cpp
@@ -57,7 +57,8 @@
mGnssNiCbIface(nullptr),
mControlClient(new LocationAPIControlClient()),
mLocationCapabilitiesMask(0),
- mLocationCapabilitiesCached(false)
+ mLocationCapabilitiesCached(false),
+ mTracking(false)
{
LOC_LOGD("%s]: (%p %p)", __FUNCTION__, &gpsCb, &niCb);
@@ -141,6 +142,11 @@
bool GnssAPIClient::gnssStart()
{
LOC_LOGD("%s]: ()", __FUNCTION__);
+
+ mMutex.lock();
+ mTracking = true;
+ mMutex.unlock();
+
bool retVal = true;
locAPIStartTracking(mTrackingOptions);
return retVal;
@@ -149,6 +155,11 @@
bool GnssAPIClient::gnssStop()
{
LOC_LOGD("%s]: ()", __FUNCTION__);
+
+ mMutex.lock();
+ mTracking = false;
+ mMutex.unlock();
+
bool retVal = true;
locAPIStopTracking();
return retVal;
@@ -349,11 +360,17 @@
void GnssAPIClient::onTrackingCb(Location location)
{
- LOC_LOGD("%s]: (flags: %02x)", __FUNCTION__, location.flags);
mMutex.lock();
auto gnssCbIface(mGnssCbIface);
+ bool isTracking = mTracking;
mMutex.unlock();
+ LOC_LOGD("%s]: (flags: %02x isTracking: %d)", __FUNCTION__, location.flags, isTracking);
+
+ if (!isTracking) {
+ return;
+ }
+
if (gnssCbIface != nullptr) {
GnssLocation gnssLocation;
convertGnssLocation(location, gnssLocation);
diff --git a/sdm845/android/location_api/GnssAPIClient.h b/sdm845/android/location_api/GnssAPIClient.h
index 82f8fbf..39e919e 100644
--- a/sdm845/android/location_api/GnssAPIClient.h
+++ b/sdm845/android/location_api/GnssAPIClient.h
@@ -98,6 +98,7 @@
LocationAPIControlClient* mControlClient;
LocationCapabilitiesMask mLocationCapabilitiesMask;
bool mLocationCapabilitiesCached;
+ bool mTracking;
TrackingOptions mTrackingOptions;
};