summaryrefslogtreecommitdiff
path: root/location/LocationAPIClientBase.h
diff options
context:
space:
mode:
authorKevin Tang <zhikait@codeaurora.org>2017-10-20 13:26:11 -0700
committerKevin Tang <zhikait@codeaurora.org>2017-10-25 15:04:06 -0700
commit63c4d2f67b37d49704cd464b23060267199a824e (patch)
tree28702d176978746abc7abe93015423979333817b /location/LocationAPIClientBase.h
parent57640c9f33972bd9e527953d90e81c4363cdc45e (diff)
downloadgps-63c4d2f67b37d49704cd464b23060267199a824e.tar.gz
locAPIRemoveGeofences roolback to async result notification
locAPIRemoveGeofences is rolled back to async result notification, using the RemoveGeofencesRequest, but using a new temporal bidict of sessions & ids, to avoid a previous race condition using the wrong id when removing and adding a geofence. Change-Id: Icd85373b82e620ea4059431f0c3d13c95f99ca3c CRs-fixed: 2132679
Diffstat (limited to 'location/LocationAPIClientBase.h')
-rw-r--r--location/LocationAPIClientBase.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/location/LocationAPIClientBase.h b/location/LocationAPIClientBase.h
index c6ea05c..99c7c87 100644
--- a/location/LocationAPIClientBase.h
+++ b/location/LocationAPIClientBase.h
@@ -36,6 +36,7 @@
#include <map>
#include "LocationAPI.h"
+#include "platform_lib_log_util.h"
enum SESSION_MODE {
SESSION_MODE_NONE = 0,
@@ -469,11 +470,24 @@ private:
class RemoveGeofencesRequest : public LocationAPIRequest {
public:
- RemoveGeofencesRequest(LocationAPIClientBase& API) : mAPI(API) {}
+ RemoveGeofencesRequest(LocationAPIClientBase& API,
+ BiDict<GeofenceBreachTypeMask>* removedGeofenceBiDict) :
+ mAPI(API), mRemovedGeofenceBiDict(removedGeofenceBiDict) {}
inline void onCollectiveResponse(size_t count, LocationError* errors, uint32_t* sessions) {
- // No need to handle collectiveResponse, cbs already notified
+ if (nullptr != mRemovedGeofenceBiDict) {
+ uint32_t *ids = (uint32_t*)malloc(sizeof(uint32_t) * count);
+ for (size_t i = 0; i < count; i++) {
+ ids[i] = mRemovedGeofenceBiDict->getId(sessions[i]);
+ }
+ mAPI.onRemoveGeofencesCb(count, errors, ids);
+ free(ids);
+ delete(mRemovedGeofenceBiDict);
+ } else {
+ LOC_LOGE("%s:%d] Unable to access removed geofences data.", __FUNCTION__, __LINE__);
+ }
}
LocationAPIClientBase& mAPI;
+ BiDict<GeofenceBreachTypeMask>* mRemovedGeofenceBiDict;
};
class ModifyGeofencesRequest : public LocationAPIRequest {