diff options
author | Kevin Tang <zhikait@codeaurora.org> | 2017-10-20 13:26:11 -0700 |
---|---|---|
committer | Kevin Tang <zhikait@codeaurora.org> | 2017-10-25 15:04:06 -0700 |
commit | 63c4d2f67b37d49704cd464b23060267199a824e (patch) | |
tree | 28702d176978746abc7abe93015423979333817b /location/LocationAPIClientBase.cpp | |
parent | 57640c9f33972bd9e527953d90e81c4363cdc45e (diff) | |
download | gps-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.cpp')
-rwxr-xr-x[-rw-r--r--] | location/LocationAPIClientBase.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/location/LocationAPIClientBase.cpp b/location/LocationAPIClientBase.cpp index 50b4b83..5a50c2d 100644..100755 --- a/location/LocationAPIClientBase.cpp +++ b/location/LocationAPIClientBase.cpp @@ -614,26 +614,24 @@ void LocationAPIClientBase::locAPIRemoveGeofences(size_t count, uint32_t* ids) } if (mRequestQueues[REQUEST_GEOFENCE].getSession() == GEOFENCE_SESSION_ID) { + BiDict<GeofenceBreachTypeMask>* removedGeofenceBiDict = + new BiDict<GeofenceBreachTypeMask>(); size_t j = 0; - uint32_t id_cb; - LocationError err; for (size_t i = 0; i < count; i++) { sessions[j] = mGeofenceBiDict.getSession(ids[i]); - id_cb = ids[i]; if (sessions[j] > 0) { + GeofenceBreachTypeMask type = mGeofenceBiDict.getExtBySession(sessions[j]); mGeofenceBiDict.rmBySession(sessions[j]); - err = LOCATION_ERROR_SUCCESS; - onRemoveGeofencesCb(1, &err, &id_cb); + removedGeofenceBiDict->set(ids[i], sessions[j], type); j++; - } else { - err = LOCATION_ERROR_ID_UNKNOWN; - onRemoveGeofencesCb(1, &err, &id_cb); } } - if (j > 0) { - mRequestQueues[REQUEST_GEOFENCE].push(new RemoveGeofencesRequest(*this)); + mRequestQueues[REQUEST_GEOFENCE].push(new RemoveGeofencesRequest(*this, + removedGeofenceBiDict)); mLocationAPI->removeGeofences(j, sessions); + } else { + delete(removedGeofenceBiDict); } } else { LOC_LOGE("%s:%d] invalid session: %d.", __FUNCTION__, __LINE__, |