Merge "Adding one level of context swith for Geofence_add"
This commit is contained in:
commit
1c669d75d6
2 changed files with 28 additions and 23 deletions
|
@ -242,30 +242,33 @@ GeofenceAdapter::addGeofencesCommand(LocationAPI* client, size_t count, Geofence
|
|||
if (NULL == mIds || NULL == mOptions || NULL == mInfos) {
|
||||
errs[i] = LOCATION_ERROR_INVALID_PARAMETER;
|
||||
} else {
|
||||
mApi.addGeofence(mIds[i],
|
||||
mOptions[i],
|
||||
mInfos[i],
|
||||
new LocApiResponseData<LocApiGeofenceData>(*mAdapter.getContext(),
|
||||
[&mAdapter = mAdapter, mOptions = mOptions, mClient = mClient,
|
||||
mCount = mCount, mIds = mIds, mInfos = mInfos, errs, i]
|
||||
(LocationError err, LocApiGeofenceData data) {
|
||||
if (LOCATION_ERROR_SUCCESS == err) {
|
||||
mAdapter.saveGeofenceItem(mClient,
|
||||
mIds[i],
|
||||
data.hwId,
|
||||
mOptions[i],
|
||||
mInfos[i]);
|
||||
}
|
||||
errs[i] = err;
|
||||
mApi.addToCallQueue(new LocApiResponse(*mAdapter.getContext(),
|
||||
[&mAdapter = mAdapter, mCount = mCount, mClient = mClient,
|
||||
mOptions = mOptions, mInfos = mInfos, mIds = mIds, &mApi = mApi,
|
||||
errs, i] (LocationError err ) {
|
||||
mApi.addGeofence(mIds[i], mOptions[i], mInfos[i],
|
||||
new LocApiResponseData<LocApiGeofenceData>(*mAdapter.getContext(),
|
||||
[&mAdapter = mAdapter, mOptions = mOptions, mClient = mClient,
|
||||
mCount = mCount, mIds = mIds, mInfos = mInfos, errs, i]
|
||||
(LocationError err, LocApiGeofenceData data) {
|
||||
if (LOCATION_ERROR_SUCCESS == err) {
|
||||
mAdapter.saveGeofenceItem(mClient,
|
||||
mIds[i],
|
||||
data.hwId,
|
||||
mOptions[i],
|
||||
mInfos[i]);
|
||||
}
|
||||
errs[i] = err;
|
||||
|
||||
// Send aggregated response on last item and cleanup
|
||||
if (i == mCount-1) {
|
||||
mAdapter.reportResponse(mClient, mCount, errs, mIds);
|
||||
delete[] errs;
|
||||
delete[] mIds;
|
||||
delete[] mOptions;
|
||||
delete[] mInfos;
|
||||
}
|
||||
// Send aggregated response on last item and cleanup
|
||||
if (i == mCount-1) {
|
||||
mAdapter.reportResponse(mClient, mCount, errs, mIds);
|
||||
delete[] errs;
|
||||
delete[] mIds;
|
||||
delete[] mOptions;
|
||||
delete[] mInfos;
|
||||
}
|
||||
}));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -488,6 +488,7 @@ private:
|
|||
for (size_t i = 0; i < count; i++) {
|
||||
ids[i] = mAPI.mGeofenceBiDict.getId(sessions[i]);
|
||||
}
|
||||
LOC_LOGD("%s:]Returned geofence-id: %d in add geofence", __FUNCTION__, *ids);
|
||||
mAPI.onAddGeofencesCb(count, errors, ids);
|
||||
free(ids);
|
||||
}
|
||||
|
@ -505,6 +506,7 @@ private:
|
|||
for (size_t i = 0; i < count; i++) {
|
||||
ids[i] = mRemovedGeofenceBiDict->getId(sessions[i]);
|
||||
}
|
||||
LOC_LOGD("%s:]Returned geofence-id: %d in remove geofence", __FUNCTION__, *ids);
|
||||
mAPI.onRemoveGeofencesCb(count, errors, ids);
|
||||
free(ids);
|
||||
delete(mRemovedGeofenceBiDict);
|
||||
|
|
Loading…
Reference in a new issue