diff --git a/android/location_api/GeofenceAPIClient.cpp b/android/location_api/GeofenceAPIClient.cpp index 5be1cff2..ee4bfc38 100644 --- a/android/location_api/GeofenceAPIClient.cpp +++ b/android/location_api/GeofenceAPIClient.cpp @@ -100,7 +100,10 @@ void GeofenceAPIClient::geofenceAdd(uint32_t geofence_id, double latitude, doubl data.longitude = longitude; data.radius = radius_meters; - locAPIAddGeofences(1, &geofence_id, &options, &data); + LocationError err = (LocationError)locAPIAddGeofences(1, &geofence_id, &options, &data); + if (LOCATION_ERROR_SUCCESS != err) { + onAddGeofencesCb(1, &err, &geofence_id); + } } void GeofenceAPIClient::geofencePause(uint32_t geofence_id) diff --git a/location/LocationAPIClientBase.cpp b/location/LocationAPIClientBase.cpp index da56440b..6ced55a0 100644 --- a/location/LocationAPIClientBase.cpp +++ b/location/LocationAPIClientBase.cpp @@ -409,17 +409,18 @@ uint32_t LocationAPIClientBase::locAPIAddGeofences( delete requests; } uint32_t* sessions = mLocationAPI->addGeofences(count, options, data); - LOC_LOGI("%s:%d] start new sessions: %p", __FUNCTION__, __LINE__, sessions); - requests = new RequestQueue(-1); - requests->push(new AddGeofencesRequest(*this)); - mRequestQueues[REQUEST_GEOFENCE] = requests; + if (sessions) { + LOC_LOGI("%s:%d] start new sessions: %p", __FUNCTION__, __LINE__, sessions); + requests = new RequestQueue(-1); + requests->push(new AddGeofencesRequest(*this)); + mRequestQueues[REQUEST_GEOFENCE] = requests; - for (size_t i = 0; i < count; i++) { - mGeofenceBiDict.set(ids[i], sessions[i], options[i].breachTypeMask); + for (size_t i = 0; i < count; i++) { + mGeofenceBiDict.set(ids[i], sessions[i], options[i].breachTypeMask); + } + retVal = LOCATION_ERROR_SUCCESS; } pthread_mutex_unlock(&mMutex); - - retVal = LOCATION_ERROR_SUCCESS; } return retVal;