summaryrefslogtreecommitdiff
path: root/location/LocationAPIClientBase.cpp
diff options
context:
space:
mode:
authorBaili Feng <bailif@codeaurora.org>2017-05-09 15:36:10 +0800
committerBaili Feng <bailif@codeaurora.org>2017-05-10 13:21:26 +0800
commit1e0be88b948f3460b3b030a080f3083a1f893db7 (patch)
tree3af86097fd56070124da2e87e63f64938233118a /location/LocationAPIClientBase.cpp
parent10ab9ccaaf7f24ce126fd0d7998f6164a5e5f871 (diff)
downloadgps-1e0be88b948f3460b3b030a080f3083a1f893db7.tar.gz
Maintain a uniq RequestQueue for Geofencing
Maintain a RequestQueue for Geofencing per LocationAPIClientBase instance. The RequestQueue must be released when LocationAPIClientBase is destroyed. Change-Id: Icceccdaae67883f8848dd2a95389b938058c5e5d CRs-fixed: 2044463
Diffstat (limited to 'location/LocationAPIClientBase.cpp')
-rw-r--r--location/LocationAPIClientBase.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/location/LocationAPIClientBase.cpp b/location/LocationAPIClientBase.cpp
index a160adc..5078313 100644
--- a/location/LocationAPIClientBase.cpp
+++ b/location/LocationAPIClientBase.cpp
@@ -34,6 +34,7 @@
#include "LocationAPIClientBase.h"
#define BATCHING_CONF_FILE "/etc/flp.conf"
+#define GEOFENCE_SESSION_ID -1
LocationAPIClientBase::LocationAPIClientBase() :
mTrackingCallback(nullptr),
@@ -405,15 +406,16 @@ uint32_t LocationAPIClientBase::locAPIAddGeofences(
if (mLocationAPI) {
pthread_mutex_lock(&mMutex);
RequestQueue* requests = mRequestQueues[REQUEST_GEOFENCE];
- if (requests) {
- delete requests;
+ if (!requests) {
+ // Create a new RequestQueue for Geofenceing if we've not had one.
+ // The RequestQueue will be released when LocationAPIClientBase is released.
+ requests = new RequestQueue(GEOFENCE_SESSION_ID);
+ mRequestQueues[REQUEST_GEOFENCE] = requests;
}
uint32_t* sessions = mLocationAPI->addGeofences(count, options, data);
if (sessions) {
LOC_LOGI("%s:%d] start new sessions: %p", __FUNCTION__, __LINE__, sessions);
- requests = new RequestQueue(-1);
requests->push(new AddGeofencesRequest(*this));
- mRequestQueues[REQUEST_GEOFENCE] = requests;
for (size_t i = 0; i < count; i++) {
mGeofenceBiDict.set(ids[i], sessions[i], options[i].breachTypeMask);