sanders: gps: update to LA.UM.7.6.r1-02000-89xx.0 tag
This commit is contained in:
@@ -29,12 +29,12 @@
|
||||
#define LOG_NDDEBUG 0
|
||||
#define LOG_TAG "LocSvc_APIClientBase"
|
||||
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <loc_pla.h>
|
||||
#include <log_util.h>
|
||||
#include <inttypes.h>
|
||||
#include <loc_cfg.h>
|
||||
#include "LocationAPIClientBase.h"
|
||||
|
||||
#define FLP_CONF_FILE "/etc/flp.conf"
|
||||
#define GEOFENCE_SESSION_ID 0xFFFFFFFF
|
||||
#define CONFIG_SESSION_ID 0xFFFFFFFF
|
||||
|
||||
@@ -153,7 +153,6 @@ uint32_t LocationAPIControlClient::locAPIGnssUpdateConfig(GnssConfig config)
|
||||
|
||||
memcpy(&mConfig, &config, sizeof(GnssConfig));
|
||||
|
||||
uint32_t session = 0;
|
||||
uint32_t* idArray = mLocationControlAPI->gnssUpdateConfig(config);
|
||||
LOC_LOGV("%s:%d] gnssUpdateConfig return array: %p", __FUNCTION__, __LINE__, idArray);
|
||||
if (idArray != nullptr) {
|
||||
@@ -365,7 +364,7 @@ int32_t LocationAPIClientBase::locAPIGetBatchSize()
|
||||
{
|
||||
{"BATCH_SIZE", &mBatchSize, nullptr, 'n'},
|
||||
};
|
||||
UTIL_READ_CONF(FLP_CONF_FILE, flp_conf_param_table);
|
||||
UTIL_READ_CONF(LOC_PATH_FLP_CONF, flp_conf_param_table);
|
||||
if (mBatchSize < 0) {
|
||||
// set mBatchSize to 0 if we got an illegal value from config file
|
||||
mBatchSize = 0;
|
||||
@@ -393,14 +392,20 @@ uint32_t LocationAPIClientBase::locAPIStartSession(uint32_t id, uint32_t session
|
||||
trackingSession = mLocationAPI->startTracking(locationOptions);
|
||||
LOC_LOGI("%s:%d] start new session: %d", __FUNCTION__, __LINE__, trackingSession);
|
||||
mRequestQueues[REQUEST_SESSION].push(new StartTrackingRequest(*this));
|
||||
} else if ((sessionMode == SESSION_MODE_ON_FULL) ||
|
||||
(sessionMode == SESSION_MODE_ON_TRIP_COMPLETED)) {
|
||||
} else {
|
||||
// Fill in the batch mode
|
||||
BatchingOptions batchOptions = {};
|
||||
batchOptions.size = sizeof(BatchingOptions);
|
||||
batchOptions.batchingMode = BATCHING_MODE_ROUTINE;
|
||||
if (sessionMode == SESSION_MODE_ON_TRIP_COMPLETED) {
|
||||
switch (sessionMode) {
|
||||
case SESSION_MODE_ON_FULL:
|
||||
batchOptions.batchingMode = BATCHING_MODE_ROUTINE;
|
||||
break;
|
||||
case SESSION_MODE_ON_TRIP_COMPLETED:
|
||||
batchOptions.batchingMode = BATCHING_MODE_TRIP;
|
||||
break;
|
||||
default:
|
||||
batchOptions.batchingMode = BATCHING_MODE_NO_AUTO_REPORT;
|
||||
break;
|
||||
}
|
||||
|
||||
batchingSession = mLocationAPI->startBatching(locationOptions, batchOptions);
|
||||
@@ -409,8 +414,7 @@ uint32_t LocationAPIClientBase::locAPIStartSession(uint32_t id, uint32_t session
|
||||
mRequestQueues[REQUEST_SESSION].push(new StartBatchingRequest(*this));
|
||||
}
|
||||
|
||||
uint32_t session = ((sessionMode == SESSION_MODE_ON_FULL ||
|
||||
(sessionMode == SESSION_MODE_ON_TRIP_COMPLETED)) ?
|
||||
uint32_t session = ((sessionMode != SESSION_MODE_ON_FIX) ?
|
||||
batchingSession : trackingSession);
|
||||
|
||||
SessionEntity entity;
|
||||
@@ -445,12 +449,9 @@ uint32_t LocationAPIClientBase::locAPIStopSession(uint32_t id)
|
||||
if (sMode == SESSION_MODE_ON_FIX) {
|
||||
mRequestQueues[REQUEST_SESSION].push(new StopTrackingRequest(*this));
|
||||
mLocationAPI->stopTracking(trackingSession);
|
||||
} else if ((sMode == SESSION_MODE_ON_FULL) ||
|
||||
(sMode == SESSION_MODE_ON_TRIP_COMPLETED)) {
|
||||
} else {
|
||||
mRequestQueues[REQUEST_SESSION].push(new StopBatchingRequest(*this));
|
||||
mLocationAPI->stopBatching(batchingSession);
|
||||
} else {
|
||||
LOC_LOGE("%s:%d] unknown mode %d.", __FUNCTION__, __LINE__, sMode);
|
||||
}
|
||||
|
||||
retVal = LOCATION_ERROR_SUCCESS;
|
||||
@@ -484,8 +485,7 @@ uint32_t LocationAPIClientBase::locAPIUpdateSessionOptions(uint32_t id, uint32_t
|
||||
mRequestQueues[REQUEST_SESSION].push(new UpdateTrackingOptionsRequest(*this));
|
||||
if (sMode == SESSION_MODE_ON_FIX) {
|
||||
mLocationAPI->updateTrackingOptions(trackingSession, options);
|
||||
} else if ((sMode == SESSION_MODE_ON_FULL) ||
|
||||
(sMode == SESSION_MODE_ON_TRIP_COMPLETED)) {
|
||||
} else {
|
||||
// stop batching
|
||||
// batchingSession will be removed from mSessionBiDict soon,
|
||||
// so we don't need to add a new request to mRequestQueues[REQUEST_SESSION].
|
||||
@@ -497,19 +497,23 @@ uint32_t LocationAPIClientBase::locAPIUpdateSessionOptions(uint32_t id, uint32_t
|
||||
trackingSession = mLocationAPI->startTracking(options);
|
||||
LOC_LOGI("%s:%d] start new session: %d",
|
||||
__FUNCTION__, __LINE__, trackingSession);
|
||||
} else {
|
||||
LOC_LOGE("%s:%d] unknown mode %d", __FUNCTION__, __LINE__, sMode);
|
||||
}
|
||||
} else if ((sessionMode == SESSION_MODE_ON_FULL) ||
|
||||
(sessionMode == SESSION_MODE_ON_TRIP_COMPLETED)) {
|
||||
} else {
|
||||
// we only add an UpdateBatchingOptionsRequest to mRequestQueues[REQUEST_SESSION],
|
||||
// even if this update request will stop tracking and then start batching.
|
||||
mRequestQueues[REQUEST_SESSION].push(new UpdateBatchingOptionsRequest(*this));
|
||||
BatchingOptions batchOptions = {};
|
||||
batchOptions.size = sizeof(BatchingOptions);
|
||||
batchOptions.batchingMode = BATCHING_MODE_ROUTINE;
|
||||
if (sessionMode == SESSION_MODE_ON_TRIP_COMPLETED) {
|
||||
batchOptions.batchingMode = BATCHING_MODE_TRIP;
|
||||
switch (sessionMode) {
|
||||
case SESSION_MODE_ON_FULL:
|
||||
batchOptions.batchingMode = BATCHING_MODE_ROUTINE;
|
||||
break;
|
||||
case SESSION_MODE_ON_TRIP_COMPLETED:
|
||||
batchOptions.batchingMode = BATCHING_MODE_TRIP;
|
||||
break;
|
||||
default:
|
||||
batchOptions.batchingMode = BATCHING_MODE_NO_AUTO_REPORT;
|
||||
break;
|
||||
}
|
||||
|
||||
if (sMode == SESSION_MODE_ON_FIX) {
|
||||
@@ -524,19 +528,13 @@ uint32_t LocationAPIClientBase::locAPIUpdateSessionOptions(uint32_t id, uint32_t
|
||||
LOC_LOGI("%s:%d] start new session: %d",
|
||||
__FUNCTION__, __LINE__, batchingSession);
|
||||
mRequestQueues[REQUEST_SESSION].setSession(batchingSession);
|
||||
} else if ((sMode == SESSION_MODE_ON_FULL) ||
|
||||
(sMode == SESSION_MODE_ON_TRIP_COMPLETED)) {
|
||||
mLocationAPI->updateBatchingOptions(batchingSession, options, batchOptions);
|
||||
} else {
|
||||
LOC_LOGE("%s:%d] unknown mode %d", __FUNCTION__, __LINE__, sMode);
|
||||
mLocationAPI->updateBatchingOptions(batchingSession, options, batchOptions);
|
||||
}
|
||||
|
||||
} else {
|
||||
LOC_LOGE("%s:%d] unknown mode %d.", __FUNCTION__, __LINE__, sessionMode);
|
||||
}
|
||||
|
||||
uint32_t session = ((sessionMode == SESSION_MODE_ON_FULL) ||
|
||||
(sessionMode == SESSION_MODE_ON_TRIP_COMPLETED) ?
|
||||
uint32_t session = ((sessionMode != SESSION_MODE_ON_FIX) ?
|
||||
batchingSession : trackingSession);
|
||||
|
||||
entity.trackingSession = trackingSession;
|
||||
@@ -556,22 +554,31 @@ uint32_t LocationAPIClientBase::locAPIUpdateSessionOptions(uint32_t id, uint32_t
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void LocationAPIClientBase::locAPIGetBatchedLocations(uint32_t id, size_t count)
|
||||
uint32_t LocationAPIClientBase::locAPIGetBatchedLocations(uint32_t id, size_t count)
|
||||
{
|
||||
uint32_t retVal = LOCATION_ERROR_GENERAL_FAILURE;
|
||||
pthread_mutex_lock(&mMutex);
|
||||
if (mLocationAPI) {
|
||||
uint32_t session = 0;
|
||||
session = mRequestQueues[REQUEST_SESSION].getSession();
|
||||
if (session > 0) {
|
||||
if (mSessionBiDict.hasId(id)) {
|
||||
SessionEntity entity = mSessionBiDict.getExtById(id);
|
||||
uint32_t batchingSession = entity.batchingSession;
|
||||
mRequestQueues[REQUEST_SESSION].push(new GetBatchedLocationsRequest(*this));
|
||||
mLocationAPI->getBatchedLocations(batchingSession, count);
|
||||
if (entity.sessionMode != SESSION_MODE_ON_FIX) {
|
||||
uint32_t batchingSession = entity.batchingSession;
|
||||
mRequestQueues[REQUEST_SESSION].push(new GetBatchedLocationsRequest(*this));
|
||||
mLocationAPI->getBatchedLocations(batchingSession, count);
|
||||
retVal = LOCATION_ERROR_SUCCESS;
|
||||
} else {
|
||||
LOC_LOGE("%s:%d] Unsupported for session id: %d, mode is SESSION_MODE_ON_FIX",
|
||||
__FUNCTION__, __LINE__, id);
|
||||
retVal = LOCATION_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
} else {
|
||||
LOC_LOGE("%s:%d] invalid session: %d.", __FUNCTION__, __LINE__, session);
|
||||
retVal = LOCATION_ERROR_ID_UNKNOWN;
|
||||
LOC_LOGE("%s:%d] invalid session: %d.", __FUNCTION__, __LINE__, id);
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&mMutex);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
uint32_t LocationAPIClientBase::locAPIAddGeofences(
|
||||
@@ -612,16 +619,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;
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
sessions[j] = mGeofenceBiDict.getSession(ids[i]);
|
||||
if (sessions[j] > 0) {
|
||||
GeofenceBreachTypeMask type = mGeofenceBiDict.getExtBySession(sessions[j]);
|
||||
mGeofenceBiDict.rmBySession(sessions[j]);
|
||||
removedGeofenceBiDict->set(ids[i], sessions[j], type);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
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__,
|
||||
@@ -743,38 +758,8 @@ void LocationAPIClientBase::locAPIResumeGeofences(
|
||||
|
||||
void LocationAPIClientBase::locAPIRemoveAllGeofences()
|
||||
{
|
||||
pthread_mutex_lock(&mMutex);
|
||||
if (mLocationAPI) {
|
||||
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);
|
||||
std::vector<uint32_t> sessionsVec = mGeofenceBiDict.getAllSessions();
|
||||
locAPIRemoveGeofences(sessionsVec.size(), &sessionsVec[0]);
|
||||
}
|
||||
|
||||
void LocationAPIClientBase::locAPIGnssNiResponse(uint32_t id, GnssNiResponse response)
|
||||
|
||||
Reference in New Issue
Block a user