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
This commit is contained in:
parent
10ab9ccaaf
commit
1e0be88b94
1 changed files with 6 additions and 4 deletions
|
@ -34,6 +34,7 @@
|
||||||
#include "LocationAPIClientBase.h"
|
#include "LocationAPIClientBase.h"
|
||||||
|
|
||||||
#define BATCHING_CONF_FILE "/etc/flp.conf"
|
#define BATCHING_CONF_FILE "/etc/flp.conf"
|
||||||
|
#define GEOFENCE_SESSION_ID -1
|
||||||
|
|
||||||
LocationAPIClientBase::LocationAPIClientBase() :
|
LocationAPIClientBase::LocationAPIClientBase() :
|
||||||
mTrackingCallback(nullptr),
|
mTrackingCallback(nullptr),
|
||||||
|
@ -405,15 +406,16 @@ uint32_t LocationAPIClientBase::locAPIAddGeofences(
|
||||||
if (mLocationAPI) {
|
if (mLocationAPI) {
|
||||||
pthread_mutex_lock(&mMutex);
|
pthread_mutex_lock(&mMutex);
|
||||||
RequestQueue* requests = mRequestQueues[REQUEST_GEOFENCE];
|
RequestQueue* requests = mRequestQueues[REQUEST_GEOFENCE];
|
||||||
if (requests) {
|
if (!requests) {
|
||||||
delete 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);
|
uint32_t* sessions = mLocationAPI->addGeofences(count, options, data);
|
||||||
if (sessions) {
|
if (sessions) {
|
||||||
LOC_LOGI("%s:%d] start new sessions: %p", __FUNCTION__, __LINE__, sessions);
|
LOC_LOGI("%s:%d] start new sessions: %p", __FUNCTION__, __LINE__, sessions);
|
||||||
requests = new RequestQueue(-1);
|
|
||||||
requests->push(new AddGeofencesRequest(*this));
|
requests->push(new AddGeofencesRequest(*this));
|
||||||
mRequestQueues[REQUEST_GEOFENCE] = requests;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < count; i++) {
|
for (size_t i = 0; i < count; i++) {
|
||||||
mGeofenceBiDict.set(ids[i], sessions[i], options[i].breachTypeMask);
|
mGeofenceBiDict.set(ids[i], sessions[i], options[i].breachTypeMask);
|
||||||
|
|
Loading…
Reference in a new issue