locAPIRemoveGeofences now notify the result inmediately
locAPIRemoveGeofences is no longer waiting for the request response, instead it will always notify his callbacks with LOCATION_ERROR_SUCCESS if the provided id is found, or LOCATION_ERROR_ID_UNKNOWN if not. Change-Id: I602ad43bee894e85fde1e80210e6477b628e4a39 CRs-fixed: 2099450
This commit is contained in:
parent
220b5cb581
commit
c7642dca5f
2 changed files with 13 additions and 39 deletions
|
@ -613,12 +613,22 @@ void LocationAPIClientBase::locAPIRemoveGeofences(size_t count, uint32_t* ids)
|
||||||
|
|
||||||
if (mRequestQueues[REQUEST_GEOFENCE].getSession() == GEOFENCE_SESSION_ID) {
|
if (mRequestQueues[REQUEST_GEOFENCE].getSession() == GEOFENCE_SESSION_ID) {
|
||||||
size_t j = 0;
|
size_t j = 0;
|
||||||
|
uint32_t id_cb;
|
||||||
|
LocationError err;
|
||||||
for (size_t i = 0; i < count; i++) {
|
for (size_t i = 0; i < count; i++) {
|
||||||
sessions[j] = mGeofenceBiDict.getSession(ids[i]);
|
sessions[j] = mGeofenceBiDict.getSession(ids[i]);
|
||||||
|
id_cb = ids[i];
|
||||||
if (sessions[j] > 0) {
|
if (sessions[j] > 0) {
|
||||||
|
mGeofenceBiDict.rmBySession(sessions[j]);
|
||||||
|
err = LOCATION_ERROR_SUCCESS;
|
||||||
|
onRemoveGeofencesCb(1, &err, &id_cb);
|
||||||
j++;
|
j++;
|
||||||
|
} else {
|
||||||
|
err = LOCATION_ERROR_ID_UNKNOWN;
|
||||||
|
onRemoveGeofencesCb(1, &err, &id_cb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j > 0) {
|
if (j > 0) {
|
||||||
mRequestQueues[REQUEST_GEOFENCE].push(new RemoveGeofencesRequest(*this));
|
mRequestQueues[REQUEST_GEOFENCE].push(new RemoveGeofencesRequest(*this));
|
||||||
mLocationAPI->removeGeofences(j, sessions);
|
mLocationAPI->removeGeofences(j, sessions);
|
||||||
|
@ -743,38 +753,8 @@ void LocationAPIClientBase::locAPIResumeGeofences(
|
||||||
|
|
||||||
void LocationAPIClientBase::locAPIRemoveAllGeofences()
|
void LocationAPIClientBase::locAPIRemoveAllGeofences()
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&mMutex);
|
std::vector<uint32_t> sessionsVec = mGeofenceBiDict.getAllSessions();
|
||||||
if (mLocationAPI) {
|
locAPIRemoveGeofences(sessionsVec.size(), &sessionsVec[0]);
|
||||||
std::vector<uint32_t> sessionsVec = mGeofenceBiDict.getAllSessions();
|
|
||||||
size_t count = sessionsVec.size();
|
|
||||||
uint32_t* sessions = (uint32_t*)malloc(sizeof(uint32_t) * count);
|
|
||||||
if (sessions == NULL) {
|
|
||||||
LOC_LOGE("%s:%d] Failed to allocate %zu bytes !",
|
|
||||||
__FUNCTION__, __LINE__, sizeof(uint32_t) * count);
|
|
||||||
pthread_mutex_unlock(&mMutex);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mRequestQueues[REQUEST_GEOFENCE].getSession() == GEOFENCE_SESSION_ID) {
|
|
||||||
size_t j = 0;
|
|
||||||
for (size_t i = 0; i < count; i++) {
|
|
||||||
sessions[j] = sessionsVec[i];
|
|
||||||
if (sessions[j] > 0) {
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (j > 0) {
|
|
||||||
mRequestQueues[REQUEST_GEOFENCE].push(new RemoveGeofencesRequest(*this));
|
|
||||||
mLocationAPI->removeGeofences(j, sessions);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
LOC_LOGE("%s:%d] invalid session: %d.", __FUNCTION__, __LINE__,
|
|
||||||
mRequestQueues[REQUEST_GEOFENCE].getSession());
|
|
||||||
}
|
|
||||||
|
|
||||||
free(sessions);
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock(&mMutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocationAPIClientBase::locAPIGnssNiResponse(uint32_t id, GnssNiResponse response)
|
void LocationAPIClientBase::locAPIGnssNiResponse(uint32_t id, GnssNiResponse response)
|
||||||
|
|
|
@ -465,13 +465,7 @@ private:
|
||||||
public:
|
public:
|
||||||
RemoveGeofencesRequest(LocationAPIClientBase& API) : mAPI(API) {}
|
RemoveGeofencesRequest(LocationAPIClientBase& API) : mAPI(API) {}
|
||||||
inline void onCollectiveResponse(size_t count, LocationError* errors, uint32_t* sessions) {
|
inline void onCollectiveResponse(size_t count, LocationError* errors, uint32_t* sessions) {
|
||||||
uint32_t *ids = (uint32_t*)malloc(sizeof(uint32_t) * count);
|
// No need to handle collectiveResponse, cbs already notified
|
||||||
for (size_t i = 0; i < count; i++) {
|
|
||||||
ids[i] = mAPI.mGeofenceBiDict.getId(sessions[i]);
|
|
||||||
mAPI.mGeofenceBiDict.rmBySession(sessions[i]);
|
|
||||||
}
|
|
||||||
mAPI.onRemoveGeofencesCb(count, errors, ids);
|
|
||||||
free(ids);
|
|
||||||
}
|
}
|
||||||
LocationAPIClientBase& mAPI;
|
LocationAPIClientBase& mAPI;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue