LocationAPI implementation

Implementation of LocationAPI into gps hal
to be a common API that is called into by platform
specific APIs.

Change-Id: Ie5a7bd217d4ae2175ad49e6aca2fb6ecd4702f3b
CRs-fixed: 1112712
This commit is contained in:
Dante Russo 2017-02-28 16:45:47 -08:00
parent 4bb940c067
commit c85c8ff673
99 changed files with 8279 additions and 22675 deletions

5
Android.mk Normal file
View file

@ -0,0 +1,5 @@
ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
LOCAL_PATH := $(call my-dir)
include $(call all-makefiles-under,$(LOCAL_PATH))
endif

56
android/Android.mk Normal file
View file

@ -0,0 +1,56 @@
ifneq ($(BUILD_TINY_ANDROID),true)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := gps.$(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE)
LOCAL_MODULE_OWNER := qti
LOCAL_MODULE_TAGS := optional
## Libs
LOCAL_SHARED_LIBRARIES := \
libutils \
libcutils \
liblog \
libloc_core \
libgps.utils \
libdl \
libloc_pla \
liblocation_api \
LOCAL_SRC_FILES += \
gps.c \
loc.cpp \
loc_geofence.cpp \
GnssAPIClient.cpp \
GeofenceAPIClient.cpp \
LOCAL_CFLAGS += \
-Wunused-parameter \
-fno-short-enums \
-D_ANDROID_ \
ifeq ($(TARGET_BUILD_VARIANT),user)
LOCAL_CFLAGS += -DTARGET_BUILD_VARIANT_USER
endif
ifeq ($(TARGET_USES_QCOM_BSP), true)
LOCAL_CFLAGS += -DTARGET_USES_QCOM_BSP
endif
## Includes
LOCAL_C_INCLUDES:= \
$(TARGET_OUT_HEADERS)/gps.utils \
$(TARGET_OUT_HEADERS)/libloc_core \
$(TARGET_OUT_HEADERS)/libloc_pla \
$(TARGET_OUT_HEADERS)/liblocation_api \
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE_RELATIVE_PATH := hw
include $(BUILD_SHARED_LIBRARY)
endif # not BUILD_TINY_ANDROID

View file

@ -0,0 +1,242 @@
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#define LOG_NDDEBUG 0
#define LOG_TAG "LocSvc_GeofenceApiClient"
#include <log_util.h>
#include <loc_cfg.h>
#include "GeofenceAPIClient.h"
static void convertGpsLocation(Location& in, GpsLocation& out)
{
memset(&out, 0, sizeof(GpsLocation));
out.size = sizeof(GpsLocation);
if (in.flags & LOCATION_HAS_LAT_LONG_BIT)
out.flags |= GPS_LOCATION_HAS_LAT_LONG;
if (in.flags & LOCATION_HAS_ALTITUDE_BIT)
out.flags |= GPS_LOCATION_HAS_ALTITUDE;
if (in.flags & LOCATION_HAS_SPEED_BIT)
out.flags |= GPS_LOCATION_HAS_SPEED;
if (in.flags & LOCATION_HAS_BEARING_BIT)
out.flags |= GPS_LOCATION_HAS_BEARING;
if (in.flags & LOCATION_HAS_ACCURACY_BIT)
out.flags |= GPS_LOCATION_HAS_ACCURACY;
out.latitude = in.latitude;
out.longitude = in.longitude;
out.altitude = in.altitude;
out.speed = in.speed;
out.bearing = in.bearing;
out.accuracy = in.accuracy;
out.timestamp = (GpsUtcTime)in.timestamp;
}
GeofenceAPIClient::GeofenceAPIClient(GpsGeofenceCallbacks* cbs) :
LocationAPIClientBase(),
mGpsGeofenceCallbacks(cbs)
{
LOC_LOGD("%s]: (%p)", __func__, cbs);
LocationCallbacks locationCallbacks;
locationCallbacks.size = sizeof(LocationCallbacks);
locationCallbacks.trackingCb = nullptr;
locationCallbacks.batchingCb = nullptr;
locationCallbacks.geofenceBreachCb = nullptr;
if (mGpsGeofenceCallbacks && mGpsGeofenceCallbacks->geofence_transition_callback) {
locationCallbacks.geofenceBreachCb =
[this](GeofenceBreachNotification geofenceBreachNotification) {
onGeofenceBreachCb(geofenceBreachNotification);
};
}
locationCallbacks.geofenceStatusCb = nullptr;
if (mGpsGeofenceCallbacks && mGpsGeofenceCallbacks->geofence_status_callback) {
locationCallbacks.geofenceStatusCb =
[this](GeofenceStatusNotification geofenceStatusNotification) {
onGeofenceStatusCb(geofenceStatusNotification);
};
}
locationCallbacks.gnssLocationInfoCb = nullptr;
locationCallbacks.gnssNiCb = nullptr;
locationCallbacks.gnssSvCb = nullptr;
locationCallbacks.gnssNmeaCb = nullptr;
locationCallbacks.gnssMeasurementsCb = nullptr;
locAPISetCallbacks(locationCallbacks);
}
void GeofenceAPIClient::geofenceAdd(uint32_t geofence_id, double latitude, double longitude,
double radius_meters, int last_transition, int monitor_transitions,
int notification_responsiveness_ms, int unknown_timer_ms)
{
LOC_LOGD("%s]: (%d %f %f %f %d %d %d %d)", __func__,
geofence_id, latitude, longitude, radius_meters,
last_transition, monitor_transitions, notification_responsiveness_ms, unknown_timer_ms);
GeofenceOption options;
memset(&options, 0, sizeof(GeofenceOption));
options.size = sizeof(GeofenceOption);
if (monitor_transitions & GPS_GEOFENCE_ENTERED)
options.breachTypeMask |= GEOFENCE_BREACH_ENTER_BIT;
if (monitor_transitions & GPS_GEOFENCE_EXITED)
options.breachTypeMask |= GEOFENCE_BREACH_EXIT_BIT;
options.responsiveness = notification_responsiveness_ms;
GeofenceInfo data;
data.size = sizeof(GeofenceInfo);
data.latitude = latitude;
data.longitude = longitude;
data.radius = radius_meters;
locAPIAddGeofences(1, &geofence_id, &options, &data);
}
void GeofenceAPIClient::geofencePause(uint32_t geofence_id)
{
LOC_LOGD("%s]: (%d)", __func__, geofence_id);
locAPIPauseGeofences(1, &geofence_id);
}
void GeofenceAPIClient::geofenceResume(uint32_t geofence_id, int monitor_transitions)
{
LOC_LOGD("%s]: (%d %d)", __func__, geofence_id, monitor_transitions);
GeofenceBreachTypeMask mask = 0;
if (monitor_transitions & GPS_GEOFENCE_ENTERED)
mask |= GEOFENCE_BREACH_ENTER_BIT;
if (monitor_transitions & GPS_GEOFENCE_EXITED)
mask |= GEOFENCE_BREACH_EXIT_BIT;
locAPIResumeGeofences(1, &geofence_id, &mask);
}
void GeofenceAPIClient::geofenceRemove(uint32_t geofence_id)
{
LOC_LOGD("%s]: (%d)", __func__, geofence_id);
locAPIRemoveGeofences(1, &geofence_id);
}
// callbacks
void GeofenceAPIClient::onGeofenceBreachCb(GeofenceBreachNotification geofenceBreachNotification)
{
LOC_LOGD("%s]: (%zu)", __func__, geofenceBreachNotification.count);
if (mGpsGeofenceCallbacks && mGpsGeofenceCallbacks->geofence_transition_callback) {
for (size_t i = 0; i < geofenceBreachNotification.count; i++) {
GpsLocation location;
convertGpsLocation(geofenceBreachNotification.location, location);
uint32_t transition;
if (geofenceBreachNotification.type == GEOFENCE_BREACH_ENTER)
transition = GPS_GEOFENCE_ENTERED;
else if (geofenceBreachNotification.type == GEOFENCE_BREACH_EXIT)
transition = GPS_GEOFENCE_EXITED;
else {
// continue with other breach if transition is
// nether GPS_GEOFENCE_ENTERED nor GPS_GEOFENCE_EXITED
continue;
}
GpsUtcTime time = geofenceBreachNotification.timestamp;
mGpsGeofenceCallbacks->geofence_transition_callback(geofenceBreachNotification.ids[i],
&location, transition, time);
}
}
}
void GeofenceAPIClient::onGeofenceStatusCb(GeofenceStatusNotification geofenceStatusNotification)
{
LOC_LOGD("%s]: (%d)", __func__, geofenceStatusNotification.available);
if (mGpsGeofenceCallbacks && mGpsGeofenceCallbacks->geofence_status_callback) {
int32_t status = GPS_GEOFENCE_UNAVAILABLE;
if (geofenceStatusNotification.available == GEOFENCE_STATUS_AVAILABILE_YES) {
status = GPS_GEOFENCE_AVAILABLE;
}
mGpsGeofenceCallbacks->geofence_status_callback(status, nullptr);
}
}
void GeofenceAPIClient::onAddGeofencesCb(size_t count, LocationError* errors, uint32_t* ids)
{
LOC_LOGD("%s]: (%zu)", __func__, count);
if (mGpsGeofenceCallbacks && mGpsGeofenceCallbacks->geofence_add_callback) {
for (size_t i = 0; i < count; i++) {
int32_t status = GPS_GEOFENCE_ERROR_GENERIC;
if (errors[i] == LOCATION_ERROR_SUCCESS)
status = GPS_GEOFENCE_OPERATION_SUCCESS;
mGpsGeofenceCallbacks->geofence_add_callback(ids[i], status);
}
}
}
void GeofenceAPIClient::onRemoveGeofencesCb(size_t count, LocationError* errors, uint32_t* ids)
{
LOC_LOGD("%s]: (%zu)", __func__, count);
if (mGpsGeofenceCallbacks && mGpsGeofenceCallbacks->geofence_remove_callback) {
for (size_t i = 0; i < count; i++) {
int32_t status = GPS_GEOFENCE_ERROR_GENERIC;
if (errors[i] == LOCATION_ERROR_SUCCESS)
status = GPS_GEOFENCE_OPERATION_SUCCESS;
else if (errors[i] == LOCATION_ERROR_ID_UNKNOWN)
status = GPS_GEOFENCE_ERROR_ID_UNKNOWN;
mGpsGeofenceCallbacks->geofence_remove_callback(ids[i], status);
}
}
}
void GeofenceAPIClient::onPauseGeofencesCb(size_t count, LocationError* errors, uint32_t* ids)
{
LOC_LOGD("%s]: (%zu)", __func__, count);
if (mGpsGeofenceCallbacks && mGpsGeofenceCallbacks->geofence_pause_callback) {
for (size_t i = 0; i < count; i++) {
int32_t status = GPS_GEOFENCE_ERROR_GENERIC;
if (errors[i] == LOCATION_ERROR_SUCCESS)
status = GPS_GEOFENCE_OPERATION_SUCCESS;
else if (errors[i] == LOCATION_ERROR_ID_UNKNOWN)
status = GPS_GEOFENCE_ERROR_ID_UNKNOWN;
mGpsGeofenceCallbacks->geofence_pause_callback(ids[i], status);
}
}
}
void GeofenceAPIClient::onResumeGeofencesCb(size_t count, LocationError* errors, uint32_t* ids)
{
LOC_LOGD("%s]: (%zu)", __func__, count);
if (mGpsGeofenceCallbacks && mGpsGeofenceCallbacks->geofence_resume_callback) {
for (size_t i = 0; i < count; i++) {
int32_t status = GPS_GEOFENCE_ERROR_GENERIC;
if (errors[i] == LOCATION_ERROR_SUCCESS)
status = GPS_GEOFENCE_OPERATION_SUCCESS;
else if (errors[i] == LOCATION_ERROR_ID_UNKNOWN)
status = GPS_GEOFENCE_ERROR_ID_UNKNOWN;
mGpsGeofenceCallbacks->geofence_resume_callback(ids[i], status);
}
}
}

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -27,18 +27,34 @@
*
*/
#ifndef LOC_ENG_LOG_H
#define LOC_ENG_LOG_H
#ifndef GEOFENCE_API_CLINET_H
#define GEOFENCE_API_CLINET_H
#ifdef __cplusplus
extern "C"
#include <hardware/gps.h>
#include <LocationAPIClientBase.h>
class GeofenceAPIClient : public LocationAPIClientBase
{
#endif
public:
GeofenceAPIClient(GpsGeofenceCallbacks* cbs);
virtual ~GeofenceAPIClient() = default;
#include <ctype.h>
void geofenceAdd(uint32_t geofence_id, double latitude, double longitude,
double radius_meters, int last_transition, int monitor_transitions,
int notification_responsiveness_ms, int unknown_timer_ms);
void geofencePause(uint32_t geofence_id);
void geofenceResume(uint32_t geofence_id, int monitor_transitions);
void geofenceRemove(uint32_t geofence_id);
#ifdef __cplusplus
}
#endif
// callbacks
void onGeofenceBreachCb(GeofenceBreachNotification geofenceBreachNotification) final;
void onGeofenceStatusCb(GeofenceStatusNotification geofenceStatusNotification) final;
void onAddGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
void onRemoveGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
void onPauseGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
void onResumeGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
#endif /* LOC_ENG_LOG_H */
private:
GpsGeofenceCallbacks* mGpsGeofenceCallbacks;
};
#endif // GEOFENCE_API_CLINET_H

765
android/GnssAPIClient.cpp Normal file
View file

@ -0,0 +1,765 @@
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#define LOG_NDDEBUG 0
#define LOG_TAG "LocSvc_GnssAPIClient"
#include <log_util.h>
#include <loc_cfg.h>
#include "GnssAPIClient.h"
static void convertGpsLocation(Location& in, GpsLocation& out);
static void convertGpsSvStatus(GnssSvNotification& in, GpsSvStatus& out);
static void convertGnssConstellationType(GnssSvType& in, GnssConstellationType& out);
static void convertGnssSvStatus(GnssSvNotification& in, GnssSvStatus& out);
static void convertGpsMeasurement(GnssMeasurementsData& in, GpsMeasurement& out);
static void convertGpsClock(GnssMeasurementsClock& in, GpsClock& out);
static void convertGpsData(GnssMeasurementsNotification& in, GpsData& out);
static void convertGnssClock(GnssMeasurementsClock& in, GnssClock& out);
static void convertGnssData(GnssMeasurementsNotification& in, GnssData& out);
GnssAPIClient::GnssAPIClient(GpsCallbacks* gpsCb,
GpsNiCallbacks* niCb,
GpsMeasurementCallbacks* measurementCb) :
LocationAPIClientBase(),
mGpsCallbacks(nullptr),
mGpsNiCallbacks(nullptr),
mLocationCapabilitiesMask(0),
mGpsMeasurementCallbacks(nullptr)
{
LOC_LOGD("%s]: (%p %p %p)", __func__, gpsCb, niCb, measurementCb);
pthread_mutex_init(&mLock, nullptr);
// set default LocationOptions.
memset(&mLocationOptions, 0, sizeof(LocationOptions));
mLocationOptions.size = sizeof(LocationOptions);
mLocationOptions.minInterval = 1000;
mLocationOptions.minDistance = 0;
mLocationOptions.mode = GNSS_SUPL_MODE_STANDALONE;
gnssUpdateCallbacks(gpsCb, niCb, measurementCb);
}
GnssAPIClient::~GnssAPIClient()
{
LOC_LOGD("%s]: ()", __func__);
pthread_mutex_destroy(&mLock);
}
// for GpsInterface
void GnssAPIClient::gnssUpdateCallbacks(GpsCallbacks* gpsCb,
GpsNiCallbacks* niCb,
GpsMeasurementCallbacks* measurementCb)
{
LOC_LOGD("%s]: (%p %p %p)", __func__, gpsCb, niCb, measurementCb);
mGpsCallbacks = gpsCb;
mGpsNiCallbacks = niCb;
mGpsMeasurementCallbacks = measurementCb;
LocationCallbacks locationCallbacks;
locationCallbacks.size = sizeof(LocationCallbacks);
locationCallbacks.trackingCb = nullptr;
if (mGpsCallbacks && mGpsCallbacks->location_cb) {
locationCallbacks.trackingCb = [this](Location location) {
onTrackingCb(location);
};
}
locationCallbacks.batchingCb = nullptr;
locationCallbacks.geofenceBreachCb = nullptr;
locationCallbacks.geofenceStatusCb = nullptr;
locationCallbacks.gnssLocationInfoCb = nullptr;
locationCallbacks.gnssNiCb = nullptr;
if (mGpsNiCallbacks && mGpsNiCallbacks->notify_cb) {
locationCallbacks.gnssNiCb = [this](uint32_t id, GnssNiNotification gnssNiNotification) {
onGnssNiCb(id, gnssNiNotification);
};
}
locationCallbacks.gnssSvCb = nullptr;
if (mGpsCallbacks && mGpsCallbacks->sv_status_cb) {
locationCallbacks.gnssSvCb = [this](GnssSvNotification gnssSvNotification) {
onGnssSvCb(gnssSvNotification);
};
}
locationCallbacks.gnssNmeaCb = nullptr;
if (mGpsCallbacks && mGpsCallbacks->nmea_cb) {
locationCallbacks.gnssNmeaCb = [this](GnssNmeaNotification gnssNmeaNotification) {
onGnssNmeaCb(gnssNmeaNotification);
};
}
locationCallbacks.gnssMeasurementsCb = nullptr;
if (mGpsMeasurementCallbacks &&
(mGpsMeasurementCallbacks->measurement_callback ||
mGpsMeasurementCallbacks->gnss_measurement_callback)) {
locationCallbacks.gnssMeasurementsCb =
[this](GnssMeasurementsNotification gnssMeasurementsNotification) {
onGnssMeasurementsCb(gnssMeasurementsNotification);
};
}
locAPISetCallbacks(locationCallbacks);
}
int GnssAPIClient::gnssStart()
{
LOC_LOGD("%s]: ()", __func__);
int retVal = 0;
locAPIStartTracking(mLocationOptions);
return retVal;
}
int GnssAPIClient::gnssStop()
{
LOC_LOGD("%s]: ()", __func__);
int retVal = 0;
locAPIStopTracking();
return retVal;
}
void GnssAPIClient::gnssDeleteAidingData(GpsAidingData f)
{
LOC_LOGD("%s]: (%02x)", __func__, f);
GnssAidingData data;
memset(&data, 0, sizeof (GnssAidingData));
data.sv.svTypeMask = GNSS_AIDING_DATA_SV_TYPE_GPS |
GNSS_AIDING_DATA_SV_TYPE_GLONASS |
GNSS_AIDING_DATA_SV_TYPE_QZSS |
GNSS_AIDING_DATA_SV_TYPE_BEIDOU |
GNSS_AIDING_DATA_SV_TYPE_GALILEO;
if (f == GPS_DELETE_ALL)
data.deleteAll = true;
else {
if (f & GPS_DELETE_EPHEMERIS) data.sv.svMask |= GNSS_AIDING_DATA_SV_EPHEMERIS;
if (f & GPS_DELETE_ALMANAC) data.sv.svMask |= GNSS_AIDING_DATA_SV_ALMANAC;
if (f & GPS_DELETE_POSITION) data.common.mask |= GNSS_AIDING_DATA_COMMON_POSITION;
if (f & GPS_DELETE_TIME) data.common.mask |= GNSS_AIDING_DATA_COMMON_TIME;
if (f & GPS_DELETE_IONO) data.sv.svMask |= GNSS_AIDING_DATA_SV_IONOSPHERE;
if (f & GPS_DELETE_UTC) data.common.mask |= GNSS_AIDING_DATA_COMMON_UTC;
if (f & GPS_DELETE_HEALTH) data.sv.svMask |= GNSS_AIDING_DATA_SV_HEALTH;
if (f & GPS_DELETE_SVDIR) data.sv.svMask |= GNSS_AIDING_DATA_SV_DIRECTION;
if (f & GPS_DELETE_SVSTEER) data.sv.svMask |= GNSS_AIDING_DATA_SV_STEER;
if (f & GPS_DELETE_SADATA) data.sv.svMask |= GNSS_AIDING_DATA_SV_SA_DATA;
if (f & GPS_DELETE_RTI) data.common.mask |= GNSS_AIDING_DATA_COMMON_RTI;
if (f & GPS_DELETE_CELLDB_INFO) data.common.mask |= GNSS_AIDING_DATA_COMMON_CELLDB;
}
locAPIGnssDeleteAidingData(data);
}
int GnssAPIClient::gnssSetPositionMode(GpsPositionMode mode, GpsPositionRecurrence recurrence,
uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time)
{
LOC_LOGD("%s]: (%d %d %d %d %d)", __func__,
mode, recurrence, min_interval, preferred_accuracy, preferred_time);
int retVal = 0;
memset(&mLocationOptions, 0, sizeof(LocationOptions));
mLocationOptions.size = sizeof(LocationOptions);
mLocationOptions.minInterval = min_interval;
mLocationOptions.minDistance = preferred_accuracy;
if (mode == GPS_POSITION_MODE_STANDALONE)
mLocationOptions.mode = GNSS_SUPL_MODE_STANDALONE;
else if (mode == GPS_POSITION_MODE_MS_BASED)
mLocationOptions.mode = GNSS_SUPL_MODE_MSB;
else if (mode == GPS_POSITION_MODE_MS_ASSISTED)
mLocationOptions.mode = GNSS_SUPL_MODE_MSA;
return retVal;
}
// for AGpsInterface
void GnssAPIClient::gnssAgnssSetServer(AGpsType type, const char *hostname, int port)
{
LOC_LOGD("%s]: (%d %s %d)", __func__, type, hostname, port);
GnssConfig data;
memset(&data, 0, sizeof(GnssConfig));
data.size = sizeof(GnssConfig);
data.flags |= GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT;
memset(&data.assistanceServer, 0, sizeof(GnssConfigSetAssistanceServer));
data.assistanceServer.size = sizeof(GnssConfigSetAssistanceServer);
if (type == AGPS_TYPE_SUPL)
data.assistanceServer.type = GNSS_ASSISTANCE_TYPE_SUPL;
else if (type == AGPS_TYPE_C2K)
data.assistanceServer.type = GNSS_ASSISTANCE_TYPE_C2K;
data.assistanceServer.hostName = hostname;
data.assistanceServer.port = port;
locAPIGnssUpdateConfig(data);
}
// for GpsNiInterface
void GnssAPIClient::gnssNiRespond(int notif_id, GpsUserResponseType user_response)
{
LOC_LOGD("%s]: (%d %d)", __func__, notif_id, user_response);
GnssNiResponse data = GNSS_NI_RESPONSE_IGNORE;
if (user_response == GPS_NI_RESPONSE_ACCEPT) data = GNSS_NI_RESPONSE_ACCEPT;
else if (user_response == GPS_NI_RESPONSE_DENY) data = GNSS_NI_RESPONSE_DENY;
else if (user_response == GPS_NI_RESPONSE_NORESP) data = GNSS_NI_RESPONSE_NO_RESPONSE;
locAPIGnssNiResponse(notif_id, data);
}
// for GpsMeasurementInterface
void GnssAPIClient::gnssMeasurementClose() {
LOC_LOGD("%s]: ()", __func__);
pthread_mutex_lock(&mLock);
mGpsMeasurementCallbacks = nullptr;
pthread_mutex_unlock(&mLock);
}
// for GnssConfigurationInterface
void GnssAPIClient::gnssConfigurationUpdate(const char* config_data, int32_t length)
{
LOC_LOGD("%s]: (%s %d)", __func__, config_data, length);
int n = 10;
uint8_t flags[n];
memset(&flags, 0, sizeof(uint8_t) * n);
GnssConfig data;
memset(&data, 0, sizeof(GnssConfig));
data.size = sizeof(GnssConfig);
const loc_param_s_type gnssConfTable[] =
{
{"GPS_LOCK", &data.gpsLock, flags+0, 'n'},
{"SUPL_VER", &data.suplVersion, flags+1, 'n'},
//{"ASSISTANCE_SERVER", &data.assistanceServer, nullptr, 's'},
{"LPP_PROFILE", &data.lppProfile, flags+3, 'n'},
{"LPPE_CP_TECHNOLOGY", &data.lppeControlPlaneMask, flags+4, 'n'},
{"LPPE_UP_TECHNOLOGY", &data.lppeUserPlaneMask, flags+5, 'n'},
{"A_GLONASS_POS_PROTOCOL_SELECT", &data.aGlonassPositionProtocolMask, flags+6, 'n'},
{"USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL",&data.emergencyPdnForEmergencySupl, flags+7, 'n'},
{"SUPL_ES", &data.suplEmergencyServices, flags+8, 'n'},
{"SUPL_MODE", &data.suplModeMask, flags+9, 'n'},
};
UTIL_UPDATE_CONF(config_data, length, gnssConfTable);
for (int i = 0; i < n; i++) {
if (flags[i] != 0)
data.flags |= (0x1 << i);
}
locAPIGnssUpdateConfig(data);
}
// callbacks
void GnssAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask)
{
LOC_LOGD("%s]: (%02x)", __func__, capabilitiesMask);
mLocationCapabilitiesMask = capabilitiesMask;
if (mGpsCallbacks && mGpsCallbacks->set_capabilities_cb) {
uint32_t data = 0;
if ((capabilitiesMask & LOCATION_CAPABILITIES_TIME_BASED_TRACKING_BIT) ||
(capabilitiesMask & LOCATION_CAPABILITIES_TIME_BASED_BATCHING_BIT) ||
(capabilitiesMask & LOCATION_CAPABILITIES_DISTANCE_BASED_TRACKING_BIT) ||
(capabilitiesMask & LOCATION_CAPABILITIES_DISTANCE_BASED_BATCHING_BIT))
data |= GPS_CAPABILITY_SCHEDULING;
if (capabilitiesMask & LOCATION_CAPABILITIES_GEOFENCE_BIT)
data |= GPS_CAPABILITY_GEOFENCING;
if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT)
data |= GPS_CAPABILITY_MEASUREMENTS;
if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MSB_BIT)
data |= GPS_CAPABILITY_MSB;
if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MSA_BIT)
data |= GPS_CAPABILITY_MSA;
mGpsCallbacks->set_capabilities_cb(data);
}
if (mGpsCallbacks && mGpsCallbacks->set_system_info_cb) {
GnssSystemInfo info;
info.size = sizeof(GnssSystemInfo);
info.year_of_hw = 2015;
if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT) {
info.year_of_hw = 2017;
}
LOC_LOGV("%s:%d] set_system_info_cb (%d)", __func__, __LINE__, info.year_of_hw);
mGpsCallbacks->set_system_info_cb(&info);
}
}
void GnssAPIClient::onTrackingCb(Location location)
{
LOC_LOGD("%s]: (flags: %02x)", __func__, location.flags);
if (mGpsCallbacks && mGpsCallbacks->location_cb) {
GpsLocation data;
convertGpsLocation(location, data);
mGpsCallbacks->location_cb(&data);
}
}
void GnssAPIClient::onGnssNiCb(uint32_t id, GnssNiNotification gnssNiNotification)
{
LOC_LOGD("%s]: (id: %d)", __func__, id);
if (mGpsNiCallbacks && mGpsNiCallbacks->notify_cb) {
GpsNiNotification data;
memset(&data, 0, sizeof(GpsNiNotification));
data.size = sizeof(GpsNiNotification);
data.notification_id = id;
if (gnssNiNotification.type == GNSS_NI_TYPE_VOICE)
data.ni_type = GPS_NI_TYPE_VOICE;
else if (gnssNiNotification.type == GNSS_NI_TYPE_SUPL)
data.ni_type = GPS_NI_TYPE_UMTS_SUPL;
else if (gnssNiNotification.type == GNSS_NI_TYPE_CONTROL_PLANE)
data.ni_type = GPS_NI_TYPE_UMTS_CTRL_PLANE;
// GNSS_NI_TYPE_EMERGENCY_SUPL not supported
if (gnssNiNotification.options == GNSS_NI_OPTIONS_NOTIFICATION)
data.notify_flags = GPS_NI_NEED_NOTIFY;
else if (gnssNiNotification.options == GNSS_NI_OPTIONS_VERIFICATION)
data.notify_flags = GPS_NI_NEED_VERIFY;
else if (gnssNiNotification.options == GNSS_NI_OPTIONS_PRIVACY_OVERRIDE)
data.notify_flags = GPS_NI_PRIVACY_OVERRIDE;
data.timeout = gnssNiNotification.timeout;
if (gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_ACCEPT)
data.default_response = GPS_NI_RESPONSE_ACCEPT;
else if (gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_DENY)
data.default_response = GPS_NI_RESPONSE_DENY;
else if (gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_NO_RESPONSE ||
gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_IGNORE)
data.default_response = GPS_NI_RESPONSE_NORESP;
int len = GPS_NI_SHORT_STRING_MAXLEN < GNSS_NI_REQUESTOR_MAX
? GPS_NI_SHORT_STRING_MAXLEN : GNSS_NI_REQUESTOR_MAX;
memcpy(data.requestor_id, gnssNiNotification.requestor, len);
len = GPS_NI_LONG_STRING_MAXLEN < GNSS_NI_MESSAGE_ID_MAX
? GPS_NI_LONG_STRING_MAXLEN : GNSS_NI_MESSAGE_ID_MAX;
memcpy(data.text, gnssNiNotification.message, len);
if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_NONE)
data.requestor_id_encoding = GPS_ENC_NONE;
else if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_GSM_DEFAULT)
data.requestor_id_encoding = GPS_ENC_SUPL_GSM_DEFAULT;
else if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_UTF8)
data.requestor_id_encoding = GPS_ENC_SUPL_UTF8;
else if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_UCS2)
data.requestor_id_encoding = GPS_ENC_SUPL_UCS2;
if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_NONE)
data.text_encoding = GPS_ENC_NONE;
else if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_GSM_DEFAULT)
data.text_encoding = GPS_ENC_SUPL_GSM_DEFAULT;
else if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_UTF8)
data.text_encoding = GPS_ENC_SUPL_UTF8;
else if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_UCS2)
data.text_encoding = GPS_ENC_SUPL_UCS2;
data.text_encoding = gnssNiNotification.messageEncoding;
memcpy(data.extras, gnssNiNotification.extras, len);
mGpsNiCallbacks->notify_cb(&data);
}
}
void GnssAPIClient::onGnssSvCb(GnssSvNotification gnssSvNotification)
{
LOC_LOGD("%s]: (count: %zu)", __func__, gnssSvNotification.count);
if (mGpsCallbacks && mGpsCallbacks->sv_status_cb) {
GpsSvStatus data;
convertGpsSvStatus(gnssSvNotification, data);
mGpsCallbacks->sv_status_cb(&data);
}
if (mGpsCallbacks && mGpsCallbacks->gnss_sv_status_cb) {
GnssSvStatus data;
convertGnssSvStatus(gnssSvNotification, data);
mGpsCallbacks->gnss_sv_status_cb(&data);
}
}
void GnssAPIClient::onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification)
{
if (mGpsCallbacks && mGpsCallbacks->nmea_cb) {
mGpsCallbacks->nmea_cb((GpsUtcTime)gnssNmeaNotification.timestamp,
gnssNmeaNotification.nmea, gnssNmeaNotification.length);
}
}
void GnssAPIClient::onGnssMeasurementsCb(GnssMeasurementsNotification gnssMeasurementsNotification)
{
LOC_LOGD("%s]: (count: %zu)", __func__, gnssMeasurementsNotification.count);
// we don't need to lock the mutext
// if mGpsMeasurementCallbacks is set to nullptr
if (mGpsMeasurementCallbacks) {
pthread_mutex_lock(&mLock);
if (mGpsMeasurementCallbacks) {
if (mGpsMeasurementCallbacks->measurement_callback) {
GpsData data;
convertGpsData(gnssMeasurementsNotification, data);
mGpsMeasurementCallbacks->measurement_callback(&data);
}
if (mGpsMeasurementCallbacks->gnss_measurement_callback) {
GnssData data;
convertGnssData(gnssMeasurementsNotification, data);
mGpsMeasurementCallbacks->gnss_measurement_callback(&data);
}
}
pthread_mutex_unlock(&mLock);
}
}
void GnssAPIClient::onStartTrackingCb(LocationError error)
{
LOC_LOGD("%s]: (%d)", __func__, error);
if (error == LOCATION_ERROR_SUCCESS && mGpsCallbacks && mGpsCallbacks->status_cb) {
GpsStatus data;
data.size = sizeof(GpsStatus);
data.status = GPS_STATUS_ENGINE_ON;
mGpsCallbacks->status_cb(&data);
data.status = GPS_STATUS_SESSION_BEGIN;
mGpsCallbacks->status_cb(&data);
}
}
void GnssAPIClient::onStopTrackingCb(LocationError error)
{
LOC_LOGD("%s]: (%d)", __func__, error);
if (error == LOCATION_ERROR_SUCCESS && mGpsCallbacks && mGpsCallbacks->status_cb) {
GpsStatus data;
data.size = sizeof(GpsStatus);
data.status = GPS_STATUS_SESSION_END;
mGpsCallbacks->status_cb(&data);
data.status = GPS_STATUS_ENGINE_OFF;
mGpsCallbacks->status_cb(&data);
}
}
static void convertGpsLocation(Location& in, GpsLocation& out)
{
memset(&out, 0, sizeof(GpsLocation));
out.size = sizeof(GpsLocation);
if (in.flags & LOCATION_HAS_LAT_LONG_BIT)
out.flags |= GPS_LOCATION_HAS_LAT_LONG;
if (in.flags & LOCATION_HAS_ALTITUDE_BIT)
out.flags |= GPS_LOCATION_HAS_ALTITUDE;
if (in.flags & LOCATION_HAS_SPEED_BIT)
out.flags |= GPS_LOCATION_HAS_SPEED;
if (in.flags & LOCATION_HAS_BEARING_BIT)
out.flags |= GPS_LOCATION_HAS_BEARING;
if (in.flags & LOCATION_HAS_ACCURACY_BIT)
out.flags |= GPS_LOCATION_HAS_ACCURACY;
out.latitude = in.latitude;
out.longitude = in.longitude;
out.altitude = in.altitude;
out.speed = in.speed;
out.bearing = in.bearing;
out.accuracy = in.accuracy;
out.timestamp = (GpsUtcTime)in.timestamp;
}
static void convertGpsSvStatus(GnssSvNotification& in, GpsSvStatus& out)
{
memset(&out, 0, sizeof(GpsSvStatus));
out.size = sizeof(GpsSvStatus);
out.num_svs = in.count;
int len = GPS_MAX_SVS < GNSS_SV_MAX ? GPS_MAX_SVS : GNSS_SV_MAX;
for (int i = 0; i < len; i++) {
GpsSvInfo& info = out.sv_list[i];
info.size = sizeof(GpsSvInfo);
info.prn = in.gnssSvs[i].svId;
info.snr = in.gnssSvs[i].cN0Dbhz;
info.elevation = in.gnssSvs[i].elevation;
info.azimuth = in.gnssSvs[i].azimuth;
if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_EPHEMER_BIT)
out.ephemeris_mask |= 0x1 < i;
if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_ALMANAC_BIT)
out.almanac_mask |= 0x1 < i;
if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_USED_IN_FIX_BIT)
out.used_in_fix_mask |= 0x1 < i;
}
}
static void convertGnssConstellationType(GnssSvType& in, GnssConstellationType& out)
{
switch(in) {
case GNSS_SV_TYPE_GPS:
out = GNSS_CONSTELLATION_GPS;
break;
case GNSS_SV_TYPE_SBAS:
out = GNSS_CONSTELLATION_SBAS;
break;
case GNSS_SV_TYPE_GLONASS:
out = GNSS_CONSTELLATION_GLONASS;
break;
case GNSS_SV_TYPE_QZSS:
out = GNSS_CONSTELLATION_QZSS;
break;
case GNSS_SV_TYPE_BEIDOU:
out = GNSS_CONSTELLATION_BEIDOU;
break;
case GNSS_SV_TYPE_GALILEO:
out = GNSS_CONSTELLATION_GALILEO;
break;
default:
out = GNSS_CONSTELLATION_UNKNOWN;
break;
}
}
static void convertGnssSvStatus(GnssSvNotification& in, GnssSvStatus& out)
{
memset(&out, 0, sizeof(GnssSvStatus));
out.size = sizeof(GnssSvStatus);
out.num_svs = in.count;
int len = GNSS_MAX_SVS < GNSS_SV_MAX ? GNSS_MAX_SVS : GNSS_SV_MAX;
for (int i = 0; i < len; i++) {
GnssSvInfo& info = out.gnss_sv_list[i];
info.size = sizeof(GnssSvInfo);
info.svid = in.gnssSvs[i].svId;
convertGnssConstellationType(in.gnssSvs[i].type, info.constellation);
info.c_n0_dbhz = in.gnssSvs[i].cN0Dbhz;
info.elevation = in.gnssSvs[i].elevation;
info.azimuth = in.gnssSvs[i].azimuth;
info.flags = GNSS_SV_FLAGS_NONE;
if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_EPHEMER_BIT)
info.flags |= GNSS_SV_FLAGS_HAS_EPHEMERIS_DATA;
if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_ALMANAC_BIT)
info.flags |= GNSS_SV_FLAGS_HAS_ALMANAC_DATA;
if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_USED_IN_FIX_BIT)
info.flags |= GNSS_SV_FLAGS_USED_IN_FIX;
}
}
static void convertGpsMeasurement(GnssMeasurementsData& in, GpsMeasurement& out)
{
memset(&out, 0, sizeof(GpsMeasurement));
out.size = sizeof(GpsMeasurement);
if (in.flags & GNSS_MEASUREMENTS_DATA_SIGNAL_TO_NOISE_RATIO_BIT)
out.flags |= GPS_MEASUREMENT_HAS_SNR;
if (in.flags & GNSS_MEASUREMENTS_DATA_PSEUDORANGE_RATE_BIT)
out.flags |= GPS_MEASUREMENT_HAS_PSEUDORANGE;
if (in.flags & GNSS_MEASUREMENTS_DATA_PSEUDORANGE_RATE_UNCERTAINTY_BIT)
out.flags |= GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY;
if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_FREQUENCY_BIT)
out.flags |= GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY;
if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_CYCLES_BIT)
out.flags |= GPS_MEASUREMENT_HAS_CARRIER_CYCLES;
if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_BIT)
out.flags |= GPS_MEASUREMENT_HAS_CARRIER_PHASE;
if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_UNCERTAINTY_BIT)
out.flags |= GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY;
out.prn = in.svId;
out.time_offset_ns = in.timeOffsetNs;
out.state = GNSS_MEASUREMENT_STATE_UNKNOWN;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_CODE_LOCK_BIT)
out.state |= GPS_MEASUREMENT_STATE_CODE_LOCK;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_BIT_SYNC_BIT)
out.state |= GPS_MEASUREMENT_STATE_BIT_SYNC;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_SUBFRAME_SYNC_BIT)
out.state |= GPS_MEASUREMENT_STATE_SUBFRAME_SYNC;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_TOW_DECODED_BIT)
out.state |= GPS_MEASUREMENT_STATE_TOW_DECODED;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_MSEC_AMBIGUOUS_BIT)
out.state |= GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS;
out.received_gps_tow_ns = in.receivedSvTimeNs;
out.received_gps_tow_uncertainty_ns = in.receivedSvTimeUncertaintyNs;
out.c_n0_dbhz = in.carrierToNoiseDbHz;
out.pseudorange_rate_mps = in.pseudorangeRateMps;
out.pseudorange_rate_uncertainty_mps = in.pseudorangeRateUncertaintyMps;
out.accumulated_delta_range_state = GNSS_ADR_STATE_UNKNOWN;
if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_VALID_BIT)
out.accumulated_delta_range_state |= GPS_ADR_STATE_VALID;
if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_RESET_BIT)
out.accumulated_delta_range_state |= GPS_ADR_STATE_RESET;
if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_CYCLE_SLIP_BIT)
out.accumulated_delta_range_state |= GPS_ADR_STATE_CYCLE_SLIP;
out.accumulated_delta_range_m = in.adrMeters;
out.accumulated_delta_range_uncertainty_m = in.adrUncertaintyMeters;
out.carrier_frequency_hz = in.carrierFrequencyHz;
out.carrier_cycles = in.carrierCycles;
out.carrier_phase = in.carrierPhase;
out.carrier_phase_uncertainty = in.carrierPhaseUncertainty;
out.loss_of_lock = GPS_LOSS_OF_LOCK_UNKNOWN;
out.multipath_indicator = GPS_MULTIPATH_INDICATOR_UNKNOWN;
if (in.multipathIndicator & GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_PRESENT)
out.multipath_indicator |= GPS_MULTIPATH_INDICATOR_DETECTED;
if (in.multipathIndicator & GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_NOT_PRESENT)
out.multipath_indicator |= GPS_MULTIPATH_INDICATOR_NOT_USED;
out.snr_db = in.signalToNoiseRatioDb;
}
static void convertGpsClock(GnssMeasurementsClock& in, GpsClock& out)
{
memset(&out, 0, sizeof(GpsClock));
out.size = sizeof(GpsClock);
if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_LEAP_SECOND_BIT)
out.flags |= GPS_CLOCK_HAS_LEAP_SECOND;
if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_TIME_UNCERTAINTY_BIT)
out.flags |= GPS_CLOCK_HAS_TIME_UNCERTAINTY;
if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_FULL_BIAS_BIT)
out.flags |= GPS_CLOCK_HAS_FULL_BIAS;
if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_BIT)
out.flags |= GPS_CLOCK_HAS_BIAS;
if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_UNCERTAINTY_BIT)
out.flags |= GPS_CLOCK_HAS_BIAS_UNCERTAINTY;
if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_BIT)
out.flags |= GPS_CLOCK_HAS_DRIFT;
if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_UNCERTAINTY_BIT)
out.flags |= GPS_CLOCK_HAS_DRIFT_UNCERTAINTY;
out.leap_second = in.leapSecond;
out.type = GPS_CLOCK_TYPE_UNKNOWN;
out.time_ns = in.timeNs;
out.time_uncertainty_ns = in.timeUncertaintyNs;
out.full_bias_ns = in.fullBiasNs;
out.bias_ns = in.biasNs;
out.bias_uncertainty_ns = in.biasUncertaintyNs;
out.drift_nsps = in.driftNsps;
out.drift_uncertainty_nsps = in.driftUncertaintyNsps;
}
static void convertGpsData(GnssMeasurementsNotification& in, GpsData& out)
{
memset(&out, 0, sizeof(GpsData));
out.size = sizeof(GpsData);
out.measurement_count = in.count;
int len = GPS_MAX_MEASUREMENT < GNSS_MEASUREMENTS_MAX
? GPS_MAX_MEASUREMENT : GNSS_MEASUREMENTS_MAX;
for (int i = 0; i < len; i++) {
convertGpsMeasurement(in.measurements[i], out.measurements[i]);
}
convertGpsClock(in.clock, out.clock);
}
static void convertGnssMeasurement(GnssMeasurementsData& in, GnssMeasurement& out)
{
memset(&out, 0, sizeof(GnssMeasurement));
out.size = sizeof(GnssMeasurement);
if (in.flags & GNSS_MEASUREMENTS_DATA_SIGNAL_TO_NOISE_RATIO_BIT)
out.flags |= GNSS_MEASUREMENT_HAS_SNR;
if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_FREQUENCY_BIT)
out.flags |= GNSS_MEASUREMENT_HAS_CARRIER_FREQUENCY;
if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_CYCLES_BIT)
out.flags |= GNSS_MEASUREMENT_HAS_CARRIER_CYCLES;
if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_BIT)
out.flags |= GNSS_MEASUREMENT_HAS_CARRIER_PHASE;
if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_UNCERTAINTY_BIT)
out.flags |= GNSS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY;
out.svid = in.svId;
convertGnssConstellationType(in.svType, out.constellation);
out.time_offset_ns = in.timeOffsetNs;
out.state = GNSS_MEASUREMENT_STATE_UNKNOWN;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_CODE_LOCK_BIT)
out.state |= GNSS_MEASUREMENT_STATE_CODE_LOCK;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_BIT_SYNC_BIT)
out.state |= GNSS_MEASUREMENT_STATE_BIT_SYNC;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_SUBFRAME_SYNC_BIT)
out.state |= GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_TOW_DECODED_BIT)
out.state |= GNSS_MEASUREMENT_STATE_TOW_DECODED;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_MSEC_AMBIGUOUS_BIT)
out.state |= GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_SYMBOL_SYNC_BIT)
out.state |= GNSS_MEASUREMENT_STATE_SYMBOL_SYNC;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_GLO_STRING_SYNC_BIT)
out.state |= GNSS_MEASUREMENT_STATE_GLO_STRING_SYNC;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_GLO_TOD_DECODED_BIT)
out.state |= GNSS_MEASUREMENT_STATE_GLO_TOD_DECODED;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_BDS_D2_BIT_SYNC_BIT)
out.state |= GNSS_MEASUREMENT_STATE_BDS_D2_BIT_SYNC;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_BDS_D2_SUBFRAME_SYNC_BIT)
out.state |= GNSS_MEASUREMENT_STATE_BDS_D2_SUBFRAME_SYNC;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1BC_CODE_LOCK_BIT)
out.state |= GNSS_MEASUREMENT_STATE_GAL_E1BC_CODE_LOCK;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1C_2ND_CODE_LOCK_BIT)
out.state |= GNSS_MEASUREMENT_STATE_GAL_E1C_2ND_CODE_LOCK;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1B_PAGE_SYNC_BIT)
out.state |= GNSS_MEASUREMENT_STATE_GAL_E1B_PAGE_SYNC;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_SBAS_SYNC_BIT)
out.state |= GNSS_MEASUREMENT_STATE_SBAS_SYNC;
out.received_sv_time_in_ns = in.receivedSvTimeNs;
out.received_sv_time_uncertainty_in_ns = in.receivedSvTimeUncertaintyNs;
out.c_n0_dbhz = in.carrierToNoiseDbHz;
out.pseudorange_rate_mps = in.pseudorangeRateMps;
out.pseudorange_rate_uncertainty_mps = in.pseudorangeRateUncertaintyMps;
out.accumulated_delta_range_state = GNSS_ADR_STATE_UNKNOWN;
if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_VALID_BIT)
out.accumulated_delta_range_state |= GNSS_ADR_STATE_VALID;
if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_RESET_BIT)
out.accumulated_delta_range_state |= GNSS_ADR_STATE_RESET;
if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_CYCLE_SLIP_BIT)
out.accumulated_delta_range_state |= GNSS_ADR_STATE_CYCLE_SLIP;
out.accumulated_delta_range_m = in.adrMeters;
out.accumulated_delta_range_uncertainty_m = in.adrUncertaintyMeters;
out.carrier_frequency_hz = in.carrierFrequencyHz;
out.carrier_cycles = in.carrierCycles;
out.carrier_phase = in.carrierPhase;
out.carrier_phase_uncertainty = in.carrierPhaseUncertainty;
out.multipath_indicator = GNSS_MULTIPATH_INDICATOR_UNKNOWN;
if (in.multipathIndicator & GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_PRESENT)
out.multipath_indicator |= GNSS_MULTIPATH_INDICATOR_PRESENT;
if (in.multipathIndicator & GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_NOT_PRESENT)
out.multipath_indicator |= GNSS_MULTIPATH_INDICATOR_NOT_PRESENT;
out.snr_db = in.signalToNoiseRatioDb;
}
static void convertGnssClock(GnssMeasurementsClock& in, GnssClock& out)
{
memset(&out, 0, sizeof(GnssClock));
out.size = sizeof(GnssClock);
if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_LEAP_SECOND_BIT)
out.flags |= GNSS_CLOCK_HAS_LEAP_SECOND;
if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_TIME_UNCERTAINTY_BIT)
out.flags |= GNSS_CLOCK_HAS_TIME_UNCERTAINTY;
if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_FULL_BIAS_BIT)
out.flags |= GNSS_CLOCK_HAS_FULL_BIAS;
if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_BIT)
out.flags |= GNSS_CLOCK_HAS_BIAS;
if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_UNCERTAINTY_BIT)
out.flags |= GNSS_CLOCK_HAS_BIAS_UNCERTAINTY;
if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_BIT)
out.flags |= GNSS_CLOCK_HAS_DRIFT;
if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_UNCERTAINTY_BIT)
out.flags |= GNSS_CLOCK_HAS_DRIFT_UNCERTAINTY;
out.leap_second = in.leapSecond;
out.time_ns = in.timeNs;
out.time_uncertainty_ns = in.timeUncertaintyNs;
out.full_bias_ns = in.fullBiasNs;
out.bias_ns = in.biasNs;
out.bias_uncertainty_ns = in.biasUncertaintyNs;
out.drift_nsps = in.driftNsps;
out.drift_uncertainty_nsps = in.driftUncertaintyNsps;
out.hw_clock_discontinuity_count = in.hwClockDiscontinuityCount;
}
static void convertGnssData(GnssMeasurementsNotification& in, GnssData& out)
{
memset(&out, 0, sizeof(GnssData));
out.size = sizeof(GnssData);
out.measurement_count = in.count;
int len = GNSS_MAX_MEASUREMENT < GNSS_MEASUREMENTS_MAX
? GNSS_MAX_MEASUREMENT : GNSS_MEASUREMENTS_MAX;
for (int i = 0; i < len; i++) {
convertGnssMeasurement(in.measurements[i], out.measurements[i]);
}
convertGnssClock(in.clock, out.clock);
}

97
android/GnssAPIClient.h Normal file
View file

@ -0,0 +1,97 @@
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GNSS_API_CLINET_H
#define GNSS_API_CLINET_H
#include <hardware/gps.h>
#include <LocationAPIClientBase.h>
class GnssAPIClient : public LocationAPIClientBase
{
public:
GnssAPIClient(GpsCallbacks* gpsCb,
GpsNiCallbacks* niCb,
GpsMeasurementCallbacks* measurementCb);
virtual ~GnssAPIClient();
GnssAPIClient(const GnssAPIClient&) = delete;
GnssAPIClient& operator=(const GnssAPIClient&) = delete;
// for GpsInterface
void gnssUpdateCallbacks(GpsCallbacks* gpsCb,
GpsNiCallbacks* niCb,
GpsMeasurementCallbacks* measurementCb);
int gnssStart();
int gnssStop();
void gnssDeleteAidingData(GpsAidingData f);
int gnssSetPositionMode(GpsPositionMode mode, GpsPositionRecurrence recurrence,
uint32_t min_interval, uint32_t preferred_accuracy,
uint32_t preferred_time);
// for AGpsInterface
void gnssAgnssSetServer(AGpsType type, const char *hostname, int port);
// for GpsNiInterface
void gnssNiRespond(int notif_id, GpsUserResponseType user_response);
// for GpsMeasurementInterface
void gnssMeasurementClose();
// for GnssConfigurationInterface
void gnssConfigurationUpdate(const char* config_data, int32_t length);
inline LocationCapabilitiesMask gnssGetCapabilities() const {
return mLocationCapabilitiesMask;
}
// callbacks we are interested in
void onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask) final;
void onTrackingCb(Location location) final;
void onGnssNiCb(uint32_t id, GnssNiNotification gnssNiNotification) final;
void onGnssSvCb(GnssSvNotification gnssSvNotification) final;
void onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification) final;
void onGnssMeasurementsCb(GnssMeasurementsNotification gnssMeasurementsNotification) final;
void onStartTrackingCb(LocationError error) final;
void onStopTrackingCb(LocationError error) final;
private:
pthread_mutex_t mLock;
GpsCallbacks* mGpsCallbacks;
GpsNiCallbacks* mGpsNiCallbacks;
LocationCapabilitiesMask mLocationCapabilitiesMask;
GpsMeasurementCallbacks* mGpsMeasurementCallbacks;
LocationOptions mLocationOptions;
};
#endif // GNSS_API_CLINET_H

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011,2015 The Linux Foundation. All rights reserved.
/* Copyright (c) 2011, 2015-2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -32,16 +32,20 @@
#include <stdlib.h>
#include <string.h>
#define UNUSED(...) (void)(__VA_ARGS__)
extern const GpsInterface* get_gps_interface();
const GpsInterface* gps__get_gps_interface(struct gps_device_t* dev)
{
UNUSED(dev);
return get_gps_interface();
}
static int open_gps(const struct hw_module_t* module, char const* name,
struct hw_device_t** device)
{
UNUSED(name);
struct gps_device_t *dev = (struct gps_device_t *) malloc(sizeof(struct gps_device_t));
if(dev == NULL)

380
android/loc.cpp Normal file
View file

@ -0,0 +1,380 @@
/* Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#define LOG_NDDEBUG 0
#define LOG_TAG "LocSvc_afw"
#include <hardware/gps.h>
#include <LocDualContext.h>
#include <loc_target.h>
#include "GnssAPIClient.h"
extern "C" const GpsGeofencingInterface* get_gps_geofence_interface();
static GnssAPIClient* sClient = nullptr;
static GpsCallbacks sGpsCallbacks;
static GpsCallbacks* pGpsCallbacks = nullptr;
static GpsNiCallbacks sGpsNiCallbacks;
static GpsNiCallbacks* pGpsNiCallbacks = nullptr;
static GpsMeasurementCallbacks sGpsMeasurementCallbacks;
static GpsMeasurementCallbacks* pGpsMeasurementCallbacks = nullptr;
typedef struct {
bool pending;
AGpsType type;
char *hostname;
int port;
} AgnssServerPack;
static AgnssServerPack pendingAgnssServer = {
false,
AGPS_TYPE_SUPL,
nullptr,
0
};
typedef struct {
bool pending;
char* config_data;
int32_t length;
} ConfigurationPack;
static ConfigurationPack pendingConfiguration = {
false,
nullptr,
0
};
static GnssAPIClient* getClient() {
if (!sClient &&
// in order to create a GnssClient to call gnssUpdateConfig,
// one of pGpsCallbacks and pGpsNiCallbacks should not be nullptr.
(pGpsCallbacks != nullptr || pGpsNiCallbacks != nullptr)) {
sClient = new GnssAPIClient(pGpsCallbacks, pGpsNiCallbacks, pGpsMeasurementCallbacks);
if (sClient) {
sClient->locAPIEnable(LOCATION_TECHNOLOGY_TYPE_GNSS);
if (pendingAgnssServer.pending && pendingAgnssServer.hostname) {
sClient->gnssAgnssSetServer(pendingAgnssServer.type,
pendingAgnssServer.hostname,
pendingAgnssServer.port);
pendingAgnssServer.pending = false;
free(pendingAgnssServer.hostname);
pendingAgnssServer.hostname = nullptr;
}
if (pendingConfiguration.pending && pendingConfiguration.config_data) {
sClient->gnssConfigurationUpdate(pendingConfiguration.config_data,
pendingConfiguration.length);
pendingConfiguration.pending = false;
free(pendingConfiguration.config_data);
pendingConfiguration.config_data = nullptr;
}
}
}
if (!sClient) {
LOC_LOGE("%s:%d] get GnssAPIClient failed", __func__, __LINE__);
}
return sClient;
}
/*===========================================================================
Functions and variables for sGpsInterface
===========================================================================*/
static int loc_init(GpsCallbacks* callbacks) {
ENTRY_LOG_CALLFLOW();
int retVal = -1;
if (callbacks) {
GnssAPIClient* client = getClient();
// backup callbacks in case *callbacks is a stack variable
pGpsCallbacks = &sGpsCallbacks;
pGpsCallbacks->size = callbacks->size;
pGpsCallbacks->location_cb = callbacks->location_cb;
pGpsCallbacks->status_cb = callbacks->status_cb;
pGpsCallbacks->sv_status_cb = callbacks->sv_status_cb;
pGpsCallbacks->nmea_cb = callbacks->nmea_cb;
pGpsCallbacks->set_capabilities_cb = callbacks->set_capabilities_cb;
pGpsCallbacks->set_system_info_cb = callbacks->set_system_info_cb;
pGpsCallbacks->gnss_sv_status_cb = callbacks->gnss_sv_status_cb;
// create MsgTask
pGpsCallbacks->create_thread_cb = callbacks->create_thread_cb;
loc_core::LocDualContext::getLocFgContext(
(LocThread::tCreate)pGpsCallbacks->create_thread_cb,
nullptr, loc_core::LocDualContext::mLocationHalName, false);
// will never call these cbs
pGpsCallbacks->acquire_wakelock_cb = nullptr;
pGpsCallbacks->release_wakelock_cb = nullptr;
pGpsCallbacks->request_utc_time_cb = nullptr;
// we can't create GnssAPIClient before GpsCallbacks or GpsNiCallbacks is set
if (client) {
client->gnssUpdateCallbacks(pGpsCallbacks, pGpsNiCallbacks, pGpsMeasurementCallbacks);
}
retVal = 0;
}
return retVal;
}
static int loc_start() {
ENTRY_LOG_CALLFLOW();
int retVal = -1;
GnssAPIClient* client = getClient();
if (client)
retVal = client->gnssStart();
return retVal;
}
static int loc_stop() {
ENTRY_LOG_CALLFLOW();
int retVal = -1;
GnssAPIClient* client = getClient();
if (client)
retVal = client->gnssStop();
return retVal;
}
static void loc_cleanup() {
ENTRY_LOG_CALLFLOW();
if (sClient) {
sClient->locAPIDisable();
}
pGpsCallbacks = nullptr;
pGpsNiCallbacks = nullptr;
pGpsMeasurementCallbacks = nullptr;
pendingAgnssServer.pending = false;
if (pendingAgnssServer.hostname) {
free(pendingAgnssServer.hostname);
pendingAgnssServer.hostname = nullptr;
}
pendingConfiguration.pending = false;
if (pendingConfiguration.config_data) {
free(pendingConfiguration.config_data);
pendingConfiguration.config_data = nullptr;
}
}
static int loc_inject_time(GpsUtcTime /*time*/, int64_t /*timeReference*/, int /*uncertainty*/) {
return -1;
}
static int loc_inject_location(double /*latitude*/, double /*longitude*/, float /*accuracy*/) {
return -1;
}
static void loc_delete_aiding_data(GpsAidingData f) {
ENTRY_LOG_CALLFLOW();
GnssAPIClient* client = getClient();
if (client)
client->gnssDeleteAidingData(f);
}
static int loc_set_position_mode(GpsPositionMode mode, GpsPositionRecurrence recurrence,
uint32_t min_interval, uint32_t preferred_accuracy,
uint32_t preferred_time) {
ENTRY_LOG_CALLFLOW();
int retVal = -1;
GnssAPIClient* client = getClient();
if (client)
retVal = client->gnssSetPositionMode(mode, recurrence,
min_interval, preferred_accuracy, preferred_time);
return retVal;
}
static const void* loc_get_extension(const char* name);
static const GpsInterface sGpsInterface = {
sizeof(GpsInterface),
loc_init,
loc_start,
loc_stop,
loc_cleanup,
loc_inject_time,
loc_inject_location,
loc_delete_aiding_data,
loc_set_position_mode,
loc_get_extension
};
/*===========================================================================
Functions and variables for sAGpsInterface
===========================================================================*/
static void loc_agps_init(AGpsCallbacks* /*callbacks*/) {
}
static int loc_agps_open(const char* /*apn*/) {
return -1;
}
static int loc_agps_closed() { return -1; }
static int loc_agps_open_failed() { return -1; }
static int loc_agps_set_server(AGpsType type, const char *hostname, int port) {
GnssAPIClient* client = getClient();
if (client)
client->gnssAgnssSetServer(type, hostname, port);
else {
// client is not ready yet
if (pendingAgnssServer.hostname)
free(pendingAgnssServer.hostname);
pendingAgnssServer.type = type;
pendingAgnssServer.hostname = strdup(hostname);
pendingAgnssServer.port = port;
pendingAgnssServer.pending = true;
}
return 0;
}
static int loc_agps_open_with_apniptype(const char* /*apn*/, ApnIpType /*apnIpType*/) {
return -1;
}
static const AGpsInterface sAGpsInterface = {
sizeof(AGpsInterface),
loc_agps_init,
loc_agps_open,
loc_agps_closed,
loc_agps_open_failed,
loc_agps_set_server,
loc_agps_open_with_apniptype
};
/*===========================================================================
Functions and variables for sGpsNiInterface
===========================================================================*/
static void loc_ni_init(GpsNiCallbacks *callbacks) {
ENTRY_LOG_CALLFLOW();
if (callbacks) {
GnssAPIClient* client = getClient();
pGpsNiCallbacks = &sGpsNiCallbacks;
pGpsNiCallbacks->notify_cb = callbacks->notify_cb;
pGpsNiCallbacks->create_thread_cb = callbacks->create_thread_cb;
if (client) {
client->gnssUpdateCallbacks(pGpsCallbacks, pGpsNiCallbacks, pGpsMeasurementCallbacks);
}
}
}
static void loc_ni_respond(int notif_id, GpsUserResponseType user_response) {
ENTRY_LOG_CALLFLOW();
GnssAPIClient* client = getClient();
if (client)
client->gnssNiRespond(notif_id, user_response);
}
static const GpsNiInterface sGpsNiInterface =
{
sizeof(GpsNiInterface),
loc_ni_init,
loc_ni_respond,
};
/*===========================================================================
Functions and variables for sGpsMeasurementInterface
===========================================================================*/
static int loc_gps_measurement_init(GpsMeasurementCallbacks* callbacks) {
ENTRY_LOG_CALLFLOW();
int retVal = -1;
if (callbacks) {
GnssAPIClient* client = getClient();
pGpsMeasurementCallbacks = &sGpsMeasurementCallbacks;
pGpsMeasurementCallbacks->size = sizeof(GpsMeasurementCallbacks);
pGpsMeasurementCallbacks->measurement_callback = callbacks->measurement_callback;
pGpsMeasurementCallbacks->gnss_measurement_callback = callbacks->gnss_measurement_callback;
if (client) {
client->gnssUpdateCallbacks(pGpsCallbacks, pGpsNiCallbacks, pGpsMeasurementCallbacks);
}
retVal = 0;
}
return retVal;
}
static void loc_gps_measurement_close() {
ENTRY_LOG_CALLFLOW();
GnssAPIClient* client = getClient();
if (client)
client->gnssMeasurementClose();
}
static const GpsMeasurementInterface sGpsMeasurementInterface =
{
sizeof(GpsMeasurementInterface),
loc_gps_measurement_init,
loc_gps_measurement_close
};
/*===========================================================================
Functions and variables for sGnssConfigurationInterface
===========================================================================*/
static void loc_configuration_update(const char* config_data, int32_t length) {
ENTRY_LOG_CALLFLOW();
GnssAPIClient* client = getClient();
if (client)
client->gnssConfigurationUpdate(config_data, length);
else {
// client is not ready yet
if (pendingConfiguration.config_data)
free(pendingConfiguration.config_data);
pendingConfiguration.config_data = strdup(config_data);
pendingConfiguration.length = length;
pendingConfiguration.pending = true;
}
}
static const GnssConfigurationInterface sGnssConfigurationInterface =
{
sizeof(GnssConfigurationInterface),
loc_configuration_update
};
// Function exposed to gps hal
extern "C" const GpsInterface* get_gps_interface()
{
unsigned int target = loc_get_target();
int gnssType = getTargetGnssType(target);
if (gnssType == GNSS_NONE){
LOC_LOGE("%s:%d] No GNSS HW on this target. Returning nullptr", __func__, __LINE__);
return nullptr;
}
return &sGpsInterface;
}
const void* loc_get_extension(const char* name)
{
const void* retVal = nullptr;
LOC_LOGD("%s:%d] For Interface = %s\n", __func__, __LINE__, name);
if (strcmp(name, AGPS_INTERFACE) == 0) {
retVal = &sAGpsInterface;
} else if (strcmp(name, GPS_NI_INTERFACE) == 0) {
retVal = &sGpsNiInterface;
} else if (strcmp(name, GPS_GEOFENCING_INTERFACE) == 0) {
retVal = get_gps_geofence_interface();
} else if (strcmp(name, GPS_MEASUREMENT_INTERFACE) == 0) {
retVal = &sGpsMeasurementInterface;
} else if (strcmp(name, GNSS_CONFIGURATION_INTERFACE) == 0) {
retVal = &sGnssConfigurationInterface;
}
if (!retVal) {
LOC_LOGE ("%s:%d] %s is not supported", __func__, __LINE__, name);
}
return retVal;
}

91
android/loc_geofence.cpp Normal file
View file

@ -0,0 +1,91 @@
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#define LOG_NDDEBUG 0
#define LOG_TAG "LocSvc_geofence"
#include <hardware/gps.h>
#include <GeofenceAPIClient.h>
static GeofenceAPIClient* sClient = nullptr;
/*===========================================================================
Functions and variables for sGpsGeofencingInterface
===========================================================================*/
static GpsGeofenceCallbacks sGpsGeofenceCbs;
static void loc_geofence_init(GpsGeofenceCallbacks* callbacks) {
if (callbacks && !sClient) {
sGpsGeofenceCbs.geofence_transition_callback = callbacks->geofence_transition_callback;
sGpsGeofenceCbs.geofence_status_callback = callbacks->geofence_status_callback;
sGpsGeofenceCbs.geofence_add_callback = callbacks->geofence_add_callback;
sGpsGeofenceCbs.geofence_remove_callback = callbacks->geofence_remove_callback;
sGpsGeofenceCbs.geofence_pause_callback = callbacks->geofence_pause_callback;
sGpsGeofenceCbs.geofence_resume_callback = callbacks->geofence_resume_callback;
sGpsGeofenceCbs.create_thread_cb = callbacks->create_thread_cb;
sClient = new GeofenceAPIClient(&sGpsGeofenceCbs);
}
}
static void loc_add_geofence_area(int32_t geofence_id, double latitude, double longitude,
double radius_meters, int last_transition, int monitor_transitions,
int notification_responsiveness_ms, int unknown_timer_ms) {
if (sClient)
sClient->geofenceAdd(geofence_id, latitude, longitude,
radius_meters, last_transition, monitor_transitions,
notification_responsiveness_ms, unknown_timer_ms);
}
static void loc_pause_geofence(int32_t geofence_id) {
if (sClient)
sClient->geofencePause(geofence_id);
}
static void loc_resume_geofence(int32_t geofence_id, int monitor_transitions) {
if (sClient)
sClient->geofenceResume(geofence_id, monitor_transitions);
}
static void loc_remove_geofence_area(int32_t geofence_id) {
if (sClient)
sClient->geofenceRemove(geofence_id);
}
static const GpsGeofencingInterface sGpsGeofencingInterface =
{
sizeof(GpsGeofencingInterface),
loc_geofence_init,
loc_add_geofence_area,
loc_pause_geofence,
loc_resume_geofence,
loc_remove_geofence_area
};
// Function exposed to gps hal
extern "C" const GpsGeofencingInterface* get_gps_geofence_interface()
{
return &sGpsGeofencingInterface;
}

View file

@ -6,7 +6,7 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libloc_core
LOCAL_MODULE_OWNER := qcom
LOCAL_MODULE_OWNER := qti
LOCAL_MODULE_TAGS := optional
@ -37,8 +37,8 @@ LOCAL_CFLAGS += \
LOCAL_C_INCLUDES:= \
$(TARGET_OUT_HEADERS)/gps.utils \
$(TARGET_OUT_HEADERS)/libflp \
$(TARGET_OUT_HEADERS)/libloc_pla
$(TARGET_OUT_HEADERS)/libloc_pla \
$(TARGET_OUT_HEADERS)/liblocation_api
LOCAL_COPY_HEADERS_TO:= libloc_core/
LOCAL_COPY_HEADERS:= \

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014,2016-2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -40,8 +40,116 @@
namespace loc_core {
loc_gps_cfg_s_type ContextBase::mGps_conf {0};
loc_sap_cfg_s_type ContextBase::mSap_conf {0};
loc_gps_cfg_s_type ContextBase::mGps_conf {};
loc_sap_cfg_s_type ContextBase::mSap_conf {};
const loc_param_s_type ContextBase::mGps_conf_table[] =
{
{"GPS_LOCK", &mGps_conf.GPS_LOCK, NULL, 'n'},
{"SUPL_VER", &mGps_conf.SUPL_VER, NULL, 'n'},
{"LPP_PROFILE", &mGps_conf.LPP_PROFILE, NULL, 'n'},
{"A_GLONASS_POS_PROTOCOL_SELECT", &mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT, NULL, 'n'},
{"LPPE_CP_TECHNOLOGY", &mGps_conf.LPPE_CP_TECHNOLOGY, NULL, 'n'},
{"LPPE_UP_TECHNOLOGY", &mGps_conf.LPPE_UP_TECHNOLOGY, NULL, 'n'},
{"AGPS_CERT_WRITABLE_MASK", &mGps_conf.AGPS_CERT_WRITABLE_MASK, NULL, 'n'},
{"SUPL_MODE", &mGps_conf.SUPL_MODE, NULL, 'n'},
{"SUPL_ES", &mGps_conf.SUPL_ES, NULL, 'n'},
{"INTERMEDIATE_POS", &mGps_conf.INTERMEDIATE_POS, NULL, 'n'},
{"ACCURACY_THRES", &mGps_conf.ACCURACY_THRES, NULL, 'n'},
{"NMEA_PROVIDER", &mGps_conf.NMEA_PROVIDER, NULL, 'n'},
{"CAPABILITIES", &mGps_conf.CAPABILITIES, NULL, 'n'},
{"XTRA_VERSION_CHECK", &mGps_conf.XTRA_VERSION_CHECK, NULL, 'n'},
{"XTRA_SERVER_1", &mGps_conf.XTRA_SERVER_1, NULL, 's'},
{"XTRA_SERVER_2", &mGps_conf.XTRA_SERVER_2, NULL, 's'},
{"XTRA_SERVER_3", &mGps_conf.XTRA_SERVER_3, NULL, 's'},
{"USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL", &mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL, NULL, 'n'},
{"AGPS_CONFIG_INJECT", &mGps_conf.AGPS_CONFIG_INJECT, NULL, 'n'},
{"EXTERNAL_DR_ENABLED", &mGps_conf.EXTERNAL_DR_ENABLED, NULL, 'n'},
};
const loc_param_s_type ContextBase::mSap_conf_table[] =
{
{"GYRO_BIAS_RANDOM_WALK", &mSap_conf.GYRO_BIAS_RANDOM_WALK, &mSap_conf.GYRO_BIAS_RANDOM_WALK_VALID, 'f'},
{"ACCEL_RANDOM_WALK_SPECTRAL_DENSITY", &mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY, &mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
{"ANGLE_RANDOM_WALK_SPECTRAL_DENSITY", &mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY, &mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
{"RATE_RANDOM_WALK_SPECTRAL_DENSITY", &mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY, &mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
{"VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY", &mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY, &mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
{"SENSOR_ACCEL_BATCHES_PER_SEC", &mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC, NULL, 'n'},
{"SENSOR_ACCEL_SAMPLES_PER_BATCH", &mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH, NULL, 'n'},
{"SENSOR_GYRO_BATCHES_PER_SEC", &mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC, NULL, 'n'},
{"SENSOR_GYRO_SAMPLES_PER_BATCH", &mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH, NULL, 'n'},
{"SENSOR_ACCEL_BATCHES_PER_SEC_HIGH", &mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH, NULL, 'n'},
{"SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH", &mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH, NULL, 'n'},
{"SENSOR_GYRO_BATCHES_PER_SEC_HIGH", &mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH, NULL, 'n'},
{"SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH", &mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH, NULL, 'n'},
{"SENSOR_CONTROL_MODE", &mSap_conf.SENSOR_CONTROL_MODE, NULL, 'n'},
{"SENSOR_USAGE", &mSap_conf.SENSOR_USAGE, NULL, 'n'},
{"SENSOR_ALGORITHM_CONFIG_MASK", &mSap_conf.SENSOR_ALGORITHM_CONFIG_MASK, NULL, 'n'},
{"SENSOR_PROVIDER", &mSap_conf.SENSOR_PROVIDER, NULL, 'n'}
};
void ContextBase::readConfig()
{
/*Defaults for gps.conf*/
mGps_conf.INTERMEDIATE_POS = 0;
mGps_conf.ACCURACY_THRES = 0;
mGps_conf.NMEA_PROVIDER = 0;
mGps_conf.GPS_LOCK = 0;
mGps_conf.SUPL_VER = 0x10000;
mGps_conf.SUPL_MODE = 0x3;
mGps_conf.SUPL_ES = 0;
mGps_conf.CAPABILITIES = 0x7;
/* LTE Positioning Profile configuration is disable by default*/
mGps_conf.LPP_PROFILE = 0;
/*By default no positioning protocol is selected on A-GLONASS system*/
mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT = 0;
/*XTRA version check is disabled by default*/
mGps_conf.XTRA_VERSION_CHECK=0;
/*Use emergency PDN by default*/
mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL = 1;
/* By default no LPPe CP technology is enabled*/
mGps_conf.LPPE_CP_TECHNOLOGY = 0;
/* By default no LPPe UP technology is enabled*/
mGps_conf.LPPE_UP_TECHNOLOGY = 0;
/*Defaults for sap.conf*/
mSap_conf.GYRO_BIAS_RANDOM_WALK = 0;
mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC = 2;
mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH = 5;
mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC = 2;
mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH = 5;
mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH = 4;
mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH = 25;
mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH = 4;
mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH = 25;
mSap_conf.SENSOR_CONTROL_MODE = 0; /* AUTO */
mSap_conf.SENSOR_USAGE = 0; /* Enabled */
mSap_conf.SENSOR_ALGORITHM_CONFIG_MASK = 0; /* INS Disabled = FALSE*/
/* Values MUST be set by OEMs in configuration for sensor-assisted
navigation to work. There are NO default values */
mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY = 0;
mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY = 0;
mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY = 0;
mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY = 0;
mSap_conf.GYRO_BIAS_RANDOM_WALK_VALID = 0;
mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
/* default provider is SSC */
mSap_conf.SENSOR_PROVIDER = 1;
/* None of the 10 slots for agps certificates are writable by default */
mGps_conf.AGPS_CERT_WRITABLE_MASK = 0;
/* inject supl config to modem with config values from config.xml or gps.conf, default 1 */
mGps_conf.AGPS_CONFIG_INJECT = 1;
const char* GPS_CONF_FILE = "/etc/gps.conf";
const char* SAP_CONF_FILE = "/etc/sap.conf";
UTIL_READ_CONF(GPS_CONF_FILE, mGps_conf_table);
UTIL_READ_CONF(SAP_CONF_FILE, mSap_conf_table);
}
uint32_t ContextBase::getCarrierCapabilities() {
#define carrierMSA (uint32_t)0x2

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -34,6 +34,7 @@
#include <MsgTask.h>
#include <LocApiBase.h>
#include <LBSProxyBase.h>
#include <loc_cfg.h>
#define MAX_XTRA_SERVER_URL_LENGTH 256
@ -105,6 +106,8 @@ class LocAdapterBase;
class ContextBase {
static LBSProxyBase* getLBSProxy(const char* libName);
LocApiBase* createLocApi(LOC_API_ADAPTER_EVENT_MASK_T excludedMask);
static const loc_param_s_type mGps_conf_table[];
static const loc_param_s_type mSap_conf_table[];
protected:
const LBSProxyBase* mLBSProxy;
const MsgTask* mMsgTask;
@ -135,6 +138,7 @@ public:
static loc_gps_cfg_s_type mGps_conf;
static loc_sap_cfg_s_type mSap_conf;
void readConfig();
static uint32_t getCarrierCapabilities();
};

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014, 2016-2017The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -50,6 +50,16 @@ LocAdapterBase::LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
mLocApi->addAdapter(this);
}
uint32_t LocAdapterBase::mSessionIdCounter(1);
uint32_t LocAdapterBase::generateSessionId()
{
if (++mSessionIdCounter == 0xFFFFFFFF)
mSessionIdCounter = 1;
return mSessionIdCounter;
}
void LocAdapterBase::handleEngineUpEvent()
{
if (mLocAdapterProxyBase) {
@ -65,32 +75,31 @@ void LocAdapterBase::handleEngineDownEvent()
}
void LocAdapterBase::
reportPosition(UlpLocation &location,
GpsLocationExtended &locationExtended,
void* locationExt,
reportPositionEvent(const UlpLocation& location,
const GpsLocationExtended& locationExtended,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask) {
if (mLocAdapterProxyBase == NULL ||
!mLocAdapterProxyBase->reportPosition(location,
locationExtended,
LocPosTechMask loc_technology_mask,
bool fromUlp) {
if (mLocAdapterProxyBase != NULL) {
mLocAdapterProxyBase->reportPositionEvent((UlpLocation&)location,
(GpsLocationExtended&)locationExtended,
status,
loc_technology_mask)) {
loc_technology_mask);
} else {
DEFAULT_IMPL()
}
}
void LocAdapterBase::
reportSv(LocGnssSvStatus &svStatus,
GpsLocationExtended &locationExtended,
void* svExt)
reportSvEvent(const GnssSvNotification& svNotify, bool fromUlp)
DEFAULT_IMPL()
void LocAdapterBase::
reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet)
reportSvMeasurementEvent(GnssSvMeasurementSet &svMeasurementSet)
DEFAULT_IMPL()
void LocAdapterBase::
reportSvPolynomial(GnssSvPolynomial &svPolynomial)
reportSvPolynomialEvent(GnssSvPolynomial &svPolynomial)
DEFAULT_IMPL()
void LocAdapterBase::
@ -99,7 +108,7 @@ DEFAULT_IMPL()
void LocAdapterBase::
reportNmea(const char* nmea, int length)
reportNmeaEvent(const char* nmea, size_t length, bool fromUlp)
DEFAULT_IMPL()
bool LocAdapterBase::
@ -140,11 +149,11 @@ bool LocAdapterBase::
DEFAULT_IMPL(false)
bool LocAdapterBase::
requestNiNotify(LocGpsNiNotification &notify, const void* data)
requestNiNotifyEvent(GnssNiNotification &notify, const void* data)
DEFAULT_IMPL(false)
void LocAdapterBase::
reportGnssMeasurementData(LocGnssData &gnssMeasurementData)
reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& measurementsNotify)
DEFAULT_IMPL()
bool LocAdapterBase::

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2014,2016 The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014, 2016-2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -32,19 +32,39 @@
#include <gps_extended.h>
#include <UlpProxyBase.h>
#include <ContextBase.h>
#include <LocationAPI.h>
#include <map>
typedef struct LocationSessionKey {
LocationAPI* client;
uint32_t id;
inline LocationSessionKey(LocationAPI* _client, uint32_t _id) :
client(_client), id(_id) {}
} LocationSessionKey;
inline bool operator <(LocationSessionKey const& left, LocationSessionKey const& right) {
return left.id < right.id || (left.id == right.id && left.client < right.client);
}
inline bool operator ==(LocationSessionKey const& left, LocationSessionKey const& right) {
return left.id == right.id && left.client == right.client;
}
inline bool operator !=(LocationSessionKey const& left, LocationSessionKey const& right) {
return left.id != right.id || left.client != right.client;
}
typedef std::map<LocationSessionKey, LocationOptions> LocationSessionMap;
namespace loc_core {
class LocAdapterProxyBase;
class LocAdapterBase {
private:
static uint32_t mSessionIdCounter;
protected:
LOC_API_ADAPTER_EVENT_MASK_T mEvtMask;
ContextBase* mContext;
LocApiBase* mLocApi;
LocAdapterProxyBase* mLocAdapterProxyBase;
const MsgTask* mMsgTask;
inline LocAdapterBase(const MsgTask* msgTask) :
mEvtMask(0), mContext(NULL), mLocApi(NULL),
mLocAdapterProxyBase(NULL), mMsgTask(msgTask) {}
@ -70,11 +90,19 @@ public:
}
inline void updateEvtMask(LOC_API_ADAPTER_EVENT_MASK_T event,
loc_registration_mask_status isEnabled)
loc_registration_mask_status status)
{
mEvtMask =
isEnabled == LOC_REGISTRATION_MASK_ENABLED ? (mEvtMask|event):(mEvtMask&~event);
switch(status) {
case (LOC_REGISTRATION_MASK_ENABLED):
mEvtMask = mEvtMask | event;
break;
case (LOC_REGISTRATION_MASK_DISABLED):
mEvtMask = mEvtMask &~ event;
break;
case (LOC_REGISTRATION_MASK_SET):
mEvtMask = event;
break;
}
mLocApi->updateEvtMask();
}
@ -82,33 +110,33 @@ public:
return mLocApi->isFeatureSupported(featureVal);
}
uint32_t generateSessionId();
// This will be overridden by the individual adapters
// if necessary.
inline virtual void setUlpProxy(UlpProxyBase* ulp) {
inline virtual void setUlpProxyCommand(UlpProxyBase* ulp) {
(void)ulp;
}
virtual void handleEngineUpEvent();
virtual void handleEngineDownEvent();
inline virtual void setPositionModeInt(LocPosMode& posMode) {
inline virtual void setPositionModeCommand(LocPosMode& posMode) {
(void)posMode;
}
virtual void startFixInt() {}
virtual void stopFixInt() {}
virtual void getZppInt() {}
virtual void reportPosition(UlpLocation &location,
GpsLocationExtended &locationExtended,
void* locationExt,
virtual void startTrackingCommand() {}
virtual void stopTrackingCommand() {}
virtual void getZppCommand() {}
virtual void reportPositionEvent(const UlpLocation& location,
const GpsLocationExtended& locationExtended,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask);
virtual void reportSv(LocGnssSvStatus &svStatus,
GpsLocationExtended &locationExtended,
void* svExt);
virtual void reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet);
virtual void reportSvPolynomial(GnssSvPolynomial &svPolynomial);
LocPosTechMask loc_technology_mask,
bool fromUlp=false);
virtual void reportSvEvent(const GnssSvNotification& svNotify, bool fromUlp=false);
virtual void reportNmeaEvent(const char* nmea, size_t length, bool fromUlp=false);
virtual void reportSvMeasurementEvent(GnssSvMeasurementSet &svMeasurementSet);
virtual void reportSvPolynomialEvent(GnssSvPolynomial &svPolynomial);
virtual void reportStatus(LocGpsStatusValue status);
virtual void reportNmea(const char* nmea, int length);
virtual bool reportXtraServer(const char* url1, const char* url2,
const char* url3, const int maxlength);
virtual bool requestXtraData();
@ -119,11 +147,10 @@ public:
virtual bool requestSuplES(int connHandle);
virtual bool reportDataCallOpened();
virtual bool reportDataCallClosed();
virtual bool requestNiNotify(LocGpsNiNotification &notify,
const void* data);
virtual bool requestNiNotifyEvent(GnssNiNotification &notify, const void* data);
inline virtual bool isInSession() { return false; }
ContextBase* getContext() const { return mContext; }
virtual void reportGnssMeasurementData(LocGnssData &gnssMeasurementData);
virtual void reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& measurementsNotify);
virtual bool reportWwanZppFix(LocGpsLocation &zppLoc);
};

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2014 The Linux Foundation. All rights reserved.
/* Copyright (c) 2014, 2016-2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -51,13 +51,17 @@ protected:
mLocAdapterBase->updateEvtMask(event,isEnabled);
}
inline uint32_t generateSessionId() {
return mLocAdapterBase->generateSessionId();
}
public:
inline ContextBase* getContext() const {
return mLocAdapterBase->getContext();
}
inline virtual void handleEngineUpEvent() {};
inline virtual void handleEngineDownEvent() {};
inline virtual bool reportPosition(UlpLocation &location,
inline virtual void reportPositionEvent(UlpLocation &location,
GpsLocationExtended &locationExtended,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask) {
@ -66,7 +70,6 @@ public:
(void)locationExtended;
(void)status;
(void)loc_technology_mask;
return false;
}
};

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2014,2016 The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014, 2016-2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -227,14 +227,13 @@ void LocApiBase::handleEngineDownEvent()
TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineDownEvent());
}
void LocApiBase::reportPosition(UlpLocation &location,
GpsLocationExtended &locationExtended,
void* locationExt,
void LocApiBase::reportPosition(UlpLocation& location,
GpsLocationExtended& locationExtended,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask)
{
// print the location info before delivering
LOC_LOGV("flags: %d\n source: %d\n latitude: %f\n longitude: %f\n "
LOC_LOGD("flags: %d\n source: %d\n latitude: %f\n longitude: %f\n "
"altitude: %f\n speed: %f\n bearing: %f\n accuracy: %f\n "
"timestamp: %lld\n rawDataSize: %d\n rawData: %p\n "
"Session status: %d\n Technology mask: %u\n "
@ -251,11 +250,8 @@ void LocApiBase::reportPosition(UlpLocation &location,
locationExtended.gnss_sv_used_ids.gal_sv_used_ids_mask);
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(
mLocAdapters[i]->reportPosition(location,
locationExtended,
locationExt,
status,
loc_technology_mask)
mLocAdapters[i]->reportPositionEvent(location, locationExtended,
status, loc_technology_mask)
);
}
@ -265,9 +261,7 @@ void LocApiBase::reportWwanZppFix(LocGpsLocation &zppLoc)
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportWwanZppFix(zppLoc));
}
void LocApiBase::reportSv(LocGnssSvStatus &svStatus,
GpsLocationExtended &locationExtended,
void* svExt)
void LocApiBase::reportSv(GnssSvNotification& svNotify)
{
const char* constellationString[] = { "Unknown", "GPS", "SBAS", "GLONASS",
"QZSS", "BEIDOU", "GALILEO" };
@ -276,27 +270,25 @@ void LocApiBase::reportSv(LocGnssSvStatus &svStatus,
LOC_LOGV("num sv: %d\n"
" sv: constellation svid cN0"
" elevation azimuth flags",
svStatus.num_svs);
for (int i = 0; i < svStatus.num_svs && i < LOC_GNSS_MAX_SVS; i++) {
if (svStatus.gnss_sv_list[i].constellation >
svNotify.count);
for (int i = 0; i < svNotify.count && i < LOC_GNSS_MAX_SVS; i++) {
if (svNotify.gnssSvs[i].type >
sizeof(constellationString) / sizeof(constellationString[0]) - 1) {
svStatus.gnss_sv_list[i].constellation = 0;
svNotify.gnssSvs[i].type = GNSS_SV_TYPE_UNKNOWN;
}
LOC_LOGV(" %03d: %*s %02d %f %f %f 0x%02X",
i,
13,
constellationString[svStatus.gnss_sv_list[i].constellation],
svStatus.gnss_sv_list[i].svid,
svStatus.gnss_sv_list[i].c_n0_dbhz,
svStatus.gnss_sv_list[i].elevation,
svStatus.gnss_sv_list[i].azimuth,
svStatus.gnss_sv_list[i].flags);
constellationString[svNotify.gnssSvs[i].type],
svNotify.gnssSvs[i].svId,
svNotify.gnssSvs[i].cN0Dbhz,
svNotify.gnssSvs[i].elevation,
svNotify.gnssSvs[i].azimuth,
svNotify.gnssSvs[i].gnssSvOptionsMask);
}
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(
mLocAdapters[i]->reportSv(svStatus,
locationExtended,
svExt)
mLocAdapters[i]->reportSvEvent(svNotify)
);
}
@ -304,7 +296,7 @@ void LocApiBase::reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet)
{
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(
mLocAdapters[i]->reportSvMeasurement(svMeasurementSet)
mLocAdapters[i]->reportSvMeasurementEvent(svMeasurementSet)
);
}
@ -312,7 +304,7 @@ void LocApiBase::reportSvPolynomial(GnssSvPolynomial &svPolynomial)
{
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(
mLocAdapters[i]->reportSvPolynomial(svPolynomial)
mLocAdapters[i]->reportSvPolynomialEvent(svPolynomial)
);
}
@ -325,7 +317,7 @@ void LocApiBase::reportStatus(LocGpsStatusValue status)
void LocApiBase::reportNmea(const char* nmea, int length)
{
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportNmea(nmea, length));
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportNmeaEvent(nmea, length));
}
void LocApiBase::reportXtraServer(const char* url1, const char* url2,
@ -384,10 +376,10 @@ void LocApiBase::reportDataCallClosed()
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportDataCallClosed());
}
void LocApiBase::requestNiNotify(LocGpsNiNotification &notify, const void* data)
void LocApiBase::requestNiNotify(GnssNiNotification &notify, const void* data)
{
// loop through adapters, and deliver to the first handling adapter.
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestNiNotify(notify, data));
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestNiNotifyEvent(notify, data));
}
void LocApiBase::saveSupportedMsgList(uint64_t supportedMsgList)
@ -406,10 +398,10 @@ void* LocApiBase :: getSibling()
LocApiProxyBase* LocApiBase :: getLocApiProxy()
DEFAULT_IMPL(NULL)
void LocApiBase::reportGnssMeasurementData(LocGnssData &gnssMeasurementData)
void LocApiBase::reportGnssMeasurementData(GnssMeasurementsNotification& measurementsNotify)
{
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssMeasurementData(gnssMeasurementData));
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssMeasurementDataEvent(measurementsNotify));
}
enum loc_api_adapter_err LocApiBase::
@ -428,9 +420,9 @@ enum loc_api_adapter_err LocApiBase::
stopFix()
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
deleteAidingData(LocGpsAidingData f)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
LocationError LocApiBase::
deleteAidingData(const GnssAidingData& data)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
enableData(int enable)
@ -469,31 +461,29 @@ enum loc_api_adapter_err LocApiBase::
setPositionMode(const LocPosMode& posMode)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
LocationError LocApiBase::
setServer(const char* url, int len)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setServer(unsigned int ip, int port,
LocServerType type)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
LocationError LocApiBase::
setServer(unsigned int ip, int port, LocServerType type)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
informNiResponse(LocGpsUserResponseType userResponse,
const void* passThroughData)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
LocationError LocApiBase::
informNiResponse(GnssNiResponse userResponse, const void* passThroughData)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setSUPLVersion(uint32_t version)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
LocationError LocApiBase::
setSUPLVersion(GnssConfigSuplVersion version)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setNMEATypes (uint32_t typesMask)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setLPPConfig(uint32_t profile)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
LocationError LocApiBase::
setLPPConfig(GnssConfigLppProfile profile)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setSensorControlConfig(int sensorUsage,
@ -526,13 +516,17 @@ enum loc_api_adapter_err LocApiBase::
int algorithmConfig)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setAGLONASSProtocol(unsigned long aGlonassProtocol)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
LocationError LocApiBase::
setAGLONASSProtocol(GnssConfigAGlonassPositionProtocolMask aGlonassProtocol)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setLPPeProtocol(unsigned long lppeCP, unsigned long lppeUP)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
LocationError LocApiBase::
setLPPeProtocolCp(GnssConfigLppeControlPlaneMask lppeCP)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
LocationError LocApiBase::
setLPPeProtocolUp(GnssConfigLppeUserPlaneMask lppeUP)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
getWwanZppFix()
@ -573,9 +567,9 @@ void LocApiBase::
releaseDataServiceClient()
DEFAULT_IMPL()
int LocApiBase::
setGpsLock(LOC_GPS_LOCK_MASK lock)
DEFAULT_IMPL(-1)
LocationError LocApiBase::
setGpsLock(GnssConfigGpsLock lock)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
void LocApiBase::
installAGpsCert(const LocDerEncodedCertificate* pData,
@ -587,9 +581,9 @@ int LocApiBase::
getGpsLock()
DEFAULT_IMPL(-1)
enum loc_api_adapter_err LocApiBase::
setXtraVersionCheck(enum xtra_version_check check)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
LocationError LocApiBase::
setXtraVersionCheck(uint32_t check)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
bool LocApiBase::
gnssConstellationConfig()

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2014, 2016 The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014, 2016-2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -32,6 +32,7 @@
#include <stddef.h>
#include <ctype.h>
#include <gps_extended.h>
#include <LocationAPI.h>
#include <MsgTask.h>
#include <platform_lib_log_util.h>
@ -102,22 +103,18 @@ public:
inline void sendMsg(const LocMsg* msg) const {
mMsgTask->sendMsg(msg);
}
void addAdapter(LocAdapterBase* adapter);
void removeAdapter(LocAdapterBase* adapter);
// upward calls
void handleEngineUpEvent();
void handleEngineDownEvent();
void reportPosition(UlpLocation &location,
GpsLocationExtended &locationExtended,
void* locationExt,
void reportPosition(UlpLocation& location,
GpsLocationExtended& locationExtended,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask =
LOC_POS_TECH_MASK_DEFAULT);
void reportSv(LocGnssSvStatus &svStatus,
GpsLocationExtended &locationExtended,
void* svExt);
void reportSv(GnssSvNotification& svNotify);
void reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet);
void reportSvPolynomial(GnssSvPolynomial &svPolynomial);
void reportStatus(LocGpsStatusValue status);
@ -132,9 +129,9 @@ public:
void requestSuplES(int connHandle);
void reportDataCallOpened();
void reportDataCallClosed();
void requestNiNotify(LocGpsNiNotification &notify, const void* data);
void requestNiNotify(GnssNiNotification &notify, const void* data);
void saveSupportedMsgList(uint64_t supportedMsgList);
void reportGnssMeasurementData(LocGnssData &gnssMeasurementData);
void reportGnssMeasurementData(GnssMeasurementsNotification& measurementsNotify);
void saveSupportedFeatureList(uint8_t *featureList);
void reportWwanZppFix(LocGpsLocation &zppLoc);
@ -148,8 +145,8 @@ public:
startFix(const LocPosMode& posMode);
virtual enum loc_api_adapter_err
stopFix();
virtual enum loc_api_adapter_err
deleteAidingData(LocGpsAidingData f);
virtual LocationError
deleteAidingData(const GnssAidingData& data);
virtual enum loc_api_adapter_err
enableData(int enable);
virtual enum loc_api_adapter_err
@ -168,19 +165,17 @@ public:
atlCloseStatus(int handle, int is_succ);
virtual enum loc_api_adapter_err
setPositionMode(const LocPosMode& posMode);
virtual enum loc_api_adapter_err
virtual LocationError
setServer(const char* url, int len);
virtual enum loc_api_adapter_err
virtual LocationError
setServer(unsigned int ip, int port,
LocServerType type);
virtual enum loc_api_adapter_err
informNiResponse(LocGpsUserResponseType userResponse, const void* passThroughData);
virtual enum loc_api_adapter_err
setSUPLVersion(uint32_t version);
virtual LocationError
informNiResponse(GnssNiResponse userResponse, const void* passThroughData);
virtual LocationError setSUPLVersion(GnssConfigSuplVersion version);
virtual enum loc_api_adapter_err
setNMEATypes (uint32_t typesMask);
virtual enum loc_api_adapter_err
setLPPConfig(uint32_t profile);
virtual LocationError setLPPConfig(GnssConfigLppProfile profile);
virtual enum loc_api_adapter_err
setSensorControlConfig(int sensorUsage, int sensorProvider);
virtual enum loc_api_adapter_err
@ -205,10 +200,10 @@ public:
int gyroSamplesPerBatchHigh,
int gyroBatchesPerSecHigh,
int algorithmConfig);
virtual enum loc_api_adapter_err
setAGLONASSProtocol(unsigned long aGlonassProtocol);
virtual enum loc_api_adapter_err
setLPPeProtocol(unsigned long lppeCP, unsigned long lppeUP);
virtual LocationError
setAGLONASSProtocol(GnssConfigAGlonassPositionProtocolMask aGlonassProtocol);
virtual LocationError setLPPeProtocolCp(GnssConfigLppeControlPlaneMask lppeCP);
virtual LocationError setLPPeProtocolUp(GnssConfigLppeUserPlaneMask lppeUP);
virtual enum loc_api_adapter_err
getWwanZppFix();
virtual enum loc_api_adapter_err
@ -238,15 +233,10 @@ public:
return (messageChecker & mSupportedMsg) == messageChecker;
}
}
void updateEvtMask();
/*Values for lock
1 = Do not lock any position sessions
2 = Lock MI position sessions
3 = Lock MT position sessions
4 = Lock all position sessions
*/
virtual int setGpsLock(LOC_GPS_LOCK_MASK lock);
virtual LocationError setGpsLock(GnssConfigGpsLock lock);
/*
Returns
Current value of GPS Lock on success
@ -254,8 +244,7 @@ public:
*/
virtual int getGpsLock(void);
virtual enum loc_api_adapter_err setXtraVersionCheck(enum xtra_version_check check);
virtual LocationError setXtraVersionCheck(uint32_t check);
/*
Check if the modem support the service
*/

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014, 2016-2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -44,8 +44,7 @@ LocDualContext::mFgExclMask = 0;
// excluded events for background clients
const LOC_API_ADAPTER_EVENT_MASK_T
LocDualContext::mBgExclMask =
(LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT |
LOC_API_ADAPTER_BIT_SATELLITE_REPORT |
(LOC_API_ADAPTER_BIT_SATELLITE_REPORT |
LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT |
LOC_API_ADAPTER_BIT_NMEA_POSITION_REPORT |
LOC_API_ADAPTER_BIT_IOCTL_REPORT |

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -30,7 +30,8 @@
#define ULP_PROXY_BASE_H
#include <gps_extended.h>
#include "fused_location_extended.h"
#include <LocationAPI.h>
namespace loc_core {
class LocAdapterBase;
@ -51,24 +52,18 @@ public:
return false;
}
inline virtual bool reportPosition(UlpLocation &location,
GpsLocationExtended &locationExtended,
void* locationExt,
inline virtual bool reportPosition(const UlpLocation &location,
const GpsLocationExtended &locationExtended,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask) {
(void)location;
(void)locationExtended;
(void)locationExt;
(void)status;
(void)loc_technology_mask;
return false;
}
inline virtual bool reportSv(LocGnssSvStatus &svStatus,
GpsLocationExtended &locationExtended,
void* svExt) {
(void)svStatus;
(void)locationExtended;
(void)svExt;
inline virtual bool reportSv(const GnssSvNotification& svNotify) {
(void)svNotify;
return false;
}
inline virtual bool reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet) {
@ -94,17 +89,21 @@ public:
(void)capabilities;
}
inline virtual bool reportBatchingSession(FlpExtBatchOptions &options,
bool active) {
inline virtual bool reportBatchingSession(const LocationOptions& options, bool active)
{
(void)options;
(void)active;
return false;
}
inline virtual bool reportPositions(const FlpExtLocation* locations,
int32_t number_of_locations) {
(void)locations;
(void)number_of_locations;
inline virtual bool reportPositions(const UlpLocation* ulpLocations,
const GpsLocationExtended* extendedLocations,
const uint32_t* techMasks,
const size_t count)
{
(void)ulpLocations;
(void)extendedLocations;
(void)techMasks;
(void)count;
return false;
}
inline virtual bool reportDeleteAidingData(LocGpsAidingData aidingData)

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -29,19 +29,21 @@
#ifndef GPS_EXTENDED_H
#define GPS_EXTENDED_H
#include <gps_extended_c.h>
/**
* @file
* @brief C++ declarations for GPS types
*/
#include <gps_extended_c.h>
#if defined(USE_GLIB) || defined(OFF_TARGET)
#include <string.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#if defined(USE_GLIB) || defined(OFF_TARGET)
#include <string.h>
#endif
struct LocPosMode
{

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2013-2015, 2016 The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -34,6 +34,7 @@
#include <stdlib.h>
#include <string.h>
#include <loc_gps.h>
#include <LocationAPI.h>
#include <time.h>
/**
@ -88,7 +89,8 @@ extern "C" {
enum loc_registration_mask_status {
LOC_REGISTRATION_MASK_ENABLED,
LOC_REGISTRATION_MASK_DISABLED
LOC_REGISTRATION_MASK_DISABLED,
LOC_REGISTRATION_MASK_SET
};
typedef enum {

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2013, 2016-2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -30,14 +30,14 @@
#ifndef LOC_CORE_LOG_H
#define LOC_CORE_LOG_H
#include <ctype.h>
#include <gps_extended.h>
#ifdef __cplusplus
extern "C"
{
#endif
#include <ctype.h>
#include <gps_extended.h>
const char* loc_get_gps_status_name(LocGpsStatusValue gps_status);
const char* loc_get_position_mode_name(LocGpsPositionMode mode);
const char* loc_get_position_recurrence_name(LocGpsPositionRecurrence recur);

43
gnss/Android.mk Normal file
View file

@ -0,0 +1,43 @@
ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
ifneq ($(BUILD_TINY_ANDROID),true)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libgnss
LOCAL_MODULE_OWNER := qti
LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := \
libutils \
libcutils \
libdl \
liblog \
libloc_core \
libgps.utils
LOCAL_SRC_FILES += \
location_gnss.cpp \
GnssAdapter.cpp
LOCAL_CFLAGS += \
-fno-short-enums \
ifeq ($(TARGET_BUILD_VARIANT),user)
LOCAL_CFLAGS += -DTARGET_BUILD_VARIANT_USER
endif
LOCAL_C_INCLUDES:= \
$(TARGET_OUT_HEADERS)/gps.utils \
$(TARGET_OUT_HEADERS)/libloc_core \
$(TARGET_OUT_HEADERS)/libloc_pla \
$(TARGET_OUT_HEADERS)/liblocation_api
LOCAL_PRELINK_MODULE := false
include $(BUILD_SHARED_LIBRARY)
endif # not BUILD_TINY_ANDROID
endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE

2880
gnss/GnssAdapter.cpp Normal file

File diff suppressed because it is too large Load diff

259
gnss/GnssAdapter.h Normal file
View file

@ -0,0 +1,259 @@
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GNSS_ADAPTER_H
#define GNSS_ADAPTER_H
#include <LocAdapterBase.h>
#include <LocDualContext.h>
#include <UlpProxyBase.h>
#include <LocationAPI.h>
#define MAX_URL_LEN 256
#define NMEA_SENTENCE_MAX_LENGTH 200
#define GLONASS_SV_ID_OFFSET 64
#define MAX_SATELLITES_IN_USE 12
#define LOC_NI_NO_RESPONSE_TIME 20
#define LOC_GPS_NI_RESPONSE_IGNORE 4
class GnssAdapter;
typedef struct {
pthread_t thread; /* NI thread */
uint32_t respTimeLeft; /* examine time for NI response */
bool respRecvd; /* NI User reponse received or not from Java layer*/
void* rawRequest;
uint32_t reqID; /* ID to check against response */
GnssNiResponse resp;
pthread_cond_t tCond;
pthread_mutex_t tLock;
GnssAdapter* adapter;
} NiSession;
typedef struct {
NiSession session; /* SUPL NI Session */
NiSession sessionEs; /* Emergency SUPL NI Session */
uint32_t reqIDCounter;
} NiData;
typedef enum {
NMEA_PROVIDER_AP = 0, // Application Processor Provider of NMEA
NMEA_PROVIDER_MP // Modem Processor Provider of NMEA
} NmeaProviderType;
typedef struct {
GnssSvType svType;
const char* talker;
uint64_t mask;
uint32_t svIdOffset;
} NmeaSvMeta;
using namespace loc_core;
class GnssAdapter : public LocAdapterBase {
/* ==== ULP ============================================================================ */
UlpProxyBase* mUlpProxy;
/* ==== CLIENT ========================================================================= */
typedef std::map<LocationAPI*, LocationCallbacks> ClientDataMap;
ClientDataMap mClientData;
/* ==== TRACKING ======================================================================= */
LocationSessionMap mTrackingSessions;
GnssSuplMode mSuplMode;
LocPosMode mUlpPositionMode;
GnssSvUsedInPosition mGnssSvIdUsedInPosition;
bool mGnssSvIdUsedInPosAvail;
/* ==== CONTROL ======================================================================== */
LocationControlCallbacks mControlCallbacks;
uint32_t mPowerVoteId;
/* ==== NI ============================================================================= */
NiData mNiData;
/*==== CONVERSION ===================================================================*/
static void convertOptions(LocPosMode& out, const LocationOptions& options);
static void convertLocation(Location& out, const LocGpsLocation& locGpsLocation,
const LocPosTechMask techMask);
static void convertLocationInfo(GnssLocationInfoNotification& out,
const GpsLocationExtended& locationExtended);
public:
GnssAdapter();
virtual ~GnssAdapter();
/* ==== SSR ============================================================================ */
/* ======== EVENTS ====(Called from QMI Thread)========================================= */
virtual void handleEngineUpEvent();
/* ======== UTILITIES ================================================================== */
void restartSessions();
/* ==== ULP ============================================================================ */
/* ======== COMMANDS ====(Called from ULP Thread)==================================== */
virtual void setUlpProxyCommand(UlpProxyBase* ulp);
/* ======== UTILITIES ================================================================== */
void setUlpProxy(UlpProxyBase* ulp);
inline UlpProxyBase* getUlpProxy() { return mUlpProxy; }
/* ==== CLIENT ========================================================================= */
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
void addClientCommand(LocationAPI* client, const LocationCallbacks& callbacks);
void removeClientCommand(LocationAPI* client);
void requestCapabilitiesCommand(LocationAPI* client);
/* ======== UTILITIES ================================================================== */
void saveClient(LocationAPI* client, const LocationCallbacks& callbacks);
void eraseClient(LocationAPI* client);
void updateClientsEventMask();
void stopClientSessions(LocationAPI* client);
LocationCallbacks getClientCallbacks(LocationAPI* client);
/* ==== TRACKING ======================================================================= */
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
uint32_t startTrackingCommand(LocationAPI* client, LocationOptions& options);
void updateTrackingOptionsCommand(LocationAPI* client, uint32_t id, LocationOptions& options);
void stopTrackingCommand(LocationAPI* client, uint32_t id);
/* ======================(Called from ULP Thread)======================================= */
virtual void setPositionModeCommand(LocPosMode& locPosMode);
virtual void startTrackingCommand();
virtual void stopTrackingCommand();
virtual void getZppCommand();
/* ======== RESPONSES ================================================================== */
void reportResponse(LocationAPI* client, LocationError err, uint32_t sessionId);
/* ======== UTILITIES ================================================================== */
bool hasTrackingCallback(LocationAPI* client);
bool hasMeasurementsCallback(LocationAPI* client);
bool isTrackingSession(LocationAPI* client, uint32_t sessionId);
void saveTrackingSession(LocationAPI* client, uint32_t sessionId,
const LocationOptions& options);
void eraseTrackingSession(LocationAPI* client, uint32_t sessionId);
void setUlpPositionMode(const LocPosMode& mode) { mUlpPositionMode = mode; }
LocPosMode& getUlpPositionMode() { return mUlpPositionMode; }
void setSuplMode(GnssSuplMode mode) { mSuplMode = mode; }
LocationError startTrackingMultiplex(const LocationOptions& options);
LocationError startTracking(const LocationOptions& options);
LocationError stopTrackingMultiplex(LocationAPI* client, uint32_t id);
LocationError stopTracking();
/* ==== NI ============================================================================= */
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
void gnssNiResponseCommand(LocationAPI* client, uint32_t id, GnssNiResponse response);
/* ======================(Called from NI Thread)======================================== */
void gnssNiResponseCommand(GnssNiResponse response, void* rawRequest);
/* ======== UTILITIES ================================================================== */
bool hasNiNotifyCallback(LocationAPI* client);
NiData& getNiData() { return mNiData; }
/* ==== CONTROL ======================================================================== */
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
uint32_t enableCommand(LocationTechnologyType techType);
void disableCommand(uint32_t id);
void setControlCallbacksCommand(LocationControlCallbacks& controlCallbacks);
void readConfigCommand();
void setConfigCommand();
uint32_t* gnssUpdateConfigCommand(GnssConfig config);
uint32_t gnssDeleteAidingDataCommand(GnssAidingData& data);
/* ======== RESPONSES ================================================================== */
void reportResponse(LocationError err, uint32_t sessionId);
void reportResponse(size_t count, LocationError* errs, uint32_t* ids);
/* ======== UTILITIES ================================================================== */
LocationControlCallbacks& getControlCallbacks() { return mControlCallbacks; }
void setControlCallbacks(const LocationControlCallbacks& controlCallbacks)
{ mControlCallbacks = controlCallbacks; }
void setPowerVoteId(uint32_t id) { mPowerVoteId = id; }
uint32_t getPowerVoteId() { return mPowerVoteId; }
bool resolveInAddress(const char* hostAddress, struct in_addr* inAddress);
/* ==== REPORTS ======================================================================== */
/* ======== EVENTS ====(Called from QMI/ULP Thread)===================================== */
virtual void reportPositionEvent(const UlpLocation& ulpLocation,
const GpsLocationExtended& locationExtended,
enum loc_sess_status status,
LocPosTechMask techMask,
bool fromUlp=false);
virtual void reportSvEvent(const GnssSvNotification& svNotify, bool fromUlp=false);
virtual void reportNmeaEvent(const char* nmea, size_t length, bool fromUlp=false);
virtual bool requestNiNotifyEvent(const GnssNiNotification& notify, const void* data);
virtual void reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& measurementsNotify);
virtual void reportSvMeasurementEvent(GnssSvMeasurementSet &svMeasurementSet);
virtual void reportSvPolynomialEvent(GnssSvPolynomial &svPolynomial);
/* ======== UTILITIES ================================================================= */
void reportPosition(const UlpLocation &ulpLocation,
const GpsLocationExtended &locationExtended,
enum loc_sess_status status,
LocPosTechMask techMask);
void reportSv(GnssSvNotification& svNotify);
void reportNmea(const char* nmea, size_t length);
bool requestNiNotify(const GnssNiNotification& notify, const void* data);
void reportGnssMeasurementData(const GnssMeasurementsNotification& measurementsNotify);
/*==== NMEA Generation =============================================================== */
/*======== SVS ======================================================================= */
void generateNmea(const GnssSvNotification& svNotify);
void generateNmeaGSV(const GnssSvNotification& svNotify,
NmeaSvMeta& svMeta, char* sentence, size_t size);
/*======== POSITION ================================================================== */
void generateNmea(const UlpLocation& ulpLocation,
const GpsLocationExtended& locationExtended);
void generateNmeaBlank();
uint8_t generateNmeaGSA(const GpsLocationExtended& locationExtended,
NmeaSvMeta& svMeta, char* sentence, size_t size);
void generateNmeaVTG(const UlpLocation& ulpLocation,
const GpsLocationExtended& locationExtended,
NmeaSvMeta& svMeta, char* sentence, size_t size);
void generateNmeaRMC(const UlpLocation& ulpLocation,
const GpsLocationExtended& locationExtended,
NmeaSvMeta& svMeta, tm& utcTime, char* sentence, size_t size);
void generateNmeaGGA(const UlpLocation& ulpLocation,
const GpsLocationExtended& locationExtended,
NmeaSvMeta& svMeta, tm& utcTime, uint32_t svUsedCount,
char* sentence, size_t size);
/*======== UTILITIES ================================================================*/
int nmeaPutChecksum(char *nmea, size_t maxSize);
/*==== CONVERSION ===================================================================*/
static uint32_t convertGpsLock(const GnssConfigGpsLock gpsLock);
static GnssConfigGpsLock convertGpsLock(const uint32_t gpsLock);
static uint32_t convertSuplVersion(const GnssConfigSuplVersion suplVersion);
static GnssConfigSuplVersion convertSuplVersion(const uint32_t suplVersion);
static uint32_t convertLppProfile(const GnssConfigLppProfile lppProfile);
static GnssConfigLppProfile convertLppProfile(const uint32_t lppProfile);
static uint32_t convertEP4ES(const GnssConfigEmergencyPdnForEmergencySupl);
static uint32_t convertSuplEs(const GnssConfigSuplEmergencyServices suplEmergencyServices);
static uint32_t convertLppeCp(const GnssConfigLppeControlPlaneMask lppeControlPlaneMask);
static GnssConfigLppeControlPlaneMask convertLppeCp(const uint32_t lppeControlPlaneMask);
static uint32_t convertLppeUp(const GnssConfigLppeUserPlaneMask lppeUserPlaneMask);
static GnssConfigLppeUserPlaneMask convertLppeUp(const uint32_t lppeUserPlaneMask);
static uint32_t convertAGloProt(const GnssConfigAGlonassPositionProtocolMask);
static uint32_t convertSuplMode(const GnssConfigSuplModeMask suplModeMask);
void injectLocationCommand(double latitude, double longitude, float accuracy);
void injectTimeCommand(int64_t time, int64_t timeReference, int32_t uncertainty);
};
#endif //GNSS_ADAPTER_H

206
gnss/location_gnss.cpp Normal file
View file

@ -0,0 +1,206 @@
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "GnssAdapter.h"
#include "location_interface.h"
static GnssAdapter* gGnssAdapter = NULL;
static void initialize();
static void deinitialize();
static void addClient(LocationAPI* client, const LocationCallbacks& callbacks);
static void removeClient(LocationAPI* client);
static void requestCapabilities(LocationAPI* client);
static uint32_t startTracking(LocationAPI* client, LocationOptions& options);
static void updateTrackingOptions(LocationAPI* client, uint32_t id, LocationOptions& options);
static void stopTracking(LocationAPI* client, uint32_t id);
static void gnssNiResponse(LocationAPI* client, uint32_t id, GnssNiResponse response);
static uint32_t gnssDeleteAidingData(GnssAidingData& data);
static void setControlCallbacks(LocationControlCallbacks& controlCallbacks);
static uint32_t enable(LocationTechnologyType techType);
static void disable(uint32_t id);
static uint32_t* gnssUpdateConfig(GnssConfig config);
static void injectLocation(double latitude, double longitude, float accuracy);
static void injectTime(int64_t time, int64_t timeReference, int32_t uncertainty);
static const GnssInterface gGnssInterface = {
sizeof(GnssInterface),
initialize,
deinitialize,
addClient,
removeClient,
requestCapabilities,
startTracking,
updateTrackingOptions,
stopTracking,
gnssNiResponse,
setControlCallbacks,
enable,
disable,
gnssUpdateConfig,
gnssDeleteAidingData,
injectLocation,
injectTime
};
#ifndef DEBUG_X86
extern "C" const GnssInterface* getGnssInterface()
#else
const GnssInterface* getGnssInterface()
#endif // DEBUG_X86
{
return &gGnssInterface;
}
static void initialize()
{
if (NULL == gGnssAdapter) {
gGnssAdapter = new GnssAdapter();
}
}
static void deinitialize()
{
if (NULL != gGnssAdapter) {
delete gGnssAdapter;
gGnssAdapter = NULL;
}
}
static void addClient(LocationAPI* client, const LocationCallbacks& callbacks)
{
if (NULL != gGnssAdapter) {
gGnssAdapter->addClientCommand(client, callbacks);
}
}
static void removeClient(LocationAPI* client)
{
if (NULL != gGnssAdapter) {
gGnssAdapter->removeClientCommand(client);
}
}
static void requestCapabilities(LocationAPI* client)
{
if (NULL != gGnssAdapter) {
gGnssAdapter->requestCapabilitiesCommand(client);
}
}
static uint32_t startTracking(LocationAPI* client, LocationOptions& options)
{
if (NULL != gGnssAdapter) {
return gGnssAdapter->startTrackingCommand(client, options);
} else {
return 0;
}
}
static void updateTrackingOptions(LocationAPI* client, uint32_t id, LocationOptions& options)
{
if (NULL != gGnssAdapter) {
gGnssAdapter->updateTrackingOptionsCommand(client, id, options);
}
}
static void stopTracking(LocationAPI* client, uint32_t id)
{
if (NULL != gGnssAdapter) {
gGnssAdapter->stopTrackingCommand(client, id);
}
}
static void gnssNiResponse(LocationAPI* client, uint32_t id, GnssNiResponse response)
{
if (NULL != gGnssAdapter) {
gGnssAdapter->gnssNiResponseCommand(client, id, response);
}
}
static void setControlCallbacks(LocationControlCallbacks& controlCallbacks)
{
if (NULL != gGnssAdapter) {
return gGnssAdapter->setControlCallbacksCommand(controlCallbacks);
}
}
static uint32_t enable(LocationTechnologyType techType)
{
if (NULL != gGnssAdapter) {
return gGnssAdapter->enableCommand(techType);
} else {
return 0;
}
}
static void disable(uint32_t id)
{
if (NULL != gGnssAdapter) {
return gGnssAdapter->disableCommand(id);
}
}
static uint32_t* gnssUpdateConfig(GnssConfig config)
{
if (NULL != gGnssAdapter) {
return gGnssAdapter->gnssUpdateConfigCommand(config);
} else {
return NULL;
}
}
static uint32_t gnssDeleteAidingData(GnssAidingData& data)
{
if (NULL != gGnssAdapter) {
return gGnssAdapter->gnssDeleteAidingDataCommand(data);
} else {
return NULL;
}
}
static void injectLocation(double latitude, double longitude, float accuracy)
{
if (NULL != gGnssAdapter) {
gGnssAdapter->injectLocationCommand(latitude, longitude, accuracy);
}
}
static void injectTime(int64_t time, int64_t timeReference, int32_t uncertainty)
{
if (NULL != gGnssAdapter) {
gGnssAdapter->injectTimeCommand(time, timeReference, uncertainty);
}
}

View file

@ -1,17 +0,0 @@
ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
LOCAL_PATH := $(call my-dir)
# add RPC dirs if RPC is available
ifneq ($(TARGET_NO_RPC),true)
GPS_DIR_LIST += $(LOCAL_PATH)/libloc_api-rpc-50001/
endif #TARGET_NO_RPC
GPS_DIR_LIST += $(LOCAL_PATH)/libloc_api_50001/
#call the subfolders
include $(addsuffix Android.mk, $(GPS_DIR_LIST))
endif#BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE

View file

@ -1,120 +0,0 @@
AM_CFLAGS = \
-I./ \
-I../core \
-I./libloc_api_50001 \
-I../utils \
$(LOCPLA_CFLAGS) \
-fno-short-enums \
-D__func__=__PRETTY_FUNCTION__ \
-DTARGET_USES_QCOM_BSP \
-std=c++11
AM_CPPFLAGS = \
-std=c++11
libloc_eng_so_la_h_sources = \
loc_eng_dmn_conn_glue_msg.h \
loc_eng_dmn_conn_glue_pipe.h \
loc_eng_dmn_conn.h \
loc_eng_dmn_conn_handler.h \
loc_eng_dmn_conn_thread_helper.h
libloc_eng_so_la_SOURCES = \
libloc_api_50001/loc.cpp \
libloc_api_50001/loc_eng.cpp \
libloc_api_50001/loc_eng_agps.cpp \
libloc_api_50001/loc_eng_xtra.cpp \
libloc_api_50001/loc_eng_ni.cpp \
libloc_api_50001/loc_eng_log.cpp \
libloc_api_50001/loc_eng_nmea.cpp \
libloc_api_50001/LocEngAdapter.cpp \
libloc_api_50001/loc_eng_dmn_conn.cpp \
libloc_api_50001/loc_eng_dmn_conn_handler.cpp \
libloc_api_50001/loc_eng_dmn_conn_thread_helper.c \
libloc_api_50001/loc_eng_dmn_conn_glue_msg.c \
libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c
libloc_eng_so_la_SOURCES += libloc_eng_so_la_h_sources
if USE_GLIB
libloc_eng_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
libloc_eng_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
libloc_eng_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libloc_eng_so_la_CFLAGS = $(AM_CFLAGS)
libloc_eng_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
libloc_eng_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
libloc_eng_so_la_LIBADD = -lstdc++ -ldl -llog $(LOCPLA_LIBS) ../utils/libgps_utils_so.la ../core/libloc_core.la
libloc_ds_api_CFLAGS = \
$(QMIF_CFLAGS) \
$(QMI_CFLAGS) \
$(DATA_CFLAGS) \
-I$(WORKSPACE)/qcom-opensource/location/loc_api/ds_api
libloc_ds_api_la_SOURCES = \
$(WORKSPACE)/qcom-opensource/location/loc_api/ds_api/ds_client.c
if USE_GLIB
libloc_ds_api_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(libloc_ds_api_CFLAGS) @GLIB_CFLAGS@
libloc_ds_api_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
libloc_ds_api_la_LDFLAGS += -Wl,--export-dynamic
libloc_ds_api_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(libloc_ds_api_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libloc_ds_api_la_CFLAGS = $(AM_CFLAGS) $(libloc_ds_api_CFLAGS)
libloc_ds_api_la_LDFLAGS = -lstdc++ -lpthread -Wl,--export-dynamic -shared -version-info 1:0:0
libloc_ds_api_la_LDFLAGS += -Wl,--export-dynamic
libloc_ds_api_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) $(libloc_ds_api_CFLAGS)
endif
libloc_ds_api_la_LIBADD = -lstdc++ $(QMIF_LIBS) -lqmiservices -ldsi_netctrl $(LOCPLA_LIBS) ../utils/libgps_utils_so.la
#libloc_ds_api_la_LIBADD = -lstdc++ $(QMIF_LIBS) -lqmiservices $(LOCPLA_LIBS) ../utils/libgps_utils_so.la
libloc_api_v02_CFLAGS = \
$(QMIF_CFLAGS) \
-I$(WORKSPACE)/qcom-opensource/location/loc_api/ds_api \
-I$(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02
libloc_api_v02_la_SOURCES = \
$(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02/LocApiV02.cpp \
$(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02/loc_api_v02_log.c \
$(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02/loc_api_v02_client.c \
$(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02/loc_api_sync_req.c \
$(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02/location_service_v02.c
if USE_GLIB
libloc_api_v02_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(libloc_api_v02_CFLAGS) @GLIB_CFLAGS@
libloc_api_v02_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
libloc_api_v02_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(libloc_api_v02_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libloc_api_v02_la_CFLAGS = $(AM_CFLAGS) $(libloc_api_v02_CFLAGS)
libloc_api_v02_la_LDFLAGS = -lstdc++ -lpthread -shared -version-info 1:0:0
libloc_api_v02_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) $(libloc_api_v02_CFLAGS)
endif
libloc_api_v02_la_CXXFLAGS = -std=c++0x
libloc_api_v02_la_LIBADD = -lstdc++ -lqmi_cci -lqmi_common_so $(QMIF_LIBS) $(LOCPLA_LIBS) ../core/libloc_core.la ../utils/libgps_utils_so.la libloc_ds_api.la
library_include_HEADERS = \
libloc_api_50001/LocEngAdapter.h \
libloc_api_50001/loc.h \
libloc_api_50001/loc_eng.h \
libloc_api_50001/loc_eng_xtra.h \
libloc_api_50001/loc_eng_ni.h \
libloc_api_50001/loc_eng_agps.h \
libloc_api_50001/loc_eng_msg.h \
libloc_api_50001/loc_eng_log.h \
$(WORKSPACE)/qcom-opensource/location/loc_api/ds_api/ds_client.h \
$(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02/location_service_v02.h \
$(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02/loc_api_v02_log.h \
$(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02/loc_api_v02_client.h \
$(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02/loc_api_sync_req.h \
$(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02/LocApiV02.h \
$(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02/loc_util_log.h
library_includedir = $(pkgincludedir)
#Create and Install libraries
lib_LTLIBRARIES = libloc_eng_so.la libloc_ds_api.la libloc_api_v02.la

View file

@ -1,3 +0,0 @@
ifeq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_AMSS_VERSION),50001)
include $(call all-subdir-makefiles)
endif

View file

@ -1,60 +0,0 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
RPC_INC:=rpc_inc
source_files:= \
src/loc_api_rpc_glue.c \
src/loc_api_sync_call.c \
src/loc_apicb_appinit.c \
src/loc_api_fixup.c \
src/loc_api_log.c \
src/LocApiRpc.cpp
LOCAL_SRC_FILES:= $(source_files)
LOCAL_CFLAGS:=-fno-short-enums
LOCAL_CFLAGS+=-DDEBUG -DUSE_QCOM_AUTO_RPC -DUSE_QCOM_AUTO_RPC
LOCAL_CFLAGS+=$(GPS_FEATURES)
# for loc_api_fixup.c
LOCAL_CFLAGS+=-DADD_XDR_FLOAT -DADD_XDR_BOOL
LOCAL_SHARED_LIBRARIES:= \
librpc \
libutils \
libcutils \
libcommondefs \
libgps.utils \
libloc_core
LOCAL_STATIC_LIBRARIES := \
libloc_api_rpcgen
LOCAL_PRELINK_MODULE:= false
LOCAL_C_INCLUDES:= \
$(LOCAL_PATH) \
$(LOCAL_PATH)/rpc_inc \
$(TARGET_OUT_HEADERS)/gps.utils \
$(TARGET_OUT_HEADERS)/libloc_core \
$(TARGET_OUT_HEADERS)/loc_api/rpcgen/inc \
$(TARGET_OUT_HEADERS)/libcommondefs/rpcgen/inc \
$(TARGET_OUT_HEADERS)/librpc \
$(TARGET_OUT_HEADERS)/libloc-rpc/rpc_inc \
$(TOP)/hardware/msm7k/librpc
LOCAL_COPY_HEADERS_TO:= libloc_api-rpc-qc/$(RPC_INC)
LOCAL_COPY_HEADERS:= \
$(RPC_INC)/loc_api_rpc_glue.h \
$(RPC_INC)/loc_api_fixup.h \
$(RPC_INC)/loc_api_sync_call.h \
$(RPC_INC)/loc_apicb_appinit.h \
$(RPC_INC)/LocApiRpc.h
LOCAL_MODULE:= libloc_api-rpc-qc
LOCAL_MODULE_OWNER := qcom
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)

View file

@ -1,46 +0,0 @@
AM_CFLAGS = \
-I../../../utils \
-I../../../platform_lib_abstractions \
-I./rpc_inc \
-I../libloc_api-rpc-stub/inc \
-I../../libloc_api_50001 \
$(MSM7K_CFLAGS) \
-DUSE_QCOM_AUTO_RPC
requiredlibs = \
../../../utils/libgps_utils_so.la \
$(MSM7K_LIBS)
h_sources = \
rpc_inc/loc_api_rpc_glue.h \
rpc_inc/loc_api_fixup.h \
rpc_inc/loc_api_sync_call.h \
rpc_inc/loc_apicb_appinit.h \
c_sources = \
src/loc_api_rpc_glue.c \
src/loc_api_sync_call.c \
src/loc_apicb_appinit.c \
src/loc_api_fixup.c \
src/loc_api_log.c \
src/LocApiRpcAdapter.cpp \
library_includedir = $(pkgincludedir)/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc
library_include_HEADERS = $(h_sources)
libloc_api_rpc_qc_la_SOURCES = $(c_sources) $(h_sources)
if USE_GLIB
libloc_api_rpc_qc_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
libloc_api_rpc_qc_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
libloc_api_rpc_qc_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libloc_api_rpc_qc_la_CFLAGS = $(AM_CFLAGS)
libloc_api_rpc_qc_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
libloc_api_rpc_qc_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
libloc_api_rpc_qc_la_LIBADD = $(requiredlibs) -lstdc++
#Create and Install Libraries
lib_LTLIBRARIES = libloc_api_rpc_qc.la

View file

@ -1,142 +0,0 @@
/* Copyright (c) 2011,2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef LOC_API_RPC_H
#define LOC_API_RPC_H
#include <rpc/rpc.h>
#include <loc_api_rpcgen_common_rpc.h>
#include <loc_api_rpc_glue.h>
#include <LocApiBase.h>
#include <loc_log.h>
using namespace loc_core;
class LocApiRpc : public LocApiBase {
protected:
// RPC communication establishment
rpc_loc_client_handle_type client_handle;
private:
int dataEnableLastSet;
char apnLastSet[MAX_APN_LEN];
static const LOC_API_ADAPTER_EVENT_MASK_T maskAll;
static const rpc_loc_event_mask_type locBits[];
static rpc_loc_event_mask_type convertMask(LOC_API_ADAPTER_EVENT_MASK_T mask);
static rpc_loc_lock_e_type convertGpsLockMask(LOC_GPS_LOCK_MASK lockMask);
static enum loc_api_adapter_err convertErr(int rpcErr);
static LocGpsNiEncodingType convertNiEncodingType(int loc_encoding);
static int NIEventFillVerfiyType(LocGpsNiNotification &notif,
rpc_loc_ni_notify_verify_e_type notif_priv);
void reportPosition(const rpc_loc_parsed_position_s_type *location_report_ptr);
void reportSv(const rpc_loc_gnss_info_s_type *gnss_report_ptr);
void reportStatus(const rpc_loc_status_event_s_type *status_report_ptr);
void reportNmea(const rpc_loc_nmea_report_s_type *nmea_report_ptr);
void ATLEvent(const rpc_loc_server_request_s_type *server_request_ptr);
void NIEvent(const rpc_loc_ni_event_s_type *ni_req_ptr);
protected:
virtual enum loc_api_adapter_err
open(LOC_API_ADAPTER_EVENT_MASK_T mask);
virtual enum loc_api_adapter_err
close();
LocApiRpc(const MsgTask* msgTask,
LOC_API_ADAPTER_EVENT_MASK_T exMask);
public:
static LocApiRpc* createLocApiRpc(const MsgTask* msgTask,
LOC_API_ADAPTER_EVENT_MASK_T exMask);
~LocApiRpc();
virtual int locEventCB(rpc_loc_client_handle_type client_handle,
rpc_loc_event_mask_type loc_event,
const rpc_loc_event_payload_u_type* loc_event_payload);
void locRpcGlobalCB(CLIENT* clnt, enum rpc_reset_event event);
// RPC adapter interface implementations
virtual enum loc_api_adapter_err
startFix(const LocPosMode& posMode);
virtual enum loc_api_adapter_err
stopFix();
virtual enum loc_api_adapter_err
setPositionMode(const LocPosMode& mode);
inline virtual enum loc_api_adapter_err
enableData(int enable) { return enableData(enable, false); }
virtual enum loc_api_adapter_err
enableData(int enable, boolean force);
virtual enum loc_api_adapter_err
setTime(LocGpsUtcTime time, int64_t timeReference, int uncertainty);
virtual enum loc_api_adapter_err
injectPosition(double latitude, double longitude, float accuracy);
virtual enum loc_api_adapter_err
deleteAidingData(LocGpsAidingData f);
virtual enum loc_api_adapter_err
informNiResponse(LocGpsUserResponseType userResponse, const void* passThroughData);
inline virtual enum loc_api_adapter_err
setAPN(char* apn, int len) { return setAPN(apn, len, false); }
virtual enum loc_api_adapter_err
setAPN(char* apn, int len, boolean force);
virtual enum loc_api_adapter_err
setServer(const char* url, int len);
virtual enum loc_api_adapter_err
setServer(unsigned int ip, int port, LocServerType type);
virtual enum loc_api_adapter_err
setXtraData(char* data, int length);
virtual enum loc_api_adapter_err
requestXtraServer();
virtual enum loc_api_adapter_err
atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bear, LocAGpsType agpsType);
virtual enum loc_api_adapter_err
atlCloseStatus(int handle, int is_succ);
virtual enum loc_api_adapter_err
setSUPLVersion(uint32_t version);
virtual void setInSession(bool inSession);
/*Values for lock
1 = Do not lock any position sessions
2 = Lock MI position sessions
3 = Lock MT position sessions
4 = Lock all position sessions
*/
virtual int setGpsLock(LOC_GPS_LOCK_MASK lock);
/*
Returns
Current value of GPS Lock on success
-1 on failure
*/
virtual int getGpsLock(void);
};
extern "C" LocApiBase* getLocApi(const MsgTask* msgTask,
LOC_API_ADAPTER_EVENT_MASK_T exMask,
ContextBase *context);
#endif //LOC_API_RPC_H

View file

@ -1,69 +0,0 @@
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef DEBUG_H
#define DEBUG_H
#include <stdio.h>
#define LOG_TAG "LocSvc_rpc"
#include <utils/Log.h>
#define PRINT(x...) do { \
fprintf(stdout, "%s(%d) ", __FUNCTION__, __LINE__); \
fprintf(stdout, ##x); \
ALOGD(x); \
} while(0)
#ifdef DEBUG
#define D PRINT
#else
#define D(x...) do { } while(0)
#endif
#ifdef VERBOSE
#define V PRINT
#else
#define V(x...) do { } while(0)
#endif
#define E(x...) do { \
fprintf(stderr, "%s(%d) ", __FUNCTION__, __LINE__); \
fprintf(stderr, ##x); \
ALOGE(x); \
} while(0)
#define FAILIF(cond, msg...) do { \
if (__builtin_expect (cond, 0)) { \
fprintf(stderr, "%s:%s:(%d): ", __FILE__, __FUNCTION__, __LINE__); \
fprintf(stderr, ##msg); \
ALOGE(##msg); \
} \
} while(0)
#endif/*DEBUG_H*/

View file

@ -1,226 +0,0 @@
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef LOC_API_FIXUP_H
#define LOC_API_FIXUP_H
#ifdef __cplusplus
extern "C"
{
#endif
#ifndef NULLPROC
#define NULLPROC 0
#endif /* NULLPROC */
#ifdef ADD_XDR_FLOAT
extern bool_t xdr_float (XDR *__xdrs, float *__fp);
extern bool_t xdr_double (XDR *__xdrs, double *__dp);
#endif /* ADD_XDR_FLOAT */
#ifdef ADD_XDR_BOOL
extern bool_t xdr_bool(XDR *__xdrs, int *__bp);
#endif /* ADD_XDR_BOOL */
#define RPC_LOC_API_MAJOR_VERSION_NUMBER 1
#define RPC_LOC_API_MINOR_VERSION_NUMBER 0
// Return value for loc_open in case of failure.
#define RPC_LOC_CLIENT_HANDLE_INVALID -1
// Return value of loc api calls for loc_close, loc_start_fix, loc_stop_fix and loc_ioctl
// These are also the status for the ioctl callback
#define RPC_LOC_API_SUCCESS 0
#define RPC_LOC_API_GENERAL_FAILURE 1
#define RPC_LOC_API_UNSUPPORTED 2
#define RPC_LOC_API_INVALID_HANDLE 4
#define RPC_LOC_API_INVALID_PARAMETER 5
#define RPC_LOC_API_ENGINE_BUSY 6
#define RPC_LOC_API_PHONE_OFFLINE 7
#define RPC_LOC_API_TIMEOUT 8
// Special return value for loc api calls in case of RPC failure
#define RPC_LOC_API_RPC_FAILURE (-1234)
// Special return value for modem restart incurred RPC failure
#define RPC_LOC_API_RPC_MODEM_RESTART (-1235)
#define RPC_LOC_API_MAX_SV_COUNT 80
#define RPC_LOC_API_MAX_NMEA_STRING_LENGTH 1200
// Maximum server address that will be used in location API
#define RPC_LOC_API_MAX_SERVER_ADDR_LENGTH 256
#define RPC_LOC_API_MAX_NUM_PREDICTED_ORBITS_SERVERS 3
#define RPC_LOC_API_MAX_NUM_NTP_SERVERS 3
#define RPC_LOC_EVENT_PARSED_POSITION_REPORT 0x00000001 // Position report comes in loc_parsed_position_s_type
#define RPC_LOC_EVENT_SATELLITE_REPORT 0x00000002 // Satellite in view report
#define RPC_LOC_EVENT_NMEA_1HZ_REPORT 0x00000004 // NMEA report at 1HZ rate
#define RPC_LOC_EVENT_NMEA_POSITION_REPORT 0x00000008 // NMEA report at position report rate
#define RPC_LOC_EVENT_NI_NOTIFY_VERIFY_REQUEST 0x00000010 // NI notification/verification request
#define RPC_LOC_EVENT_ASSISTANCE_DATA_REQUEST 0x00000020 // Assistance data, eg: time, predicted orbits request
#define RPC_LOC_EVENT_LOCATION_SERVER_REQUEST 0x00000040 // Request for location server
#define RPC_LOC_EVENT_IOCTL_REPORT 0x00000080 // Callback report for loc_ioctl
#define RPC_LOC_EVENT_STATUS_REPORT 0x00000100 // Misc status report: eg, engine state
#define RPC_LOC_POS_VALID_SESSION_STATUS 0x00000001
#define RPC_LOC_POS_VALID_TIMESTAMP_CALENDAR 0x00000002
#define RPC_LOC_POS_VALID_TIMESTAMP_UTC 0x00000004
#define RPC_LOC_POS_VALID_LEAP_SECONDS 0x00000008
#define RPC_LOC_POS_VALID_TIME_UNC 0x00000010
#define RPC_LOC_POS_VALID_LATITUDE 0x00000020
#define RPC_LOC_POS_VALID_LONGITUDE 0x00000040
#define RPC_LOC_POS_VALID_ALTITUDE_WRT_ELLIPSOID 0x00000080
#define RPC_LOC_POS_VALID_ALTITUDE_WRT_MEAN_SEA_LEVEL 0x00000100
#define RPC_LOC_POS_VALID_SPEED_HORIZONTAL 0x00000200
#define RPC_LOC_POS_VALID_SPEED_VERTICAL 0x00000400
#define RPC_LOC_POS_VALID_HEADING 0x00000800
#define RPC_LOC_POS_VALID_HOR_UNC_CIRCULAR 0x00001000
#define RPC_LOC_POS_VALID_HOR_UNC_ELLI_SEMI_MAJ 0x00002000
#define RPC_LOC_POS_VALID_HOR_UNC_ELLI_SEMI_MIN 0x00004000
#define RPC_LOC_POS_VALID_HOR_UNC_ELLI_ORIENT_AZIMUTH 0x00008000
#define RPC_LOC_POS_VALID_VERTICAL_UNC 0x00010000
#define RPC_LOC_POS_VALID_SPEED_UNC 0x00020000
#define RPC_LOC_POS_VALID_HEADING_UNC 0x00040000
#define RPC_LOC_POS_VALID_CONFIDENCE_HORIZONTAL 0x00080000
#define RPC_LOC_POS_VALID_CONFIDENCE_VERTICAL 0x00100000
#define RPC_LOC_POS_VALID_MAGNETIC_VARIATION 0x00200000
#define RPC_LOC_POS_VALID_TECHNOLOGY_MASK 0x00400000
#define RPC_LOC_POS_TECH_SATELLITE 0x00000001
#define RPC_LOC_POS_TECH_CELLID 0x00000002
#define RPC_LOC_POS_TECH_WIFI 0x00000004
#define RPC_LOC_SV_INFO_VALID_SYSTEM 0x00000001
#define RPC_LOC_SV_INFO_VALID_PRN 0x00000002
#define RPC_LOC_SV_INFO_VALID_HEALTH_STATUS 0x00000004
#define RPC_LOC_SV_INFO_VALID_PROCESS_STATUS 0x00000008
#define RPC_LOC_SV_INFO_VALID_HAS_EPH 0x00000010
#define RPC_LOC_SV_INFO_VALID_HAS_ALM 0x00000020
#define RPC_LOC_SV_INFO_VALID_ELEVATION 0x00000040
#define RPC_LOC_SV_INFO_VALID_AZIMUTH 0x00000080
#define RPC_LOC_SV_INFO_VALID_SNR 0x00000100
#define RPC_LOC_GNSS_INFO_VALID_POS_DOP 0x00000001
#define RPC_LOC_GNSS_INFO_VALID_HOR_DOP 0x00000002
#define RPC_LOC_GNSS_INFO_VALID_VERT_DOP 0x00000004
#define RPC_LOC_GNSS_INFO_VALID_ALTITUDE_ASSUMED 0x00000008
#define RPC_LOC_GNSS_INFO_VALID_SV_COUNT 0x00000010
#define RPC_LOC_GNSS_INFO_VALID_SV_LIST 0x00000020
#define RPC_LOC_NI_MAX_REQUESTOR_ID_LENGTH 200
#define RPC_LOC_NI_SUPL_HASH_LENGTH 8
#define RPC_LOC_NI_SUPL_SLP_SESSION_ID_BYTE_LENGTH 4
#define RPC_LOC_NI_MAX_CLIENT_NAME_LENGTH 64
#define RPC_LOC_NI_MAX_EXT_CLIENT_ADDRESS 20
#define RPC_LOC_NI_CODEWORD_LENGTH 20
#define RPC_LOC_NI_SUPL_QOP_VALID 0x01
#define RPC_LOC_NI_SUPL_QOP_VERACC_VALID 0x02
#define RPC_LOC_NI_SUPL_QOP_MAXAGE_VALID 0x04
#define RPC_LOC_NI_SUPL_QOP_DELAY_VALID 0x08
#define RPC_LOC_FIX_CRIT_VALID_RECURRENCE_TYPE 0x00000001
#define RPC_LOC_FIX_CRIT_VALID_PREFERRED_OPERATION_MODE 0x00000002
#define RPC_LOC_FIX_CRIT_VALID_PREFERRED_ACCURACY 0x00000004
#define RPC_LOC_FIX_CRIT_VALID_PREFERRED_RESPONSE_TIME 0x00000008
#define RPC_LOC_FIX_CRIT_VALID_INTERMEDIATE_POS_REPORT_ENABLED 0x00000010
#define RPC_LOC_FIX_CRIT_VALID_NOTIFY_TYPE 0x00000020
#define RPC_LOC_FIX_CRIT_VALID_MIN_INTERVAL 0x00000040
#define RPC_LOC_FIX_CRIT_VALID_MIN_DISTANCE 0x00000080
#define RPC_LOC_FIX_CRIT_VALID_MIN_DIST_SAMPLE_INTERVAL 0x00000100
#define RPC_LOC_ASSIST_POS_VALID_TIMESTAMP_UTC 0x00000001
#define RPC_LOC_ASSIST_POS_VALID_LATITUDE 0x00000002
#define RPC_LOC_ASSIST_POS_VALID_LONGITUDE 0x00000004
#define RPC_LOC_ASSIST_POS_VALID_ALTITUDE_WRT_ELLIPSOID 0x00000008
#define RPC_LOC_ASSIST_POS_VALID_ALTITUDE_WRT_MEAN_SEA_LEVEL 0x00000010
#define RPC_LOC_ASSIST_POS_VALID_HOR_UNC_CIRCULAR 0x00000020
#define RPC_LOC_ASSIST_POS_VALID_VERT_UNC 0x00000040
#define RPC_LOC_ASSIST_POS_VALID_CONFIDENCE_HORIZONTAL 0x00000080
#define RPC_LOC_ASSIST_POS_VALID_CONFIDENCE_VERTICAL 0x00000100
#define RPC_LOC_ASSIST_POS_VALID_TIMESTAMP_AGE 0x00000200
#define RPC_LOC_ASSIST_DATA_ALL 0xFFFFFFFF
#define RPC_LOC_NMEA_MASK_ALL 0xffff
#define RPC_LOC_NMEA_MASK_GGA 0x0001
#define RPC_LOC_NMEA_MASK_RMC 0x0002
#define RPC_LOC_NMEA_MASK_GSV 0x0004
#define RPC_LOC_NMEA_MASK_GSA 0x0008
#define RPC_LOC_NMEA_MASK_VTG 0x0010
/* EFS data access */
#define RPC_LOC_EFS_MAX_PATH_LEN_BYTES 64 /* Max file name length in bytes that can be written*/
#define RPC_LOC_EFS_MAX_FILE_LEN_BYTES 2000 /* Max file size in bytes that can be written */
/* WIPER valid information flag in log report */
#define RPC_LOC_WIPER_LOG_TIME_VALID 0x01
#define RPC_LOC_WIPER_LOG_POS_VALID 0x02
#define RPC_LOC_WIPER_LOG_AP_SET_VALID 0x04
/* General WIPER defines */
#define RPC_LOC_WIPER_MAC_ADDR_LENGTH 6 // Do not change this number since it affects RPC and log packet sizes
#define RPC_LOC_WIPER_MAX_REPORTED_APS_PER_LOG_MSG 50 // Do not change this number since it affects RPC and log packet sizes
/* WIPER AP Qualifier */
#define RPC_LOC_WIPER_AP_QUALIFIER_BEING_USED 0x1 /* AP is being used by WPS */
#define RPC_LOC_WIPER_AP_QUALIFIER_HIDDEN_SSID 0x2 /* AP does not broadcast SSID */
#define RPC_LOC_WIPER_AP_QUALIFIER_PRIVATE 0x4 /* AP has encryption turned on */
#define RPC_LOC_WIPER_AP_QUALIFIER_INFRASTRUCTURE_MODE 0x8 /* AP is in infrastructure mode and not in ad-hoc/unknown mode */
/* flags for notification */
#define RPC_LOC_NI_CLIENT_NAME_PRESENT 0x0001
#define RPC_LOC_NI_CLIENT_EXTADDR_PRESENT 0x0002
#define RPC_LOC_NI_DEF_LOCATION_TYPE_PRESENT 0x0010
#define RPC_LOC_NI_REQUESTOR_ID_PRESENT 0x0020
#define RPC_LOC_NI_CODEWORD_PRESENT 0x0040
#define RPC_LOC_NI_SERVICE_TYPE_ID_PRESENT 0x0080
#define RPC_LOC_NI_ENCODING_TYPE_PRESENT 0x0100
/* below are for RPC_LOC_IOCTL_SET_LBS_APN_PROFILE data */
/* values for apn_profiles[0].srv_system_type */
#define LOC_APN_PROFILE_SRV_SYS_CDMA 0x01
#define LOC_APN_PROFILE_SRV_SYS_HDR 0x02
#define LOC_APN_PROFILE_SRV_SYS_GSM 0x04
#define LOC_APN_PROFILE_SRV_SYS_WCDMA 0x08
#define LOC_APN_PROFILE_SRV_SYS_LTE 0x10
#define LOC_APN_PROFILE_SRV_SYS_MAX 0x1F
/* values for apn_profiles[0].pdp_type */
#define LOC_APN_PROFILE_PDN_TYPE_IPV4 0x01
#define LOC_APN_PROFILE_PDN_TYPE_IPV6 0x02
#define LOC_APN_PROFILE_PDN_TYPE_IPV4V6 0x03
#define LOC_APN_PROFILE_PDN_TYPE_PPP 0x04
#define LOC_APN_PROFILE_PDN_TYPE_MAX 0x04
#ifdef __cplusplus
}
#endif
#endif /* LOC_API_FIXUP_H */

View file

@ -1,59 +0,0 @@
/* Copyright (c) 2011 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef LOC_API_LOG_H
#define LOC_API_LOG_H
#ifdef __cplusplus
extern "C"
{
#endif
#include <ctype.h>
#include "loc_api_rpcgen_common_rpc.h"
extern int loc_callback_log(
rpc_loc_event_mask_type loc_event, /* event mask */
const rpc_loc_event_payload_u_type* loc_event_payload /* payload */
);
extern const char* loc_get_event_atl_open_name(rpc_loc_server_request_e_type loc_event_atl_open);
extern const char* loc_get_event_name(rpc_loc_event_mask_type loc_event_mask);
extern const char* loc_get_ioctl_type_name(rpc_loc_ioctl_e_type ioctl_type);
extern const char* loc_get_ioctl_status_name(uint32 status);
extern const char* loc_get_sess_status_name(rpc_loc_session_status_e_type status);
extern const char* loc_get_engine_state_name(rpc_loc_engine_state_e_type state);
extern const char* loc_get_fix_session_state_name(rpc_loc_fix_session_state_e_type state);
extern const char* loc_get_rpc_reset_event_name(enum rpc_reset_event event);
#ifdef __cplusplus
}
#endif
#endif /* LOC_API_LOG_H */

View file

@ -1,123 +0,0 @@
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef LOC_API_RPC_GLUE_H
#define LOC_API_RPC_GLUE_H
/* Include RPC headers */
#ifdef USE_LOCAL_RPC
#include "rpc_inc/loc_api_common.h"
#include "rpc_inc/loc_api.h"
#include "rpc_inc/loc_api_cb.h"
#endif
#ifdef USE_QCOM_AUTO_RPC
#include "loc_api_rpcgen_rpc.h"
#include "loc_api_rpcgen_common_rpc.h"
#include "loc_api_rpcgen_cb_rpc.h"
#endif
/* Boolean */
/* Other data types in comdef.h are defined in rpc stubs, so fix it here */
typedef unsigned char boolean;
#define TRUE 1
#define FALSE 0
#include "loc_api_fixup.h"
#include "loc_api_sync_call.h"
#include <rpc/clnt.h>
#ifdef __cplusplus
extern "C"
{
#endif
extern int loc_api_glue_init(void);
extern int loc_api_null(void);
typedef int32 (loc_event_cb_f_type)(
void* userData,
rpc_loc_client_handle_type loc_handle, /* handle of the client */
rpc_loc_event_mask_type loc_event, /* event mask */
const rpc_loc_event_payload_u_type* loc_event_payload /* payload */
);
typedef void (loc_reset_notif_cb_f_type)(
void* userData,
CLIENT* clnt,
enum rpc_reset_event event
);
extern rpc_loc_client_handle_type loc_open(
rpc_loc_event_mask_type event_reg_mask,
loc_event_cb_f_type *event_callback,
loc_reset_notif_cb_f_type *rpc_global_cb,
void* userData
);
extern int32 loc_close
(
rpc_loc_client_handle_type handle
);
extern void loc_clear
(
rpc_loc_client_handle_type handle
);
extern int32 loc_start_fix
(
rpc_loc_client_handle_type handle
);
extern int32 loc_stop_fix
(
rpc_loc_client_handle_type handle
);
extern int32 loc_ioctl
(
rpc_loc_client_handle_type handle,
rpc_loc_ioctl_e_type ioctl_type,
rpc_loc_ioctl_data_u_type* ioctl_data
);
extern int loc_eng_ioctl
(
rpc_loc_client_handle_type handle,
rpc_loc_ioctl_e_type ioctl_type,
rpc_loc_ioctl_data_u_type* ioctl_data_ptr,
uint32 timeout_msec,
rpc_loc_ioctl_callback_s_type *cb_data_ptr
);
#ifdef __cplusplus
}
#endif
#endif /* LOC_API_RPC_GLUE_H */

View file

@ -1,90 +0,0 @@
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef LOC_API_CB_SYNC_H
#define LOC_API_CB_SYNC_H
#ifdef __cplusplus
extern "C"
{
#endif
#include "loc_api_rpc_glue.h"
#define LOC_SYNC_CALL_SLOTS_MAX 8
typedef struct {
pthread_mutex_t lock;
/* Client ID */
rpc_loc_client_handle_type loc_handle;
/* Callback waiting conditional variable */
pthread_cond_t loc_cb_arrived_cond;
/* Callback waiting data block, protected by loc_cb_data_mutex */
boolean in_use;
boolean signal_sent;
boolean not_available;
rpc_loc_event_mask_type loc_cb_wait_event_mask; /* event to wait for */
rpc_loc_ioctl_e_type ioctl_type; /* ioctl to wait for */
rpc_loc_event_payload_u_type loc_cb_received_payload; /* received payload */
rpc_loc_event_mask_type loc_cb_received_event_mask; /* received event */
} loc_sync_call_slot_s_type;
typedef struct {
int num_of_slots;
loc_sync_call_slot_s_type slots[LOC_SYNC_CALL_SLOTS_MAX];
} loc_sync_call_slot_array_s_type;
/* Init function */
void loc_api_sync_call_init();
/* Destroy function */
void loc_api_sync_call_destroy();
/* Process Loc API callbacks to wake up blocked user threads */
void loc_api_callback_process_sync_call(
rpc_loc_client_handle_type loc_handle, /* handle of the client */
rpc_loc_event_mask_type loc_event, /* event mask */
const rpc_loc_event_payload_u_type* loc_event_payload /* payload */
);
/* Reentrant synchronous IOCTL call, using Loc API return code */
int loc_api_sync_ioctl
(
rpc_loc_client_handle_type handle,
rpc_loc_ioctl_e_type ioctl_type,
rpc_loc_ioctl_data_u_type* ioctl_data_ptr,
uint32 timeout_msec,
rpc_loc_ioctl_callback_s_type *cb_data_ptr
);
#ifdef __cplusplus
}
#endif
#endif /* LOC_API_CB_SYNC_H */

View file

@ -1,45 +0,0 @@
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef LOC_APICB_APPINIT_H
#define LOC_APICB_APPINIT_H
#ifdef __cplusplus
extern "C"
{
#endif
/* Initialization function for callbacks */
extern int loc_apicb_app_init();
extern void loc_apicb_app_deinit();
#ifdef __cplusplus
}
#endif
#endif /* LOC_APICB_APPINIT_H */

View file

@ -1,52 +0,0 @@
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <rpc/rpc.h>
#include "loc_api_fixup.h"
#ifdef ADD_XDR_FLOAT
int
xdr_float(xdrp, fp)
XDR *xdrp;
float *fp;
{
return xdr_long(xdrp, (long*)fp);
}
int
xdr_double(xdrp, dp)
XDR *xdrp;
double *dp;
{
return xdr_long(xdrp, (long*)dp + 1)
&& xdr_long(xdrp, (long*)dp);
}
#endif /* ADD_XDR_FLOAT */

View file

@ -1,344 +0,0 @@
/* Copyright (c) 2011, 2014 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#define LOG_NDDEBUG 0
#define LOG_TAG "LocSvc_api_rpc_glue"
#include "loc_api_log.h"
#include "loc_log.h"
#include "platform_lib_includes.h"
#include "rpc/rpc.h"
#include "loc_api_fixup.h"
/* Event names */
loc_name_val_s_type loc_event_name[] =
{
NAME_VAL( RPC_LOC_EVENT_PARSED_POSITION_REPORT ),
NAME_VAL( RPC_LOC_EVENT_SATELLITE_REPORT ),
NAME_VAL( RPC_LOC_EVENT_NMEA_1HZ_REPORT ),
NAME_VAL( RPC_LOC_EVENT_NMEA_POSITION_REPORT ),
NAME_VAL( RPC_LOC_EVENT_NI_NOTIFY_VERIFY_REQUEST ),
NAME_VAL( RPC_LOC_EVENT_ASSISTANCE_DATA_REQUEST ),
NAME_VAL( RPC_LOC_EVENT_LOCATION_SERVER_REQUEST ),
NAME_VAL( RPC_LOC_EVENT_IOCTL_REPORT ),
NAME_VAL( RPC_LOC_EVENT_STATUS_REPORT ),
NAME_VAL( RPC_LOC_EVENT_WPS_NEEDED_REQUEST ),
};
int loc_event_num = sizeof loc_event_name / sizeof(loc_name_val_s_type);
/* Event names */
loc_name_val_s_type loc_event_atl_open_name[] =
{
NAME_VAL( RPC_LOC_SERVER_REQUEST_OPEN ),
NAME_VAL( RPC_LOC_SERVER_REQUEST_CLOSE ),
NAME_VAL( RPC_LOC_SERVER_REQUEST_MULTI_OPEN )
};
int loc_event_atl_open_num = sizeof loc_event_atl_open_name / sizeof(loc_name_val_s_type);
/* Finds the first event found in the mask */
const char* loc_get_event_atl_open_name(rpc_loc_server_request_e_type loc_event_atl_open)
{
return loc_get_name_from_val(loc_event_atl_open_name, loc_event_atl_open_num,
(long) loc_event_atl_open);
}
/* IOCTL Type names */
loc_name_val_s_type loc_ioctl_type_name[] =
{
NAME_VAL( RPC_LOC_IOCTL_GET_API_VERSION ),
NAME_VAL( RPC_LOC_IOCTL_SET_FIX_CRITERIA ),
NAME_VAL( RPC_LOC_IOCTL_GET_FIX_CRITERIA ),
NAME_VAL( RPC_LOC_IOCTL_INFORM_NI_USER_RESPONSE ),
NAME_VAL( RPC_LOC_IOCTL_INJECT_PREDICTED_ORBITS_DATA ),
NAME_VAL( RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_VALIDITY ),
NAME_VAL( RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE ),
NAME_VAL( RPC_LOC_IOCTL_SET_PREDICTED_ORBITS_DATA_AUTO_DOWNLOAD ),
NAME_VAL( RPC_LOC_IOCTL_INJECT_UTC_TIME ),
NAME_VAL( RPC_LOC_IOCTL_INJECT_RTC_VALUE ),
NAME_VAL( RPC_LOC_IOCTL_INJECT_POSITION ),
NAME_VAL( RPC_LOC_IOCTL_QUERY_ENGINE_STATE ),
NAME_VAL( RPC_LOC_IOCTL_ERROR_ESTIMATE_CONFIG),
NAME_VAL( RPC_LOC_IOCTL_INFORM_SERVER_MULTI_OPEN_STATUS ),
NAME_VAL( RPC_LOC_IOCTL_INFORM_SERVER_OPEN_STATUS ),
NAME_VAL( RPC_LOC_IOCTL_INFORM_SERVER_CLOSE_STATUS ),
NAME_VAL( RPC_LOC_IOCTL_SEND_WIPER_POSITION_REPORT ),
NAME_VAL( RPC_LOC_IOCTL_NOTIFY_WIPER_STATUS ),
NAME_VAL( RPC_LOC_IOCTL_SET_ENGINE_LOCK ),
NAME_VAL( RPC_LOC_IOCTL_GET_ENGINE_LOCK ),
NAME_VAL( RPC_LOC_IOCTL_SET_SBAS_CONFIG ),
NAME_VAL( RPC_LOC_IOCTL_GET_SBAS_CONFIG ),
NAME_VAL( RPC_LOC_IOCTL_SET_NMEA_TYPES ),
NAME_VAL( RPC_LOC_IOCTL_GET_NMEA_TYPES ),
NAME_VAL( RPC_LOC_IOCTL_SET_CDMA_PDE_SERVER_ADDR ),
NAME_VAL( RPC_LOC_IOCTL_GET_CDMA_PDE_SERVER_ADDR ),
NAME_VAL( RPC_LOC_IOCTL_SET_CDMA_MPC_SERVER_ADDR ),
NAME_VAL( RPC_LOC_IOCTL_GET_CDMA_MPC_SERVER_ADDR ),
NAME_VAL( RPC_LOC_IOCTL_SET_UMTS_SLP_SERVER_ADDR ),
NAME_VAL( RPC_LOC_IOCTL_GET_UMTS_SLP_SERVER_ADDR ),
NAME_VAL( RPC_LOC_IOCTL_SET_ON_DEMAND_LPM ),
NAME_VAL( RPC_LOC_IOCTL_GET_ON_DEMAND_LPM ),
NAME_VAL( RPC_LOC_IOCTL_SET_XTRA_T_SESSION_CONTROL ),
NAME_VAL( RPC_LOC_IOCTL_GET_XTRA_T_SESSION_CONTROL ),
NAME_VAL( RPC_LOC_IOCTL_SET_LBS_APN_PROFILE ),
NAME_VAL( RPC_LOC_IOCTL_GET_LBS_APN_PROFILE ),
NAME_VAL( RPC_LOC_IOCTL_SET_XTRA_APN_PROFILE ),
NAME_VAL( RPC_LOC_IOCTL_GET_XTRA_APN_PROFILE ),
NAME_VAL( RPC_LOC_IOCTL_SET_DATA_ENABLE ),
NAME_VAL( RPC_LOC_IOCTL_SET_SUPL_VERSION ),
NAME_VAL( RPC_LOC_IOCTL_GET_SUPL_VERSION ),
NAME_VAL( RPC_LOC_IOCTL_DELETE_ASSIST_DATA ),
NAME_VAL( RPC_LOC_IOCTL_SET_CUSTOM_PDE_SERVER_ADDR ),
NAME_VAL( RPC_LOC_IOCTL_GET_CUSTOM_PDE_SERVER_ADDR ),
};
int loc_ioctl_type_num = sizeof loc_ioctl_type_name / sizeof(loc_name_val_s_type);
/* IOCTL Status names */
loc_name_val_s_type loc_ioctl_status_name[] =
{
NAME_VAL( RPC_LOC_API_SUCCESS ),
NAME_VAL( RPC_LOC_API_GENERAL_FAILURE ),
NAME_VAL( RPC_LOC_API_UNSUPPORTED ),
NAME_VAL( RPC_LOC_API_INVALID_HANDLE ),
NAME_VAL( RPC_LOC_API_INVALID_PARAMETER ),
NAME_VAL( RPC_LOC_API_ENGINE_BUSY ),
NAME_VAL( RPC_LOC_API_PHONE_OFFLINE ),
NAME_VAL( RPC_LOC_API_TIMEOUT ),
NAME_VAL( RPC_LOC_API_RPC_FAILURE ),
NAME_VAL( RPC_LOC_API_RPC_MODEM_RESTART )
};
int loc_ioctl_status_num = sizeof loc_ioctl_status_name / sizeof(loc_name_val_s_type);
/* Fix session status names */
loc_name_val_s_type loc_sess_status_name[] =
{
NAME_VAL( RPC_LOC_SESS_STATUS_SUCCESS ),
NAME_VAL( RPC_LOC_SESS_STATUS_IN_PROGESS ),
NAME_VAL( RPC_LOC_SESS_STATUS_GENERAL_FAILURE ),
NAME_VAL( RPC_LOC_SESS_STATUS_TIMEOUT ),
NAME_VAL( RPC_LOC_SESS_STATUS_USER_END ),
NAME_VAL( RPC_LOC_SESS_STATUS_BAD_PARAMETER ),
NAME_VAL( RPC_LOC_SESS_STATUS_PHONE_OFFLINE ),
NAME_VAL( RPC_LOC_SESS_STATUS_USER_END ),
NAME_VAL( RPC_LOC_SESS_STATUS_ENGINE_LOCKED )
};
int loc_sess_status_num = sizeof loc_sess_status_name / sizeof(loc_name_val_s_type);
/* Engine state names */
loc_name_val_s_type loc_engine_state_name[] =
{
NAME_VAL( RPC_LOC_ENGINE_STATE_ON ),
NAME_VAL( RPC_LOC_ENGINE_STATE_OFF )
};
int loc_engine_state_num = sizeof loc_engine_state_name / sizeof(loc_name_val_s_type);
/* Fix session state names */
loc_name_val_s_type loc_fix_session_state_name[] =
{
NAME_VAL( RPC_LOC_FIX_SESSION_STATE_BEGIN ),
NAME_VAL( RPC_LOC_FIX_SESSION_STATE_END )
};
int loc_fix_session_state_num = sizeof loc_fix_session_state_name / sizeof(loc_name_val_s_type);
static const char* log_final_interm_string(int is_final)
{
return is_final ? "final" : "intermediate";
}
/* Logs parsed report */
static void log_parsed_report(const rpc_loc_parsed_position_s_type *parsed_report)
{
rpc_loc_session_status_e_type status = parsed_report->session_status;
LOC_LOGD("Session status: %s Valid mask: 0x%X\n",
loc_get_sess_status_name(status),
(uint) parsed_report->valid_mask);
LOC_LOGD("Latitude: %.7f (%s)\n", parsed_report->latitude,
log_final_interm_string(
(parsed_report->valid_mask & RPC_LOC_POS_VALID_LATITUDE) &&
parsed_report->session_status == RPC_LOC_SESS_STATUS_SUCCESS));
LOC_LOGD("Longitude: %.7f\n", parsed_report->longitude);
LOC_LOGD("Accuracy: %.7f\n", parsed_report->hor_unc_circular);
}
/* Logs status report */
static void log_status_report(const rpc_loc_status_event_s_type *status_event)
{
rpc_loc_status_event_e_type event = status_event->event;
switch (event) {
case RPC_LOC_STATUS_EVENT_ENGINE_STATE:
LOC_LOGD("Engine state: %s\n",
loc_get_engine_state_name(
status_event->payload.rpc_loc_status_event_payload_u_type_u.engine_state));
break;
case RPC_LOC_STATUS_EVENT_FIX_SESSION_STATE:
LOC_LOGD("Fix session state: %s\n",
loc_get_fix_session_state_name(
status_event->payload.rpc_loc_status_event_payload_u_type_u.fix_session_state));
break;
default:
break;
}
}
/* Logs valid fields in the GNSS SV constellation report */
static void log_satellite_report(const rpc_loc_gnss_info_s_type *gnss)
{
if (gnss->valid_mask & RPC_LOC_GNSS_INFO_VALID_POS_DOP)
{
LOC_LOGV("position dop: %.3f\n", (float) gnss->position_dop);
}
if (gnss->valid_mask & RPC_LOC_GNSS_INFO_VALID_HOR_DOP)
{
LOC_LOGV("horizontal dop: %.3f\n", (float) gnss->horizontal_dop);
}
if (gnss->valid_mask & RPC_LOC_GNSS_INFO_VALID_VERT_DOP)
{
LOC_LOGV("vertical dop: %.3f\n", (float) gnss->vertical_dop);
}
if (gnss->valid_mask & RPC_LOC_GNSS_INFO_VALID_ALTITUDE_ASSUMED)
{
LOC_LOGV("altitude assumed: %d\n", (int) gnss->altitude_assumed);
}
if (gnss->valid_mask & RPC_LOC_GNSS_INFO_VALID_SV_COUNT)
{
LOC_LOGD("sv count: %d\n", (int) gnss->sv_count);
}
if (gnss->valid_mask & RPC_LOC_GNSS_INFO_VALID_SV_LIST)
{
LOC_LOGV("sv list: ");
if (gnss->sv_count)
{
LOC_LOGV("\n\tsys\tprn\thlth\tproc\teph\talm\telev\tazi\tsnr\n");
}
else {
LOC_LOGV("empty\n");
}
int i;
for (i = 0; i < gnss->sv_count; i++)
{
const rpc_loc_sv_info_s_type *sv = &gnss->sv_list.sv_list_val[i];
rpc_loc_sv_info_valid_mask_type mask = sv->valid_mask;
LOC_LOGV(" %d: \t%d\t%d\t%d\t%d\t%d\t%d\t%.3f\t%.3f\t%.3f\n", i,
CHECK_MASK(int, sv->system, mask, RPC_LOC_SV_INFO_VALID_SYSTEM),
CHECK_MASK(int, sv->prn, mask, RPC_LOC_SV_INFO_VALID_PRN),
CHECK_MASK(int, sv->health_status, mask, RPC_LOC_SV_INFO_VALID_HEALTH_STATUS),
CHECK_MASK(int, sv->process_status, mask, RPC_LOC_SV_INFO_VALID_PROCESS_STATUS),
CHECK_MASK(int, sv->has_eph, mask, RPC_LOC_SV_INFO_VALID_HAS_EPH),
CHECK_MASK(int, sv->has_alm, mask, RPC_LOC_SV_INFO_VALID_HAS_ALM),
CHECK_MASK(float, sv->elevation, mask, RPC_LOC_SV_INFO_VALID_ELEVATION),
CHECK_MASK(float, sv->azimuth, mask, RPC_LOC_SV_INFO_VALID_AZIMUTH),
CHECK_MASK(float, sv->snr, mask, RPC_LOC_SV_INFO_VALID_SNR)
);
}
}
}
/* Logs a callback event */
int loc_callback_log(
rpc_loc_event_mask_type loc_event, /* event mask */
const rpc_loc_event_payload_u_type* loc_event_payload /* payload */
)
{
switch (loc_event)
{
case RPC_LOC_EVENT_SATELLITE_REPORT:
log_satellite_report(&loc_event_payload->
rpc_loc_event_payload_u_type_u.gnss_report);
break;
case RPC_LOC_EVENT_STATUS_REPORT:
log_status_report(&loc_event_payload->
rpc_loc_event_payload_u_type_u.status_report);
break;
case RPC_LOC_EVENT_PARSED_POSITION_REPORT:
log_parsed_report(&loc_event_payload->
rpc_loc_event_payload_u_type_u.parsed_location_report);
break;
default:
break;
}
return 0;
}
/* Finds the first event found in the mask */
const char* loc_get_event_name(rpc_loc_event_mask_type loc_event_mask)
{
return loc_get_name_from_mask(loc_event_name, loc_event_num,
(long) loc_event_mask);
}
/* Finds IOCTL type name */
const char* loc_get_ioctl_type_name(rpc_loc_ioctl_e_type ioctl_type)
{
return loc_get_name_from_val(loc_ioctl_type_name, loc_ioctl_type_num,
(long) ioctl_type);
}
/* Finds IOCTL status name */
const char* loc_get_ioctl_status_name(uint32 status)
{
return loc_get_name_from_val(loc_ioctl_status_name, loc_ioctl_status_num,
(long) status);
}
/* Finds session status name */
const char* loc_get_sess_status_name(rpc_loc_session_status_e_type status)
{
return loc_get_name_from_val(loc_sess_status_name, loc_sess_status_num,
(long) status);
}
/* Find engine state name */
const char* loc_get_engine_state_name(rpc_loc_engine_state_e_type state)
{
return loc_get_name_from_val(loc_engine_state_name, loc_engine_state_num,
(long) state);
}
/* Find engine state name */
const char* loc_get_fix_session_state_name(rpc_loc_fix_session_state_e_type state)
{
return loc_get_name_from_val(loc_fix_session_state_name, loc_fix_session_state_num,
(long) state);
}
/* Event names */
loc_name_val_s_type rpc_reset_event_name[] =
{
NAME_VAL( RPC_SUBSYSTEM_RESTART_BEGIN ),
NAME_VAL( RPC_SUBSYSTEM_RESTART_END )
};
int rpc_reset_event_num = sizeof rpc_reset_event_name / sizeof(loc_name_val_s_type);
const char* loc_get_rpc_reset_event_name(enum rpc_reset_event event)
{
return loc_get_name_from_val(rpc_reset_event_name, rpc_reset_event_num, event);
}

View file

@ -1,635 +0,0 @@
/* Copyright (c) 2011-2012,2014 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*=====================================================================
INCLUDE FILES FOR MODULE
======================================================================*/
#include <stdio.h>
#include <pthread.h>
#include <errno.h>
#include <string.h>
#include <sys/select.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
#include <stdlib.h>
#include <assert.h>
#include <loc_api_log.h>
#include <rpc/rpc.h>
/* Include RPC headers */
#include "rpc_inc/loc_api_rpc_glue.h"
/* Callback init */
#include "rpc_inc/loc_apicb_appinit.h"
/* Logging */
#define LOG_TAG "LocSvc_api_rpc_glue"
#define LOG_NDDEBUG 0
#ifndef USE_GLIB
#include <utils/Log.h>
#endif /* USE_GLIB */
/* Logging Improvement */
#include "platform_lib_includes.h"
/*Maximum number of Modem init*/
#define RPC_TRY_NUM 10
/*Maximum number of Modem init*/
#define RPC_TRY_NUM 10
/* Uncomment to force ALOGD messages */
// #define ALOGD ALOGI
/*=====================================================================
External declarations
======================================================================*/
CLIENT* loc_api_clnt = NULL;
/* Callback ID and pointer */
#define LOC_API_CB_MAX_CLIENTS 16
typedef struct
{
uint32 cb_id; /* same as rpc/types.h */
loc_event_cb_f_type *cb_func; /* callback func */
loc_reset_notif_cb_f_type *rpc_cb; /* callback from RPC */
rpc_loc_client_handle_type handle; /* stores handle for client closing */
void* user; /* user's own data handle */
} loc_glue_cb_entry_s_type;
loc_glue_cb_entry_s_type loc_glue_callback_table[LOC_API_CB_MAX_CLIENTS];
#define RPC_FUNC_VERSION_BASE(a,b) a ## b
#define RPC_FUNC_VERSION(a,b) RPC_FUNC_VERSION_BASE(a,b)
#define RPC_CALLBACK_FUNC_VERSION_BASE(a,v,b) a ## v ## b
#define RPC_CALLBACK_FUNC_VERSION(a,v,b) RPC_CALLBACK_FUNC_VERSION_BASE(a,v,b)
#define LOC_GLUE_CHECK_INIT(ret_type) \
if (loc_api_clnt == NULL) { EXIT_LOG_CALLFLOW(%d, RPC_LOC_API_RPC_FAILURE); return (ret_type) RPC_LOC_API_RPC_FAILURE; }
#define LOC_GLUE_CHECK_RESULT(stat, ret_type) \
if (stat != RPC_SUCCESS) { \
LOC_LOGE("%s:%d] failure code %d", __func__, __LINE__, stat); \
return (ret_type)((stat == RPC_SUBSYSTEM_RESTART) ? \
RPC_LOC_API_RPC_MODEM_RESTART : RPC_LOC_API_RPC_FAILURE); \
}
/* Callback functions */
/* Returns 1 if successful */
bool_t rpc_loc_event_cb_f_type_svc(
rpc_loc_event_cb_f_type_args *argp,
rpc_loc_event_cb_f_type_rets *ret,
struct svc_req *req)
{
// The lower word of cd_id is the index
int index = argp->cb_id & 0xFFFF;
/* Callback not registered, or unexpected ID (shouldn't happen) */
if (index >= LOC_API_CB_MAX_CLIENTS || loc_glue_callback_table[index].cb_func == NULL)
{
LOC_LOGE("Warning: No callback handler %d.\n", index);
ret->loc_event_cb_f_type_result = 0;
return 1; /* simply return */
}
LOC_LOGV("proc: %x prog: %x vers: %x\n",
(int) req->rq_proc,
(int) req->rq_prog,
(int) req->rq_vers);
LOC_LOGV("Callback received: %x (cb_id=%p handle=%d ret_ptr=%d)\n",
(int) argp->loc_event,
argp->cb_id,
(int) argp->loc_handle,
(int) ret);
/* Forward callback to real callback procedure */
rpc_loc_client_handle_type loc_handle = argp->loc_handle;
rpc_loc_event_mask_type loc_event = argp->loc_event;
const rpc_loc_event_payload_u_type* loc_event_payload =
(const rpc_loc_event_payload_u_type*) argp->loc_event_payload;
/* Gives control to synchronous call handler */
loc_api_callback_process_sync_call(loc_handle, loc_event, loc_event_payload);
int32 rc = (loc_glue_callback_table[index].cb_func)(loc_glue_callback_table[index].user,
loc_handle, loc_event, loc_event_payload);
LOC_LOGV("cb_func=%p", loc_glue_callback_table[index].cb_func);
ret->loc_event_cb_f_type_result = rc;
return 1; /* ok */
}
int loc_apicbprog_freeresult (SVCXPRT *transp, xdrproc_t xdr_result, caddr_t result)
{
xdr_free (xdr_result, result);
/*
* Insert additional freeing code here, if needed
*/
// LOC_LOGD("***** loc_apicbprog_freeresult\n");
return 1;
}
/*===========================================================================
FUNCTION rpc_loc_event_cb_f_type_<version>_svc (MACRO)
DESCRIPTION
Callback function for Loc API
RETURN VALUE
1 for success
0 for failure
===========================================================================*/
bool_t RPC_CALLBACK_FUNC_VERSION(rpc_loc_event_cb_f_type_, RPC_LOC_EVENT_CB_F_TYPE_VERSION, _svc) (
rpc_loc_event_cb_f_type_args *argp,
rpc_loc_event_cb_f_type_rets *ret,
struct svc_req *req)
{
return rpc_loc_event_cb_f_type_svc(argp, ret, req);
}
/*===========================================================================
FUNCTION loc_apicbprog_<version>_freeresult (MACRO)
DESCRIPTION
Free up RPC data structure
RETURN VALUE
1 for success
0 for failure
===========================================================================*/
#define VERSION_CONCAT(MAJOR,MINOR) MAJOR##MINOR
#define loc_apicb_prog_VER_freeresult(M,N) \
int RPC_CALLBACK_FUNC_VERSION(loc_apicbprog_, VERSION_CONCAT(M,N), _freeresult) \
(SVCXPRT *transp, xdrproc_t xdr_result, caddr_t result) \
{ \
return loc_apicbprog_freeresult(transp, xdr_result, result); \
}
/* Define all of the possible minors */
loc_apicb_prog_VER_freeresult(RPC_LOC_API_API_MAJOR_NUM, 0001);
loc_apicb_prog_VER_freeresult(RPC_LOC_API_API_MAJOR_NUM, 0002);
loc_apicb_prog_VER_freeresult(RPC_LOC_API_API_MAJOR_NUM, 0003);
loc_apicb_prog_VER_freeresult(RPC_LOC_API_API_MAJOR_NUM, 0004);
loc_apicb_prog_VER_freeresult(RPC_LOC_API_API_MAJOR_NUM, 0005);
loc_apicb_prog_VER_freeresult(RPC_LOC_API_API_MAJOR_NUM, 0006);
/*===========================================================================
FUNCTION rpc_loc_api_cb_null_<version>_svc (MACRO) [Patch for wrong RPCGEN stubs]
DESCRIPTION
Null callback function for Loc API
RETURN VALUE
1 for success
===========================================================================*/
#define rpc_loc_api_cb_null_VER_svc(M,N) \
bool_t RPC_CALLBACK_FUNC_VERSION(rpc_loc_api_cb_null_, VERSION_CONCAT(M,N), _svc) ( \
void *a, int *b, struct svc_req *req) \
{ \
return 1; \
}
/* Define all of the possible minors */
rpc_loc_api_cb_null_VER_svc(RPC_LOC_API_API_MAJOR_NUM, 0001);
rpc_loc_api_cb_null_VER_svc(RPC_LOC_API_API_MAJOR_NUM, 0002);
rpc_loc_api_cb_null_VER_svc(RPC_LOC_API_API_MAJOR_NUM, 0003);
rpc_loc_api_cb_null_VER_svc(RPC_LOC_API_API_MAJOR_NUM, 0004);
rpc_loc_api_cb_null_VER_svc(RPC_LOC_API_API_MAJOR_NUM, 0005);
rpc_loc_api_cb_null_VER_svc(RPC_LOC_API_API_MAJOR_NUM, 0006);
static void loc_api_glue_rpc_cb(CLIENT* client, enum rpc_reset_event event)
{
int i;
for (i = 0; i < LOC_API_CB_MAX_CLIENTS; i++) {
if (NULL != loc_glue_callback_table[i].rpc_cb) {
loc_glue_callback_table[i].rpc_cb(loc_glue_callback_table[i].user, client, event);
}
}
}
/*===========================================================================
FUNCTION loc_api_glue_init
DESCRIPTION
Initiates the RPC client
RETURN VALUE
1 for success
0 for failure
===========================================================================*/
int loc_api_glue_init(void)
{
if (loc_api_clnt == NULL)
{
/* Initialize data */
int i;
int pid = getpid();
for (i = 0; i < LOC_API_CB_MAX_CLIENTS; i++)
{
loc_glue_callback_table[i].cb_id = i | (pid << 16);
loc_glue_callback_table[i].cb_func = NULL;
loc_glue_callback_table[i].handle = -1;
loc_glue_callback_table[i].rpc_cb = NULL;
loc_glue_callback_table[i].user = NULL;
}
/* Print msg */
LOC_LOGV("Trying to create RPC client...\n");
loc_api_clnt = clnt_create(NULL, LOC_APIPROG, LOC_APIVERS, NULL);
LOC_LOGV("Created loc_api_clnt ---- %x\n", (unsigned int)loc_api_clnt);
if (loc_api_clnt == NULL)
{
LOC_LOGE("Error: cannot create RPC client.\n");
return 0;
}
/* Init RPC callbacks */
loc_api_sync_call_init();
int rc = loc_apicb_app_init();
if (rc >= 0)
{
LOC_LOGD("Loc API RPC client initialized.\n");
clnt_register_reset_notification_cb(loc_api_clnt, loc_api_glue_rpc_cb);
}
else {
LOC_LOGE("Loc API callback initialization failed.\n");
return 0;
}
}
return 1;
}
rpc_loc_client_handle_type loc_open (
rpc_loc_event_mask_type event_reg_mask,
loc_event_cb_f_type *event_callback,
loc_reset_notif_cb_f_type *rpc_cb,
void* userData
)
{
int try_num = RPC_TRY_NUM;
ENTRY_LOG();
LOC_GLUE_CHECK_INIT(rpc_loc_client_handle_type);
rpc_loc_client_handle_type ret_val;
rpc_loc_open_args args;
args.event_reg_mask = event_reg_mask;
int i, j = LOC_API_CB_MAX_CLIENTS;
for (i = 0; i < LOC_API_CB_MAX_CLIENTS; i++)
{
if (loc_glue_callback_table[i].user == userData)
{
LOC_LOGW("Client already opened service (callback=%p)...\n",
event_callback);
break;
} else if (j == LOC_API_CB_MAX_CLIENTS &&
loc_glue_callback_table[i].user == NULL) {
j = i;
}
}
if (i == LOC_API_CB_MAX_CLIENTS)
{
i = j;
}
if (i == LOC_API_CB_MAX_CLIENTS)
{
LOC_LOGE("Too many clients opened at once...\n");
return RPC_LOC_CLIENT_HANDLE_INVALID;
}
loc_glue_callback_table[i].cb_func = event_callback;
loc_glue_callback_table[i].rpc_cb = rpc_cb;
loc_glue_callback_table[i].user = userData;
args.event_callback = loc_glue_callback_table[i].cb_id;
LOC_LOGV("cb_id=%d, func=0x%x", i, (unsigned int) event_callback);
rpc_loc_open_rets rets;
enum clnt_stat stat = RPC_SUCCESS;
EXIT_LOG_CALLFLOW(%s, "loc client open");
/*try more for rpc_loc_open_xx()*/
do
{
stat = RPC_FUNC_VERSION(rpc_loc_open_, RPC_LOC_OPEN_VERSION)(&args, &rets, loc_api_clnt);
ret_val = (rpc_loc_client_handle_type) rets.loc_open_result;
try_num--;
}while( (RPC_SUCCESS != stat||0 > ret_val) && 0 != try_num );
LOC_GLUE_CHECK_RESULT(stat, int32);
/* save the handle in the table */
loc_glue_callback_table[i].handle = (rpc_loc_client_handle_type) rets.loc_open_result;
return ret_val;
}
int32 loc_close
(
rpc_loc_client_handle_type handle
)
{
ENTRY_LOG();
LOC_GLUE_CHECK_INIT(int32);
int32 ret_val;
rpc_loc_close_args args;
args.handle = handle;
rpc_loc_close_rets rets;
enum clnt_stat stat = RPC_SUCCESS;
EXIT_LOG_CALLFLOW(%s, "loc client close");
stat = RPC_FUNC_VERSION(rpc_loc_close_, RPC_LOC_CLOSE_VERSION)(&args, &rets, loc_api_clnt);
loc_clear(handle);
LOC_GLUE_CHECK_RESULT(stat, int32);
ret_val = (int32) rets.loc_close_result;
return ret_val;
}
void loc_clear(rpc_loc_client_handle_type handle) {
/* Clean the client's callback function in callback table */
int i;
for (i = 0; i < LOC_API_CB_MAX_CLIENTS; i++)
{
if (loc_glue_callback_table[i].handle == handle)
{
/* Found the client */
loc_glue_callback_table[i].cb_func = NULL;
loc_glue_callback_table[i].rpc_cb = NULL;
loc_glue_callback_table[i].handle = -1;
loc_glue_callback_table[i].user = NULL;
break;
}
}
if (i == LOC_API_CB_MAX_CLIENTS)
{
LOC_LOGW("Handle not found (handle=%d)...\n", (int) handle);
}
}
int32 loc_start_fix
(
rpc_loc_client_handle_type handle
)
{
ENTRY_LOG();
LOC_GLUE_CHECK_INIT(int32);
int32 ret_val;
rpc_loc_start_fix_args args;
args.handle = handle;
rpc_loc_start_fix_rets rets;
enum clnt_stat stat = RPC_SUCCESS;
EXIT_LOG_CALLFLOW(%s, "loc start fix");
stat = RPC_FUNC_VERSION(rpc_loc_start_fix_, RPC_LOC_START_FIX_VERSION)(&args, &rets, loc_api_clnt);
LOC_GLUE_CHECK_RESULT(stat, int32);
ret_val = (int32) rets.loc_start_fix_result;
return ret_val;
}
int32 loc_stop_fix
(
rpc_loc_client_handle_type handle
)
{
ENTRY_LOG();
LOC_GLUE_CHECK_INIT(int32);
int32 ret_val;
rpc_loc_stop_fix_args args;
args.handle = handle;
rpc_loc_stop_fix_rets rets;
enum clnt_stat stat = RPC_SUCCESS;
EXIT_LOG_CALLFLOW(%s, "loc stop fix");
stat = RPC_FUNC_VERSION(rpc_loc_stop_fix_, RPC_LOC_STOP_FIX_VERSION)(&args, &rets, loc_api_clnt);
LOC_GLUE_CHECK_RESULT(stat, int32);
ret_val = (int32) rets.loc_stop_fix_result;
return ret_val;
}
int32 loc_ioctl
(
rpc_loc_client_handle_type handle,
rpc_loc_ioctl_e_type ioctl_type,
rpc_loc_ioctl_data_u_type* ioctl_data
)
{
ENTRY_LOG();
LOC_GLUE_CHECK_INIT(int32);
int32 ret_val;
rpc_loc_ioctl_args args;
args.handle = handle;
args.ioctl_data = ioctl_data;
args.ioctl_type = ioctl_type;
if (ioctl_data != NULL)
{
/* Assign ioctl union discriminator */
ioctl_data->disc = ioctl_type;
/* In case the user hasn't filled in other disc fields,
automatically fill them in here */
switch (ioctl_type)
{
case RPC_LOC_IOCTL_GET_API_VERSION:
break;
case RPC_LOC_IOCTL_SET_FIX_CRITERIA:
break;
case RPC_LOC_IOCTL_GET_FIX_CRITERIA:
break;
case RPC_LOC_IOCTL_INFORM_NI_USER_RESPONSE:
break;
case RPC_LOC_IOCTL_INJECT_PREDICTED_ORBITS_DATA:
break;
case RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_VALIDITY:
break;
case RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE:
break;
case RPC_LOC_IOCTL_SET_PREDICTED_ORBITS_DATA_AUTO_DOWNLOAD:
break;
case RPC_LOC_IOCTL_INJECT_UTC_TIME:
break;
case RPC_LOC_IOCTL_INJECT_RTC_VALUE:
break;
case RPC_LOC_IOCTL_INJECT_POSITION:
break;
case RPC_LOC_IOCTL_QUERY_ENGINE_STATE:
break;
case RPC_LOC_IOCTL_INFORM_SERVER_OPEN_STATUS:
break;
case RPC_LOC_IOCTL_INFORM_SERVER_CLOSE_STATUS:
break;
case RPC_LOC_IOCTL_SET_ENGINE_LOCK:
break;
case RPC_LOC_IOCTL_GET_ENGINE_LOCK:
break;
case RPC_LOC_IOCTL_SET_SBAS_CONFIG:
break;
case RPC_LOC_IOCTL_GET_SBAS_CONFIG:
break;
case RPC_LOC_IOCTL_SET_NMEA_TYPES:
break;
case RPC_LOC_IOCTL_GET_NMEA_TYPES:
break;
case RPC_LOC_IOCTL_SET_CDMA_PDE_SERVER_ADDR:
case RPC_LOC_IOCTL_SET_CDMA_MPC_SERVER_ADDR:
case RPC_LOC_IOCTL_SET_UMTS_SLP_SERVER_ADDR:
case RPC_LOC_IOCTL_SET_CUSTOM_PDE_SERVER_ADDR:
args.ioctl_data->rpc_loc_ioctl_data_u_type_u.server_addr.addr_info.disc =
args.ioctl_data->rpc_loc_ioctl_data_u_type_u.server_addr.addr_type;
break;
case RPC_LOC_IOCTL_GET_CDMA_PDE_SERVER_ADDR:
case RPC_LOC_IOCTL_GET_CDMA_MPC_SERVER_ADDR:
case RPC_LOC_IOCTL_GET_UMTS_SLP_SERVER_ADDR:
case RPC_LOC_IOCTL_GET_CUSTOM_PDE_SERVER_ADDR:
break;
case RPC_LOC_IOCTL_SET_ON_DEMAND_LPM:
break;
case RPC_LOC_IOCTL_GET_ON_DEMAND_LPM:
break;
case RPC_LOC_IOCTL_DELETE_ASSIST_DATA:
break;
default:
break;
} /* switch */
} /* ioctl_data != NULL */
rpc_loc_ioctl_rets rets;
enum clnt_stat stat = RPC_SUCCESS;
EXIT_LOG_CALLFLOW(%s, loc_get_ioctl_type_name(ioctl_type));
stat = RPC_FUNC_VERSION(rpc_loc_ioctl_, RPC_LOC_IOCTL_VERSION)(&args, &rets, loc_api_clnt);
LOC_GLUE_CHECK_RESULT(stat, int32);
ret_val = (int32) rets.loc_ioctl_result;
return ret_val;
}
/* Returns 0 if error */
int32 loc_api_null(void)
{
LOC_GLUE_CHECK_INIT(int32);
int32 rets;
enum clnt_stat stat = RPC_SUCCESS;
clnt_unregister_reset_notification_cb(loc_api_clnt);
stat = RPC_FUNC_VERSION(rpc_loc_api_null_, RPC_LOC_API_NULL_VERSION)(NULL, &rets, loc_api_clnt);
LOC_GLUE_CHECK_RESULT(stat, int32);
return (int32) rets;
}
/*===========================================================================
FUNCTION loc_eng_ioctl
DESCRIPTION
This function calls loc_ioctl and waits for the callback result before
returning back to the user.
DEPENDENCIES
N/A
RETURN VALUE
TRUE if successful
FALSE if failed
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_ioctl
(
rpc_loc_client_handle_type handle,
rpc_loc_ioctl_e_type ioctl_type,
rpc_loc_ioctl_data_u_type* ioctl_data_ptr,
uint32 timeout_msec,
rpc_loc_ioctl_callback_s_type *cb_data_ptr
)
{
int ret_val = RPC_LOC_API_SUCCESS;
ret_val = loc_api_sync_ioctl(handle, ioctl_type, ioctl_data_ptr, timeout_msec, cb_data_ptr);
LOC_LOGD("loc_eng_ioctl result: client = %d, ioctl_type = %s, returt %s\n",
(int32) handle,
loc_get_ioctl_type_name(ioctl_type),
loc_get_ioctl_status_name(ret_val) );
return ret_val;
}

View file

@ -1,565 +0,0 @@
/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <assert.h>
#include <errno.h>
#include <sys/time.h>
#include <string.h>
#include <pthread.h>
#include <rpc/rpc.h>
#include <loc_api_rpc_glue.h>
#include "loc_api_sync_call.h"
/* Logging */
#define LOG_TAG "LocSvc_api_rpc_glue"
// #define LOG_NDDEBUG 0
#ifndef USE_GLIB
#include <utils/Log.h>
#endif /* USE_GLIB */
/***************************************************************************
* DATA FOR ASYNCHRONOUS RPC PROCESSING
**************************************************************************/
loc_sync_call_slot_array_s_type loc_sync_data;
pthread_mutex_t loc_sync_call_mutex = PTHREAD_MUTEX_INITIALIZER;
boolean loc_sync_call_inited = 0;
/*===========================================================================
FUNCTION loc_api_sync_call_init
DESCRIPTION
Initialize this module
DEPENDENCIES
N/A
RETURN VALUE
none
SIDE EFFECTS
N/A
===========================================================================*/
void loc_api_sync_call_init()
{
pthread_mutex_lock(&loc_sync_call_mutex);
if (loc_sync_call_inited == 1) {
pthread_mutex_unlock(&loc_sync_call_mutex);
return;
}
loc_sync_call_inited = 1;
loc_sync_data.num_of_slots = LOC_SYNC_CALL_SLOTS_MAX;
int i;
for (i = 0; i < loc_sync_data.num_of_slots; i++)
{
loc_sync_call_slot_s_type *slot = &loc_sync_data.slots[i];
pthread_mutex_init(&slot->lock, NULL);
pthread_cond_init(&slot->loc_cb_arrived_cond, NULL);
slot->not_available = 0;
slot->in_use = 0;
slot->loc_handle = -1;
slot->loc_cb_wait_event_mask = 0; /* event to wait */
slot->loc_cb_received_event_mask = 0; /* received event */
}
pthread_mutex_unlock(&loc_sync_call_mutex);
}
/*===========================================================================
FUNCTION loc_api_sync_call_destroy
DESCRIPTION
Initialize this module
DEPENDENCIES
N/A
RETURN VALUE
none
SIDE EFFECTS
N/A
===========================================================================*/
void loc_api_sync_call_destroy()
{
int i;
pthread_mutex_lock(&loc_sync_call_mutex);
if (loc_sync_call_inited == 0) {
pthread_mutex_unlock(&loc_sync_call_mutex);
return;
}
loc_sync_call_inited = 0;
for (i = 0; i < loc_sync_data.num_of_slots; i++)
{
loc_sync_call_slot_s_type *slot = &loc_sync_data.slots[i];
pthread_mutex_lock(&slot->lock);
slot->not_available = 1;
pthread_mutex_unlock(&slot->lock);
pthread_cond_destroy(&slot->loc_cb_arrived_cond);
pthread_mutex_destroy(&slot->lock);
}
pthread_mutex_unlock(&loc_sync_call_mutex);
}
/*===========================================================================
FUNCTION loc_match_callback
DESCRIPTION
Checks if an awaited event has arrived
RETURN VALUE
TRUE arrived
FALSE not matching
===========================================================================*/
static boolean loc_match_callback(
rpc_loc_event_mask_type wait_mask,
rpc_loc_ioctl_e_type wait_ioctl,
rpc_loc_event_mask_type event_mask,
const rpc_loc_event_payload_u_type *callback_payload
)
{
if ((event_mask & wait_mask) == 0) return FALSE;
if (event_mask != RPC_LOC_EVENT_IOCTL_REPORT || wait_ioctl == 0 ||
( (callback_payload != NULL) &&
callback_payload->rpc_loc_event_payload_u_type_u.ioctl_report.type == wait_ioctl) )
return TRUE;
return FALSE;
}
/*===========================================================================
FUNCTION loc_api_callback_process_sync_call
DESCRIPTION
Wakes up blocked API calls to check if the needed callback has arrived
DEPENDENCIES
N/A
RETURN VALUE
none
SIDE EFFECTS
N/A
===========================================================================*/
void loc_api_callback_process_sync_call(
rpc_loc_client_handle_type loc_handle, /* handle of the client */
rpc_loc_event_mask_type loc_event, /* event mask */
const rpc_loc_event_payload_u_type* loc_event_payload /* payload */
)
{
int i;
ALOGV("loc_handle = 0x%lx, loc_event = 0x%lx", loc_handle, loc_event);
for (i = 0; i < loc_sync_data.num_of_slots; i++)
{
loc_sync_call_slot_s_type *slot = &loc_sync_data.slots[i];
pthread_mutex_lock(&slot->lock);
if (slot->in_use &&
slot->signal_sent == 0 &&
slot->loc_handle == loc_handle &&
loc_match_callback(slot->loc_cb_wait_event_mask, slot->ioctl_type, loc_event, loc_event_payload))
{
memcpy(&slot->loc_cb_received_payload, loc_event_payload, sizeof (rpc_loc_event_payload_u_type));
slot->loc_cb_received_event_mask = loc_event;
ALOGV("signal slot %d in_use %d, loc_handle 0x%lx, event_mask 0x%1x, ioctl_type %d", i, slot->in_use, slot->loc_handle, (int) slot->loc_cb_wait_event_mask, (int) slot->ioctl_type);
pthread_cond_signal(&slot->loc_cb_arrived_cond);
slot->signal_sent = 1;
pthread_mutex_unlock(&slot->lock);
break;
} else {
/* do nothing */
}
pthread_mutex_unlock(&slot->lock);
}
}
/*===========================================================================
FUNCTION loc_lock_a_slot
DESCRIPTION
Allocates a buffer slot for the synchronous API call
DEPENDENCIES
N/A
RETURN VALUE
Select ID (>=0) : successful
-1 : buffer full
SIDE EFFECTS
N/A
===========================================================================*/
static int loc_lock_a_slot()
{
int i, select_id = -1; /* no free buffer */
for (i = 0; i < loc_sync_data.num_of_slots; i++)
{
loc_sync_call_slot_s_type *slot = &loc_sync_data.slots[i];
if (pthread_mutex_trylock(&slot->lock) == EBUSY)
{
ALOGV("trylock EBUSY : %d", i);
continue;
}
if (!slot->in_use && !slot->not_available)
{
select_id = i;
/* Return from here and leave the mutex locked.
* will unlock it in loc_unlock_slot()
*/
break;
}
/* ALOGV("slot %d in_use = %d, not_available = %d : %d", i, slot->in_use, slot->not_available, i); */
pthread_mutex_unlock(&slot->lock);
}
return select_id;
}
/*===========================================================================
FUNCTION loc_unlock_slot
DESCRIPTION
Unlocks a buffer slot
DEPENDENCIES
N/A
RETURN VALUE
None
SIDE EFFECTS
N/A
===========================================================================*/
static void loc_unlock_slot(int select_id)
{
pthread_mutex_unlock(&loc_sync_data.slots[select_id].lock);
}
/*===========================================================================
FUNCTION loc_lock_slot
DESCRIPTION
Locks a specific slot that was previously locked from loc_lock_a_slot
DEPENDENCIES
N/A
RETURN VALUE
None
SIDE EFFECTS
N/A
===========================================================================*/
static void loc_lock_slot(int select_id)
{
pthread_mutex_lock(&loc_sync_data.slots[select_id].lock);
}
/*===========================================================================
FUNCTION loc_set_slot_in_use
DESCRIPTION
Sets the in_use flag of slot to true or false.
Should be called only after the slot is locked
DEPENDENCIES
N/A
RETURN VALUE
None
SIDE EFFECTS
N/A
===========================================================================*/
static void loc_set_slot_in_use(int select_id, boolean in_use)
{
loc_sync_data.slots[select_id].in_use = in_use;
if (in_use == 1)
loc_sync_data.slots[select_id].signal_sent = 0;
}
/*===========================================================================
FUNCTION loc_api_save_callback
DESCRIPTION
Selects which callback or IOCTL event to wait for.
The event_mask specifies the event(s). If it is RPC_LOC_EVENT_IOCTL_REPORT,
then ioctl_type specifies the IOCTL event.
If ioctl_type is non-zero, RPC_LOC_EVENT_IOCTL_REPORT is automatically added.
DEPENDENCIES
N/A
RETURN VALUE
Select ID (>=0) : successful
-1 : out of buffer
SIDE EFFECTS
N/A
===========================================================================*/
static void loc_api_save_callback(
int select_id, /* Selected slot */
rpc_loc_client_handle_type loc_handle, /* Client handle */
rpc_loc_event_mask_type event_mask, /* Event mask to wait for */
rpc_loc_ioctl_e_type ioctl_type /* IOCTL type to wait for */
)
{
loc_sync_call_slot_s_type *slot = &loc_sync_data.slots[select_id];
slot->loc_handle = loc_handle;
slot->loc_cb_wait_event_mask = event_mask;
slot->ioctl_type = ioctl_type;
if (ioctl_type) slot->loc_cb_wait_event_mask |= RPC_LOC_EVENT_IOCTL_REPORT;
return;
}
/*===========================================================================
FUNCTION loc_save_user_payload
DESCRIPTION
Saves received payload into user data structures
RETURN VALUE
None
===========================================================================*/
static void loc_save_user_payload(
rpc_loc_event_payload_u_type *user_cb_payload,
rpc_loc_ioctl_callback_s_type *user_ioctl_buffer,
const rpc_loc_event_payload_u_type *received_cb_payload
)
{
if (user_cb_payload)
{
memcpy(user_cb_payload, received_cb_payload,
sizeof (rpc_loc_event_payload_u_type));
}
if (user_ioctl_buffer)
{
memcpy(user_ioctl_buffer,
&received_cb_payload->rpc_loc_event_payload_u_type_u.ioctl_report,
sizeof *user_ioctl_buffer);
}
}
/*===========================================================================
FUNCTION loc_api_wait_callback
DESCRIPTION
Waits for a selected callback. The wait expires in timeout_seconds seconds.
If the function is called before an existing wait has finished, it will
immediately return EBUSY.
DEPENDENCIES
N/A
RETURN VALUE
RPC_LOC_API_SUCCESS if successful (0)
RPC_LOC_API_TIMEOUT if timed out
RPC_LOC_API_ENGINE_BUSY if already in a wait
RPC_LOC_API_INVALID_PARAMETER if callback is not yet selected
SIDE EFFECTS
N/A
===========================================================================*/
static int loc_api_wait_callback(
int select_id, /* ID from loc_select_callback() */
int timeout_seconds, /* Timeout in this number of seconds */
rpc_loc_event_payload_u_type *callback_payload, /* Pointer to callback payload buffer, can be NULL */
rpc_loc_ioctl_callback_s_type *ioctl_payload /* Pointer to IOCTL payload, can be NULL */
)
{
int ret_val = RPC_LOC_API_SUCCESS; /* the return value of this function: 0 = no error */
int rc = 0; /* return code from pthread calls */
struct timespec expire_time;
loc_sync_call_slot_s_type *slot = &loc_sync_data.slots[select_id];
clock_gettime(CLOCK_REALTIME, &expire_time);
expire_time.tv_sec += timeout_seconds;
/* Waiting */
while (slot->signal_sent == 0 && rc != ETIMEDOUT) {
rc = pthread_cond_timedwait(&slot->loc_cb_arrived_cond,
&slot->lock, &expire_time);
}
if (rc == ETIMEDOUT)
{
ret_val = RPC_LOC_API_TIMEOUT; /* Timed out */
ALOGE("TIMEOUT: %d", select_id);
}
else {
/* Obtained the first awaited callback */
ret_val = RPC_LOC_API_SUCCESS; /* Successful */
loc_save_user_payload(callback_payload, ioctl_payload, &slot->loc_cb_received_payload);
}
return ret_val;
}
/*===========================================================================
FUNCTION loc_api_sync_ioctl
DESCRIPTION
Synchronous IOCTL call (reentrant version)
DEPENDENCIES
N/A
RETURN VALUE
Loc API error code (0 = success)
SIDE EFFECTS
N/A
===========================================================================*/
int loc_api_sync_ioctl
(
rpc_loc_client_handle_type handle,
rpc_loc_ioctl_e_type ioctl_type,
rpc_loc_ioctl_data_u_type* ioctl_data_ptr,
uint32 timeout_msec,
rpc_loc_ioctl_callback_s_type *cb_data_ptr
)
{
int rc = -1;
int select_id;
rpc_loc_ioctl_callback_s_type callback_data;
select_id = loc_lock_a_slot();
if (select_id < 0 || select_id >= loc_sync_data.num_of_slots)
{
ALOGE("slot not available ioctl_type = %s",
loc_get_ioctl_type_name(ioctl_type));
return rc;
}
loc_set_slot_in_use(select_id, 1); // set slot in use to true
// Select the callback we are waiting for
loc_api_save_callback(select_id, handle, 0, ioctl_type);
loc_unlock_slot(select_id); // slot is unlocked, but in_use is still true
// we want to avoid keeping the slot locked during the loc_ioctl because the rpc
// framework will also lock a different mutex during this call, and typically
// locking two different mutexes at the same time can lead to deadlock.
rc = loc_ioctl(handle, ioctl_type, ioctl_data_ptr);
loc_lock_slot(select_id);
if (rc != RPC_LOC_API_SUCCESS)
{
ALOGE("loc_ioctl failed select_id = %d, ioctl_type %s, returned %s",
select_id, loc_get_ioctl_type_name(ioctl_type), loc_get_ioctl_status_name(rc));
}
else {
ALOGV("select_id = %d, ioctl_type %d, returned RPC_LOC_API_SUCCESS",
select_id, ioctl_type);
// Wait for the callback of loc_ioctl
if ((rc = loc_api_wait_callback(select_id, timeout_msec / 1000, NULL, &callback_data)) != 0)
{
// Callback waiting failed
ALOGE("callback wait failed select_id = %d, ioctl_type %s, returned %s",
select_id, loc_get_ioctl_type_name(ioctl_type), loc_get_ioctl_status_name(rc));
}
else
{
if (cb_data_ptr) memcpy(cb_data_ptr, &callback_data, sizeof *cb_data_ptr);
if (callback_data.status != RPC_LOC_API_SUCCESS)
{
rc = callback_data.status;
ALOGE("callback status failed select_id = %d, ioctl_type %s, returned %s",
select_id, loc_get_ioctl_type_name(ioctl_type), loc_get_ioctl_status_name(rc));
} else {
ALOGV("callback status success select_id = %d, ioctl_type %d, returned %d",
select_id, ioctl_type, rc);
}
} /* wait callback */
} /* loc_ioctl */
loc_set_slot_in_use(select_id, 0); // set slot in use to false
loc_unlock_slot(select_id);
return rc;
}

View file

@ -1,86 +0,0 @@
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "rpc/rpc.h"
/* Include RPC headers */
#ifdef USE_LOCAL_RPC
#include "rpc_inc/loc_api_common.h"
#include "rpc_inc/loc_api.h"
#include "rpc_inc/loc_api_cb.h"
#endif
#ifdef USE_QCOM_AUTO_RPC
#include "loc_api_rpcgen_rpc.h"
#include "loc_api_rpcgen_common_rpc.h"
#include "loc_api_rpcgen_cb_rpc.h"
#endif
#include "rpc_inc/loc_api_fixup.h"
#include "loc_apicb_appinit.h"
#define RPC_FUNC_VERSION_BASE(a,b) a ## b
#define RPC_CB_FUNC_VERS(a,b) RPC_FUNC_VERSION_BASE(a,b)
static SVCXPRT* svrPort = NULL;
extern void RPC_CB_FUNC_VERS(loc_apicbprog_,LOC_APICBVERS_0001)(struct svc_req *rqstp, register SVCXPRT *transp);
int loc_apicb_app_init(void)
{
/* Register a callback server to use the loc_apicbprog_* function */
if (svrPort == NULL) {
svrPort = svcrtr_create();
}
if (!svrPort) return -1;
xprt_register(svrPort);
if(svc_register(svrPort, LOC_APICBPROG, LOC_APICBVERS_0001, RPC_CB_FUNC_VERS(loc_apicbprog_,LOC_APICBVERS_0001),0))
{
return 0;
}
else
{
return -1;
}
}
void loc_apicb_app_deinit(void)
{
if (svrPort == NULL)
{
return;
}
svc_unregister(svrPort, LOC_APICBPROG, LOC_APICBVERS_0001);
xprt_unregister(svrPort);
svc_destroy(svrPort);
svrPort = NULL;
}

View file

@ -1,36 +0,0 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# functions
LOC_RPCGEN_APIS_PATH := $(TARGET_OUT_INTERMEDIATES)/loc_api/libloc_api_rpcgen_intermediates
LOC_RPCGEN_APIS_PATH_FL := ../../../../../$(TARGET_OUT_INTERMEDIATES)/loc_api/libloc_api_rpcgen_intermediates
LOCAL_MODULE := libloc_api_rpcgen
LOCAL_MODULE_OWNER := qcom
LOCAL_SHARED_LIBRARIES := \
librpc \
libcommondefs
LOCAL_SRC_FILES += \
src/loc_api_rpcgen_cb_xdr.c \
src/loc_api_rpcgen_common_xdr.c \
src/loc_api_rpcgen_cb_svc.c \
src/loc_api_rpcgen_clnt.c \
src/loc_api_rpcgen_xdr.c
LOCAL_C_INCLUDES += hardware/msm7k/librpc
LOCAL_C_INCLUDES += $(LOC_RPCGEN_APIS_PATH)/../../SHARED_LIBRARIES/libcommondefs_intermediates/inc
LOCAL_C_INCLUDES += $(LOCAL_PATH)/inc
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/libcommondefs/rpcgen/inc
LOCAL_COPY_HEADERS_TO := loc_api/rpcgen/inc
LOCAL_COPY_HEADERS := inc/loc_api_rpcgen_rpc.h
LOCAL_COPY_HEADERS += inc/loc_api_rpcgen_common_rpc.h
LOCAL_COPY_HEADERS += inc/loc_api_rpcgen_cb_rpc.h
LOCAL_COPY_HEADERS += inc/loc_apicb_appinit.h
LOCAL_LDLIBS += -lpthread
LOCAL_PRELINK_MODULE := false
include $(BUILD_STATIC_LIBRARY)

View file

@ -1,42 +0,0 @@
AM_CFLAGS = \
-I../../../utils \
-I./inc \
$(MSM7K_CFLAGS)
requiredlibs = \
../../../utils/libgps_utils_so.la \
$(MSM7K_LIBS)
h_sources = \
inc/loc_api_rpcgen_rpc.h \
inc/loc_api_rpcgen_common_rpc.h \
inc/loc_api_rpcgen_cb_rpc.h \
inc/loc_apicb_appinit.h
c_sources = \
src/loc_api_rpcgen_cb_xdr.c \
src/loc_api_rpcgen_common_xdr.c \
src/loc_api_rpcgen_cb_svc.c \
src/loc_api_rpcgen_clnt.c \
src/loc_api_rpcgen_xdr.c
library_includedir = $(pkgincludedir)/libloc_api-rpc-50001/libloc_api-rpc-stub/inc
library_include_HEADERS = $(h_sources)
libloc_api_rpcgen_la_SOURCES = $(c_sources) $(h_sources)
if USE_GLIB
libloc_api_rpcgen_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
libloc_api_rpcgen_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
libloc_api_rpcgen_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libloc_api_rpcgen_la_CFLAGS = $(AM_CFLAGS)
libloc_api_rpcgen_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
libloc_api_rpcgen_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
libloc_api_rpcgen_la_LIBADD = $(requiredlibs) -lstdc++
#Create and Install Libraries
lib_LTLIBRARIES = libloc_api_rpcgen.la

View file

@ -1,156 +0,0 @@
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#ifndef _LOC_API_CB_RPC_H_RPCGEN
#define _LOC_API_CB_RPC_H_RPCGEN
#include "librpc.h"
#include "commondefs_rpcgen_rpc.h"
#include "loc_api_rpcgen_common_rpc.h"
#include <pthread.h>
#ifdef __cplusplus
extern "C" {
#endif
struct rpc_loc_event_cb_f_type_args {
rpc_uint32 cb_id;
rpc_loc_client_handle_type loc_handle;
rpc_loc_event_mask_type loc_event;
rpc_loc_event_payload_u_type *loc_event_payload;
};
typedef struct rpc_loc_event_cb_f_type_args rpc_loc_event_cb_f_type_args;
struct rpc_loc_event_cb_f_type_rets {
rpc_int32 loc_event_cb_f_type_result;
};
typedef struct rpc_loc_event_cb_f_type_rets rpc_loc_event_cb_f_type_rets;
#define LOC_APICBVERS 0x00050006
#define LOC_APICBPROG 0x3100008C
#define LOC_APICBVERS_0001 0x00050001
#if defined(__STDC__) || defined(__cplusplus)
#define rpc_loc_event_cb_f_type 1
extern enum clnt_stat rpc_loc_event_cb_f_type_0x00050001(rpc_loc_event_cb_f_type_args *, rpc_loc_event_cb_f_type_rets *, CLIENT *);
extern bool_t rpc_loc_event_cb_f_type_0x00050001_svc(rpc_loc_event_cb_f_type_args *, rpc_loc_event_cb_f_type_rets *, struct svc_req *);
extern int loc_apicbprog_0x00050001_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
#define rpc_loc_event_cb_f_type 1
extern enum clnt_stat rpc_loc_event_cb_f_type_0x00050001();
extern bool_t rpc_loc_event_cb_f_type_0x00050001_svc();
extern int loc_apicbprog_0x00050001_freeresult ();
#endif /* K&R C */
#define LOC_APICBVERS_0002 0x00050002
#if defined(__STDC__) || defined(__cplusplus)
#define rpc_loc_api_cb_null 0xffffff00
extern enum clnt_stat rpc_loc_api_cb_null_0x00050002(void *, int *, CLIENT *);
extern bool_t rpc_loc_api_cb_null_0x00050002_svc(void *, int *, struct svc_req *);
extern int loc_apicbprog_0x00050002_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
#define rpc_loc_api_cb_null 0xffffff00
extern enum clnt_stat rpc_loc_api_cb_null_0x00050002();
extern bool_t rpc_loc_api_cb_null_0x00050002_svc();
extern int loc_apicbprog_0x00050002_freeresult ();
#endif /* K&R C */
#define LOC_APICBVERS_0003 0x00050003
#if defined(__STDC__) || defined(__cplusplus)
extern enum clnt_stat rpc_loc_api_cb_null_0x00050003(void *, int *, CLIENT *);
extern bool_t rpc_loc_api_cb_null_0x00050003_svc(void *, int *, struct svc_req *);
extern int loc_apicbprog_0x00050003_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
extern enum clnt_stat rpc_loc_api_cb_null_0x00050003();
extern bool_t rpc_loc_api_cb_null_0x00050003_svc();
extern int loc_apicbprog_0x00050003_freeresult ();
#endif /* K&R C */
#define LOC_APICBVERS_0004 0x00050004
#if defined(__STDC__) || defined(__cplusplus)
extern enum clnt_stat rpc_loc_api_cb_null_0x00050004(void *, int *, CLIENT *);
extern bool_t rpc_loc_api_cb_null_0x00050004_svc(void *, int *, struct svc_req *);
extern int loc_apicbprog_0x00050004_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
extern enum clnt_stat rpc_loc_api_cb_null_0x00050004();
extern bool_t rpc_loc_api_cb_null_0x00050004_svc();
extern int loc_apicbprog_0x00050004_freeresult ();
#endif /* K&R C */
#define LOC_APICBVERS_0005 0x00050005
#if defined(__STDC__) || defined(__cplusplus)
extern enum clnt_stat rpc_loc_api_cb_null_0x00050005(void *, int *, CLIENT *);
extern bool_t rpc_loc_api_cb_null_0x00050005_svc(void *, int *, struct svc_req *);
extern int loc_apicbprog_0x00050005_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
extern enum clnt_stat rpc_loc_api_cb_null_0x00050005();
extern bool_t rpc_loc_api_cb_null_0x00050005_svc();
extern int loc_apicbprog_0x00050005_freeresult ();
#endif /* K&R C */
#define LOC_APICBVERS_0006 0x00050006
#if defined(__STDC__) || defined(__cplusplus)
extern enum clnt_stat rpc_loc_api_cb_null_0x00050006(void *, int *, CLIENT *);
extern bool_t rpc_loc_api_cb_null_0x00050006_svc(void *, int *, struct svc_req *);
extern int loc_apicbprog_0x00050006_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
extern enum clnt_stat rpc_loc_api_cb_null_0x00050006();
extern bool_t rpc_loc_api_cb_null_0x00050006_svc();
extern int loc_apicbprog_0x00050006_freeresult ();
#endif /* K&R C */
/* the xdr functions */
#if defined(__STDC__) || defined(__cplusplus)
extern bool_t xdr_rpc_loc_event_cb_f_type_args (XDR *, rpc_loc_event_cb_f_type_args*);
extern bool_t xdr_rpc_loc_event_cb_f_type_rets (XDR *, rpc_loc_event_cb_f_type_rets*);
#else /* K&R C */
extern bool_t xdr_rpc_loc_event_cb_f_type_args ();
extern bool_t xdr_rpc_loc_event_cb_f_type_rets ();
#endif /* K&R C */
#ifdef __cplusplus
}
#endif
#endif /* !_LOC_API_CB_RPC_H_RPCGEN */

View file

@ -1,288 +0,0 @@
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#ifndef _LOC_API_RPC_H_RPCGEN
#define _LOC_API_RPC_H_RPCGEN
#include "librpc.h"
#include "commondefs_rpcgen_rpc.h"
#include "loc_api_rpcgen_common_rpc.h"
#include <pthread.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
u_int rpc_loc_api_api_versions_return_type_len;
rpc_uint32 *rpc_loc_api_api_versions_return_type_val;
} rpc_loc_api_api_versions_return_type;
typedef rpc_uint32 rpc_loc_event_cb_f_type;
struct rpc_loc_open_args {
rpc_loc_event_mask_type event_reg_mask;
rpc_loc_event_cb_f_type event_callback;
};
typedef struct rpc_loc_open_args rpc_loc_open_args;
struct rpc_loc_close_args {
rpc_loc_client_handle_type handle;
};
typedef struct rpc_loc_close_args rpc_loc_close_args;
struct rpc_loc_start_fix_args {
rpc_loc_client_handle_type handle;
};
typedef struct rpc_loc_start_fix_args rpc_loc_start_fix_args;
struct rpc_loc_stop_fix_args {
rpc_loc_client_handle_type handle;
};
typedef struct rpc_loc_stop_fix_args rpc_loc_stop_fix_args;
struct rpc_loc_ioctl_args {
rpc_loc_client_handle_type handle;
rpc_loc_ioctl_e_type ioctl_type;
rpc_loc_ioctl_data_u_type *ioctl_data;
};
typedef struct rpc_loc_ioctl_args rpc_loc_ioctl_args;
struct rpc_loc_api_api_version_s_args {
rpc_boolean len_not_null;
};
typedef struct rpc_loc_api_api_version_s_args rpc_loc_api_api_version_s_args;
struct rpc_loc_api_rpc_glue_code_info_remote_rets {
rpc_uint32 toolvers;
rpc_uint32 features;
rpc_uint32 proghash;
rpc_uint32 cbproghash;
};
typedef struct rpc_loc_api_rpc_glue_code_info_remote_rets rpc_loc_api_rpc_glue_code_info_remote_rets;
struct rpc_loc_open_rets {
rpc_loc_client_handle_type loc_open_result;
};
typedef struct rpc_loc_open_rets rpc_loc_open_rets;
struct rpc_loc_close_rets {
rpc_int32 loc_close_result;
};
typedef struct rpc_loc_close_rets rpc_loc_close_rets;
struct rpc_loc_start_fix_rets {
rpc_int32 loc_start_fix_result;
};
typedef struct rpc_loc_start_fix_rets rpc_loc_start_fix_rets;
struct rpc_loc_stop_fix_rets {
rpc_int32 loc_stop_fix_result;
};
typedef struct rpc_loc_stop_fix_rets rpc_loc_stop_fix_rets;
struct rpc_loc_ioctl_rets {
rpc_int32 loc_ioctl_result;
};
typedef struct rpc_loc_ioctl_rets rpc_loc_ioctl_rets;
struct rpc_loc_api_api_versions_rets {
rpc_loc_api_api_versions_return_type loc_api_api_versions_result;
rpc_uint32 *len;
};
typedef struct rpc_loc_api_api_versions_rets rpc_loc_api_api_versions_rets;
#define LOC_APIVERS 0x00050006
#define LOC_APIPROG 0x3000008C
#define LOC_APIVERS_0001 0x00050001
#if defined(__STDC__) || defined(__cplusplus)
#define rpc_loc_api_null 0
extern enum clnt_stat rpc_loc_api_null_0x00050001(void *, void *, CLIENT *);
extern bool_t rpc_loc_api_null_0x00050001_svc(void *, void *, struct svc_req *);
#define rpc_loc_api_rpc_glue_code_info_remote 1
extern enum clnt_stat rpc_loc_api_rpc_glue_code_info_remote_0x00050001(void *, rpc_loc_api_rpc_glue_code_info_remote_rets *, CLIENT *);
extern bool_t rpc_loc_api_rpc_glue_code_info_remote_0x00050001_svc(void *, rpc_loc_api_rpc_glue_code_info_remote_rets *, struct svc_req *);
#define rpc_loc_open 2
extern enum clnt_stat rpc_loc_open_0x00050001(rpc_loc_open_args *, rpc_loc_open_rets *, CLIENT *);
extern bool_t rpc_loc_open_0x00050001_svc(rpc_loc_open_args *, rpc_loc_open_rets *, struct svc_req *);
#define rpc_loc_close 3
extern enum clnt_stat rpc_loc_close_0x00050001(rpc_loc_close_args *, rpc_loc_close_rets *, CLIENT *);
extern bool_t rpc_loc_close_0x00050001_svc(rpc_loc_close_args *, rpc_loc_close_rets *, struct svc_req *);
#define rpc_loc_start_fix 4
extern enum clnt_stat rpc_loc_start_fix_0x00050001(rpc_loc_start_fix_args *, rpc_loc_start_fix_rets *, CLIENT *);
extern bool_t rpc_loc_start_fix_0x00050001_svc(rpc_loc_start_fix_args *, rpc_loc_start_fix_rets *, struct svc_req *);
#define rpc_loc_stop_fix 5
extern enum clnt_stat rpc_loc_stop_fix_0x00050001(rpc_loc_stop_fix_args *, rpc_loc_stop_fix_rets *, CLIENT *);
extern bool_t rpc_loc_stop_fix_0x00050001_svc(rpc_loc_stop_fix_args *, rpc_loc_stop_fix_rets *, struct svc_req *);
#define rpc_loc_ioctl 6
extern enum clnt_stat rpc_loc_ioctl_0x00050001(rpc_loc_ioctl_args *, rpc_loc_ioctl_rets *, CLIENT *);
extern bool_t rpc_loc_ioctl_0x00050001_svc(rpc_loc_ioctl_args *, rpc_loc_ioctl_rets *, struct svc_req *);
#define rpc_loc_api_api_versions 0xFFFFFFFF
extern enum clnt_stat rpc_loc_api_api_versions_0x00050001(void *, rpc_loc_api_api_versions_rets *, CLIENT *);
extern bool_t rpc_loc_api_api_versions_0x00050001_svc(void *, rpc_loc_api_api_versions_rets *, struct svc_req *);
extern int loc_apiprog_0x00050001_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
#define rpc_loc_api_null 0
extern enum clnt_stat rpc_loc_api_null_0x00050001();
extern bool_t rpc_loc_api_null_0x00050001_svc();
#define rpc_loc_api_rpc_glue_code_info_remote 1
extern enum clnt_stat rpc_loc_api_rpc_glue_code_info_remote_0x00050001();
extern bool_t rpc_loc_api_rpc_glue_code_info_remote_0x00050001_svc();
#define rpc_loc_open 2
extern enum clnt_stat rpc_loc_open_0x00050001();
extern bool_t rpc_loc_open_0x00050001_svc();
#define rpc_loc_close 3
extern enum clnt_stat rpc_loc_close_0x00050001();
extern bool_t rpc_loc_close_0x00050001_svc();
#define rpc_loc_start_fix 4
extern enum clnt_stat rpc_loc_start_fix_0x00050001();
extern bool_t rpc_loc_start_fix_0x00050001_svc();
#define rpc_loc_stop_fix 5
extern enum clnt_stat rpc_loc_stop_fix_0x00050001();
extern bool_t rpc_loc_stop_fix_0x00050001_svc();
#define rpc_loc_ioctl 6
extern enum clnt_stat rpc_loc_ioctl_0x00050001();
extern bool_t rpc_loc_ioctl_0x00050001_svc();
#define rpc_loc_api_api_versions 0xFFFFFFFF
extern enum clnt_stat rpc_loc_api_api_versions_0x00050001();
extern bool_t rpc_loc_api_api_versions_0x00050001_svc();
extern int loc_apiprog_0x00050001_freeresult ();
#endif /* K&R C */
#define LOC_APIVERS_0002 0x00050002
#if defined(__STDC__) || defined(__cplusplus)
extern enum clnt_stat rpc_loc_api_null_0x00050002(void *, void *, CLIENT *);
extern bool_t rpc_loc_api_null_0x00050002_svc(void *, void *, struct svc_req *);
extern int loc_apiprog_0x00050002_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
extern enum clnt_stat rpc_loc_api_null_0x00050002();
extern bool_t rpc_loc_api_null_0x00050002_svc();
extern int loc_apiprog_0x00050002_freeresult ();
#endif /* K&R C */
#define LOC_APIVERS_0003 0x00050003
#if defined(__STDC__) || defined(__cplusplus)
extern enum clnt_stat rpc_loc_api_null_0x00050003(void *, void *, CLIENT *);
extern bool_t rpc_loc_api_null_0x00050003_svc(void *, void *, struct svc_req *);
extern int loc_apiprog_0x00050003_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
extern enum clnt_stat rpc_loc_api_null_0x00050003();
extern bool_t rpc_loc_api_null_0x00050003_svc();
extern int loc_apiprog_0x00050003_freeresult ();
#endif /* K&R C */
#define LOC_APIVERS_0004 0x00050004
#if defined(__STDC__) || defined(__cplusplus)
extern enum clnt_stat rpc_loc_api_null_0x00050004(void *, void *, CLIENT *);
extern bool_t rpc_loc_api_null_0x00050004_svc(void *, void *, struct svc_req *);
extern int loc_apiprog_0x00050004_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
extern enum clnt_stat rpc_loc_api_null_0x00050004();
extern bool_t rpc_loc_api_null_0x00050004_svc();
extern int loc_apiprog_0x00050004_freeresult ();
#endif /* K&R C */
#define LOC_APIVERS_0005 0x00050005
#if defined(__STDC__) || defined(__cplusplus)
extern enum clnt_stat rpc_loc_api_null_0x00050005(void *, void *, CLIENT *);
extern bool_t rpc_loc_api_null_0x00050005_svc(void *, void *, struct svc_req *);
extern int loc_apiprog_0x00050005_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
extern enum clnt_stat rpc_loc_api_null_0x00050005();
extern bool_t rpc_loc_api_null_0x00050005_svc();
extern int loc_apiprog_0x00050005_freeresult ();
#endif /* K&R C */
#define LOC_APIVERS_0006 0x00050006
#if defined(__STDC__) || defined(__cplusplus)
extern enum clnt_stat rpc_loc_api_null_0x00050006(void *, void *, CLIENT *);
extern bool_t rpc_loc_api_null_0x00050006_svc(void *, void *, struct svc_req *);
extern int loc_apiprog_0x00050006_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
extern enum clnt_stat rpc_loc_api_null_0x00050006();
extern bool_t rpc_loc_api_null_0x00050006_svc();
extern int loc_apiprog_0x00050006_freeresult ();
#endif /* K&R C */
/* the xdr functions */
#if defined(__STDC__) || defined(__cplusplus)
extern bool_t xdr_rpc_loc_api_api_versions_return_type (XDR *, rpc_loc_api_api_versions_return_type*);
extern bool_t xdr_rpc_loc_event_cb_f_type (XDR *, rpc_loc_event_cb_f_type*);
extern bool_t xdr_rpc_loc_open_args (XDR *, rpc_loc_open_args*);
extern bool_t xdr_rpc_loc_close_args (XDR *, rpc_loc_close_args*);
extern bool_t xdr_rpc_loc_start_fix_args (XDR *, rpc_loc_start_fix_args*);
extern bool_t xdr_rpc_loc_stop_fix_args (XDR *, rpc_loc_stop_fix_args*);
extern bool_t xdr_rpc_loc_ioctl_args (XDR *, rpc_loc_ioctl_args*);
extern bool_t xdr_rpc_loc_api_api_version_s_args (XDR *, rpc_loc_api_api_version_s_args*);
extern bool_t xdr_rpc_loc_api_rpc_glue_code_info_remote_rets (XDR *, rpc_loc_api_rpc_glue_code_info_remote_rets*);
extern bool_t xdr_rpc_loc_open_rets (XDR *, rpc_loc_open_rets*);
extern bool_t xdr_rpc_loc_close_rets (XDR *, rpc_loc_close_rets*);
extern bool_t xdr_rpc_loc_start_fix_rets (XDR *, rpc_loc_start_fix_rets*);
extern bool_t xdr_rpc_loc_stop_fix_rets (XDR *, rpc_loc_stop_fix_rets*);
extern bool_t xdr_rpc_loc_ioctl_rets (XDR *, rpc_loc_ioctl_rets*);
extern bool_t xdr_rpc_loc_api_api_versions_rets (XDR *, rpc_loc_api_api_versions_rets*);
#else /* K&R C */
extern bool_t xdr_rpc_loc_api_api_versions_return_type ();
extern bool_t xdr_rpc_loc_event_cb_f_type ();
extern bool_t xdr_rpc_loc_open_args ();
extern bool_t xdr_rpc_loc_close_args ();
extern bool_t xdr_rpc_loc_start_fix_args ();
extern bool_t xdr_rpc_loc_stop_fix_args ();
extern bool_t xdr_rpc_loc_ioctl_args ();
extern bool_t xdr_rpc_loc_api_api_version_s_args ();
extern bool_t xdr_rpc_loc_api_rpc_glue_code_info_remote_rets ();
extern bool_t xdr_rpc_loc_open_rets ();
extern bool_t xdr_rpc_loc_close_rets ();
extern bool_t xdr_rpc_loc_start_fix_rets ();
extern bool_t xdr_rpc_loc_stop_fix_rets ();
extern bool_t xdr_rpc_loc_ioctl_rets ();
extern bool_t xdr_rpc_loc_api_api_versions_rets ();
#endif /* K&R C */
#ifdef __cplusplus
}
#endif
#endif /* !_LOC_API_RPC_H_RPCGEN */

View file

@ -1,34 +0,0 @@
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/* Initialization function for callbacks */
int loc_apicb_app_init();
void loc_apicb_app_deinit();

View file

@ -1,327 +0,0 @@
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#include "loc_api_rpcgen_cb_rpc.h"
#include <stdio.h>
#include <stdlib.h>
#include <rpc/pmap_clnt.h>
#include <string.h>
#include <memory.h>
#include <sys/socket.h>
#include <netinet/in.h>
#ifndef SIG_PF
#define SIG_PF void(*)(int)
#endif
void
loc_apicbprog_0x00050001(struct svc_req *rqstp, register SVCXPRT *transp)
{
union {
rpc_loc_event_cb_f_type_args rpc_loc_event_cb_f_type_0x00050001_arg;
} argument;
union {
rpc_loc_event_cb_f_type_rets rpc_loc_event_cb_f_type_0x00050001_res;
} result;
bool_t retval;
xdrproc_t _xdr_argument, _xdr_result;
bool_t (*local)(char *, void *, struct svc_req *);
switch (rqstp->rq_proc) {
case NULLPROC:
(void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL);
return;
case rpc_loc_event_cb_f_type:
_xdr_argument = (xdrproc_t) xdr_rpc_loc_event_cb_f_type_args;
_xdr_result = (xdrproc_t) xdr_rpc_loc_event_cb_f_type_rets;
local = (bool_t (*) (char *, void *, struct svc_req *))rpc_loc_event_cb_f_type_0x00050001_svc;
break;
default:
svcerr_noproc (transp);
return;
}
memset ((char *)&argument, 0, sizeof (argument));
if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
svcerr_decode (transp);
return;
}
retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
if (retval > 0 && !svc_sendreply(transp, (xdrproc_t) _xdr_result, (char *)&result)) {
svcerr_systemerr (transp);
}
if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
fprintf (stderr, "%s", "unable to free arguments");
exit (1);
}
if (!loc_apicbprog_0x00050001_freeresult (transp, _xdr_result, (caddr_t) &result))
fprintf (stderr, "%s", "unable to free results");
return;
}
void
loc_apicbprog_0x00050002(struct svc_req *rqstp, register SVCXPRT *transp)
{
union {
int fill;
} argument;
union {
int rpc_loc_api_cb_null_0x00050002_res;
} result;
bool_t retval;
xdrproc_t _xdr_argument, _xdr_result;
bool_t (*local)(char *, void *, struct svc_req *);
switch (rqstp->rq_proc) {
case NULLPROC:
(void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL);
return;
case rpc_loc_api_cb_null:
_xdr_argument = (xdrproc_t) xdr_void;
_xdr_result = (xdrproc_t) xdr_int;
local = (bool_t (*) (char *, void *, struct svc_req *))rpc_loc_api_cb_null_0x00050002_svc;
break;
default:
svcerr_noproc (transp);
return;
}
memset ((char *)&argument, 0, sizeof (argument));
if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
svcerr_decode (transp);
return;
}
retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
if (retval > 0 && !svc_sendreply(transp, (xdrproc_t) _xdr_result, (char *)&result)) {
svcerr_systemerr (transp);
}
if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
fprintf (stderr, "%s", "unable to free arguments");
exit (1);
}
if (!loc_apicbprog_0x00050002_freeresult (transp, _xdr_result, (caddr_t) &result))
fprintf (stderr, "%s", "unable to free results");
return;
}
void
loc_apicbprog_0x00050003(struct svc_req *rqstp, register SVCXPRT *transp)
{
union {
int fill;
} argument;
union {
int rpc_loc_api_cb_null_0x00050003_res;
} result;
bool_t retval;
xdrproc_t _xdr_argument, _xdr_result;
bool_t (*local)(char *, void *, struct svc_req *);
switch (rqstp->rq_proc) {
case NULLPROC:
(void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL);
return;
case rpc_loc_api_cb_null:
_xdr_argument = (xdrproc_t) xdr_void;
_xdr_result = (xdrproc_t) xdr_int;
local = (bool_t (*) (char *, void *, struct svc_req *))rpc_loc_api_cb_null_0x00050003_svc;
break;
default:
svcerr_noproc (transp);
return;
}
memset ((char *)&argument, 0, sizeof (argument));
if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
svcerr_decode (transp);
return;
}
retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
if (retval > 0 && !svc_sendreply(transp, (xdrproc_t) _xdr_result, (char *)&result)) {
svcerr_systemerr (transp);
}
if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
fprintf (stderr, "%s", "unable to free arguments");
exit (1);
}
if (!loc_apicbprog_0x00050003_freeresult (transp, _xdr_result, (caddr_t) &result))
fprintf (stderr, "%s", "unable to free results");
return;
}
void
loc_apicbprog_0x00050004(struct svc_req *rqstp, register SVCXPRT *transp)
{
union {
int fill;
} argument;
union {
int rpc_loc_api_cb_null_0x00050004_res;
} result;
bool_t retval;
xdrproc_t _xdr_argument, _xdr_result;
bool_t (*local)(char *, void *, struct svc_req *);
switch (rqstp->rq_proc) {
case NULLPROC:
(void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL);
return;
case rpc_loc_api_cb_null:
_xdr_argument = (xdrproc_t) xdr_void;
_xdr_result = (xdrproc_t) xdr_int;
local = (bool_t (*) (char *, void *, struct svc_req *))rpc_loc_api_cb_null_0x00050004_svc;
break;
default:
svcerr_noproc (transp);
return;
}
memset ((char *)&argument, 0, sizeof (argument));
if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
svcerr_decode (transp);
return;
}
retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
if (retval > 0 && !svc_sendreply(transp, (xdrproc_t) _xdr_result, (char *)&result)) {
svcerr_systemerr (transp);
}
if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
fprintf (stderr, "%s", "unable to free arguments");
exit (1);
}
if (!loc_apicbprog_0x00050004_freeresult (transp, _xdr_result, (caddr_t) &result))
fprintf (stderr, "%s", "unable to free results");
return;
}
void
loc_apicbprog_0x00050005(struct svc_req *rqstp, register SVCXPRT *transp)
{
union {
int fill;
} argument;
union {
int rpc_loc_api_cb_null_0x00050005_res;
} result;
bool_t retval;
xdrproc_t _xdr_argument, _xdr_result;
bool_t (*local)(char *, void *, struct svc_req *);
switch (rqstp->rq_proc) {
case NULLPROC:
(void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL);
return;
case rpc_loc_api_cb_null:
_xdr_argument = (xdrproc_t) xdr_void;
_xdr_result = (xdrproc_t) xdr_int;
local = (bool_t (*) (char *, void *, struct svc_req *))rpc_loc_api_cb_null_0x00050005_svc;
break;
default:
svcerr_noproc (transp);
return;
}
memset ((char *)&argument, 0, sizeof (argument));
if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
svcerr_decode (transp);
return;
}
retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
if (retval > 0 && !svc_sendreply(transp, (xdrproc_t) _xdr_result, (char *)&result)) {
svcerr_systemerr (transp);
}
if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
fprintf (stderr, "%s", "unable to free arguments");
exit (1);
}
if (!loc_apicbprog_0x00050005_freeresult (transp, _xdr_result, (caddr_t) &result))
fprintf (stderr, "%s", "unable to free results");
return;
}
void
loc_apicbprog_0x00050006(struct svc_req *rqstp, register SVCXPRT *transp)
{
union {
int fill;
} argument;
union {
int rpc_loc_api_cb_null_0x00050006_res;
} result;
bool_t retval;
xdrproc_t _xdr_argument, _xdr_result;
bool_t (*local)(char *, void *, struct svc_req *);
switch (rqstp->rq_proc) {
case NULLPROC:
(void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL);
return;
case rpc_loc_api_cb_null:
_xdr_argument = (xdrproc_t) xdr_void;
_xdr_result = (xdrproc_t) xdr_int;
local = (bool_t (*) (char *, void *, struct svc_req *))rpc_loc_api_cb_null_0x00050006_svc;
break;
default:
svcerr_noproc (transp);
return;
}
memset ((char *)&argument, 0, sizeof (argument));
if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
svcerr_decode (transp);
return;
}
retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
if (retval > 0 && !svc_sendreply(transp, (xdrproc_t) _xdr_result, (char *)&result)) {
svcerr_systemerr (transp);
}
if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
fprintf (stderr, "%s", "unable to free arguments");
exit (1);
}
if (!loc_apicbprog_0x00050006_freeresult (transp, _xdr_result, (caddr_t) &result))
fprintf (stderr, "%s", "unable to free results");
return;
}

View file

@ -1,60 +0,0 @@
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#include "loc_api_rpcgen_cb_rpc.h"
bool_t
xdr_rpc_loc_event_cb_f_type_args (XDR *xdrs, rpc_loc_event_cb_f_type_args *objp)
{
;
if (!xdr_rpc_uint32 (xdrs, &objp->cb_id))
return FALSE;
if (!xdr_rpc_loc_client_handle_type (xdrs, &objp->loc_handle))
return FALSE;
if (!xdr_rpc_loc_event_mask_type (xdrs, &objp->loc_event))
return FALSE;
if (!xdr_pointer (xdrs, (char **)&objp->loc_event_payload, sizeof (rpc_loc_event_payload_u_type), (xdrproc_t) xdr_rpc_loc_event_payload_u_type))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_event_cb_f_type_rets (XDR *xdrs, rpc_loc_event_cb_f_type_rets *objp)
{
;
if (!xdr_rpc_int32 (xdrs, &objp->loc_event_cb_f_type_result))
return FALSE;
return TRUE;
}

View file

@ -1,155 +0,0 @@
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#include <memory.h> /* for memset */
#include "loc_api_rpcgen_rpc.h"
/* Default timeout can be changed using clnt_control() */
static struct timeval TIMEOUT = { 25, 0 };
enum clnt_stat
rpc_loc_api_null_0x00050001(void *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_api_null,
(xdrproc_t) xdr_void, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_api_rpc_glue_code_info_remote_0x00050001(void *argp, rpc_loc_api_rpc_glue_code_info_remote_rets *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_api_rpc_glue_code_info_remote,
(xdrproc_t) xdr_void, (caddr_t) argp,
(xdrproc_t) xdr_rpc_loc_api_rpc_glue_code_info_remote_rets, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_open_0x00050001(rpc_loc_open_args *argp, rpc_loc_open_rets *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_open,
(xdrproc_t) xdr_rpc_loc_open_args, (caddr_t) argp,
(xdrproc_t) xdr_rpc_loc_open_rets, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_close_0x00050001(rpc_loc_close_args *argp, rpc_loc_close_rets *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_close,
(xdrproc_t) xdr_rpc_loc_close_args, (caddr_t) argp,
(xdrproc_t) xdr_rpc_loc_close_rets, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_start_fix_0x00050001(rpc_loc_start_fix_args *argp, rpc_loc_start_fix_rets *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_start_fix,
(xdrproc_t) xdr_rpc_loc_start_fix_args, (caddr_t) argp,
(xdrproc_t) xdr_rpc_loc_start_fix_rets, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_stop_fix_0x00050001(rpc_loc_stop_fix_args *argp, rpc_loc_stop_fix_rets *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_stop_fix,
(xdrproc_t) xdr_rpc_loc_stop_fix_args, (caddr_t) argp,
(xdrproc_t) xdr_rpc_loc_stop_fix_rets, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_ioctl_0x00050001(rpc_loc_ioctl_args *argp, rpc_loc_ioctl_rets *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_ioctl,
(xdrproc_t) xdr_rpc_loc_ioctl_args, (caddr_t) argp,
(xdrproc_t) xdr_rpc_loc_ioctl_rets, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_api_api_versions_0x00050001(void *argp, rpc_loc_api_api_versions_rets *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_api_api_versions,
(xdrproc_t) xdr_void, (caddr_t) argp,
(xdrproc_t) xdr_rpc_loc_api_api_versions_rets, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_api_null_0x00050002(void *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_api_null,
(xdrproc_t) xdr_void, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_api_null_0x00050003(void *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_api_null,
(xdrproc_t) xdr_void, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_api_null_0x00050004(void *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_api_null,
(xdrproc_t) xdr_void, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_api_null_0x00050005(void *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_api_null,
(xdrproc_t) xdr_void, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_api_null_0x00050006(void *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_api_null,
(xdrproc_t) xdr_void, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}

View file

@ -1,199 +0,0 @@
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#include "loc_api_rpcgen_rpc.h"
bool_t
xdr_rpc_loc_api_api_versions_return_type (XDR *xdrs, rpc_loc_api_api_versions_return_type *objp)
{
;
if (!xdr_array (xdrs, (char **)&objp->rpc_loc_api_api_versions_return_type_val, (u_int *) &objp->rpc_loc_api_api_versions_return_type_len, ~0,
sizeof (rpc_uint32), (xdrproc_t) xdr_rpc_uint32))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_event_cb_f_type (XDR *xdrs, rpc_loc_event_cb_f_type *objp)
{
;
if (!xdr_rpc_uint32 (xdrs, objp))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_open_args (XDR *xdrs, rpc_loc_open_args *objp)
{
;
if (!xdr_rpc_loc_event_mask_type (xdrs, &objp->event_reg_mask))
return FALSE;
if (!xdr_rpc_loc_event_cb_f_type (xdrs, &objp->event_callback))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_close_args (XDR *xdrs, rpc_loc_close_args *objp)
{
;
if (!xdr_rpc_loc_client_handle_type (xdrs, &objp->handle))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_start_fix_args (XDR *xdrs, rpc_loc_start_fix_args *objp)
{
;
if (!xdr_rpc_loc_client_handle_type (xdrs, &objp->handle))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_stop_fix_args (XDR *xdrs, rpc_loc_stop_fix_args *objp)
{
;
if (!xdr_rpc_loc_client_handle_type (xdrs, &objp->handle))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_ioctl_args (XDR *xdrs, rpc_loc_ioctl_args *objp)
{
;
if (!xdr_rpc_loc_client_handle_type (xdrs, &objp->handle))
return FALSE;
if (!xdr_rpc_loc_ioctl_e_type (xdrs, &objp->ioctl_type))
return FALSE;
if (!xdr_pointer (xdrs, (char **)&objp->ioctl_data, sizeof (rpc_loc_ioctl_data_u_type), (xdrproc_t) xdr_rpc_loc_ioctl_data_u_type))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_api_api_version_s_args (XDR *xdrs, rpc_loc_api_api_version_s_args *objp)
{
;
if (!xdr_rpc_boolean (xdrs, &objp->len_not_null))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_api_rpc_glue_code_info_remote_rets (XDR *xdrs, rpc_loc_api_rpc_glue_code_info_remote_rets *objp)
{
;
if (!xdr_rpc_uint32 (xdrs, &objp->toolvers))
return FALSE;
if (!xdr_rpc_uint32 (xdrs, &objp->features))
return FALSE;
if (!xdr_rpc_uint32 (xdrs, &objp->proghash))
return FALSE;
if (!xdr_rpc_uint32 (xdrs, &objp->cbproghash))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_open_rets (XDR *xdrs, rpc_loc_open_rets *objp)
{
;
if (!xdr_rpc_loc_client_handle_type (xdrs, &objp->loc_open_result))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_close_rets (XDR *xdrs, rpc_loc_close_rets *objp)
{
;
if (!xdr_rpc_int32 (xdrs, &objp->loc_close_result))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_start_fix_rets (XDR *xdrs, rpc_loc_start_fix_rets *objp)
{
;
if (!xdr_rpc_int32 (xdrs, &objp->loc_start_fix_result))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_stop_fix_rets (XDR *xdrs, rpc_loc_stop_fix_rets *objp)
{
;
if (!xdr_rpc_int32 (xdrs, &objp->loc_stop_fix_result))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_ioctl_rets (XDR *xdrs, rpc_loc_ioctl_rets *objp)
{
;
if (!xdr_rpc_int32 (xdrs, &objp->loc_ioctl_result))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_api_api_versions_rets (XDR *xdrs, rpc_loc_api_api_versions_rets *objp)
{
;
if (!xdr_rpc_loc_api_api_versions_return_type (xdrs, &objp->loc_api_api_versions_result))
return FALSE;
if (!xdr_pointer (xdrs, (char **)&objp->len, sizeof (rpc_uint32), (xdrproc_t) xdr_rpc_uint32))
return FALSE;
return TRUE;
}

View file

@ -1,74 +0,0 @@
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "librpc.h"
#include "loc_api_rpcgen_rpc.h"
#include "loc_api_rpcgen_cb_rpc.h"
#define RPC_FUNC_VERSION_BASE(a,b) a ## b
#define RPC_CB_FUNC_VERS(a,b) RPC_FUNC_VERSION_BASE(a,b)
static SVCXPRT* svrPort = NULL;
extern void RPC_CB_FUNC_VERS(loc_apicbprog_,LOC_APICBVERS_0001)(struct svc_req *rqstp, register SVCXPRT *transp);
int loc_apicb_app_init(void)
{
/* Register a callback server to use the loc_apicbprog_0x00010001 */
if (svrPort == NULL) {
svrPort = svcrtr_create();
}
if (!svrPort) return -1;
xprt_register(svrPort);
if(svc_register(svrPort, LOC_APICBPROG,LOC_APICBVERS_0001, RPC_CB_FUNC_VERS(loc_apicbprog_,LOC_APICBVERS_0001),0))
{
return 0;
}
else
{
return -1;
}
}
void loc_apicb_app_deinit(void)
{
if (svrPort == NULL)
{
return;
}
svc_unregister(svrPort, LOC_APICBPROG,LOC_APICBVERS_0001);
}

View file

@ -1,261 +0,0 @@
/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/* LOC_API TOOL VERSION: 4.48 */
/* GENERATED: TUE JUN 14 2011 */
/*=============================================================================
L O C _ A P I . X D R
GENERAL DESCRIPTION
This is an AUTO GENERATED file that provides an xdr compatible definition of
the loc_api API.
---------------------------------------------------------------------------
---------------------------------------------------------------------------
=============================================================================*/
/*=============================================================================
Edit History
AUTO GENERATED
Generated by following versions of Htorpc modules:
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/htorpc.pl#1
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Start.pm#1
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Htoxdr.pm#1
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/XDR.pm#3
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Output.pm#5
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Parser.pm#1
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Metacomments.pm#1
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/SymbolTable.pm#1
loc_api Definition File(s):
Id: //source/qcom/qct/modem/api/gps/main/latest/loc_api.h#24
=============================================================================*/
/*=============================================================================
$Header$
=============================================================================*/
typedef rpc_uint32 rpc_loc_api_api_versions_return_type<>;
/*
* Declare an rpc_uint32 type for each callback type in the API
*/
typedef rpc_uint32 rpc_loc_event_cb_f_type;
/*
* These are struct declarations for the function arguments
*/
struct rpc_loc_open_args {
rpc_loc_event_mask_type event_reg_mask;
rpc_loc_event_cb_f_type event_callback;
};
struct rpc_loc_close_args {
rpc_loc_client_handle_type handle;
};
struct rpc_loc_start_fix_args {
rpc_loc_client_handle_type handle;
};
struct rpc_loc_stop_fix_args {
rpc_loc_client_handle_type handle;
};
struct rpc_loc_ioctl_args {
rpc_loc_client_handle_type handle;
rpc_loc_ioctl_e_type ioctl_type;
rpc_loc_ioctl_data_u_type *ioctl_data;
};
struct rpc_loc_api_api_version_s_args {
rpc_boolean len_not_null;
};
/*
* These are struct declarations for the function results
*/
struct rpc_loc_api_rpc_glue_code_info_remote_rets {
rpc_uint32 toolvers; /* Tool version */
rpc_uint32 features; /* Features turned on in the code.
* 0x00000001 ONCRPC Server Cleanup Support
*/
rpc_uint32 proghash; /* Unique hash value for the API XDR definition */
rpc_uint32 cbproghash; /* Unique hash value for the Callbacks' XDR definition */
};
struct rpc_loc_open_rets {
rpc_loc_client_handle_type loc_open_result;
};
struct rpc_loc_close_rets {
rpc_int32 loc_close_result;
};
struct rpc_loc_start_fix_rets {
rpc_int32 loc_start_fix_result;
};
struct rpc_loc_stop_fix_rets {
rpc_int32 loc_stop_fix_result;
};
struct rpc_loc_ioctl_rets {
rpc_int32 loc_ioctl_result;
};
struct rpc_loc_api_api_versions_rets {
rpc_loc_api_api_versions_return_type loc_api_api_versions_result;
rpc_uint32 *len;
};
/*
* XDR definition of the LOC_API program ( vers. 0x00050006 )
*/
program LOC_APIPROG {
version LOC_APIVERS_0001 {
void
rpc_loc_api_null( void ) = 0;
rpc_loc_api_rpc_glue_code_info_remote_rets
rpc_loc_api_rpc_glue_code_info_remote( void ) = 1;
rpc_loc_open_rets
rpc_loc_open( rpc_loc_open_args ) = 2;
rpc_loc_close_rets
rpc_loc_close( rpc_loc_close_args ) = 3;
rpc_loc_start_fix_rets
rpc_loc_start_fix( rpc_loc_start_fix_args ) = 4;
rpc_loc_stop_fix_rets
rpc_loc_stop_fix( rpc_loc_stop_fix_args ) = 5;
rpc_loc_ioctl_rets
rpc_loc_ioctl( rpc_loc_ioctl_args ) = 6;
rpc_loc_api_api_versions_rets
rpc_loc_api_api_versions( void ) = 0xFFFFFFFF;
} = 0x00050001;
version LOC_APIVERS_0002 {
/* Following elements added in enum rpc_loc_assist_data_request_e_type in 0x00050002
RPC_LOC_ASSIST_DATA_POSITION_INJECTION_REQ
*/
/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050002
RPC_LOC_IOCTL_GET_XTRA_T_SESSION_CONTROL
RPC_LOC_IOCTL_RESERVED_CMD
RPC_LOC_IOCTL_SET_XTRA_T_SESSION_CONTROL
*/
void
rpc_loc_api_null( void ) = 0;
} = 0x00050002;
version LOC_APIVERS_0003 {
/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050003
RPC_LOC_IOCTL_SET_DATA_ENABLE
RPC_LOC_IOCTL_SET_LBS_APN_PROFILE
RPC_LOC_IOCTL_GET_XTRA_APN_PROFILE
RPC_LOC_IOCTL_GET_LBS_APN_PROFILE
RPC_LOC_IOCTL_SET_XTRA_APN_PROFILE
*/
void
rpc_loc_api_null( void ) = 0;
} = 0x00050003;
version LOC_APIVERS_0004 {
/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050004
RPC_LOC_IOCTL_GET_SUPL_VERSION
RPC_LOC_IOCTL_SET_SUPL_VERSION
*/
void
rpc_loc_api_null( void ) = 0;
} = 0x00050004;
version LOC_APIVERS_0005 {
/* Following elements added in enum rpc_loc_server_addr_e_type in 0x00050005
RPC_LOC_SERVER_ADDR_IPV6
*/
/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050005
RPC_LOC_IOCTL_ERROR_ESTIMATE_CONFIG
*/
void
rpc_loc_api_null( void ) = 0;
} = 0x00050005;
version LOC_APIVERS_0006 {
/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050006
RPC_LOC_IOCTL_INFORM_SERVER_MULTI_OPEN_STATUS
*/
/* Following elements added in enum rpc_loc_server_request_e_type in 0x00050006
RPC_LOC_SERVER_REQUEST_MULTI_OPEN
*/
void
rpc_loc_api_null( void ) = 0;
} = 0x00050006;
} = 0x3000008C;
const LOC_APIVERS = 0x00050006;

View file

@ -1,187 +0,0 @@
/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/* LOC_API TOOL VERSION: 4.48 */
/* GENERATED: TUE JUN 14 2011 */
/*=============================================================================
L O C _ A P I _ C B . X D R
GENERAL DESCRIPTION
This is an AUTO GENERATED file that provides an xdr compatible definition of
an api that represents the grouping of the different callback functions the
loc_api API supports.
---------------------------------------------------------------------------
---------------------------------------------------------------------------
=============================================================================*/
/*=============================================================================
Edit History
AUTO GENERATED
Generated by following versions of Htorpc modules:
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/htorpc.pl#1
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Start.pm#1
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Htoxdr.pm#1
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/XDR.pm#3
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Output.pm#5
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Parser.pm#1
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Metacomments.pm#1
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/SymbolTable.pm#1
loc_api Definition File(s):
Id: //source/qcom/qct/modem/api/gps/main/latest/loc_api.h#24
=============================================================================*/
/*=============================================================================
$Header$
=============================================================================*/
/*
* These are struct declarations for the function arguments
*/
struct rpc_loc_event_cb_f_type_args {
rpc_uint32 cb_id;
rpc_loc_client_handle_type loc_handle;
rpc_loc_event_mask_type loc_event;
rpc_loc_event_payload_u_type *loc_event_payload;
};
/*
* These are struct declaratios for the function results
*/
struct rpc_loc_event_cb_f_type_rets {
rpc_int32 loc_event_cb_f_type_result;
};
/*
* XDR definition of the LOC_API callback program ( vers. 0x00050006 )
*/
program LOC_APICBPROG {
version LOC_APICBVERS_0001 {
rpc_loc_event_cb_f_type_rets
rpc_loc_event_cb_f_type( rpc_loc_event_cb_f_type_args ) = 1;
} = 0x00050001;
version LOC_APICBVERS_0002 {
/* Following elements added in enum rpc_loc_assist_data_request_e_type in 0x00050002
RPC_LOC_ASSIST_DATA_POSITION_INJECTION_REQ
*/
/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050002
RPC_LOC_IOCTL_GET_XTRA_T_SESSION_CONTROL
RPC_LOC_IOCTL_RESERVED_CMD
RPC_LOC_IOCTL_SET_XTRA_T_SESSION_CONTROL
*/
int
rpc_loc_api_cb_null( void ) = 0xffffff00;
} = 0x00050002;
version LOC_APICBVERS_0003 {
/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050003
RPC_LOC_IOCTL_SET_DATA_ENABLE
RPC_LOC_IOCTL_SET_LBS_APN_PROFILE
RPC_LOC_IOCTL_GET_XTRA_APN_PROFILE
RPC_LOC_IOCTL_GET_LBS_APN_PROFILE
RPC_LOC_IOCTL_SET_XTRA_APN_PROFILE
*/
int
rpc_loc_api_cb_null( void ) = 0xffffff00;
} = 0x00050003;
version LOC_APICBVERS_0004 {
/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050004
RPC_LOC_IOCTL_GET_SUPL_VERSION
RPC_LOC_IOCTL_SET_SUPL_VERSION
*/
int
rpc_loc_api_cb_null( void ) = 0xffffff00;
} = 0x00050004;
version LOC_APICBVERS_0005 {
/* Following elements added in enum rpc_loc_server_addr_e_type in 0x00050005
RPC_LOC_SERVER_ADDR_IPV6
*/
/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050005
RPC_LOC_IOCTL_ERROR_ESTIMATE_CONFIG
*/
int
rpc_loc_api_cb_null( void ) = 0xffffff00;
} = 0x00050005;
version LOC_APICBVERS_0006 {
/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050006
RPC_LOC_IOCTL_INFORM_SERVER_MULTI_OPEN_STATUS
*/
/* Following elements added in enum rpc_loc_server_request_e_type in 0x00050006
RPC_LOC_SERVER_REQUEST_MULTI_OPEN
*/
int
rpc_loc_api_cb_null( void ) = 0xffffff00;
} = 0x00050006;
} = 0x3100008C;
const LOC_APICBVERS = 0x00050006;

View file

@ -1,116 +0,0 @@
ifneq ($(BUILD_TINY_ANDROID),true)
#Compile this library only for builds with the latest modem image
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libloc_eng
LOCAL_MODULE_OWNER := qcom
LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := \
libutils \
libcutils \
libdl \
liblog \
libloc_core \
libgps.utils \
libloc_pla
LOCAL_SRC_FILES += \
loc.cpp \
loc_eng.cpp \
loc_eng_agps.cpp \
loc_eng_xtra.cpp \
loc_eng_ni.cpp \
loc_eng_log.cpp \
loc_eng_nmea.cpp \
LocEngAdapter.cpp
LOCAL_SRC_FILES += \
loc_eng_dmn_conn.cpp \
loc_eng_dmn_conn_handler.cpp \
loc_eng_dmn_conn_thread_helper.c \
loc_eng_dmn_conn_glue_msg.c \
loc_eng_dmn_conn_glue_pipe.c
LOCAL_CFLAGS += \
-fno-short-enums \
-D_ANDROID_
LOCAL_C_INCLUDES:= \
$(TARGET_OUT_HEADERS)/gps.utils \
$(TARGET_OUT_HEADERS)/libloc_core \
hardware/qcom/gps/loc_api/libloc_api_50001 \
$(TARGET_OUT_HEADERS)/libflp \
$(TARGET_OUT_HEADERS)/libloc_pla
LOCAL_COPY_HEADERS_TO:= libloc_eng/
LOCAL_COPY_HEADERS:= \
LocEngAdapter.h \
loc.h \
loc_eng.h \
loc_eng_xtra.h \
loc_eng_ni.h \
loc_eng_agps.h \
loc_eng_msg.h \
loc_eng_log.h
LOCAL_PRELINK_MODULE := false
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := gps.$(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE)
LOCAL_MODULE_OWNER := qcom
LOCAL_MODULE_TAGS := optional
## Libs
LOCAL_SHARED_LIBRARIES := \
libutils \
libcutils \
liblog \
libloc_eng \
libloc_core \
libgps.utils \
libdl \
libloc_pla
ifneq ($(filter $(TARGET_DEVICE), apq8084 msm8960), false)
endif
LOCAL_SRC_FILES += \
gps_interface.cpp \
gps_converter.cpp \
gps.c
LOCAL_CFLAGS += \
-fno-short-enums \
-D_ANDROID_ \
ifeq ($(TARGET_BUILD_VARIANT),user)
LOCAL_CFLAGS += -DTARGET_BUILD_VARIANT_USER
endif
ifeq ($(TARGET_USES_QCOM_BSP), true)
LOCAL_CFLAGS += -DTARGET_USES_QCOM_BSP
endif
## Includes
LOCAL_C_INCLUDES:= \
$(TARGET_OUT_HEADERS)/gps.utils \
$(TARGET_OUT_HEADERS)/libloc_core \
$(TARGET_OUT_HEADERS)/libflp \
$(TARGET_OUT_HEADERS)/libloc_pla
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE_RELATIVE_PATH := hw
include $(BUILD_SHARED_LIBRARY)
endif # not BUILD_TINY_ANDROID

View file

@ -1,606 +0,0 @@
/* Copyright (c) 2011-2016, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#define LOG_NDDEBUG 0
#define LOG_TAG "LocSvc_EngAdapter"
#include <sys/stat.h>
#include <errno.h>
#include <ctype.h>
#include <cutils/properties.h>
#include <LocEngAdapter.h>
#include "loc_eng_msg.h"
#include "loc_log.h"
#define CHIPSET_SERIAL_NUMBER_MAX_LEN 16
#define USER_AGENT_MAX_LEN 512
using namespace loc_core;
LocInternalAdapter::LocInternalAdapter(LocEngAdapter* adapter) :
LocAdapterBase(adapter->getMsgTask()),
mLocEngAdapter(adapter)
{
}
void LocInternalAdapter::setPositionModeInt(LocPosMode& posMode) {
sendMsg(new LocEngPositionMode(mLocEngAdapter, posMode));
}
void LocInternalAdapter::startFixInt() {
sendMsg(new LocEngStartFix(mLocEngAdapter));
}
void LocInternalAdapter::stopFixInt() {
sendMsg(new LocEngStopFix(mLocEngAdapter));
}
void LocInternalAdapter::getZppInt() {
sendMsg(new LocEngGetZpp(mLocEngAdapter));
}
LocEngAdapter::LocEngAdapter(LOC_API_ADAPTER_EVENT_MASK_T mask,
void* owner, ContextBase* context,
LocThread::tCreate tCreator) :
LocAdapterBase(mask,
//Get the AFW context if VzW context has not already been intialized in
//loc_ext
context == NULL?
LocDualContext::getLocFgContext(tCreator,
NULL,
LocDualContext::mLocationHalName,
false)
:context),
mOwner(owner), mInternalAdapter(new LocInternalAdapter(this)),
mUlp(new UlpProxyBase()), mNavigating(false),
mSupportsAgpsRequests(false),
mSupportsPositionInjection(false),
mSupportsTimeInjection(false),
mPowerVote(0)
{
memset(&mFixCriteria, 0, sizeof(mFixCriteria));
mFixCriteria.mode = LOC_POSITION_MODE_INVALID;
clearGnssSvUsedListData();
LOC_LOGD("LocEngAdapter created");
}
inline
LocEngAdapter::~LocEngAdapter()
{
delete mInternalAdapter;
LOC_LOGV("LocEngAdapter deleted");
}
void LocEngAdapter::setXtraUserAgent() {
struct LocSetXtraUserAgent : public LocMsg {
const ContextBase* const mContext;
inline LocSetXtraUserAgent(ContextBase* context) :
LocMsg(), mContext(context) {
}
virtual void proc() const {
char release[PROPERTY_VALUE_MAX];
char manufacture[PROPERTY_VALUE_MAX];
char model[PROPERTY_VALUE_MAX];
char board[PROPERTY_VALUE_MAX];
char brand[PROPERTY_VALUE_MAX];
char chipsetsn[CHIPSET_SERIAL_NUMBER_MAX_LEN];
char userAgent[USER_AGENT_MAX_LEN];
const char defVal[] = "-";
property_get("ro.build.version.release", release, defVal);
property_get("ro.product.manufacturer", manufacture, defVal);
property_get("ro.product.model", model, defVal);
property_get("ro.product.board", board, defVal);
property_get("ro.product.brand", brand, defVal);
getChipsetSerialNo(chipsetsn, sizeof(chipsetsn), defVal);
encodeInPlace(release, PROPERTY_VALUE_MAX);
encodeInPlace(manufacture, PROPERTY_VALUE_MAX);
encodeInPlace(model, PROPERTY_VALUE_MAX);
encodeInPlace(board, PROPERTY_VALUE_MAX);
encodeInPlace(brand, PROPERTY_VALUE_MAX);
snprintf(userAgent, sizeof(userAgent), "A/%s/%s/%s/%s/-/QCX3/s%u/-/%s/-/%s/-/-/-",
release, manufacture, model, board,
mContext->getIzatDevId(), chipsetsn, brand);
for (int i = 0; i < sizeof(userAgent) && userAgent[i]; i++) {
if (' ' == userAgent[i]) userAgent[i] = '#';
}
saveUserAgentString(userAgent, strlen(userAgent));
LOC_LOGV("%s] UserAgent %s", __func__, userAgent);
}
void saveUserAgentString(const char* data, const int len) const {
const char XTRA_FOLDER[] = "/data/misc/location/xtra";
const char USER_AGENT_FILE[] = "/data/misc/location/xtra/useragent.txt";
if (data == NULL || len < 1) {
LOC_LOGE("%s:%d]: invalid input data = %p len = %d", __func__, __LINE__, data, len);
return;
}
struct stat s;
int err = stat(XTRA_FOLDER, &s);
if (err < 0) {
if (ENOENT == errno) {
if (mkdir(XTRA_FOLDER, 0700) < 0) {
LOC_LOGE("%s:%d]: make XTRA_FOLDER failed", __func__, __LINE__);
return;
}
} else {
LOC_LOGE("%s:%d]: XTRA_FOLDER invalid", __func__, __LINE__);
return;
}
}
FILE* file = fopen(USER_AGENT_FILE, "wt");
if (file == NULL) {
LOC_LOGE("%s:%d]: open USER_AGENT_FILE failed", __func__, __LINE__);
return;
}
size_t written = fwrite(data, 1, len, file);
fclose(file);
file = NULL;
// set file permission
chmod(USER_AGENT_FILE, 0600);
if (written != len) {
LOC_LOGE("%s:%d]: write USER_AGENT_FILE failed", __func__, __LINE__);
}
}
void getChipsetSerialNo(char buf[], int buflen, const char def[]) const {
const char SOC_SERIAL_NUMBER[] = "/sys/devices/soc0/serial_number";
FILE* file = fopen(SOC_SERIAL_NUMBER, "rt");
if (file == NULL) {
// use default upon unreadable file
strlcpy(buf, def, buflen);
} else {
size_t size = fread(buf, 1, buflen - 1, file);
if (size == 0) {
// use default upon empty file
strlcpy(buf, def, buflen);
} else {
buf[size] = '\0';
}
fclose(file);
// remove trailing spaces
size_t len = strlen(buf);
while (--len >= 0 && isspace(buf[len])) {
buf[len] = '\0';
}
}
return;
}
/**
* encode the given string value such that all separator characters ('/','+','|','%')
* in the string are repaced by their corresponding encodings (%2F","%2B","%7C", "%25")
*/
static void encodeInPlace(char value[], const int size) {
char buffer[size];
struct ENCODE {
const char ch;
const char *code;
};
const ENCODE encodings[] = { {'/', "%2F"}, {'+', "%2B"}, {'|', "%7C",}, {'%', "%25"} };
const int nencodings = (int)sizeof(encodings) / sizeof(encodings[0]);
int inpos = 0, outpos = 0;
while(value[inpos] != '\0' && outpos < size - 1) {
// check if escaped character
int escchar = 0;
while(escchar < nencodings && encodings[escchar].ch != value[inpos]) {
escchar++;
}
if (escchar == nencodings) {
// non escaped character
buffer[outpos++] = value[inpos++];
continue;
}
// escaped character
int codepos = 0;
#define NUM_CHARS_IN_CODE 3
if (outpos + NUM_CHARS_IN_CODE >= size) {
// skip last character if there is insufficient space
break;
}
while(outpos < size - 1 && codepos < NUM_CHARS_IN_CODE) {
buffer[outpos++] = encodings[escchar].code[codepos++];
}
inpos++;
}
// copy to ouput
value[outpos] = '\0';
while(--outpos >= 0) {
value[outpos] = buffer[outpos];
}
}
};
sendMsg(new LocSetXtraUserAgent(mContext));
}
void LocInternalAdapter::setUlpProxy(UlpProxyBase* ulp) {
struct LocSetUlpProxy : public LocMsg {
LocAdapterBase* mAdapter;
UlpProxyBase* mUlp;
inline LocSetUlpProxy(LocAdapterBase* adapter, UlpProxyBase* ulp) :
LocMsg(), mAdapter(adapter), mUlp(ulp) {
}
virtual void proc() const {
LOC_LOGV("%s] ulp %p adapter %p", __func__,
mUlp, mAdapter);
mAdapter->setUlpProxy(mUlp);
}
};
sendMsg(new LocSetUlpProxy(mLocEngAdapter, ulp));
}
void LocEngAdapter::setUlpProxy(UlpProxyBase* ulp)
{
if (ulp == mUlp) {
//This takes care of the case when double initalization happens
//and we get the same object back for UlpProxyBase . Do nothing
return;
}
LOC_LOGV("%s] %p", __func__, ulp);
if (NULL == ulp) {
LOC_LOGE("%s:%d]: ulp pointer is NULL", __func__, __LINE__);
ulp = new UlpProxyBase();
}
if (LOC_POSITION_MODE_INVALID != mUlp->mPosMode.mode) {
// need to send this mode and start msg to ULP
ulp->sendFixMode(mUlp->mPosMode);
}
if(mUlp->mFixSet) {
ulp->sendStartFix();
}
delete mUlp;
mUlp = ulp;
}
int LocEngAdapter::setGpsLockMsg(LOC_GPS_LOCK_MASK lockMask)
{
struct LocEngAdapterGpsLock : public LocMsg {
LocEngAdapter* mAdapter;
LOC_GPS_LOCK_MASK mLockMask;
inline LocEngAdapterGpsLock(LocEngAdapter* adapter, LOC_GPS_LOCK_MASK lockMask) :
LocMsg(), mAdapter(adapter), mLockMask(lockMask)
{
locallog();
}
inline virtual void proc() const {
mAdapter->setGpsLock(mLockMask);
}
inline void locallog() const {
LOC_LOGV("LocEngAdapterGpsLock - mLockMask: %x", mLockMask);
}
inline virtual void log() const {
locallog();
}
};
sendMsg(new LocEngAdapterGpsLock(this, lockMask));
return 0;
}
void LocEngAdapter::requestPowerVote()
{
if (getPowerVoteRight()) {
/* Power voting without engine lock:
* 101: vote down, 102-104 - vote up
* These codes are used not to confuse with actual engine lock
* functionality, that can't be used in SSR scenario, as it
* conflicts with initialization sequence.
*/
bool powerUp = getPowerVote();
LOC_LOGV("LocEngAdapterVotePower - Vote Power: %d", (int)powerUp);
setGpsLock(powerUp ? 103 : 101);
}
}
void LocInternalAdapter::reportPosition(UlpLocation &location,
GpsLocationExtended &locationExtended,
void* locationExt,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask)
{
sendMsg(new LocEngReportPosition(mLocEngAdapter,
location,
locationExtended,
locationExt,
status,
loc_technology_mask));
}
void LocEngAdapter::reportPosition(UlpLocation &location,
GpsLocationExtended &locationExtended,
void* locationExt,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask)
{
if (! mUlp->reportPosition(location,
locationExtended,
locationExt,
status,
loc_technology_mask )) {
mInternalAdapter->reportPosition(location,
locationExtended,
locationExt,
status,
loc_technology_mask);
}
}
void LocInternalAdapter::reportSv(LocGnssSvStatus &svStatus,
GpsLocationExtended &locationExtended,
void* svExt){
sendMsg(new LocEngReportSv(mLocEngAdapter, svStatus,
locationExtended, svExt));
}
void LocEngAdapter::reportSv(LocGnssSvStatus &svStatus,
GpsLocationExtended &locationExtended,
void* svExt)
{
// We want to send SV info to ULP to help it in determining GNSS
// signal strength ULP will forward the SV reports to HAL without
// any modifications
if (! mUlp->reportSv(svStatus, locationExtended, svExt)) {
mInternalAdapter->reportSv(svStatus, locationExtended, svExt);
}
}
void LocEngAdapter::reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet)
{
// We send SvMeasurementSet to AmtProxy/ULPProxy to be forwarded as necessary.
if (! mUlp->reportSvMeasurement(svMeasurementSet)) {
//Send to Internal Adapter later if needed by LA
}
}
void LocEngAdapter::reportSvPolynomial(GnssSvPolynomial &svPolynomial)
{
// We send SvMeasurementSet to AmtProxy/ULPProxy to be forwarded as necessary.
if (! mUlp->reportSvPolynomial(svPolynomial)) {
//Send to Internal Adapter later if needed by LA
}
}
void LocEngAdapter::setInSession(bool inSession)
{
mNavigating = inSession;
mLocApi->setInSession(inSession);
if (!mNavigating) {
mFixCriteria.mode = LOC_POSITION_MODE_INVALID;
}
}
void LocInternalAdapter::reportStatus(LocGpsStatusValue status)
{
sendMsg(new LocEngReportStatus(mLocEngAdapter, status));
}
void LocEngAdapter::reportStatus(LocGpsStatusValue status)
{
if (!mUlp->reportStatus(status)) {
mInternalAdapter->reportStatus(status);
}
}
void LocInternalAdapter::reportNmea(const char* nmea, int length)
{
sendMsg(new LocEngReportNmea(mLocEngAdapter->getOwner(), nmea, length));
}
inline void LocEngAdapter::reportNmea(const char* nmea, int length)
{
if (!mUlp->reportNmea(nmea, length)) {
//Report it to HAL
mInternalAdapter->reportNmea(nmea, length);
}
}
inline
bool LocEngAdapter::reportXtraServer(const char* url1,
const char* url2,
const char* url3,
const int maxlength)
{
if (mSupportsAgpsRequests) {
sendMsg(new LocEngReportXtraServer(mOwner, url1,
url2, url3, maxlength));
}
return mSupportsAgpsRequests;
}
inline
bool LocEngAdapter::requestATL(int connHandle, LocAGpsType agps_type)
{
if (mSupportsAgpsRequests) {
sendMsg(new LocEngRequestATL(mOwner,
connHandle, agps_type));
}
return mSupportsAgpsRequests;
}
inline
bool LocEngAdapter::releaseATL(int connHandle)
{
if (mSupportsAgpsRequests) {
sendMsg(new LocEngReleaseATL(mOwner, connHandle));
}
return mSupportsAgpsRequests;
}
inline
bool LocEngAdapter::requestXtraData()
{
if (mSupportsAgpsRequests) {
sendMsg(new LocEngRequestXtra(mOwner));
}
return mSupportsAgpsRequests;
}
inline
bool LocEngAdapter::requestTime()
{
if (mSupportsAgpsRequests) {
sendMsg(new LocEngRequestTime(mOwner));
}
return mSupportsAgpsRequests;
}
inline
bool LocEngAdapter::requestNiNotify(LocGpsNiNotification &notif, const void* data)
{
if (mSupportsAgpsRequests) {
notif.size = sizeof(notif);
notif.timeout = LOC_NI_NO_RESPONSE_TIME;
sendMsg(new LocEngRequestNi(mOwner, notif, data));
}
return mSupportsAgpsRequests;
}
inline
bool LocEngAdapter::requestSuplES(int connHandle)
{
if (mSupportsAgpsRequests)
sendMsg(new LocEngRequestSuplEs(mOwner, connHandle));
return mSupportsAgpsRequests;
}
inline
bool LocEngAdapter::reportDataCallOpened()
{
if(mSupportsAgpsRequests)
sendMsg(new LocEngSuplEsOpened(mOwner));
return mSupportsAgpsRequests;
}
inline
bool LocEngAdapter::reportDataCallClosed()
{
if(mSupportsAgpsRequests)
sendMsg(new LocEngSuplEsClosed(mOwner));
return mSupportsAgpsRequests;
}
inline
void LocEngAdapter::handleEngineDownEvent()
{
sendMsg(new LocEngDown(mOwner));
}
inline
void LocEngAdapter::handleEngineUpEvent()
{
sendMsg(new LocEngUp(mOwner));
}
enum loc_api_adapter_err LocEngAdapter::setTime(LocGpsUtcTime time,
int64_t timeReference,
int uncertainty)
{
loc_api_adapter_err result = LOC_API_ADAPTER_ERR_SUCCESS;
LOC_LOGD("%s:%d]: mSupportsTimeInjection is %d",
__func__, __LINE__, mSupportsTimeInjection);
if (mSupportsTimeInjection) {
LOC_LOGD("%s:%d]: Injecting time", __func__, __LINE__);
result = mLocApi->setTime(time, timeReference, uncertainty);
}
return result;
}
enum loc_api_adapter_err LocEngAdapter::setXtraVersionCheck(int check)
{
enum loc_api_adapter_err ret;
ENTRY_LOG();
enum xtra_version_check eCheck;
switch (check) {
case 0:
eCheck = DISABLED;
break;
case 1:
eCheck = AUTO;
break;
case 2:
eCheck = XTRA2;
break;
case 3:
eCheck = XTRA3;
break;
default:
eCheck = DISABLED;
}
ret = mLocApi->setXtraVersionCheck(eCheck);
EXIT_LOG(%d, ret);
return ret;
}
void LocEngAdapter::reportGnssMeasurementData(LocGnssData &gnssMeasurementData)
{
sendMsg(new LocEngReportGnssMeasurement(mOwner,
gnssMeasurementData));
}
/*
Set Gnss Constellation Config
*/
bool LocEngAdapter::gnssConstellationConfig()
{
LOC_LOGD("entering %s", __func__);
bool result = false;
result = mLocApi->gnssConstellationConfig();
return result;
}

View file

@ -1,380 +0,0 @@
/* Copyright (c) 2011-2016, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef LOC_API_ENG_ADAPTER_H
#define LOC_API_ENG_ADAPTER_H
#include <ctype.h>
#include <loc.h>
#include <loc_eng_log.h>
#include <LocAdapterBase.h>
#include <LocDualContext.h>
#include <UlpProxyBase.h>
#include <platform_lib_includes.h>
#define MAX_URL_LEN 256
using namespace loc_core;
class LocEngAdapter;
class LocInternalAdapter : public LocAdapterBase {
LocEngAdapter* mLocEngAdapter;
public:
LocInternalAdapter(LocEngAdapter* adapter);
virtual void reportPosition(UlpLocation &location,
GpsLocationExtended &locationExtended,
void* locationExt,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask);
virtual void reportSv(LocGnssSvStatus &svStatus,
GpsLocationExtended &locationExtended,
void* svExt);
virtual void reportStatus(LocGpsStatusValue status);
virtual void setPositionModeInt(LocPosMode& posMode);
virtual void startFixInt();
virtual void stopFixInt();
virtual void getZppInt();
virtual void setUlpProxy(UlpProxyBase* ulp);
virtual void reportNmea(const char* nmea, int length);
};
typedef void (*loc_msg_sender)(void* loc_eng_data_p, void* msgp);
class LocEngAdapter : public LocAdapterBase {
void* mOwner;
LocInternalAdapter* mInternalAdapter;
UlpProxyBase* mUlp;
LocPosMode mFixCriteria;
bool mNavigating;
// mPowerVote is encoded as
// mPowerVote & 0x20 -- powerVoteRight
// mPowerVote & 0x10 -- power On / Off
unsigned int mPowerVote;
static const unsigned int POWER_VOTE_RIGHT = 0x20;
static const unsigned int POWER_VOTE_VALUE = 0x10;
/** Gnss sv used in position data */
GnssSvUsedInPosition mGnssSvIdUsedInPosition;
bool mGnssSvIdUsedInPosAvail;
public:
bool mSupportsAgpsRequests;
bool mSupportsPositionInjection;
bool mSupportsTimeInjection;
LocGnssSystemInfo mGnssInfo;
LocEngAdapter(LOC_API_ADAPTER_EVENT_MASK_T mask,
void* owner, ContextBase* context,
LocThread::tCreate tCreator);
virtual ~LocEngAdapter();
virtual void setUlpProxy(UlpProxyBase* ulp);
void setXtraUserAgent();
inline void requestUlp(unsigned long capabilities) {
mContext->requestUlp(mInternalAdapter, capabilities);
}
inline LocInternalAdapter* getInternalAdapter() { return mInternalAdapter; }
inline UlpProxyBase* getUlpProxy() { return mUlp; }
inline void* getOwner() { return mOwner; }
inline bool hasAgpsExtendedCapabilities() {
return mContext->hasAgpsExtendedCapabilities();
}
inline bool hasCPIExtendedCapabilities() {
return mContext->hasCPIExtendedCapabilities();
}
inline bool hasNativeXtraClient() {
return mContext->hasNativeXtraClient();
}
inline const MsgTask* getMsgTask() { return mMsgTask; }
inline void clearGnssSvUsedListData() {
mGnssSvIdUsedInPosAvail = false;
memset(&mGnssSvIdUsedInPosition, 0, sizeof (GnssSvUsedInPosition));
}
inline void setGnssSvUsedListData(GnssSvUsedInPosition gnssSvUsedIds) {
mGnssSvIdUsedInPosAvail = true;
memcpy(&mGnssSvIdUsedInPosition, &gnssSvUsedIds,
sizeof(GnssSvUsedInPosition));
}
inline GnssSvUsedInPosition getGnssSvUsedListData() {
return mGnssSvIdUsedInPosition;
}
inline bool isGnssSvIdUsedInPosAvail() {
return mGnssSvIdUsedInPosAvail;
}
inline enum loc_api_adapter_err
startFix()
{
return mLocApi->startFix(mFixCriteria);
}
inline enum loc_api_adapter_err
stopFix()
{
return mLocApi->stopFix();
}
inline enum loc_api_adapter_err
deleteAidingData(LocGpsAidingData f)
{
return mLocApi->deleteAidingData(f);
}
inline enum loc_api_adapter_err
enableData(int enable)
{
return mLocApi->enableData(enable);
}
inline enum loc_api_adapter_err
setAPN(char* apn, int len)
{
return mLocApi->setAPN(apn, len);
}
inline enum loc_api_adapter_err
injectPosition(double latitude, double longitude, float accuracy)
{
return mLocApi->injectPosition(latitude, longitude, accuracy);
}
inline enum loc_api_adapter_err
setXtraData(char* data, int length)
{
return mLocApi->setXtraData(data, length);
}
inline enum loc_api_adapter_err
requestXtraServer()
{
return mLocApi->requestXtraServer();
}
inline enum loc_api_adapter_err
atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bearer, LocAGpsType agpsType)
{
return mLocApi->atlOpenStatus(handle, is_succ, apn, bearer, agpsType);
}
inline enum loc_api_adapter_err
atlCloseStatus(int handle, int is_succ)
{
return mLocApi->atlCloseStatus(handle, is_succ);
}
inline enum loc_api_adapter_err
setPositionMode(const LocPosMode *posMode)
{
if (NULL != posMode) {
mFixCriteria = *posMode;
}
return mLocApi->setPositionMode(mFixCriteria);
}
inline enum loc_api_adapter_err
setServer(const char* url, int len)
{
return mLocApi->setServer(url, len);
}
inline enum loc_api_adapter_err
setServer(unsigned int ip, int port,
LocServerType type)
{
return mLocApi->setServer(ip, port, type);
}
inline enum loc_api_adapter_err
informNiResponse(LocGpsUserResponseType userResponse, const void* passThroughData)
{
return mLocApi->informNiResponse(userResponse, passThroughData);
}
inline enum loc_api_adapter_err
setSUPLVersion(uint32_t version)
{
return mLocApi->setSUPLVersion(version);
}
inline enum loc_api_adapter_err
setNMEATypes (uint32_t typesMask)
{
return mLocApi->setNMEATypes(typesMask);
}
inline enum loc_api_adapter_err
setLPPConfig(uint32_t profile)
{
return mLocApi->setLPPConfig(profile);
}
inline enum loc_api_adapter_err
setSensorControlConfig(int sensorUsage, int sensorProvider)
{
return mLocApi->setSensorControlConfig(sensorUsage, sensorProvider);
}
inline enum loc_api_adapter_err
setSensorProperties(bool gyroBiasVarianceRandomWalk_valid, float gyroBiasVarianceRandomWalk,
bool accelBiasVarianceRandomWalk_valid, float accelBiasVarianceRandomWalk,
bool angleBiasVarianceRandomWalk_valid, float angleBiasVarianceRandomWalk,
bool rateBiasVarianceRandomWalk_valid, float rateBiasVarianceRandomWalk,
bool velocityBiasVarianceRandomWalk_valid, float velocityBiasVarianceRandomWalk)
{
return mLocApi->setSensorProperties(gyroBiasVarianceRandomWalk_valid, gyroBiasVarianceRandomWalk,
accelBiasVarianceRandomWalk_valid, accelBiasVarianceRandomWalk,
angleBiasVarianceRandomWalk_valid, angleBiasVarianceRandomWalk,
rateBiasVarianceRandomWalk_valid, rateBiasVarianceRandomWalk,
velocityBiasVarianceRandomWalk_valid, velocityBiasVarianceRandomWalk);
}
inline virtual enum loc_api_adapter_err
setSensorPerfControlConfig(int controlMode, int accelSamplesPerBatch, int accelBatchesPerSec,
int gyroSamplesPerBatch, int gyroBatchesPerSec,
int accelSamplesPerBatchHigh, int accelBatchesPerSecHigh,
int gyroSamplesPerBatchHigh, int gyroBatchesPerSecHigh, int algorithmConfig)
{
return mLocApi->setSensorPerfControlConfig(controlMode, accelSamplesPerBatch, accelBatchesPerSec,
gyroSamplesPerBatch, gyroBatchesPerSec,
accelSamplesPerBatchHigh, accelBatchesPerSecHigh,
gyroSamplesPerBatchHigh, gyroBatchesPerSecHigh,
algorithmConfig);
}
inline virtual enum loc_api_adapter_err
setAGLONASSProtocol(unsigned long aGlonassProtocol)
{
return mLocApi->setAGLONASSProtocol(aGlonassProtocol);
}
inline virtual enum loc_api_adapter_err
setLPPeProtocol(unsigned long lppeCP, unsigned long lppeUP)
{
return mLocApi->setLPPeProtocol(lppeCP, lppeUP);
}
inline virtual int initDataServiceClient(bool isDueToSsr)
{
return mLocApi->initDataServiceClient(isDueToSsr);
}
inline virtual int openAndStartDataCall()
{
return mLocApi->openAndStartDataCall();
}
inline virtual void stopDataCall()
{
mLocApi->stopDataCall();
}
inline virtual void closeDataCall()
{
mLocApi->closeDataCall();
}
inline virtual void releaseDataServiceClient()
{
mLocApi->releaseDataServiceClient();
}
inline enum loc_api_adapter_err
getZpp(LocGpsLocation &zppLoc, LocPosTechMask &tech_mask)
{
return mLocApi->getBestAvailableZppFix(zppLoc, tech_mask);
}
enum loc_api_adapter_err setTime(LocGpsUtcTime time,
int64_t timeReference,
int uncertainty);
enum loc_api_adapter_err setXtraVersionCheck(int check);
inline virtual void installAGpsCert(const LocDerEncodedCertificate* pData,
size_t length,
uint32_t slotBitMask)
{
mLocApi->installAGpsCert(pData, length, slotBitMask);
}
virtual void handleEngineDownEvent();
virtual void handleEngineUpEvent();
virtual void reportPosition(UlpLocation &location,
GpsLocationExtended &locationExtended,
void* locationExt,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask);
virtual void reportSv(LocGnssSvStatus &svStatus,
GpsLocationExtended &locationExtended,
void* svExt);
virtual void reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet);
virtual void reportSvPolynomial(GnssSvPolynomial &svPolynomial);
virtual void reportStatus(LocGpsStatusValue status);
virtual void reportNmea(const char* nmea, int length);
virtual bool reportXtraServer(const char* url1, const char* url2,
const char* url3, const int maxlength);
virtual bool requestXtraData();
virtual bool requestTime();
virtual bool requestATL(int connHandle, LocAGpsType agps_type);
virtual bool releaseATL(int connHandle);
virtual bool requestNiNotify(LocGpsNiNotification &notify, const void* data);
virtual bool requestSuplES(int connHandle);
virtual bool reportDataCallOpened();
virtual bool reportDataCallClosed();
virtual void reportGnssMeasurementData(LocGnssData &gnssMeasurementData);
inline const LocPosMode& getPositionMode() const
{return mFixCriteria;}
inline virtual bool isInSession()
{ return mNavigating; }
void setInSession(bool inSession);
// Permit/prohibit power voting
inline void setPowerVoteRight(bool powerVoteRight) {
mPowerVote = powerVoteRight ? (mPowerVote | POWER_VOTE_RIGHT) :
(mPowerVote & ~POWER_VOTE_RIGHT);
}
inline bool getPowerVoteRight() const {
return (mPowerVote & POWER_VOTE_RIGHT) != 0 ;
}
// Set the power voting up/down and do actual operation if permitted
inline void setPowerVote(bool powerOn) {
mPowerVote = powerOn ? (mPowerVote | POWER_VOTE_VALUE) :
(mPowerVote & ~POWER_VOTE_VALUE);
requestPowerVote();
mContext->modemPowerVote(powerOn);
}
inline bool getPowerVote() const {
return (mPowerVote & POWER_VOTE_VALUE) != 0 ;
}
// Do power voting according to last settings if permitted
void requestPowerVote();
/*Values for lock
1 = Do not lock any position sessions
2 = Lock MI position sessions
3 = Lock MT position sessions
4 = Lock all position sessions
*/
inline int setGpsLock(LOC_GPS_LOCK_MASK lock)
{
return mLocApi->setGpsLock(lock);
}
int setGpsLockMsg(LOC_GPS_LOCK_MASK lock);
/*
Returns
Current value of GPS lock on success
-1 on failure
*/
inline int getGpsLock()
{
return mLocApi->getGpsLock();
}
/*
Set Gnss Constellation Config
*/
bool gnssConstellationConfig();
};
#endif //LOC_API_ENG_ADAPTER_H

View file

@ -1,62 +0,0 @@
AM_CFLAGS = \
-I../../utils \
-I../../platform_lib_abstractions \
-I$(WORKSPACE)/gps-noship/flp \
-fno-short-enums \
-D__func__=__PRETTY_FUNCTION__ \
-DFEATURE_GNSS_BIT_API
libloc_adapter_so_la_SOURCES = loc_eng_log.cpp LocEngAdapter.cpp
if USE_GLIB
libloc_adapter_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
libloc_adapter_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
libloc_adapter_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libloc_adapter_so_la_CFLAGS = $(AM_CFLAGS)
libloc_adapter_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
libloc_adapter_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
libloc_adapter_so_la_LIBADD = -lstdc++ -lcutils ../../utils/libgps_utils_so.la
libloc_eng_so_la_SOURCES = \
loc.cpp \
loc_eng.cpp \
loc_eng_agps.cpp \
loc_eng_xtra.cpp \
loc_eng_ni.cpp \
loc_eng_log.cpp \
loc_eng_dmn_conn.cpp \
loc_eng_dmn_conn_handler.cpp \
loc_eng_dmn_conn_thread_helper.c \
loc_eng_dmn_conn_glue_msg.c \
loc_eng_dmn_conn_glue_pipe.c
if USE_GLIB
libloc_eng_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
libloc_eng_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
libloc_eng_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libloc_eng_so_la_CFLAGS = $(AM_CFLAGS)
libloc_eng_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
libloc_eng_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
libloc_eng_so_la_LIBADD = -lstdc++ -lcutils -ldl ../../utils/libgps_utils_so.la libloc_adapter_so.la
library_include_HEADERS = \
LocEngAdapter.h \
loc.h \
loc_eng.h \
loc_eng_xtra.h \
loc_eng_ni.h \
loc_eng_agps.h \
loc_eng_msg.h \
loc_eng_log.h
library_includedir = $(pkgincludedir)/libloc_api_50001
#Create and Install libraries
lib_LTLIBRARIES = libloc_adapter_so.la libloc_eng_so.la

View file

@ -1,255 +0,0 @@
/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <gps_converter.h>
void A2Q_DerEncodedCertificate(const DerEncodedCertificate& in, LocDerEncodedCertificate& out) {
memset(&out, 0, sizeof(LocDerEncodedCertificate));
out.length = in.length;
out.data = in.data;
}
void Q2A_GpsLocation(const LocGpsLocation& in, GpsLocation& out) {
memset(&out, 0, sizeof(GpsLocation));
out.size = sizeof(GpsLocation);
out.flags = (LocGpsLocationFlags)in.flags;
out.latitude = in.latitude;
out.longitude = in.longitude;
out.altitude = in.altitude;
out.speed = in.speed;
out.bearing = in.bearing;
out.accuracy = in.accuracy;
out.timestamp = Q2A_GpsUtcTime(in.timestamp);
}
void Q2A_GpsSvInfo(const LocGpsSvInfo& in, GpsSvInfo& out) {
memset(&out, 0, sizeof(GpsSvInfo));
out.size = sizeof(GpsSvInfo);
out.prn = in.prn;
out.snr = in.snr;
out.elevation = in.elevation;
out.azimuth = in.azimuth;
}
void Q2A_GpsSvStatus(const LocGpsSvStatus& in, GpsSvStatus& out) {
memset(&out, 0, sizeof(GpsSvStatus));
out.size = sizeof(GpsSvStatus);
out.num_svs = in.num_svs;
int len = LOC_GPS_MAX_SVS < GPS_MAX_SVS ? LOC_GPS_MAX_SVS : GPS_MAX_SVS;
for (int i = 0; i < len; i++) {
Q2A_GpsSvInfo(in.sv_list[i], out.sv_list[i]);
}
out.ephemeris_mask = in.ephemeris_mask;
out.almanac_mask = in.almanac_mask;
out.used_in_fix_mask = in.used_in_fix_mask;
}
void Q2A_GnssSvInfo(const LocGnssSvInfo& in, GnssSvInfo& out) {
memset(&out, 0, sizeof(GnssSvInfo));
out.size = sizeof(GnssSvInfo);
out.svid = in.svid;
out.constellation = (GnssConstellationType)in.constellation;
out.c_n0_dbhz = in.c_n0_dbhz;
out.elevation = in.elevation;
out.azimuth = in.azimuth;
out.flags = (GnssSvFlags)in.flags;
}
void Q2A_GnssSvStatus(const LocGnssSvStatus& in, GnssSvStatus& out) {
memset(&out, 0, sizeof(GnssSvStatus));
out.size = sizeof(GnssSvStatus);
out.num_svs = in.num_svs;
int len = LOC_GNSS_MAX_SVS < GNSS_MAX_SVS ? LOC_GNSS_MAX_SVS : GNSS_MAX_SVS;
for (int i = 0; i < len; i++) {
Q2A_GnssSvInfo(in.gnss_sv_list[i], out.gnss_sv_list[i]);
}
}
void Q2A_GpsNiNotification(const LocGpsNiNotification& in, GpsNiNotification& out) {
memset(&out, 0, sizeof(GpsNiNotification));
out.size = sizeof(GpsNiNotification);
out.notification_id = in.notification_id;
out.ni_type = (GpsNiType)in.ni_type;
out.notify_flags = (GpsNiNotifyFlags)in.notify_flags;
out.timeout = in.timeout;
out.default_response = (GpsUserResponseType)in.default_response;
int len = LOC_GPS_NI_SHORT_STRING_MAXLEN < GPS_NI_SHORT_STRING_MAXLEN
? LOC_GPS_NI_SHORT_STRING_MAXLEN : GPS_NI_SHORT_STRING_MAXLEN;
for (int i = 0; i < len; i++) {
out.requestor_id[i] = in.requestor_id[i];
}
len = LOC_GPS_NI_LONG_STRING_MAXLEN < GPS_NI_LONG_STRING_MAXLEN
? LOC_GPS_NI_LONG_STRING_MAXLEN : GPS_NI_LONG_STRING_MAXLEN;
for (int i = 0; i < len; i++) {
out.text[i] = in.text[i];
}
out.requestor_id_encoding = (GpsNiEncodingType)in.requestor_id_encoding;
out.text_encoding = (GpsNiEncodingType)in.text_encoding;
len = LOC_GPS_NI_LONG_STRING_MAXLEN < GPS_NI_LONG_STRING_MAXLEN
? LOC_GPS_NI_LONG_STRING_MAXLEN : GPS_NI_LONG_STRING_MAXLEN;
for (int i = 0; i < len; i++) {
out.extras[i] = in.extras[i];
}
}
void Q2A_GpsStatus(const LocGpsStatus& in, GpsStatus& out) {
memset(&out, 0, sizeof(GpsStatus));
out.size = sizeof(GpsStatus);
out.status = (GpsStatusValue)in.status;
}
void Q2A_GnssSystemInfo(const LocGnssSystemInfo& in, GnssSystemInfo& out) {
memset(&out, 0, sizeof(GnssSystemInfo));
out.size = sizeof(GnssSystemInfo);
out.year_of_hw = in.year_of_hw;
}
void Q2A_AGpsStatus(const LocAGpsStatus& in, AGpsStatus& out) {
memset(&out, 0, sizeof(AGpsStatus));
out.size = sizeof(AGpsStatus);
out.type = (AGpsType)in.type;
out.status = (AGpsStatusValue)in.status;
out.ipaddr = in.ipaddr;
memcpy(&out.addr, &in.addr, sizeof(sockaddr_storage));
}
void Q2A_GpsMeasurement(const LocGpsMeasurement& in, GpsMeasurement& out) {
memset(&out, 0, sizeof(GpsMeasurement));
out.size = sizeof(GpsMeasurement);
out.flags = (GpsMeasurementFlags)in.flags;
out.prn = in.prn;
out.time_offset_ns = in.time_offset_ns;
out.state = (GpsMeasurementState)in.state;
out.received_gps_tow_ns = in.received_gps_tow_ns;
out.received_gps_tow_uncertainty_ns = in.received_gps_tow_uncertainty_ns;
out.c_n0_dbhz = in.c_n0_dbhz;
out.pseudorange_rate_mps = in.pseudorange_rate_mps;
out.pseudorange_rate_uncertainty_mps = in.pseudorange_rate_uncertainty_mps;
out.accumulated_delta_range_state = (GpsAccumulatedDeltaRangeState)in.accumulated_delta_range_state;
out.accumulated_delta_range_m = in.accumulated_delta_range_m;
out.accumulated_delta_range_uncertainty_m = in.accumulated_delta_range_uncertainty_m;
out.pseudorange_m = in.pseudorange_m;
out.pseudorange_uncertainty_m = in.pseudorange_uncertainty_m;
out.code_phase_chips = in.code_phase_chips;
out.code_phase_uncertainty_chips = in.code_phase_uncertainty_chips;
out.carrier_frequency_hz = in.carrier_frequency_hz;
out.carrier_cycles = in.carrier_cycles;
out.carrier_phase = in.carrier_phase;
out.carrier_phase_uncertainty = in.carrier_phase_uncertainty;
out.loss_of_lock = (GpsLossOfLock)in.loss_of_lock;
out.bit_number = in.bit_number;
out.time_from_last_bit_ms = in.time_from_last_bit_ms;
out.doppler_shift_hz = in.doppler_shift_hz;
out.doppler_shift_uncertainty_hz = in.doppler_shift_uncertainty_hz;
out.multipath_indicator = (GpsMultipathIndicator)in.multipath_indicator;
out.snr_db = in.snr_db;
out.elevation_deg = in.elevation_deg;
out.elevation_uncertainty_deg = in.elevation_uncertainty_deg;
out.azimuth_deg = in.azimuth_deg;
out.azimuth_uncertainty_deg = in.azimuth_uncertainty_deg;
out.used_in_fix = in.used_in_fix;
}
void Q2A_GpsClock(const LocGpsClock& in, GpsClock& out) {
memset(&out, 0, sizeof(GpsClock));
out.size = sizeof(GpsClock);
out.flags = (GpsClockFlags)in.flags;
out.leap_second = in.leap_second;
out.type = (GpsClockType)in.type;
out.time_ns = in.time_ns;
out.time_uncertainty_ns = in.time_uncertainty_ns;
out.full_bias_ns = in.full_bias_ns;
out.bias_ns = in.bias_ns;
out.bias_uncertainty_ns = in.bias_uncertainty_ns;
out.drift_nsps = in.drift_nsps;
out.drift_uncertainty_nsps = in.drift_uncertainty_nsps;
}
void Q2A_GpsData(const LocGpsData& in, GpsData& out) {
memset(&out, 0, sizeof(GpsData));
out.size = sizeof(GpsData);
out.measurement_count = in.measurement_count;
int len = LOC_GPS_MAX_MEASUREMENT < GPS_MAX_MEASUREMENT
? LOC_GPS_MAX_MEASUREMENT : GPS_MAX_MEASUREMENT;
for (int i = 0; i < len; i++) {
Q2A_GpsMeasurement(in.measurements[i], out.measurements[i]);
}
Q2A_GpsClock(in.clock, out.clock);
}
void Q2A_GnssMeasurement(const LocGnssMeasurement& in, GnssMeasurement& out) {
memset(&out, 0, sizeof(GnssMeasurement));
out.size = sizeof(GnssMeasurement);
out.flags = (GpsMeasurementFlags)in.flags;
out.svid = in.svid;
out.constellation = (GnssConstellationType)in.constellation;
out.time_offset_ns = in.time_offset_ns;
out.state = (GnssMeasurementState)in.state;
out.received_sv_time_in_ns = in.received_sv_time_in_ns;
out.received_sv_time_uncertainty_in_ns = in.received_sv_time_uncertainty_in_ns;
out.c_n0_dbhz = in.c_n0_dbhz;
out.pseudorange_rate_mps = in.pseudorange_rate_mps;
out.pseudorange_rate_uncertainty_mps = in.pseudorange_rate_uncertainty_mps;
out.accumulated_delta_range_state = (GnssAccumulatedDeltaRangeState)in.accumulated_delta_range_state;
out.accumulated_delta_range_m = in.accumulated_delta_range_m;
out.accumulated_delta_range_uncertainty_m = in.accumulated_delta_range_uncertainty_m;
out.carrier_frequency_hz = in.carrier_frequency_hz;
out.carrier_cycles = in.carrier_cycles;
out.carrier_phase = in.carrier_phase;
out.carrier_phase_uncertainty = in.carrier_phase_uncertainty;
out.multipath_indicator = (GnssMultipathIndicator)in.multipath_indicator;
out.snr_db = in.snr_db;
}
void Q2A_GnssClock(const LocGnssClock& in, GnssClock& out) {
memset(&out, 0, sizeof(GnssClock));
out.size = sizeof(GnssClock);
out.flags = (GnssClockFlags)in.flags;
out.leap_second = in.leap_second;
out.time_ns = in.time_ns;
out.time_uncertainty_ns = in.time_uncertainty_ns;
out.full_bias_ns = in.full_bias_ns;
out.bias_ns = in.bias_ns;
out.bias_uncertainty_ns = in.bias_uncertainty_ns;
out.drift_nsps = in.drift_nsps;
out.drift_uncertainty_nsps = in.drift_uncertainty_nsps;
out.hw_clock_discontinuity_count = in.hw_clock_discontinuity_count;
}
void Q2A_GnssData(const LocGnssData& in, GnssData& out) {
memset(&out, 0, sizeof(GnssData));
out.size = sizeof(GnssData);
out.measurement_count = in.measurement_count;
int len = LOC_GNSS_MAX_MEASUREMENT < GNSS_MAX_MEASUREMENT
? LOC_GNSS_MAX_MEASUREMENT : GNSS_MAX_MEASUREMENT;
for (int i = 0; i < len; i++) {
Q2A_GnssMeasurement(in.measurements[i], out.measurements[i]);
}
Q2A_GnssClock(in.clock, out.clock);
}

View file

@ -1,69 +0,0 @@
/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __GPS_CONVERTER_H__
#define __GPS_CONVERTER_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <ctype.h>
#include <hardware/gps.h>
#include <gps_extended.h>
#define A2Q_GpsAidingData(in) (LocGpsAidingData)in
#define A2Q_GpsUserResponseType(in) (LocGpsUserResponseType)in
#define A2Q_GpsPositionRecurrence(in) (LocGpsPositionRecurrence)in
#define A2Q_GpsUtcTime(in) (LocGpsUtcTime)in
#define A2Q_GpsPositionMode(in) (LocGpsPositionMode)in
#define A2Q_GpsPositionRecurrence(in) (LocGpsPositionRecurrence)in
#define A2Q_ApnIpType(in) (LocApnIpType)in
#define A2Q_AGpsType(in) (LocAGpsType)in
#define A2Q_GpsPositionRecurrence(in) (LocGpsPositionRecurrence)in
#define Q2A_GpsUtcTime(in) (GpsUtcTime)in
void A2Q_DerEncodedCertificate(const DerEncodedCertificate& in, LocDerEncodedCertificate& out);
void Q2A_GpsLocation(const LocGpsLocation& in, GpsLocation& out);
void Q2A_GpsSvStatus(const LocGpsSvStatus& in, GpsSvStatus& out);
void Q2A_GnssSvStatus(const LocGnssSvStatus& in, GnssSvStatus& out);
void Q2A_GpsNiNotification(const LocGpsNiNotification& in, GpsNiNotification& out);
void Q2A_GpsStatus(const LocGpsStatus& in, GpsStatus& out);
void Q2A_GnssSystemInfo(const LocGnssSystemInfo& in, GnssSystemInfo& out);
void Q2A_AGpsStatus(const LocAGpsStatus& in, AGpsStatus& out);
void Q2A_GpsData(const LocGpsData& in, GpsData& out);
void Q2A_GnssData(const LocGnssData& in, GnssData& out);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif //__GPS_CONVERTER_H__

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,66 +0,0 @@
/* Copyright (c) 2011,2014 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __LOC_H__
#define __LOC_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <ctype.h>
#include <gps_extended.h>
#define XTRA_DATA_MAX_SIZE 100000 /*bytes*/
typedef void (*loc_location_cb_ext) (UlpLocation* location, void* locExt);
typedef void (*loc_sv_status_cb_ext) (LocGpsSvStatus* sv_status, void* svExt);
typedef void* (*loc_ext_parser)(void* data);
typedef struct {
loc_location_cb_ext location_cb;
loc_gps_status_callback status_cb;
loc_sv_status_cb_ext sv_status_cb;
loc_gps_nmea_callback nmea_cb;
loc_gps_set_capabilities set_capabilities_cb;
loc_gps_acquire_wakelock acquire_wakelock_cb;
loc_gps_release_wakelock release_wakelock_cb;
loc_gps_create_thread create_thread_cb;
loc_ext_parser location_ext_parser;
loc_ext_parser sv_ext_parser;
loc_gps_request_utc_time request_utc_time_cb;
loc_gnss_set_system_info set_system_info_cb;
loc_gnss_sv_status_callback gnss_sv_status_cb;
} LocCallbacks;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif //__LOC_H__

File diff suppressed because it is too large Load diff

View file

@ -1,211 +0,0 @@
/* Copyright (c) 2009-2014, 2016 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef LOC_ENG_H
#define LOC_ENG_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
// Uncomment to keep all LOG messages (LOGD, LOGI, LOGV, etc.)
#define MAX_NUM_ATL_CONNECTIONS 2
// Define boolean type to be used by libgps on loc api module
typedef unsigned char boolean;
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#include <loc.h>
#include <loc_eng_xtra.h>
#include <loc_eng_ni.h>
#include <loc_eng_agps.h>
#include <loc_cfg.h>
#include <loc_log.h>
#include <loc_eng_agps.h>
#include <LocEngAdapter.h>
// The data connection minimal open time
#define DATA_OPEN_MIN_TIME 1 /* sec */
// The system sees GPS engine turns off after inactive for this period of time
#define GPS_AUTO_OFF_TIME 2 /* secs */
#define SUCCESS TRUE
#define FAILURE FALSE
#define INVALID_ATL_CONNECTION_HANDLE -1
#define gps_conf ContextBase::mGps_conf
#define sap_conf ContextBase::mSap_conf
enum loc_nmea_provider_e_type {
NMEA_PROVIDER_AP = 0, // Application Processor Provider of NMEA
NMEA_PROVIDER_MP // Modem Processor Provider of NMEA
};
enum loc_mute_session_e_type {
LOC_MUTE_SESS_NONE = 0,
LOC_MUTE_SESS_WAIT,
LOC_MUTE_SESS_IN_SESSION
};
// Module data
typedef struct loc_eng_data_s
{
LocEngAdapter *adapter;
loc_location_cb_ext location_cb;
loc_gps_status_callback status_cb;
loc_sv_status_cb_ext sv_status_cb;
agps_status_extended agps_status_cb;
loc_gps_nmea_callback nmea_cb;
loc_ni_notify_callback ni_notify_cb;
loc_gps_set_capabilities set_capabilities_cb;
loc_gps_acquire_wakelock acquire_wakelock_cb;
loc_gps_release_wakelock release_wakelock_cb;
loc_gps_request_utc_time request_utc_time_cb;
loc_gnss_set_system_info set_system_info_cb;
loc_gnss_sv_status_callback gnss_sv_status_cb;
loc_gnss_measurement_callback gnss_measurement_cb;
boolean intermediateFix;
LocAGpsStatusValue agps_status;
loc_eng_xtra_data_s_type xtra_module_data;
loc_eng_ni_data_s_type loc_eng_ni_data;
// AGPS state machines
AgpsStateMachine* agnss_nif;
AgpsStateMachine* internet_nif;
//State machine for Data Services
AgpsStateMachine* ds_nif;
// GPS engine status
LocGpsStatusValue engine_status;
LocGpsStatusValue fix_session_status;
// Aiding data information to be deleted, aiding data can only be deleted when GPS engine is off
LocGpsAidingData aiding_data_for_deletion;
// For muting session broadcast
loc_mute_session_e_type mute_session_state;
// For nmea generation
boolean generateNmea;
uint32_t gps_used_mask;
uint32_t glo_used_mask;
uint32_t gal_used_mask;
float hdop;
float pdop;
float vdop;
// Address buffers, for addressing setting before init
int supl_host_set;
char supl_host_buf[101];
int supl_port_buf;
int c2k_host_set;
char c2k_host_buf[101];
int c2k_port_buf;
int mpc_host_set;
char mpc_host_buf[101];
int mpc_port_buf;
loc_ext_parser location_ext_parser;
loc_ext_parser sv_ext_parser;
} loc_eng_data_s_type;
//loc_eng functions
int loc_eng_init(loc_eng_data_s_type &loc_eng_data,
LocCallbacks* callbacks,
LOC_API_ADAPTER_EVENT_MASK_T event,
ContextBase* context);
int loc_eng_start(loc_eng_data_s_type &loc_eng_data);
int loc_eng_stop(loc_eng_data_s_type &loc_eng_data);
void loc_eng_cleanup(loc_eng_data_s_type &loc_eng_data);
int loc_eng_inject_time(loc_eng_data_s_type &loc_eng_data,
LocGpsUtcTime time, int64_t timeReference,
int uncertainty);
int loc_eng_inject_location(loc_eng_data_s_type &loc_eng_data,
double latitude, double longitude,
float accuracy);
void loc_eng_delete_aiding_data(loc_eng_data_s_type &loc_eng_data,
LocGpsAidingData f);
int loc_eng_set_position_mode(loc_eng_data_s_type &loc_eng_data,
LocPosMode &params);
const void* loc_eng_get_extension(loc_eng_data_s_type &loc_eng_data,
const char* name);
int loc_eng_set_server_proxy(loc_eng_data_s_type &loc_eng_data,
LocServerType type, const char *hostname, int port);
void loc_eng_mute_one_session(loc_eng_data_s_type &loc_eng_data);
int loc_eng_read_config(void);
//loc_eng_agps functions
void loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data,
AGpsExtCallbacks* callbacks);
int loc_eng_agps_open(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType,
const char* apn, AGpsBearerType bearerType);
int loc_eng_agps_closed(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType);
int loc_eng_agps_open_failed(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType);
void loc_eng_agps_ril_update_network_availability(loc_eng_data_s_type &loc_eng_data,
int avaiable, const char* apn);
int loc_eng_agps_install_certificates(loc_eng_data_s_type &loc_eng_data,
const LocDerEncodedCertificate* certificates,
size_t length);
//loc_eng_xtra functions
int loc_eng_xtra_init (loc_eng_data_s_type &loc_eng_data,
GpsXtraExtCallbacks* callbacks);
int loc_eng_xtra_inject_data(loc_eng_data_s_type &loc_eng_data,
char* data, int length);
int loc_eng_xtra_request_server(loc_eng_data_s_type &loc_eng_data);
void loc_eng_xtra_version_check(loc_eng_data_s_type &loc_eng_data, int check);
//loc_eng_ni functions
extern void loc_eng_ni_init(loc_eng_data_s_type &loc_eng_data,
GpsNiExtCallbacks *callbacks);
extern void loc_eng_ni_respond(loc_eng_data_s_type &loc_eng_data,
int notif_id, LocGpsUserResponseType user_response);
extern void loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data,
const LocGpsNiNotification *notif,
const void* passThrough);
extern void loc_eng_ni_reset_on_engine_restart(loc_eng_data_s_type &loc_eng_data);
void loc_eng_configuration_update (loc_eng_data_s_type &loc_eng_data,
const char* config_data, int32_t length);
int loc_eng_gps_measurement_init(loc_eng_data_s_type &loc_eng_data,
LocGpsMeasurementCallbacks* callbacks);
void loc_eng_gps_measurement_close(loc_eng_data_s_type &loc_eng_data);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // LOC_ENG_H

View file

@ -1,969 +0,0 @@
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#define LOG_NDDEBUG 0
#define LOG_TAG "LocSvc_eng"
#include <loc_eng_agps.h>
#include <loc_eng_log.h>
#include <platform_lib_includes.h>
#include <loc_eng_dmn_conn_handler.h>
#include <loc_eng_dmn_conn.h>
#include <sys/time.h>
//======================================================================
// C callbacks
//======================================================================
// This is given to linked_list_add as the dealloc callback
// data -- an instance of Subscriber
static void deleteObj(void* data)
{
delete (Subscriber*)data;
}
// This is given to linked_list_search() as the comparison callback
// when the state manchine needs to process for particular subscriber
// fromCaller -- caller provides this obj
// fromList -- linked_list_search() function take this one from list
static bool hasSubscriber(void* fromCaller, void* fromList)
{
Notification* notification = (Notification*)fromCaller;
Subscriber* s1 = (Subscriber*)fromList;
return s1->forMe(*notification);
}
// This is gvien to linked_list_search() to notify subscriber objs
// when the state machine needs to inform all subscribers of resource
// status changes, e.g. when resource is GRANTED.
// fromCaller -- caller provides this ptr to a Notification obj.
// fromList -- linked_list_search() function take this one from list
static bool notifySubscriber(void* fromCaller, void* fromList)
{
Notification* notification = (Notification*)fromCaller;
Subscriber* s1 = (Subscriber*)fromList;
// we notify every subscriber indiscriminatively
// each subscriber decides if this notification is interesting.
return s1->notifyRsrcStatus(*notification) &&
// if we do not want to delete the subscriber from the
// the list, we must set this to false so this function
// returns false
notification->postNotifyDelete;
}
//======================================================================
// Notification
//======================================================================
const int Notification::BROADCAST_ALL = 0x80000000;
const int Notification::BROADCAST_ACTIVE = 0x80000001;
const int Notification::BROADCAST_INACTIVE = 0x80000002;
const unsigned char DSStateMachine::MAX_START_DATA_CALL_RETRIES = 4;
const unsigned int DSStateMachine::DATA_CALL_RETRY_DELAY_MSEC = 500;
//======================================================================
// Subscriber: BITSubscriber / ATLSubscriber / WIFISubscriber
//======================================================================
bool Subscriber::forMe(Notification &notification)
{
if (NULL != notification.rcver) {
return equals(notification.rcver);
} else {
return Notification::BROADCAST_ALL == notification.groupID ||
(Notification::BROADCAST_ACTIVE == notification.groupID &&
!isInactive()) ||
(Notification::BROADCAST_INACTIVE == notification.groupID &&
isInactive());
}
}
bool BITSubscriber::equals(const Subscriber *s) const
{
BITSubscriber* bitS = (BITSubscriber*)s;
return (ID == bitS->ID &&
(INADDR_NONE != (unsigned int)ID ||
0 == strncmp(mIPv6Addr, bitS->mIPv6Addr, sizeof(mIPv6Addr))));
}
bool BITSubscriber::notifyRsrcStatus(Notification &notification)
{
bool notify = forMe(notification);
if (notify) {
switch(notification.rsrcStatus)
{
case RSRC_UNSUBSCRIBE:
case RSRC_RELEASED:
loc_eng_dmn_conn_loc_api_server_data_conn(
LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON,
GPSONE_LOC_API_IF_RELEASE_SUCCESS);
break;
case RSRC_DENIED:
loc_eng_dmn_conn_loc_api_server_data_conn(
LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON,
GPSONE_LOC_API_IF_FAILURE);
break;
case RSRC_GRANTED:
loc_eng_dmn_conn_loc_api_server_data_conn(
LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON,
GPSONE_LOC_API_IF_REQUEST_SUCCESS);
break;
default:
notify = false;
}
}
return notify;
}
bool ATLSubscriber::notifyRsrcStatus(Notification &notification)
{
bool notify = forMe(notification);
if (notify) {
switch(notification.rsrcStatus)
{
case RSRC_UNSUBSCRIBE:
case RSRC_RELEASED:
((LocEngAdapter*)mLocAdapter)->atlCloseStatus(ID, 1);
break;
case RSRC_DENIED:
{
AGpsExtType type = mBackwardCompatibleMode ?
LOC_AGPS_TYPE_INVALID : mStateMachine->getType();
((LocEngAdapter*)mLocAdapter)->atlOpenStatus(ID, 0,
(char*)mStateMachine->getAPN(),
mStateMachine->getBearer(),
type);
}
break;
case RSRC_GRANTED:
{
AGpsExtType type = mBackwardCompatibleMode ?
LOC_AGPS_TYPE_INVALID : mStateMachine->getType();
((LocEngAdapter*)mLocAdapter)->atlOpenStatus(ID, 1,
(char*)mStateMachine->getAPN(),
mStateMachine->getBearer(),
type);
}
break;
default:
notify = false;
}
}
return notify;
}
bool WIFISubscriber::notifyRsrcStatus(Notification &notification)
{
bool notify = forMe(notification);
if (notify) {
switch(notification.rsrcStatus)
{
case RSRC_UNSUBSCRIBE:
break;
case RSRC_RELEASED:
loc_eng_dmn_conn_loc_api_server_data_conn(
senderId,
GPSONE_LOC_API_IF_RELEASE_SUCCESS);
break;
case RSRC_DENIED:
loc_eng_dmn_conn_loc_api_server_data_conn(
senderId,
GPSONE_LOC_API_IF_FAILURE);
break;
case RSRC_GRANTED:
loc_eng_dmn_conn_loc_api_server_data_conn(
senderId,
GPSONE_LOC_API_IF_REQUEST_SUCCESS);
break;
default:
notify = false;
}
}
return notify;
}
bool DSSubscriber::notifyRsrcStatus(Notification &notification)
{
bool notify = forMe(notification);
LOC_LOGD("DSSubscriber::notifyRsrcStatus. notify:%d \n",(int)(notify));
if(notify) {
switch(notification.rsrcStatus) {
case RSRC_UNSUBSCRIBE:
case RSRC_RELEASED:
case RSRC_DENIED:
case RSRC_GRANTED:
((DSStateMachine *)mStateMachine)->informStatus(notification.rsrcStatus, ID);
break;
default:
notify = false;
}
}
return notify;
}
void DSSubscriber :: setInactive()
{
mIsInactive = true;
((DSStateMachine *)mStateMachine)->informStatus(RSRC_UNSUBSCRIBE, ID);
}
//======================================================================
// AgpsState: AgpsReleasedState / AgpsPendingState / AgpsAcquiredState
//======================================================================
// AgpsReleasedState
class AgpsReleasedState : public AgpsState
{
friend class AgpsStateMachine;
inline AgpsReleasedState(AgpsStateMachine* stateMachine) :
AgpsState(stateMachine)
{ mReleasedState = this; }
inline ~AgpsReleasedState() {}
public:
virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data);
inline virtual char* whoami() {return (char*)"AgpsReleasedState";}
};
AgpsState* AgpsReleasedState::onRsrcEvent(AgpsRsrcStatus event, void* data)
{
LOC_LOGD("AgpsReleasedState::onRsrcEvent; event:%d\n", (int)event);
if (mStateMachine->hasSubscribers()) {
LOC_LOGE("Error: %s subscriber list not empty!!!", whoami());
// I don't know how to recover from it. I am adding this rather
// for debugging purpose.
}
AgpsState* nextState = this;
switch (event)
{
case RSRC_SUBSCRIBE:
{
// no notification until we get RSRC_GRANTED
// but we need to add subscriber to the list
mStateMachine->addSubscriber((Subscriber*)data);
// request from connecivity service for NIF
//The if condition is added so that if the data call setup fails
//for DS State Machine, we want to retry in released state.
//for AGps State Machine, sendRsrcRequest() will always return success
if(!mStateMachine->sendRsrcRequest(LOC_GPS_REQUEST_AGPS_DATA_CONN)) {
// move the state to PENDING
nextState = mPendingState;
}
}
break;
case RSRC_UNSUBSCRIBE:
{
// the list should really be empty, nothing to remove.
// but we might as well just tell the client it is
// unsubscribed. False tolerance, right?
Subscriber* subscriber = (Subscriber*) data;
Notification notification(subscriber, event, false);
subscriber->notifyRsrcStatus(notification);
}
// break;
case RSRC_GRANTED:
case RSRC_RELEASED:
case RSRC_DENIED:
default:
LOC_LOGW("%s: unrecognized event %d", whoami(), event);
// no state change.
break;
}
LOC_LOGD("onRsrcEvent, old state %s, new state %s, event %d",
whoami(), nextState->whoami(), event);
return nextState;
}
// AgpsPendingState
class AgpsPendingState : public AgpsState
{
friend class AgpsStateMachine;
inline AgpsPendingState(AgpsStateMachine* stateMachine) :
AgpsState(stateMachine)
{ mPendingState = this; }
inline ~AgpsPendingState() {}
public:
virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data);
inline virtual char* whoami() {return (char*)"AgpsPendingState";}
};
AgpsState* AgpsPendingState::onRsrcEvent(AgpsRsrcStatus event, void* data)
{
AgpsState* nextState = this;;
LOC_LOGD("AgpsPendingState::onRsrcEvent; event:%d\n", (int)event);
switch (event)
{
case RSRC_SUBSCRIBE:
{
// already requested for NIF resource,
// do nothing until we get RSRC_GRANTED indication
// but we need to add subscriber to the list
mStateMachine->addSubscriber((Subscriber*)data);
// no state change.
}
break;
case RSRC_UNSUBSCRIBE:
{
Subscriber* subscriber = (Subscriber*) data;
if (subscriber->waitForCloseComplete()) {
subscriber->setInactive();
} else {
// auto notify this subscriber of the unsubscribe
Notification notification(subscriber, event, true);
mStateMachine->notifySubscribers(notification);
}
// now check if there is any subscribers left
if (!mStateMachine->hasSubscribers()) {
// no more subscribers, move to RELEASED state
nextState = mReleasedState;
// tell connecivity service we can release NIF
mStateMachine->sendRsrcRequest(LOC_GPS_RELEASE_AGPS_DATA_CONN);
} else if (!mStateMachine->hasActiveSubscribers()) {
// only inactive subscribers, move to RELEASING state
nextState = mReleasingState;
// tell connecivity service we can release NIF
mStateMachine->sendRsrcRequest(LOC_GPS_RELEASE_AGPS_DATA_CONN);
}
}
break;
case RSRC_GRANTED:
{
nextState = mAcquiredState;
Notification notification(Notification::BROADCAST_ACTIVE, event, false);
// notify all subscribers NIF resource GRANTED
// by setting false, we keep subscribers on the linked list
mStateMachine->notifySubscribers(notification);
}
break;
case RSRC_RELEASED:
// no state change.
// we are expecting either GRANTED or DENIED. Handling RELEASED
// may like break our state machine in race conditions.
break;
case RSRC_DENIED:
{
nextState = mReleasedState;
Notification notification(Notification::BROADCAST_ALL, event, true);
// notify all subscribers NIF resource RELEASED or DENIED
// by setting true, we remove subscribers from the linked list
mStateMachine->notifySubscribers(notification);
}
break;
default:
LOC_LOGE("%s: unrecognized event %d", whoami(), event);
// no state change.
}
LOC_LOGD("onRsrcEvent, old state %s, new state %s, event %d",
whoami(), nextState->whoami(), event);
return nextState;
}
class AgpsAcquiredState : public AgpsState
{
friend class AgpsStateMachine;
inline AgpsAcquiredState(AgpsStateMachine* stateMachine) :
AgpsState(stateMachine)
{ mAcquiredState = this; }
inline ~AgpsAcquiredState() {}
public:
virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data);
inline virtual char* whoami() { return (char*)"AgpsAcquiredState"; }
};
AgpsState* AgpsAcquiredState::onRsrcEvent(AgpsRsrcStatus event, void* data)
{
AgpsState* nextState = this;
LOC_LOGD("AgpsAcquiredState::onRsrcEvent; event:%d\n", (int)event);
switch (event)
{
case RSRC_SUBSCRIBE:
{
// we already have the NIF resource, simply notify subscriber
Subscriber* subscriber = (Subscriber*) data;
// we have rsrc in hand, so grant it right away
Notification notification(subscriber, RSRC_GRANTED, false);
subscriber->notifyRsrcStatus(notification);
// add subscriber to the list
mStateMachine->addSubscriber(subscriber);
// no state change.
}
break;
case RSRC_UNSUBSCRIBE:
{
Subscriber* subscriber = (Subscriber*) data;
if (subscriber->waitForCloseComplete()) {
subscriber->setInactive();
} else {
// auto notify this subscriber of the unsubscribe
Notification notification(subscriber, event, true);
mStateMachine->notifySubscribers(notification);
}
// now check if there is any subscribers left
if (!mStateMachine->hasSubscribers()) {
// no more subscribers, move to RELEASED state
nextState = mReleasedState;
// tell connecivity service we can release NIF
mStateMachine->sendRsrcRequest(LOC_GPS_RELEASE_AGPS_DATA_CONN);
} else if (!mStateMachine->hasActiveSubscribers()) {
// only inactive subscribers, move to RELEASING state
nextState = mReleasingState;
// tell connecivity service we can release NIF
mStateMachine->sendRsrcRequest(LOC_GPS_RELEASE_AGPS_DATA_CONN);
}
}
break;
case RSRC_GRANTED:
LOC_LOGW("%s: %d, RSRC_GRANTED already received", whoami(), event);
// no state change.
break;
case RSRC_RELEASED:
{
LOC_LOGW("%s: %d, a force rsrc release", whoami(), event);
nextState = mReleasedState;
Notification notification(Notification::BROADCAST_ALL, event, true);
// by setting true, we remove subscribers from the linked list
mStateMachine->notifySubscribers(notification);
}
break;
case RSRC_DENIED:
// no state change.
// we are expecting RELEASED. Handling DENIED
// may like break our state machine in race conditions.
break;
default:
LOC_LOGE("%s: unrecognized event %d", whoami(), event);
// no state change.
}
LOC_LOGD("onRsrcEvent, old state %s, new state %s, event %d",
whoami(), nextState->whoami(), event);
return nextState;
}
// AgpsPendingState
class AgpsReleasingState : public AgpsState
{
friend class AgpsStateMachine;
inline AgpsReleasingState(AgpsStateMachine* stateMachine) :
AgpsState(stateMachine)
{ mReleasingState = this; }
inline ~AgpsReleasingState() {}
public:
virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data);
inline virtual char* whoami() {return (char*)"AgpsReleasingState";}
};
AgpsState* AgpsReleasingState::onRsrcEvent(AgpsRsrcStatus event, void* data)
{
AgpsState* nextState = this;;
LOC_LOGD("AgpsReleasingState::onRsrcEvent; event:%d\n", (int)event);
switch (event)
{
case RSRC_SUBSCRIBE:
{
// already requested for NIF resource,
// do nothing until we get RSRC_GRANTED indication
// but we need to add subscriber to the list
mStateMachine->addSubscriber((Subscriber*)data);
// no state change.
}
break;
case RSRC_UNSUBSCRIBE:
{
Subscriber* subscriber = (Subscriber*) data;
if (subscriber->waitForCloseComplete()) {
subscriber->setInactive();
} else {
// auto notify this subscriber of the unsubscribe
Notification notification(subscriber, event, true);
mStateMachine->notifySubscribers(notification);
}
// now check if there is any subscribers left
if (!mStateMachine->hasSubscribers()) {
// no more subscribers, move to RELEASED state
nextState = mReleasedState;
}
}
break;
case RSRC_DENIED:
// A race condition subscriber unsubscribes before AFW denies resource.
case RSRC_RELEASED:
{
nextState = mAcquiredState;
Notification notification(Notification::BROADCAST_INACTIVE, event, true);
// notify all subscribers that are active NIF resource RELEASE
// by setting false, we keep subscribers on the linked list
mStateMachine->notifySubscribers(notification);
if (mStateMachine->hasActiveSubscribers()) {
nextState = mPendingState;
// request from connecivity service for NIF
mStateMachine->sendRsrcRequest(LOC_GPS_REQUEST_AGPS_DATA_CONN);
} else {
nextState = mReleasedState;
}
}
break;
case RSRC_GRANTED:
default:
LOC_LOGE("%s: unrecognized event %d", whoami(), event);
// no state change.
}
LOC_LOGD("onRsrcEvent, old state %s, new state %s, event %d",
whoami(), nextState->whoami(), event);
return nextState;
}
//======================================================================
//Servicer
//======================================================================
Servicer* Servicer :: getServicer(servicerType type, void *cb_func)
{
LOC_LOGD(" Enter getServicer type:%d\n", (int)type);
switch(type) {
case servicerTypeNoCbParam:
return (new Servicer(cb_func));
case servicerTypeExt:
return (new ExtServicer(cb_func));
case servicerTypeAgps:
return (new AGpsServicer(cb_func));
default:
return NULL;
}
}
int Servicer :: requestRsrc(void *cb_data)
{
callback();
return 0;
}
int ExtServicer :: requestRsrc(void *cb_data)
{
int ret=-1;
LOC_LOGD("Enter ExtServicer :: requestRsrc\n");
ret = callbackExt(cb_data);
LOC_LOGD("Exit ExtServicer :: requestRsrc\n");
return(ret);
}
int AGpsServicer :: requestRsrc(void *cb_data)
{
callbackAGps((LocAGpsStatus *)cb_data);
return 0;
}
//======================================================================
// AgpsStateMachine
//======================================================================
AgpsStateMachine::AgpsStateMachine(servicerType servType,
void *cb_func,
AGpsExtType type,
bool enforceSingleSubscriber) :
mStatePtr(new AgpsReleasedState(this)),mType(type),
mAPN(NULL),
mAPNLen(0),
mBearer(AGPS_APN_BEARER_INVALID),
mEnforceSingleSubscriber(enforceSingleSubscriber),
mServicer(Servicer :: getServicer(servType, (void *)cb_func))
{
linked_list_init(&mSubscribers);
// setting up mReleasedState
mStatePtr->mPendingState = new AgpsPendingState(this);
mStatePtr->mAcquiredState = new AgpsAcquiredState(this);
mStatePtr->mReleasingState = new AgpsReleasingState(this);
// setting up mAcquiredState
mStatePtr->mAcquiredState->mReleasedState = mStatePtr;
mStatePtr->mAcquiredState->mPendingState = mStatePtr->mPendingState;
mStatePtr->mAcquiredState->mReleasingState = mStatePtr->mReleasingState;
// setting up mPendingState
mStatePtr->mPendingState->mAcquiredState = mStatePtr->mAcquiredState;
mStatePtr->mPendingState->mReleasedState = mStatePtr;
mStatePtr->mPendingState->mReleasingState = mStatePtr->mReleasingState;
// setting up mReleasingState
mStatePtr->mReleasingState->mReleasedState = mStatePtr;
mStatePtr->mReleasingState->mPendingState = mStatePtr->mPendingState;
mStatePtr->mReleasingState->mAcquiredState = mStatePtr->mAcquiredState;
}
AgpsStateMachine::~AgpsStateMachine()
{
dropAllSubscribers();
// free the 3 states. We must read out all 3 pointers first.
// Otherwise we run the risk of getting pointers from already
// freed memory.
AgpsState* acquiredState = mStatePtr->mAcquiredState;
AgpsState* releasedState = mStatePtr->mReleasedState;
AgpsState* pendindState = mStatePtr->mPendingState;
AgpsState* releasingState = mStatePtr->mReleasingState;
delete acquiredState;
delete releasedState;
delete pendindState;
delete releasingState;
delete mServicer;
linked_list_destroy(&mSubscribers);
if (NULL != mAPN) {
delete[] mAPN;
mAPN = NULL;
}
}
void AgpsStateMachine::setAPN(const char* apn, unsigned int len)
{
if (NULL != mAPN) {
delete mAPN;
}
if (NULL != apn) {
mAPN = new char[len+1];
memcpy(mAPN, apn, len);
mAPN[len] = NULL;
mAPNLen = len;
} else {
mAPN = NULL;
mAPNLen = 0;
}
}
void AgpsStateMachine::onRsrcEvent(AgpsRsrcStatus event)
{
switch (event)
{
case RSRC_GRANTED:
case RSRC_RELEASED:
case RSRC_DENIED:
mStatePtr = mStatePtr->onRsrcEvent(event, NULL);
break;
default:
LOC_LOGW("AgpsStateMachine: unrecognized event %d", event);
break;
}
}
void AgpsStateMachine::notifySubscribers(Notification& notification) const
{
if (notification.postNotifyDelete) {
// just any non NULL value to get started
Subscriber* s = (Subscriber*)~0;
while (NULL != s) {
s = NULL;
// if the last param sets to true, _search will delete
// the node from the list for us. But the problem is
// once that is done, _search returns, leaving the
// rest of the list unprocessed. So we need a loop.
linked_list_search(mSubscribers, (void**)&s, notifySubscriber,
(void*)&notification, true);
delete s;
}
} else {
// no loop needed if it the last param sets to false, which
// mean nothing gets deleted from the list.
linked_list_search(mSubscribers, NULL, notifySubscriber,
(void*)&notification, false);
}
}
void AgpsStateMachine::addSubscriber(Subscriber* subscriber) const
{
Subscriber* s = NULL;
Notification notification((const Subscriber*)subscriber);
linked_list_search(mSubscribers, (void**)&s,
hasSubscriber, (void*)&notification, false);
if (NULL == s) {
linked_list_add(mSubscribers, subscriber->clone(), deleteObj);
}
}
int AgpsStateMachine::sendRsrcRequest(LocAGpsStatusValue action) const
{
Subscriber* s = NULL;
Notification notification(Notification::BROADCAST_ACTIVE);
linked_list_search(mSubscribers, (void**)&s, hasSubscriber,
(void*)&notification, false);
if ((NULL == s) == (LOC_GPS_RELEASE_AGPS_DATA_CONN == action)) {
AGpsExtStatus nifRequest;
nifRequest.size = sizeof(nifRequest);
nifRequest.type = mType;
nifRequest.status = action;
if (s == NULL) {
nifRequest.ipv4_addr = INADDR_NONE;
memset(&nifRequest.addr, 0, sizeof(nifRequest.addr));
nifRequest.ssid[0] = '\0';
nifRequest.password[0] = '\0';
} else {
s->setIPAddresses(nifRequest.addr);
s->setWifiInfo(nifRequest.ssid, nifRequest.password);
}
CALLBACK_LOG_CALLFLOW("agps_cb", %s, loc_get_agps_status_name(action));
mServicer->requestRsrc((void *)&nifRequest);
}
return 0;
}
void AgpsStateMachine::subscribeRsrc(Subscriber *subscriber)
{
if (mEnforceSingleSubscriber && hasSubscribers()) {
Notification notification(Notification::BROADCAST_ALL, RSRC_DENIED, true);
notifySubscriber(&notification, subscriber);
} else {
mStatePtr = mStatePtr->onRsrcEvent(RSRC_SUBSCRIBE, (void*)subscriber);
}
}
bool AgpsStateMachine::unsubscribeRsrc(Subscriber *subscriber)
{
Subscriber* s = NULL;
Notification notification((const Subscriber*)subscriber);
linked_list_search(mSubscribers, (void**)&s,
hasSubscriber, (void*)&notification, false);
if (NULL != s) {
mStatePtr = mStatePtr->onRsrcEvent(RSRC_UNSUBSCRIBE, (void*)s);
return true;
}
return false;
}
bool AgpsStateMachine::hasActiveSubscribers() const
{
Subscriber* s = NULL;
Notification notification(Notification::BROADCAST_ACTIVE);
linked_list_search(mSubscribers, (void**)&s,
hasSubscriber, (void*)&notification, false);
return NULL != s;
}
//======================================================================
// DSStateMachine
//======================================================================
void delay_callback(void *callbackData, int result)
{
if(callbackData) {
DSStateMachine *DSSMInstance = (DSStateMachine *)callbackData;
DSSMInstance->retryCallback();
}
else {
LOC_LOGE(" NULL argument received. Failing.\n");
goto err;
}
err:
return;
}
DSStateMachine :: DSStateMachine(servicerType type, void *cb_func,
LocEngAdapter* adapterHandle):
AgpsStateMachine(type, cb_func, LOC_AGPS_TYPE_INVALID,false),
mLocAdapter(adapterHandle)
{
LOC_LOGD("%s:%d]: New DSStateMachine\n", __func__, __LINE__);
mRetries = 0;
}
void DSStateMachine :: retryCallback(void)
{
DSSubscriber *subscriber = NULL;
Notification notification(Notification::BROADCAST_ACTIVE);
linked_list_search(mSubscribers, (void**)&subscriber, hasSubscriber,
(void*)&notification, false);
if(subscriber)
mLocAdapter->requestSuplES(subscriber->ID);
else
LOC_LOGE("DSStateMachine :: retryCallback: No subscriber found." \
"Cannot retry data call\n");
return;
}
int DSStateMachine :: sendRsrcRequest(LocAGpsStatusValue action) const
{
DSSubscriber* s = NULL;
dsCbData cbData;
int ret=-1;
int connHandle=-1;
LOC_LOGD("Enter DSStateMachine :: sendRsrcRequest\n");
Notification notification(Notification::BROADCAST_ACTIVE);
linked_list_search(mSubscribers, (void**)&s, hasSubscriber,
(void*)&notification, false);
if(s) {
connHandle = s->ID;
LOC_LOGD("DSStateMachine :: sendRsrcRequest - subscriber found\n");
}
else
LOC_LOGD("DSStateMachine :: sendRsrcRequest - No subscriber found\n");
cbData.action = action;
cbData.mAdapter = mLocAdapter;
ret = mServicer->requestRsrc((void *)&cbData);
//Only the request to start data call returns a success/failure
//The request to stop data call will always succeed
//Hence, the below block will only be executed when the
//request to start the data call fails
switch(ret) {
case LOC_API_ADAPTER_ERR_ENGINE_BUSY:
LOC_LOGD("DSStateMachine :: sendRsrcRequest - Failure returned: %d\n",ret);
((DSStateMachine *)this)->incRetries();
if(mRetries > MAX_START_DATA_CALL_RETRIES) {
LOC_LOGE(" Failed to start Data call. Fallback to normal ATL SUPL\n");
informStatus(RSRC_DENIED, connHandle);
}
else {
if(loc_timer_start(DATA_CALL_RETRY_DELAY_MSEC, delay_callback, (void *)this)) {
LOC_LOGE("Error: Could not start delay thread\n");
ret = -1;
goto err;
}
}
break;
case LOC_API_ADAPTER_ERR_UNSUPPORTED:
LOC_LOGE("No profile found for emergency call. Fallback to normal SUPL ATL\n");
informStatus(RSRC_DENIED, connHandle);
break;
case LOC_API_ADAPTER_ERR_SUCCESS:
LOC_LOGD("%s:%d]: Request to start data call sent\n", __func__, __LINE__);
break;
case -1:
//One of the ways this case can be encountered is if the callback function
//receives a null argument, it just exits with -1 error
LOC_LOGE("Error: Something went wrong somewhere. Falling back to normal SUPL ATL\n");
informStatus(RSRC_DENIED, connHandle);
break;
default:
LOC_LOGE("%s:%d]: Unrecognized return value\n", __func__, __LINE__);
}
err:
LOC_LOGD("EXIT DSStateMachine :: sendRsrcRequest; ret = %d\n", ret);
return ret;
}
void DSStateMachine :: onRsrcEvent(AgpsRsrcStatus event)
{
void* currState = (void *)mStatePtr;
LOC_LOGD("Enter DSStateMachine :: onRsrcEvent. event = %d\n", (int)event);
switch (event)
{
case RSRC_GRANTED:
LOC_LOGD("DSStateMachine :: onRsrcEvent RSRC_GRANTED\n");
mStatePtr = mStatePtr->onRsrcEvent(event, NULL);
break;
case RSRC_RELEASED:
LOC_LOGD("DSStateMachine :: onRsrcEvent RSRC_RELEASED\n");
mStatePtr = mStatePtr->onRsrcEvent(event, NULL);
//To handle the case where we get a RSRC_RELEASED in
//pending state, we translate that to a RSRC_DENIED state
//since the callback from DSI is either RSRC_GRANTED or RSRC_RELEASED
//for when the call is connected or disconnected respectively.
if((void *)mStatePtr != currState)
break;
else {
event = RSRC_DENIED;
LOC_LOGE(" Switching event to RSRC_DENIED\n");
}
case RSRC_DENIED:
mStatePtr = mStatePtr->onRsrcEvent(event, NULL);
break;
default:
LOC_LOGW("AgpsStateMachine: unrecognized event %d", event);
break;
}
LOC_LOGD("Exit DSStateMachine :: onRsrcEvent. event = %d\n", (int)event);
}
void DSStateMachine :: informStatus(AgpsRsrcStatus status, int ID) const
{
LOC_LOGD("DSStateMachine :: informStatus. Status=%d\n",(int)status);
switch(status) {
case RSRC_UNSUBSCRIBE:
mLocAdapter->atlCloseStatus(ID, 1);
break;
case RSRC_RELEASED:
mLocAdapter->closeDataCall();
break;
case RSRC_DENIED:
((DSStateMachine *)this)->mRetries = 0;
mLocAdapter->requestATL(ID, LOC_AGPS_TYPE_SUPL);
break;
case RSRC_GRANTED:
mLocAdapter->atlOpenStatus(ID, 1,
NULL,
AGPS_APN_BEARER_INVALID,
LOC_AGPS_TYPE_INVALID);
break;
default:
LOC_LOGW("DSStateMachine :: informStatus - unknown status");
}
return;
}

View file

@ -1,434 +0,0 @@
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __LOC_ENG_AGPS_H__
#define __LOC_ENG_AGPS_H__
#include <stdbool.h>
#include <ctype.h>
#include <string.h>
#include <arpa/inet.h>
#include <gps_extended.h>
#include <loc_core_log.h>
#include <linked_list.h>
#include <loc_timer.h>
#include <LocEngAdapter.h>
#include <platform_lib_includes.h>
#if defined(USE_GLIB) && !defined(OFF_TARGET)
#include <glib.h>
#endif /* USE_GLIB */
// forward declaration
class AgpsStateMachine;
struct Subscriber;
// NIF resource events
typedef enum {
RSRC_SUBSCRIBE,
RSRC_UNSUBSCRIBE,
RSRC_GRANTED,
RSRC_RELEASED,
RSRC_DENIED,
RSRC_STATUS_MAX
} AgpsRsrcStatus;
typedef enum {
servicerTypeNoCbParam,
servicerTypeAgps,
servicerTypeExt
}servicerType;
//DS Callback struct
typedef struct {
LocEngAdapter *mAdapter;
LocAGpsStatusValue action;
}dsCbData;
// information bundle for subscribers
struct Notification {
// goes to every subscriber
static const int BROADCAST_ALL;
// goes to every ACTIVE subscriber
static const int BROADCAST_ACTIVE;
// goes to every INACTIVE subscriber
static const int BROADCAST_INACTIVE;
// go to a specific subscriber
const Subscriber* rcver;
// broadcast
const int groupID;
// the new resource status event
const AgpsRsrcStatus rsrcStatus;
// should the subscriber be deleted after the notification
const bool postNotifyDelete;
// convenient constructor
inline Notification(const int broadcast,
const AgpsRsrcStatus status,
const bool deleteAfterwards) :
rcver(NULL), groupID(broadcast), rsrcStatus(status),
postNotifyDelete(deleteAfterwards) {}
// convenient constructor
inline Notification(const Subscriber* subscriber,
const AgpsRsrcStatus status,
const bool deleteAfterwards) :
rcver(subscriber), groupID(-1), rsrcStatus(status),
postNotifyDelete(deleteAfterwards) {}
// convenient constructor
inline Notification(const int broadcast) :
rcver(NULL), groupID(broadcast), rsrcStatus(RSRC_STATUS_MAX),
postNotifyDelete(false) {}
// convenient constructor
inline Notification(const Subscriber* subscriber) :
rcver(subscriber), groupID(-1), rsrcStatus(RSRC_STATUS_MAX),
postNotifyDelete(false) {}
};
class AgpsState {
// allows AgpsStateMachine to access private data
// no class members are public. We don't want
// anyone but state machine to use state.
friend class AgpsStateMachine;
friend class DSStateMachine;
// state transitions are done here.
// Each state implements its own transitions (of course).
inline virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data) = 0;
protected:
// handle back to state machine
const AgpsStateMachine* mStateMachine;
// each state has pointers to all 3 states
// one of which is to itself.
AgpsState* mReleasedState;
AgpsState* mAcquiredState;
AgpsState* mPendingState;
AgpsState* mReleasingState;
inline AgpsState(const AgpsStateMachine *stateMachine) :
mStateMachine(stateMachine),
mReleasedState(NULL),
mAcquiredState(NULL),
mPendingState(NULL),
mReleasingState(NULL) {}
virtual ~AgpsState() {}
public:
// for logging purpose
inline virtual char* whoami() = 0;
};
class Servicer {
void (*callback)(void);
public:
static Servicer* getServicer(servicerType type, void *cb_func);
virtual int requestRsrc(void *cb_data);
Servicer() {}
Servicer(void *cb_func)
{ callback = (void(*)(void))(cb_func); }
virtual ~Servicer(){}
inline virtual char *whoami() {return (char*)"Servicer";}
};
class ExtServicer : public Servicer {
int (*callbackExt)(void *cb_data);
public:
int requestRsrc(void *cb_data);
ExtServicer() {}
ExtServicer(void *cb_func)
{ callbackExt = (int(*)(void *))(cb_func); }
virtual ~ExtServicer(){}
inline virtual char *whoami() {return (char*)"ExtServicer";}
};
class AGpsServicer : public Servicer {
void (*callbackAGps)(LocAGpsStatus* status);
public:
int requestRsrc(void *cb_data);
AGpsServicer() {}
AGpsServicer(void *cb_func)
{ callbackAGps = (void(*)(LocAGpsStatus *))(cb_func); }
virtual ~AGpsServicer(){}
inline virtual char *whoami() {return (char*)"AGpsServicer";}
};
class AgpsStateMachine {
protected:
// a linked list of subscribers.
void* mSubscribers;
//handle to whoever provides the service
Servicer *mServicer;
// allows AgpsState to access private data
// each state is really internal data to the
// state machine, so it should be able to
// access anything within the state machine.
friend class AgpsState;
// pointer to the current state.
AgpsState* mStatePtr;
private:
// NIF type: AGNSS or INTERNET.
const AGpsExtType mType;
// apn to the NIF. Each state machine tracks
// resource state of a particular NIF. For each
// NIF, there is also an active APN.
char* mAPN;
// for convenience, we don't do strlen each time.
unsigned int mAPNLen;
// bear
AGpsBearerType mBearer;
// ipv4 address for routing
bool mEnforceSingleSubscriber;
public:
AgpsStateMachine(servicerType servType, void *cb_func,
AGpsExtType type, bool enforceSingleSubscriber);
virtual ~AgpsStateMachine();
// self explanatory methods below
void setAPN(const char* apn, unsigned int len);
inline const char* getAPN() const { return (const char*)mAPN; }
inline void setBearer(AGpsBearerType bearer) { mBearer = bearer; }
inline AGpsBearerType getBearer() const { return mBearer; }
inline AGpsExtType getType() const { return (AGpsExtType)mType; }
// someone, a ATL client or BIT, is asking for NIF
void subscribeRsrc(Subscriber *subscriber);
// someone, a ATL client or BIT, is done with NIF
bool unsubscribeRsrc(Subscriber *subscriber);
// add a subscriber in the linked list, if not already there.
void addSubscriber(Subscriber* subscriber) const;
virtual void onRsrcEvent(AgpsRsrcStatus event);
// put the data together and send the FW
virtual int sendRsrcRequest(LocAGpsStatusValue action) const;
//if list is empty, linked_list_empty returns 1
//else if list is not empty, returns 0
//so hasSubscribers() returns 1 if list is not empty
//and returns 0 if list is empty
inline bool hasSubscribers() const
{ return !linked_list_empty(mSubscribers); }
bool hasActiveSubscribers() const;
inline void dropAllSubscribers() const
{ linked_list_flush(mSubscribers); }
// private. Only a state gets to call this.
void notifySubscribers(Notification& notification) const;
};
class DSStateMachine : public AgpsStateMachine {
static const unsigned char MAX_START_DATA_CALL_RETRIES;
static const unsigned int DATA_CALL_RETRY_DELAY_MSEC;
LocEngAdapter* mLocAdapter;
unsigned char mRetries;
public:
DSStateMachine(servicerType type,
void *cb_func,
LocEngAdapter* adapterHandle);
int sendRsrcRequest(LocAGpsStatusValue action) const;
void onRsrcEvent(AgpsRsrcStatus event);
void retryCallback();
void informStatus(AgpsRsrcStatus status, int ID) const;
inline void incRetries() {mRetries++;}
inline virtual char *whoami() {return (char*)"DSStateMachine";}
};
// each subscriber is a AGPS client. In the case of ATL, there could be
// multiple clients from modem. In the case of BIT, there is only one
// cilent from BIT daemon.
struct Subscriber {
const uint32_t ID;
const AgpsStateMachine* mStateMachine;
inline Subscriber(const int id,
const AgpsStateMachine* stateMachine) :
ID(id), mStateMachine(stateMachine) {}
inline virtual ~Subscriber() {}
virtual void setIPAddresses(uint32_t &v4, char* v6) = 0;
virtual void setIPAddresses(struct sockaddr_storage& addr) = 0;
inline virtual void setWifiInfo(char* ssid, char* password)
{ ssid[0] = 0; password[0] = 0; }
inline virtual bool equals(const Subscriber *s) const
{ return ID == s->ID; }
// notifies a subscriber a new NIF resource status, usually
// either GRANTE, DENIED, or RELEASED
virtual bool notifyRsrcStatus(Notification &notification) = 0;
virtual bool waitForCloseComplete() { return false; }
virtual void setInactive() {}
virtual bool isInactive() { return false; }
virtual Subscriber* clone() = 0;
// checks if this notification is for me, i.e.
// either has my id, or has a broadcast id.
bool forMe(Notification &notification);
};
// BITSubscriber, created with requests from BIT daemon
struct BITSubscriber : public Subscriber {
char mIPv6Addr[16];
inline BITSubscriber(const AgpsStateMachine* stateMachine,
unsigned int ipv4, char* ipv6) :
Subscriber(ipv4, stateMachine)
{
if (NULL == ipv6) {
mIPv6Addr[0] = 0;
} else {
memcpy(mIPv6Addr, ipv6, sizeof(mIPv6Addr));
}
}
virtual bool notifyRsrcStatus(Notification &notification);
inline virtual void setIPAddresses(uint32_t &v4, char* v6)
{ v4 = ID; memcpy(v6, mIPv6Addr, sizeof(mIPv6Addr)); }
inline virtual void setIPAddresses(struct sockaddr_storage& addr)
{ addr.ss_family = AF_INET6;/*todo: convert mIPv6Addr into addr */ }
virtual Subscriber* clone()
{
return new BITSubscriber(mStateMachine, ID, mIPv6Addr);
}
virtual bool equals(const Subscriber *s) const;
inline virtual ~BITSubscriber(){}
};
// ATLSubscriber, created with requests from ATL
struct ATLSubscriber : public Subscriber {
const LocEngAdapter* mLocAdapter;
const bool mBackwardCompatibleMode;
inline ATLSubscriber(const int id,
const AgpsStateMachine* stateMachine,
const LocEngAdapter* adapter,
const bool compatibleMode) :
Subscriber(id, stateMachine), mLocAdapter(adapter),
mBackwardCompatibleMode(compatibleMode){}
virtual bool notifyRsrcStatus(Notification &notification);
inline virtual void setIPAddresses(uint32_t &v4, char* v6)
{ v4 = INADDR_NONE; v6[0] = 0; }
inline virtual void setIPAddresses(struct sockaddr_storage& addr)
{ addr.ss_family = AF_INET6; }
inline virtual Subscriber* clone()
{
return new ATLSubscriber(ID, mStateMachine, mLocAdapter,
mBackwardCompatibleMode);
}
inline virtual ~ATLSubscriber(){}
};
// WIFISubscriber, created with requests from MSAPM or QuIPC
struct WIFISubscriber : public Subscriber {
char * mSSID;
char * mPassword;
loc_if_req_sender_id_e_type senderId;
bool mIsInactive;
inline WIFISubscriber(const AgpsStateMachine* stateMachine,
char * ssid, char * password, loc_if_req_sender_id_e_type sender_id) :
Subscriber(sender_id, stateMachine),
mSSID(NULL == ssid ? NULL : new char[SSID_BUF_SIZE]),
mPassword(NULL == password ? NULL : new char[SSID_BUF_SIZE]),
senderId(sender_id)
{
if (NULL != mSSID)
strlcpy(mSSID, ssid, SSID_BUF_SIZE);
if (NULL != mPassword)
strlcpy(mPassword, password, SSID_BUF_SIZE);
mIsInactive = false;
}
virtual bool notifyRsrcStatus(Notification &notification);
inline virtual void setIPAddresses(uint32_t &v4, char* v6) {}
inline virtual void setIPAddresses(struct sockaddr_storage& addr)
{ addr.ss_family = AF_INET6; }
inline virtual void setWifiInfo(char* ssid, char* password)
{
if (NULL != mSSID)
strlcpy(ssid, mSSID, SSID_BUF_SIZE);
else
ssid[0] = '\0';
if (NULL != mPassword)
strlcpy(password, mPassword, SSID_BUF_SIZE);
else
password[0] = '\0';
}
inline virtual bool waitForCloseComplete() { return true; }
inline virtual void setInactive() { mIsInactive = true; }
inline virtual bool isInactive() { return mIsInactive; }
virtual Subscriber* clone()
{
return new WIFISubscriber(mStateMachine, mSSID, mPassword, senderId);
}
inline virtual ~WIFISubscriber(){}
};
struct DSSubscriber : public Subscriber {
bool mIsInactive;
inline DSSubscriber(const AgpsStateMachine *stateMachine,
const int id) :
Subscriber(id, stateMachine)
{
mIsInactive = false;
}
inline virtual void setIPAddresses(uint32_t &v4, char* v6) {}
inline virtual void setIPAddresses(struct sockaddr_storage& addr)
{ addr.ss_family = AF_INET6; }
virtual Subscriber* clone()
{return new DSSubscriber(mStateMachine, ID);}
virtual bool notifyRsrcStatus(Notification &notification);
inline virtual bool waitForCloseComplete() { return true; }
virtual void setInactive();
inline virtual bool isInactive()
{ return mIsInactive; }
inline virtual ~DSSubscriber(){}
inline virtual char *whoami() {return (char*)"DSSubscriber";}
};
#endif //__LOC_ENG_AGPS_H__

View file

@ -1,269 +0,0 @@
/* Copyright (c) 2011-2012,2014 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <linux/stat.h>
#include <fcntl.h>
#include <linux/types.h>
#include <unistd.h>
#include <errno.h>
#include <grp.h>
#include <sys/stat.h>
#include <platform_lib_includes.h>
#include "loc_eng_dmn_conn_glue_msg.h"
#include "loc_eng_dmn_conn_handler.h"
#include "loc_eng_dmn_conn.h"
#include "loc_eng_msg.h"
static int loc_api_server_msgqid;
static int loc_api_resp_msgqid;
static int quipc_msgqid;
static int msapm_msgqid;
static int msapu_msgqid;
static const char * global_loc_api_q_path = GPSONE_LOC_API_Q_PATH;
static const char * global_loc_api_resp_q_path = GPSONE_LOC_API_RESP_Q_PATH;
static const char * global_quipc_ctrl_q_path = QUIPC_CTRL_Q_PATH;
static const char * global_msapm_ctrl_q_path = MSAPM_CTRL_Q_PATH;
static const char * global_msapu_ctrl_q_path = MSAPU_CTRL_Q_PATH;
static int loc_api_server_proc_init(void *context)
{
loc_api_server_msgqid = loc_eng_dmn_conn_glue_msgget(global_loc_api_q_path, O_RDWR);
//change mode/group for the global_loc_api_q_path pipe
int result = chmod (global_loc_api_q_path, 0660);
if (result != 0)
{
LOC_LOGE("failed to change mode for %s, error = %s\n", global_loc_api_q_path, strerror(errno));
}
struct group * gps_group = getgrnam("gps");
if (gps_group != NULL)
{
result = chown (global_loc_api_q_path, -1, gps_group->gr_gid);
if (result != 0)
{
LOC_LOGE("chown for pipe failed, pipe %s, gid = %d, result = %d, error = %s\n",
global_loc_api_q_path, gps_group->gr_gid, result, strerror(errno));
}
}
else
{
LOC_LOGE("getgrnam for gps failed, error code = %d\n", errno);
}
loc_api_resp_msgqid = loc_eng_dmn_conn_glue_msgget(global_loc_api_resp_q_path, O_RDWR);
//change mode/group for the global_loc_api_resp_q_path pipe
result = chmod (global_loc_api_resp_q_path, 0660);
if (result != 0)
{
LOC_LOGE("failed to change mode for %s, error = %s\n", global_loc_api_resp_q_path, strerror(errno));
}
if (gps_group != NULL)
{
result = chown (global_loc_api_resp_q_path, -1, gps_group->gr_gid);
if (result != 0)
{
LOC_LOGE("chown for pipe failed, pipe %s, gid = %d, result = %d, error = %s\n",
global_loc_api_resp_q_path,
gps_group->gr_gid, result, strerror(errno));
}
}
quipc_msgqid = loc_eng_dmn_conn_glue_msgget(global_quipc_ctrl_q_path, O_RDWR);
msapm_msgqid = loc_eng_dmn_conn_glue_msgget(global_msapm_ctrl_q_path , O_RDWR);
msapu_msgqid = loc_eng_dmn_conn_glue_msgget(global_msapu_ctrl_q_path , O_RDWR);
LOC_LOGD("%s:%d] loc_api_server_msgqid = %d\n", __func__, __LINE__, loc_api_server_msgqid);
return 0;
}
static int loc_api_server_proc_pre(void *context)
{
return 0;
}
static int loc_api_server_proc(void *context)
{
int length, sz;
int result = 0;
static int cnt = 0;
struct ctrl_msgbuf * p_cmsgbuf;
struct ctrl_msgbuf cmsg_resp;
sz = sizeof(struct ctrl_msgbuf) + 256;
p_cmsgbuf = (struct ctrl_msgbuf *) malloc(sz);
if (!p_cmsgbuf) {
LOC_LOGE("%s:%d] Out of memory\n", __func__, __LINE__);
return -1;
}
cnt ++;
LOC_LOGD("%s:%d] %d listening on %s...\n", __func__, __LINE__, cnt, (char *) context);
length = loc_eng_dmn_conn_glue_msgrcv(loc_api_server_msgqid, p_cmsgbuf, sz);
if (length <= 0) {
free(p_cmsgbuf);
LOC_LOGE("%s:%d] fail receiving msg from gpsone_daemon, retry later\n", __func__, __LINE__);
usleep(1000);
return -1;
}
LOC_LOGD("%s:%d] received ctrl_type = %d\n", __func__, __LINE__, p_cmsgbuf->ctrl_type);
switch(p_cmsgbuf->ctrl_type) {
case GPSONE_LOC_API_IF_REQUEST:
result = loc_eng_dmn_conn_loc_api_server_if_request_handler(p_cmsgbuf, length);
break;
case GPSONE_LOC_API_IF_RELEASE:
result = loc_eng_dmn_conn_loc_api_server_if_release_handler(p_cmsgbuf, length);
break;
case GPSONE_UNBLOCK:
LOC_LOGD("%s:%d] GPSONE_UNBLOCK\n", __func__, __LINE__);
break;
default:
LOC_LOGE("%s:%d] unsupported ctrl_type = %d\n",
__func__, __LINE__, p_cmsgbuf->ctrl_type);
break;
}
free(p_cmsgbuf);
return 0;
}
static int loc_api_server_proc_post(void *context)
{
LOC_LOGD("%s:%d]\n", __func__, __LINE__);
loc_eng_dmn_conn_glue_msgremove( global_loc_api_q_path, loc_api_server_msgqid);
loc_eng_dmn_conn_glue_msgremove( global_loc_api_resp_q_path, loc_api_resp_msgqid);
loc_eng_dmn_conn_glue_msgremove( global_quipc_ctrl_q_path, quipc_msgqid);
loc_eng_dmn_conn_glue_msgremove( global_msapm_ctrl_q_path, msapm_msgqid);
loc_eng_dmn_conn_glue_msgremove( global_msapu_ctrl_q_path, msapu_msgqid);
return 0;
}
static int loc_eng_dmn_conn_unblock_proc(void)
{
struct ctrl_msgbuf cmsgbuf;
cmsgbuf.ctrl_type = GPSONE_UNBLOCK;
LOC_LOGD("%s:%d]\n", __func__, __LINE__);
loc_eng_dmn_conn_glue_msgsnd(loc_api_server_msgqid, & cmsgbuf, sizeof(cmsgbuf));
return 0;
}
static struct loc_eng_dmn_conn_thelper thelper;
int loc_eng_dmn_conn_loc_api_server_launch(thelper_create_thread create_thread_cb,
const char * loc_api_q_path, const char * resp_q_path, void *agps_handle)
{
int result;
loc_api_handle = agps_handle;
if (loc_api_q_path) global_loc_api_q_path = loc_api_q_path;
if (resp_q_path) global_loc_api_resp_q_path = resp_q_path;
result = loc_eng_dmn_conn_launch_thelper( &thelper,
loc_api_server_proc_init,
loc_api_server_proc_pre,
loc_api_server_proc,
loc_api_server_proc_post,
create_thread_cb,
(char *) global_loc_api_q_path);
if (result != 0) {
LOC_LOGE("%s:%d]\n", __func__, __LINE__);
return -1;
}
return 0;
}
int loc_eng_dmn_conn_loc_api_server_unblock(void)
{
loc_eng_dmn_conn_unblock_thelper(&thelper);
loc_eng_dmn_conn_unblock_proc();
return 0;
}
int loc_eng_dmn_conn_loc_api_server_join(void)
{
loc_eng_dmn_conn_join_thelper(&thelper);
return 0;
}
int loc_eng_dmn_conn_loc_api_server_data_conn(int sender_id, int status) {
struct ctrl_msgbuf cmsgbuf;
LOC_LOGD("%s:%d] quipc_msgqid = %d\n", __func__, __LINE__, quipc_msgqid);
cmsgbuf.ctrl_type = GPSONE_LOC_API_RESPONSE;
cmsgbuf.cmsg.cmsg_response.result = status;
switch (sender_id) {
case LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC: {
LOC_LOGD("%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC", __func__, __LINE__);
if (loc_eng_dmn_conn_glue_msgsnd(quipc_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) {
LOC_LOGD("%s:%d] error! conn_glue_msgsnd failed\n", __func__, __LINE__);
return -1;
}
break;
}
case LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM: {
LOC_LOGD("%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM", __func__, __LINE__);
if (loc_eng_dmn_conn_glue_msgsnd(msapm_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) {
LOC_LOGD("%s:%d] error! conn_glue_msgsnd failed\n", __func__, __LINE__);
return -1;
}
break;
}
case LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU: {
LOC_LOGD("%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU", __func__, __LINE__);
if (loc_eng_dmn_conn_glue_msgsnd(msapu_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) {
LOC_LOGD("%s:%d] error! conn_glue_msgsnd failed\n", __func__, __LINE__);
return -1;
}
break;
}
case LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON: {
LOC_LOGD("%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON", __func__, __LINE__);
if (loc_eng_dmn_conn_glue_msgsnd(loc_api_resp_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) {
LOC_LOGD("%s:%d] error! conn_glue_msgsnd failed\n", __func__, __LINE__);
return -1;
}
break;
}
default: {
LOC_LOGD("%s:%d] invalid sender ID!", __func__, __LINE__);
}
}
return 0;
}

View file

@ -1,59 +0,0 @@
/* Copyright (c) 2011-2012,2014 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef LOC_ENG_DATA_SERVER_H
#define LOC_ENG_DATA_SERVER_H
#include "loc_eng_dmn_conn_thread_helper.h"
#ifdef _ANDROID_
#define GPSONE_LOC_API_Q_PATH "/data/misc/location/gpsone_d/gpsone_loc_api_q"
#define GPSONE_LOC_API_RESP_Q_PATH "/data/misc/location/gpsone_d/gpsone_loc_api_resp_q"
#define QUIPC_CTRL_Q_PATH "/data/misc/location/gpsone_d/quipc_ctrl_q"
#define MSAPM_CTRL_Q_PATH "/data/misc/location/gpsone_d/msapm_ctrl_q"
#define MSAPU_CTRL_Q_PATH "/data/misc/location/gpsone_d/msapu_ctrl_q"
#else
#define GPSONE_LOC_API_Q_PATH "/tmp/gpsone_loc_api_q"
#define GPSONE_LOC_API_RESP_Q_PATH "/tmp/gpsone_loc_api_resp_q"
#define QUIPC_CTRL_Q_PATH "/tmp/quipc_ctrl_q"
#define MSAPM_CTRL_Q_PATH "/tmp/msapm_ctrl_q"
#define MSAPU_CTRL_Q_PATH "/tmp/msapu_ctrl_q"
#endif
int loc_eng_dmn_conn_loc_api_server_launch(thelper_create_thread create_thread_cb,
const char * loc_api_q_path, const char * ctrl_q_path, void *agps_handle);
int loc_eng_dmn_conn_loc_api_server_unblock(void);
int loc_eng_dmn_conn_loc_api_server_join(void);
int loc_eng_dmn_conn_loc_api_server_data_conn(int, int);
#endif /* LOC_ENG_DATA_SERVER_H */

View file

@ -1,222 +0,0 @@
/* Copyright (c) 2011,2014 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <linux/stat.h>
#include <fcntl.h>
#include <linux/types.h>
#include <platform_lib_includes.h>
#include "loc_eng_dmn_conn_glue_msg.h"
#include "loc_eng_dmn_conn_handler.h"
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_msgget
DESCRIPTION
This function get a message queue
q_path - name path of the message queue
mode -
DEPENDENCIES
None
RETURN VALUE
message queue id
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_glue_msgget(const char * q_path, int mode)
{
int msgqid;
msgqid = loc_eng_dmn_conn_glue_pipeget(q_path, mode);
return msgqid;
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_msgremove
DESCRIPTION
remove a message queue
q_path - name path of the message queue
msgqid - message queue id
DEPENDENCIES
None
RETURN VALUE
0: success or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_glue_msgremove(const char * q_path, int msgqid)
{
int result;
result = loc_eng_dmn_conn_glue_piperemove(q_path, msgqid);
return result;
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_msgsnd
DESCRIPTION
Send a message
msgqid - message queue id
msgp - pointer to the message to be sent
msgsz - size of the message
DEPENDENCIES
None
RETURN VALUE
number of bytes sent out or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_glue_msgsnd(int msgqid, const void * msgp, size_t msgsz)
{
int result;
struct ctrl_msgbuf *pmsg = (struct ctrl_msgbuf *) msgp;
pmsg->msgsz = msgsz;
result = loc_eng_dmn_conn_glue_pipewrite(msgqid, msgp, msgsz);
if (result != (int) msgsz) {
LOC_LOGE("%s:%d] pipe broken %d, msgsz = %d\n", __func__, __LINE__, result, (int) msgsz);
return -1;
}
return result;
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_msgrcv
DESCRIPTION
receive a message
msgqid - message queue id
msgp - pointer to the buffer to hold the message
msgsz - size of the buffer
DEPENDENCIES
None
RETURN VALUE
number of bytes received or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_glue_msgrcv(int msgqid, void *msgp, size_t msgbufsz)
{
int result;
struct ctrl_msgbuf *pmsg = (struct ctrl_msgbuf *) msgp;
result = loc_eng_dmn_conn_glue_piperead(msgqid, &(pmsg->msgsz), sizeof(pmsg->msgsz));
if (result != sizeof(pmsg->msgsz)) {
LOC_LOGE("%s:%d] pipe broken %d\n", __func__, __LINE__, result);
return -1;
}
if (msgbufsz < pmsg->msgsz) {
LOC_LOGE("%s:%d] msgbuf is too small %d < %d\n", __func__, __LINE__, (int) msgbufsz, (int) pmsg->msgsz);
return -1;
}
result = loc_eng_dmn_conn_glue_piperead(msgqid, (uint8_t *) msgp + sizeof(pmsg->msgsz), pmsg->msgsz - sizeof(pmsg->msgsz));
if (result != (int) (pmsg->msgsz - sizeof(pmsg->msgsz))) {
LOC_LOGE("%s:%d] pipe broken %d, msgsz = %d\n", __func__, __LINE__, result, (int) pmsg->msgsz);
return -1;
}
return pmsg->msgsz;
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_msgunblock
DESCRIPTION
unblock a message queue
msgqid - message queue id
DEPENDENCIES
None
RETURN VALUE
0: success
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_glue_msgunblock(int msgqid)
{
return loc_eng_dmn_conn_glue_pipeunblock(msgqid);
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_msgflush
DESCRIPTION
flush out the message in a queue
msgqid - message queue id
DEPENDENCIES
None
RETURN VALUE
number of bytes that are flushed out.
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_glue_msgflush(int msgqid)
{
int length;
char buf[128];
do {
length = loc_eng_dmn_conn_glue_piperead(msgqid, buf, 128);
LOC_LOGD("%s:%d] %s\n", __func__, __LINE__, buf);
} while(length);
return length;
}

View file

@ -1,51 +0,0 @@
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef LOC_ENG_DMN_CONN_GLUE_MSG_H
#define LOC_ENG_DMN_CONN_GLUE_MSG_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <linux/types.h>
#include "loc_eng_dmn_conn_glue_pipe.h"
int loc_eng_dmn_conn_glue_msgget(const char * q_path, int mode);
int loc_eng_dmn_conn_glue_msgremove(const char * q_path, int msgqid);
int loc_eng_dmn_conn_glue_msgsnd(int msgqid, const void * msgp, size_t msgsz);
int loc_eng_dmn_conn_glue_msgrcv(int msgqid, void *msgp, size_t msgsz);
int loc_eng_dmn_conn_glue_msgflush(int msgqid);
int loc_eng_dmn_conn_glue_msgunblock(int msgqid);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* LOC_ENG_DMN_CONN_GLUE_MSG_H */

View file

@ -1,215 +0,0 @@
/* Copyright (c) 2011-2012,2014 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <string.h>
#include <unistd.h>
#include <errno.h>
// #include <linux/stat.h>
#include <fcntl.h>
// #include <linux/types.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "loc_eng_dmn_conn_glue_pipe.h"
#include <platform_lib_includes.h>
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_pipeget
DESCRIPTION
create a named pipe.
pipe_name - pipe name path
mode - mode
DEPENDENCIES
None
RETURN VALUE
0: success or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_glue_pipeget(const char * pipe_name, int mode)
{
int fd;
int result;
LOC_LOGD("%s, mode = %d\n", pipe_name, mode);
result = mkfifo(pipe_name, 0660);
if ((result == -1) && (errno != EEXIST)) {
LOC_LOGE("failed: %s\n", strerror(errno));
return result;
}
// The mode in mkfifo is not honoured and does not provide the
// group permissions. Doing chmod to add group permissions.
result = chmod (pipe_name, 0660);
if (result != 0){
LOC_LOGE ("%s failed to change mode for %s, error = %s\n", __func__,
pipe_name, strerror(errno));
}
fd = open(pipe_name, mode);
if (fd <= 0)
{
LOC_LOGE("failed: %s\n", strerror(errno));
}
LOC_LOGD("fd = %d, %s\n", fd, pipe_name);
return fd;
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_piperemove
DESCRIPTION
remove a pipe
pipe_name - pipe name path
fd - fd for the pipe
DEPENDENCIES
None
RETURN VALUE
0: success
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_glue_piperemove(const char * pipe_name, int fd)
{
close(fd);
if (pipe_name != NULL) {
unlink(pipe_name);
LOC_LOGD("fd = %d, %s\n", fd, pipe_name);
}
return 0;
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_pipewrite
DESCRIPTION
write to a pipe
fd - fd of a pipe
buf - buffer for the data to write
sz - size of the data in buffer
DEPENDENCIES
None
RETURN VALUE
number of bytes written or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_glue_pipewrite(int fd, const void * buf, size_t sz)
{
int result;
result = write(fd, buf, sz);
/* @todo check for non EINTR & EAGAIN, shall not do select again, select_tut Law 7) */
/* LOC_LOGD("fd = %d, buf = 0x%lx, size = %d, result = %d\n", fd, (long) buf, (int) sz, (int) result); */
return result;
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_piperead
DESCRIPTION
read from a pipe
fd - fd for the pipe
buf - buffer to hold the data read from pipe
sz - size of the buffer
DEPENDENCIES
None
RETURN VALUE
number of bytes read from pipe or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_glue_piperead(int fd, void * buf, size_t sz)
{
int len;
len = read(fd, buf, sz);
/* @todo check for non EINTR & EAGAIN, shall not do select again, select_tut Law 7) */
/* LOC_LOGD("fd = %d, buf = 0x%lx, size = %d, len = %d\n", fd, (long) buf, (int) sz, len); */
return len;
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_pipeunblock
DESCRIPTION
unblock a pipe
fd - fd for the pipe
DEPENDENCIES
None
RETURN VALUE
0 for success or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_glue_pipeunblock(int fd)
{
int result;
struct flock flock_v;
LOC_LOGD("\n");
// result = fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NDELAY);
flock_v.l_type = F_UNLCK;
flock_v.l_len = 32;
result = fcntl(fd, F_SETLK, &flock_v);
if (result < 0) {
LOC_LOGE("fcntl failure, %s\n", strerror(errno));
}
return result;
}

View file

@ -1,50 +0,0 @@
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef LOC_ENG_DMN_CONN_GLUE_PIPE_H
#define LOC_ENG_DMN_CONN_GLUE_PIPE_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <linux/types.h>
int loc_eng_dmn_conn_glue_pipeget(const char * pipe_name, int mode);
int loc_eng_dmn_conn_glue_piperemove(const char * pipe_name, int fd);
int loc_eng_dmn_conn_glue_pipewrite(int fd, const void * buf, size_t sz);
int loc_eng_dmn_conn_glue_piperead(int fd, void * buf, size_t sz);
int loc_eng_dmn_conn_glue_pipeflush(int fd);
int loc_eng_dmn_conn_glue_pipeunblock(int fd);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* LOC_ENG_DMN_CONN_GLUE_PIPE_H */

View file

@ -1,236 +0,0 @@
/* Copyright (c) 2011-2012,2014 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <platform_lib_includes.h>
#include "loc_eng_msg.h"
#include "loc_eng_dmn_conn.h"
#include "loc_eng_dmn_conn_handler.h"
void* loc_api_handle = NULL;
int loc_eng_dmn_conn_loc_api_server_if_request_handler(struct ctrl_msgbuf *pmsg, int len)
{
LOC_LOGD("%s:%d]\n", __func__, __LINE__);
#ifndef DEBUG_DMN_LOC_API
if (NULL == loc_api_handle) {
LOC_LOGE("%s:%d] NO agps data handle\n", __func__, __LINE__);
return 1;
}
if (NULL != loc_api_handle) {
AGpsExtType type;
switch (pmsg->cmsg.cmsg_if_request.type) {
case IF_REQUEST_TYPE_SUPL:
{
LOC_LOGD("IF_REQUEST_TYPE_SUPL");
type = LOC_AGPS_TYPE_SUPL;
break;
}
case IF_REQUEST_TYPE_WIFI:
{
LOC_LOGD("IF_REQUEST_TYPE_WIFI");
type = LOC_AGPS_TYPE_WIFI;
break;
}
case IF_REQUEST_TYPE_ANY:
{
LOC_LOGD("IF_REQUEST_TYPE_ANY");
type = LOC_AGPS_TYPE_ANY;
break;
}
default:
{
LOC_LOGD("invalid IF_REQUEST_TYPE!");
return -1;
}
}
switch (pmsg->cmsg.cmsg_if_request.sender_id) {
case IF_REQUEST_SENDER_ID_QUIPC:
{
LOC_LOGD("IF_REQUEST_SENDER_ID_QUIPC");
LocEngReqRelWifi* msg =
new LocEngReqRelWifi(loc_api_handle,
type,
LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC,
(char*)pmsg->cmsg.cmsg_if_request.ssid,
(char*)pmsg->cmsg.cmsg_if_request.password,
true);
msg->send();
break;
}
case IF_REQUEST_SENDER_ID_MSAPM:
{
LOC_LOGD("IF_REQUEST_SENDER_ID_MSAPM");
LocEngReqRelWifi* msg =
new LocEngReqRelWifi(loc_api_handle,
type,
LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM,
(char*)pmsg->cmsg.cmsg_if_request.ssid,
(char*)pmsg->cmsg.cmsg_if_request.password,
true);
msg->send();
break;
}
case IF_REQUEST_SENDER_ID_MSAPU:
{
LOC_LOGD("IF_REQUEST_SENDER_ID_MSAPU");
LocEngReqRelWifi* msg =
new LocEngReqRelWifi(loc_api_handle,
type,
LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU,
(char*)pmsg->cmsg.cmsg_if_request.ssid,
(char*)pmsg->cmsg.cmsg_if_request.password,
true);
msg->send();
break;
}
case IF_REQUEST_SENDER_ID_GPSONE_DAEMON:
{
LOC_LOGD("IF_REQUEST_SENDER_ID_GPSONE_DAEMON");
LocEngReqRelBIT* msg =
new LocEngReqRelBIT(loc_api_handle,
type,
pmsg->cmsg.cmsg_if_request.ipv4_addr,
(char*)pmsg->cmsg.cmsg_if_request.ipv6_addr,
true);
msg->send();
break;
}
default:
{
LOC_LOGD("invalid IF_REQUEST_SENDER_ID!");
return -1;
}
}
}
#else
loc_eng_dmn_conn_loc_api_server_data_conn(LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON, GPSONE_LOC_API_IF_REQUEST_SUCCESS);
#endif
return 0;
}
int loc_eng_dmn_conn_loc_api_server_if_release_handler(struct ctrl_msgbuf *pmsg, int len)
{
LOC_LOGD("%s:%d]\n", __func__, __LINE__);
#ifndef DEBUG_DMN_LOC_API
AGpsExtType type;
switch (pmsg->cmsg.cmsg_if_request.type) {
case IF_REQUEST_TYPE_SUPL:
{
LOC_LOGD("IF_REQUEST_TYPE_SUPL");
type = LOC_AGPS_TYPE_SUPL;
break;
}
case IF_REQUEST_TYPE_WIFI:
{
LOC_LOGD("IF_REQUEST_TYPE_WIFI");
type = LOC_AGPS_TYPE_WIFI;
break;
}
case IF_REQUEST_TYPE_ANY:
{
LOC_LOGD("IF_REQUEST_TYPE_ANY");
type = LOC_AGPS_TYPE_ANY;
break;
}
default:
{
LOC_LOGD("invalid IF_REQUEST_TYPE!");
return -1;
}
}
switch (pmsg->cmsg.cmsg_if_request.sender_id) {
case IF_REQUEST_SENDER_ID_QUIPC:
{
LOC_LOGD("IF_REQUEST_SENDER_ID_QUIPC");
LocEngReqRelWifi* msg =
new LocEngReqRelWifi(loc_api_handle,
type,
LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC,
(char*)pmsg->cmsg.cmsg_if_request.ssid,
(char*)pmsg->cmsg.cmsg_if_request.password,
false);
msg->send();
break;
}
case IF_REQUEST_SENDER_ID_MSAPM:
{
LOC_LOGD("IF_REQUEST_SENDER_ID_MSAPM");
LocEngReqRelWifi* msg =
new LocEngReqRelWifi(loc_api_handle,
type,
LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM,
(char*)pmsg->cmsg.cmsg_if_request.ssid,
(char*)pmsg->cmsg.cmsg_if_request.password,
false);
msg->send();
break;
}
case IF_REQUEST_SENDER_ID_MSAPU:
{
LOC_LOGD("IF_REQUEST_SENDER_ID_MSAPU");
LocEngReqRelWifi* msg =
new LocEngReqRelWifi(loc_api_handle,
type,
LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU,
(char*)pmsg->cmsg.cmsg_if_request.ssid,
(char*)pmsg->cmsg.cmsg_if_request.password,
false);
msg->send();
break;
}
case IF_REQUEST_SENDER_ID_GPSONE_DAEMON:
{
LOC_LOGD("IF_REQUEST_SENDER_ID_GPSONE_DAEMON");
LocEngReqRelBIT* msg =
new LocEngReqRelBIT(loc_api_handle,
type,
pmsg->cmsg.cmsg_if_request.ipv4_addr,
(char*)pmsg->cmsg.cmsg_if_request.ipv6_addr,
false);
msg->send();
break;
}
default:
{
LOC_LOGD("invalid IF_REQUEST_SENDER_ID!");
return -1;
}
}
#else
loc_eng_dmn_conn_loc_api_server_data_conn(LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON, GPSONE_LOC_API_IF_RELEASE_SUCCESS);
#endif
return 0;
}

View file

@ -1,104 +0,0 @@
/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef LOC_ENG_DATA_SERVER_HANDLER
#define LOC_ENG_DATA_SERVER_HANDLER
#include <linux/types.h>
#include <arpa/inet.h>
//for SSID_BUF_SIZE
#ifndef SSID_BUF_SIZE
#define SSID_BUF_SIZE (32+1)
#endif
enum {
/* 0x0 - 0xEF is reserved for daemon internal */
GPSONE_LOC_API_IF_REQUEST = 0xF0,
GPSONE_LOC_API_IF_RELEASE,
GPSONE_LOC_API_RESPONSE,
GPSONE_UNBLOCK,
};
enum {
GPSONE_LOC_API_IF_REQUEST_SUCCESS = 0xF0,
GPSONE_LOC_API_IF_RELEASE_SUCCESS,
GPSONE_LOC_API_IF_FAILURE,
};
struct ctrl_msg_response {
int result;
};
struct ctrl_msg_unblock {
int reserved;
};
typedef enum {
IF_REQUEST_TYPE_SUPL = 0,
IF_REQUEST_TYPE_WIFI,
IF_REQUEST_TYPE_ANY
} ctrl_if_req_type_e_type;
typedef enum {
IF_REQUEST_SENDER_ID_QUIPC = 0,
IF_REQUEST_SENDER_ID_MSAPM,
IF_REQUEST_SENDER_ID_MSAPU,
IF_REQUEST_SENDER_ID_GPSONE_DAEMON,
IF_REQUEST_SENDER_ID_MODEM
} ctrl_if_req_sender_id_e_type;
struct ctrl_msg_if_request {
ctrl_if_req_type_e_type type;
ctrl_if_req_sender_id_e_type sender_id;
unsigned long ipv4_addr;
unsigned char ipv6_addr[16];
char ssid[SSID_BUF_SIZE];
char password[SSID_BUF_SIZE];
};
/* do not change this structure */
struct ctrl_msgbuf {
size_t msgsz;
uint16_t reserved1;
uint32_t reserved2;
uint8_t ctrl_type;
union {
struct ctrl_msg_response cmsg_response;
struct ctrl_msg_unblock cmsg_unblock;
struct ctrl_msg_if_request cmsg_if_request;
} cmsg;
};
extern void* loc_api_handle;
int loc_eng_dmn_conn_loc_api_server_if_request_handler(struct ctrl_msgbuf *pmsg, int len);
int loc_eng_dmn_conn_loc_api_server_if_release_handler(struct ctrl_msgbuf *pmsg, int len);
#endif /* LOC_ENG_DATA_SERVER_HANDLER */

View file

@ -1,398 +0,0 @@
/* Copyright (c) 2011,2014 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <stdio.h>
#include <platform_lib_includes.h>
#include "loc_eng_dmn_conn_thread_helper.h"
/*===========================================================================
FUNCTION thelper_signal_init
DESCRIPTION
This function will initialize the conditional variable resources.
thelper - thelper instance
DEPENDENCIES
None
RETURN VALUE
0: success or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int thelper_signal_init(struct loc_eng_dmn_conn_thelper * thelper)
{
int result;
thelper->thread_exit = 0;
thelper->thread_ready = 0;
result = pthread_cond_init( &thelper->thread_cond, NULL);
if (result) {
return result;
}
result = pthread_mutex_init(&thelper->thread_mutex, NULL);
if (result) {
pthread_cond_destroy(&thelper->thread_cond);
}
return result;
}
/*===========================================================================
FUNCTION
DESCRIPTION
This function will destroy the conditional variable resources
thelper - pointer to thelper instance
DEPENDENCIES
None
RETURN VALUE
0: success or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int thelper_signal_destroy(struct loc_eng_dmn_conn_thelper * thelper)
{
int result, ret_result = 0;
result = pthread_cond_destroy( &thelper->thread_cond);
if (result) {
ret_result = result;
}
result = pthread_mutex_destroy(&thelper->thread_mutex);
if (result) {
ret_result = result;
}
return ret_result;
}
/*===========================================================================
FUNCTION thelper_signal_wait
DESCRIPTION
This function will be blocked on the conditional variable until thelper_signal_ready
is called
thelper - pointer to thelper instance
DEPENDENCIES
None
RETURN VALUE
0: success or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int thelper_signal_wait(struct loc_eng_dmn_conn_thelper * thelper)
{
int result = 0;
pthread_mutex_lock(&thelper->thread_mutex);
if (!thelper->thread_ready && !thelper->thread_exit) {
result = pthread_cond_wait(&thelper->thread_cond, &thelper->thread_mutex);
}
if (thelper->thread_exit) {
result = -1;
}
pthread_mutex_unlock(&thelper->thread_mutex);
return result;
}
/*===========================================================================
FUNCTION thelper_signal_ready
DESCRIPTION
This function will wake up the conditional variable
thelper - pointer to thelper instance
DEPENDENCIES
None
RETURN VALUE
0: success or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int thelper_signal_ready(struct loc_eng_dmn_conn_thelper * thelper)
{
int result;
LOC_LOGD("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper);
pthread_mutex_lock(&thelper->thread_mutex);
thelper->thread_ready = 1;
result = pthread_cond_signal(&thelper->thread_cond);
pthread_mutex_unlock(&thelper->thread_mutex);
return result;
}
/*===========================================================================
FUNCTION thelper_signal_block
DESCRIPTION
This function will set the thread ready to 0 to block the thelper_signal_wait
thelper - pointer to thelper instance
DEPENDENCIES
None
RETURN VALUE
if thread_ready is set
SIDE EFFECTS
N/A
===========================================================================*/
int thelper_signal_block(struct loc_eng_dmn_conn_thelper * thelper)
{
int result = thelper->thread_ready;
LOC_LOGD("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper);
pthread_mutex_lock(&thelper->thread_mutex);
thelper->thread_ready = 0;
pthread_mutex_unlock(&thelper->thread_mutex);
return result;
}
/*===========================================================================
FUNCTION thelper_main
DESCRIPTION
This function is the main thread. It will be launched as a child thread
data - pointer to the instance
DEPENDENCIES
None
RETURN VALUE
NULL
SIDE EFFECTS
N/A
===========================================================================*/
static void * thelper_main(void *data)
{
int result = 0;
struct loc_eng_dmn_conn_thelper * thelper = (struct loc_eng_dmn_conn_thelper *) data;
if (thelper->thread_proc_init) {
result = thelper->thread_proc_init(thelper->thread_context);
if (result < 0) {
thelper->thread_exit = 1;
thelper_signal_ready(thelper);
LOC_LOGE("%s:%d] error: 0x%lx\n", __func__, __LINE__, (long) thelper);
return NULL;
}
}
thelper_signal_ready(thelper);
if (thelper->thread_proc_pre) {
result = thelper->thread_proc_pre(thelper->thread_context);
if (result < 0) {
thelper->thread_exit = 1;
LOC_LOGE("%s:%d] error: 0x%lx\n", __func__, __LINE__, (long) thelper);
return NULL;
}
}
do {
if (thelper->thread_proc) {
result = thelper->thread_proc(thelper->thread_context);
if (result < 0) {
thelper->thread_exit = 1;
LOC_LOGE("%s:%d] error: 0x%lx\n", __func__, __LINE__, (long) thelper);
}
}
} while (thelper->thread_exit == 0);
if (thelper->thread_proc_post) {
result = thelper->thread_proc_post(thelper->thread_context);
}
if (result != 0) {
LOC_LOGE("%s:%d] error: 0x%lx\n", __func__, __LINE__, (long) thelper);
}
return NULL;
}
static void thelper_main_2(void *data)
{
thelper_main(data);
return;
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_launch_thelper
DESCRIPTION
This function will initialize the thread context and launch the thelper_main
thelper - pointer to thelper instance
thread_proc_init - The initialization function pointer
thread_proc_pre - The function to call before task loop and after initialization
thread_proc - The task loop
thread_proc_post - The function to call after the task loop
context - the context for the above four functions
DEPENDENCIES
None
RETURN VALUE
0: success or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_launch_thelper(struct loc_eng_dmn_conn_thelper * thelper,
int (*thread_proc_init) (void * context),
int (*thread_proc_pre) (void * context),
int (*thread_proc) (void * context),
int (*thread_proc_post) (void * context),
thelper_create_thread create_thread_cb,
void * context)
{
int result;
thelper_signal_init(thelper);
if (context) {
thelper->thread_context = context;
}
thelper->thread_proc_init = thread_proc_init;
thelper->thread_proc_pre = thread_proc_pre;
thelper->thread_proc = thread_proc;
thelper->thread_proc_post = thread_proc_post;
LOC_LOGD("%s:%d] 0x%lx call pthread_create\n", __func__, __LINE__, (long) thelper);
if (create_thread_cb) {
result = 0;
thelper->thread_id = create_thread_cb("loc_eng_dmn_conn",
thelper_main_2, (void *)thelper);
} else {
result = pthread_create(&thelper->thread_id, NULL,
thelper_main, (void *)thelper);
}
if (result != 0) {
LOC_LOGE("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper);
return -1;
}
LOC_LOGD("%s:%d] 0x%lx pthread_create done\n", __func__, __LINE__, (long) thelper);
thelper_signal_wait(thelper);
LOC_LOGD("%s:%d] 0x%lx pthread ready\n", __func__, __LINE__, (long) thelper);
return thelper->thread_exit;
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_unblock_thelper
DESCRIPTION
This function unblocks thelper_main to release the thread
thelper - pointer to thelper instance
DEPENDENCIES
None
RETURN VALUE
0: success
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_unblock_thelper(struct loc_eng_dmn_conn_thelper * thelper)
{
LOC_LOGD("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper);
thelper->thread_exit = 1;
return 0;
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_join_thelper
thelper - pointer to thelper instance
DESCRIPTION
This function will wait for the thread of thelper_main to finish
DEPENDENCIES
None
RETURN VALUE
0: success or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_join_thelper(struct loc_eng_dmn_conn_thelper * thelper)
{
int result;
LOC_LOGD("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper);
result = pthread_join(thelper->thread_id, NULL);
if (result != 0) {
LOC_LOGE("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper);
}
LOC_LOGD("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper);
thelper_signal_destroy(thelper);
return result;
}

View file

@ -1,74 +0,0 @@
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __LOC_ENG_DMN_CONN_THREAD_HELPER_H__
#define __LOC_ENG_DMN_CONN_THREAD_HELPER_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <pthread.h>
struct loc_eng_dmn_conn_thelper {
unsigned char thread_exit;
unsigned char thread_ready;
pthread_cond_t thread_cond;
pthread_mutex_t thread_mutex;
pthread_t thread_id;
void * thread_context;
int (*thread_proc_init) (void * context);
int (*thread_proc_pre) (void * context);
int (*thread_proc) (void * context);
int (*thread_proc_post) (void * context);
};
typedef pthread_t (* thelper_create_thread)(const char* name, void (*start)(void *), void* arg);
int loc_eng_dmn_conn_launch_thelper(struct loc_eng_dmn_conn_thelper * thelper,
int (*thread_proc_init) (void * context),
int (*thread_proc_pre) (void * context),
int (*thread_proc) (void * context),
int (*thread_proc_post) (void * context),
thelper_create_thread create_thread_cb,
void * context);
int loc_eng_dmn_conn_unblock_thelper(struct loc_eng_dmn_conn_thelper * thelper);
int loc_eng_dmn_conn_join_thelper(struct loc_eng_dmn_conn_thelper * thelper);
/* if only need to use signal */
int thelper_signal_init(struct loc_eng_dmn_conn_thelper * thelper);
int thelper_signal_destroy(struct loc_eng_dmn_conn_thelper * thelper);
int thelper_signal_wait(struct loc_eng_dmn_conn_thelper * thelper);
int thelper_signal_ready(struct loc_eng_dmn_conn_thelper * thelper);
int thelper_signal_block(struct loc_eng_dmn_conn_thelper * thelper);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __LOC_ENG_DMN_CONN_THREAD_HELPER_H__ */

View file

@ -1,35 +0,0 @@
/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#define LOG_NDDEBUG 0
#define LOG_TAG "LocSvc_eng"
#include "loc_log.h"
#include "loc_eng_log.h"

View file

@ -1,305 +0,0 @@
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef LOC_ENG_MSG_H
#define LOC_ENG_MSG_H
#include <gps_extended.h>
#include <stdlib.h>
#include <string.h>
#include <loc_eng_log.h>
#include <loc_eng.h>
#include <MsgTask.h>
#include <LocEngAdapter.h>
#include <platform_lib_includes.h>
#ifndef SSID_BUF_SIZE
#define SSID_BUF_SIZE (32+1)
#endif
#if defined(USE_GLIB) && !defined(OFF_TARGET)
#include <glib.h>
#endif /* USE_GLIB */
#include "platform_lib_includes.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
using namespace loc_core;
struct LocEngPositionMode : public LocMsg {
LocEngAdapter* mAdapter;
const LocPosMode mPosMode;
LocEngPositionMode(LocEngAdapter* adapter, LocPosMode &mode);
virtual void proc() const;
virtual void log() const;
void send() const;
};
struct LocEngStartFix : public LocMsg {
LocEngAdapter* mAdapter;
LocEngStartFix(LocEngAdapter* adapter);
virtual void proc() const;
void locallog() const;
virtual void log() const;
void send() const;
};
struct LocEngStopFix : public LocMsg {
LocEngAdapter* mAdapter;
LocEngStopFix(LocEngAdapter* adapter);
virtual void proc() const;
void locallog() const;
virtual void log() const;
void send() const;
};
struct LocEngReportPosition : public LocMsg {
LocAdapterBase* mAdapter;
const UlpLocation mLocation;
const GpsLocationExtended mLocationExtended;
const void* mLocationExt;
const enum loc_sess_status mStatus;
const LocPosTechMask mTechMask;
LocEngReportPosition(LocAdapterBase* adapter,
UlpLocation &loc,
GpsLocationExtended &locExtended,
void* locExt,
enum loc_sess_status st,
LocPosTechMask technology);
virtual void proc() const;
void locallog() const;
virtual void log() const;
void send() const;
};
struct LocEngReportSv : public LocMsg {
LocAdapterBase* mAdapter;
const LocGnssSvStatus mSvStatus;
const GpsLocationExtended mLocationExtended;
const void* mSvExt;
LocEngReportSv(LocAdapterBase* adapter,
LocGnssSvStatus &sv,
GpsLocationExtended &locExtended,
void* svExtended);
virtual void proc() const;
void locallog() const;
virtual void log() const;
void send() const;
};
struct LocEngReportStatus : public LocMsg {
LocAdapterBase* mAdapter;
const LocGpsStatusValue mStatus;
LocEngReportStatus(LocAdapterBase* adapter,
LocGpsStatusValue engineStatus);
virtual void proc() const;
void locallog() const;
virtual void log() const;
};
struct LocEngReportNmea : public LocMsg {
void* mLocEng;
char* const mNmea;
const int mLen;
LocEngReportNmea(void* locEng,
const char* data, int len);
inline virtual ~LocEngReportNmea()
{
delete[] mNmea;
}
virtual void proc() const;
void locallog() const;
virtual void log() const;
};
struct LocEngReportXtraServer : public LocMsg {
void* mLocEng;
int mMaxLen;
char *mServers;
LocEngReportXtraServer(void* locEng,
const char *url1, const char *url2,
const char *url3, const int maxlength);
inline virtual ~LocEngReportXtraServer()
{
delete[] mServers;
}
virtual void proc() const;
void locallog() const;
virtual void log() const;
};
struct LocEngSuplEsOpened : public LocMsg {
void* mLocEng;
LocEngSuplEsOpened(void* locEng);
virtual void proc() const;
void locallog() const;
virtual void log() const;
};
struct LocEngSuplEsClosed : public LocMsg {
void* mLocEng;
LocEngSuplEsClosed(void* locEng);
virtual void proc() const;
void locallog() const;
virtual void log() const;
};
struct LocEngRequestSuplEs : public LocMsg {
void* mLocEng;
const int mID;
LocEngRequestSuplEs(void* locEng, int id);
virtual void proc() const;
void locallog() const;
virtual void log() const;
};
struct LocEngRequestATL : public LocMsg {
void* mLocEng;
const int mID;
const AGpsExtType mType;
LocEngRequestATL(void* locEng, int id,
AGpsExtType agps_type);
virtual void proc() const;
void locallog() const;
virtual void log() const;
};
struct LocEngReleaseATL : public LocMsg {
void* mLocEng;
const int mID;
LocEngReleaseATL(void* locEng, int id);
virtual void proc() const;
void locallog() const;
virtual void log() const;
};
struct LocEngReqRelBIT : public LocMsg {
void* mLocEng;
const AGpsExtType mType;
const int mIPv4Addr;
char* const mIPv6Addr;
const bool mIsReq;
LocEngReqRelBIT(void* instance, AGpsExtType type,
int ipv4, char* ipv6, bool isReq);
virtual ~LocEngReqRelBIT();
virtual void proc() const;
void locallog() const;
virtual void log() const;
void send() const;
};
struct LocEngReqRelWifi : public LocMsg {
void* mLocEng;
const AGpsExtType mType;
const loc_if_req_sender_id_e_type mSenderId;
char* const mSSID;
char* const mPassword;
const bool mIsReq;
LocEngReqRelWifi(void* locEng, AGpsExtType type,
loc_if_req_sender_id_e_type sender_id,
char* s, char* p, bool isReq);
virtual ~LocEngReqRelWifi();
virtual void proc() const;
void locallog() const;
virtual void log() const;
void send() const;
};
struct LocEngRequestXtra : public LocMsg {
void* mLocEng;
LocEngRequestXtra(void* locEng);
virtual void proc() const;
void locallog() const;
virtual void log() const;
};
struct LocEngRequestTime : public LocMsg {
void* mLocEng;
LocEngRequestTime(void* locEng);
virtual void proc() const;
void locallog() const;
virtual void log() const;
};
struct LocEngRequestNi : public LocMsg {
void* mLocEng;
const LocGpsNiNotification mNotify;
const void *mPayload;
LocEngRequestNi(void* locEng,
LocGpsNiNotification &notif,
const void* data);
virtual void proc() const;
void locallog() const;
virtual void log() const;
};
struct LocEngDown : public LocMsg {
void* mLocEng;
LocEngDown(void* locEng);
virtual void proc() const;
void locallog() const;
virtual void log() const;
};
struct LocEngUp : public LocMsg {
void* mLocEng;
LocEngUp(void* locEng);
virtual void proc() const;
void locallog() const;
virtual void log() const;
};
struct LocEngGetZpp : public LocMsg {
LocEngAdapter* mAdapter;
LocEngGetZpp(LocEngAdapter* adapter);
virtual void proc() const;
void locallog() const;
virtual void log() const;
void send() const;
};
struct LocEngReportGnssMeasurement : public LocMsg {
void* mLocEng;
const LocGnssData mGnssData;
LocEngReportGnssMeasurement(void* locEng,
LocGnssData &gnssData);
virtual void proc() const;
void locallog() const;
virtual void log() const;
};
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* LOC_ENG_MSG_H */

View file

@ -1,413 +0,0 @@
/* Copyright (c) 2009-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#define LOG_NDDEBUG 0
#define LOG_TAG "LocSvc_eng"
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <pthread.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <time.h>
#include <MsgTask.h>
#include <loc_eng.h>
#include <platform_lib_includes.h>
using namespace loc_core;
/*=============================================================================
*
* DATA DECLARATION
*
*============================================================================*/
/*=============================================================================
*
* FUNCTION DECLARATIONS
*
*============================================================================*/
static void* ni_thread_proc(void *args);
struct LocEngInformNiResponse : public LocMsg {
LocEngAdapter* mAdapter;
const LocGpsUserResponseType mResponse;
const void *mPayload;
inline LocEngInformNiResponse(LocEngAdapter* adapter,
LocGpsUserResponseType resp,
const void* data) :
LocMsg(), mAdapter(adapter),
mResponse(resp), mPayload(data)
{
locallog();
}
inline ~LocEngInformNiResponse()
{
// this is a bit weird since mPayload is not
// allocated by this class. But there is no better way.
// mPayload actually won't be NULL here.
free((void*)mPayload);
}
inline virtual void proc() const
{
mAdapter->informNiResponse(mResponse, mPayload);
}
inline void locallog() const
{
LOC_LOGV("LocEngInformNiResponse - "
"response: %s\n mPayload: %p",
loc_get_ni_response_name(mResponse),
mPayload);
}
inline virtual void log() const
{
locallog();
}
};
/*===========================================================================
FUNCTION loc_eng_ni_request_handler
DESCRIPTION
Displays the NI request and awaits user input. If a previous request is
in session, it is ignored.
RETURN VALUE
none
===========================================================================*/
void loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data,
const LocGpsNiNotification *notif,
const void* passThrough)
{
ENTRY_LOG();
char lcs_addr[32]; // Decoded LCS address for UMTS CP NI
loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data;
loc_eng_ni_session_s_type* pSession = NULL;
if (NULL == loc_eng_data.ni_notify_cb) {
EXIT_LOG(%s, "loc_eng_ni_init hasn't happened yet.");
return;
}
if (notif->ni_type == LOC_GPS_NI_TYPE_EMERGENCY_SUPL) {
if (NULL != loc_eng_ni_data_p->sessionEs.rawRequest) {
LOC_LOGW("loc_eng_ni_request_handler, supl es NI in progress, new supl es NI ignored, type: %d",
notif->ni_type);
if (NULL != passThrough) {
free((void*)passThrough);
}
} else {
pSession = &loc_eng_ni_data_p->sessionEs;
}
} else {
if (NULL != loc_eng_ni_data_p->session.rawRequest ||
NULL != loc_eng_ni_data_p->sessionEs.rawRequest) {
LOC_LOGW("loc_eng_ni_request_handler, supl NI in progress, new supl NI ignored, type: %d",
notif->ni_type);
if (NULL != passThrough) {
free((void*)passThrough);
}
} else {
pSession = &loc_eng_ni_data_p->session;
}
}
if (pSession) {
/* Save request */
pSession->rawRequest = (void*)passThrough;
pSession->reqID = ++loc_eng_ni_data_p->reqIDCounter;
pSession->adapter = loc_eng_data.adapter;
/* Fill in notification */
((LocGpsNiNotification*)notif)->notification_id = pSession->reqID;
if (notif->notify_flags == LOC_GPS_NI_PRIVACY_OVERRIDE)
{
loc_eng_mute_one_session(loc_eng_data);
}
/* Log requestor ID and text for debugging */
LOC_LOGI("Notification: notif_type: %d, timeout: %d, default_resp: %d", notif->ni_type, notif->timeout, notif->default_response);
LOC_LOGI(" requestor_id: %s (encoding: %d)", notif->requestor_id, notif->requestor_id_encoding);
LOC_LOGI(" text: %s text (encoding: %d)", notif->text, notif->text_encoding);
if (notif->extras[0])
{
LOC_LOGI(" extras: %s", notif->extras);
}
/* For robustness, spawn a thread at this point to timeout to clear up the notification status, even though
* the OEM layer in java does not do so.
**/
pSession->respTimeLeft = 5 + (notif->timeout != 0 ? notif->timeout : LOC_NI_NO_RESPONSE_TIME);
LOC_LOGI("Automatically sends 'no response' in %d seconds (to clear status)\n", pSession->respTimeLeft);
int rc = 0;
rc = pthread_create(&pSession->thread, NULL, ni_thread_proc, pSession);
if (rc)
{
LOC_LOGE("Loc NI thread is not created.\n");
}
rc = pthread_detach(pSession->thread);
if (rc)
{
LOC_LOGE("Loc NI thread is not detached.\n");
}
CALLBACK_LOG_CALLFLOW("ni_notify_cb - id", %d, notif->notification_id);
loc_eng_data.ni_notify_cb((LocGpsNiNotification*)notif, gps_conf.SUPL_ES != 0);
}
EXIT_LOG(%s, VOID_RET);
}
/*===========================================================================
FUNCTION ni_thread_proc
===========================================================================*/
static void* ni_thread_proc(void *args)
{
ENTRY_LOG();
loc_eng_ni_session_s_type* pSession = (loc_eng_ni_session_s_type*)args;
int rc = 0; /* return code from pthread calls */
struct timeval present_time;
struct timespec expire_time;
LOC_LOGD("Starting Loc NI thread...\n");
pthread_mutex_lock(&pSession->tLock);
/* Calculate absolute expire time */
gettimeofday(&present_time, NULL);
expire_time.tv_sec = present_time.tv_sec + pSession->respTimeLeft;
expire_time.tv_nsec = present_time.tv_usec * 1000;
LOC_LOGD("ni_thread_proc-Time out set for abs time %ld with delay %d sec\n",
(long) expire_time.tv_sec, pSession->respTimeLeft );
while (!pSession->respRecvd)
{
rc = pthread_cond_timedwait(&pSession->tCond,
&pSession->tLock,
&expire_time);
if (rc == ETIMEDOUT)
{
pSession->resp = LOC_GPS_NI_RESPONSE_NORESP;
LOC_LOGD("ni_thread_proc-Thread time out after valting for specified time. Ret Val %d\n",rc );
break;
}
}
LOC_LOGD("ni_thread_proc-Java layer has sent us a user response and return value from "
"pthread_cond_timedwait = %d\n",rc );
pSession->respRecvd = FALSE; /* Reset the user response flag for the next session*/
LOC_LOGD("pSession->resp is %d\n",pSession->resp);
// adding this check to support modem restart, in which case, we need the thread
// to exit without calling sending data. We made sure that rawRequest is NULL in
// loc_eng_ni_reset_on_engine_restart()
LocEngAdapter* adapter = pSession->adapter;
LocEngInformNiResponse *msg = NULL;
if (NULL != pSession->rawRequest) {
if (pSession->resp != LOC_GPS_NI_RESPONSE_IGNORE) {
LOC_LOGD("pSession->resp != LOC_GPS_NI_RESPONSE_IGNORE \n");
msg = new LocEngInformNiResponse(adapter,
pSession->resp,
pSession->rawRequest);
} else {
LOC_LOGD("this is the ignore reply for SUPL ES\n");
free(pSession->rawRequest);
}
pSession->rawRequest = NULL;
}
pthread_mutex_unlock(&pSession->tLock);
pSession->respTimeLeft = 0;
pSession->reqID = 0;
if (NULL != msg) {
LOC_LOGD("ni_thread_proc: adapter->sendMsg(msg)\n");
adapter->sendMsg(msg);
}
EXIT_LOG(%s, VOID_RET);
return NULL;
}
void loc_eng_ni_reset_on_engine_restart(loc_eng_data_s_type &loc_eng_data)
{
ENTRY_LOG();
loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data;
if (NULL == loc_eng_data.ni_notify_cb) {
EXIT_LOG(%s, "loc_eng_ni_init hasn't happened yet.");
return;
}
// only if modem has requested but then died.
if (NULL != loc_eng_ni_data_p->sessionEs.rawRequest) {
free(loc_eng_ni_data_p->sessionEs.rawRequest);
loc_eng_ni_data_p->sessionEs.rawRequest = NULL;
pthread_mutex_lock(&loc_eng_ni_data_p->sessionEs.tLock);
// the goal is to wake up ni_thread_proc
// and let it exit.
loc_eng_ni_data_p->sessionEs.respRecvd = TRUE;
pthread_cond_signal(&loc_eng_ni_data_p->sessionEs.tCond);
pthread_mutex_unlock(&loc_eng_ni_data_p->sessionEs.tLock);
}
if (NULL != loc_eng_ni_data_p->session.rawRequest) {
free(loc_eng_ni_data_p->session.rawRequest);
loc_eng_ni_data_p->session.rawRequest = NULL;
pthread_mutex_lock(&loc_eng_ni_data_p->session.tLock);
// the goal is to wake up ni_thread_proc
// and let it exit.
loc_eng_ni_data_p->session.respRecvd = TRUE;
pthread_cond_signal(&loc_eng_ni_data_p->session.tCond);
pthread_mutex_unlock(&loc_eng_ni_data_p->session.tLock);
}
EXIT_LOG(%s, VOID_RET);
}
/*===========================================================================
FUNCTION loc_eng_ni_init
DESCRIPTION
This function initializes the NI interface
DEPENDENCIES
NONE
RETURN VALUE
None
SIDE EFFECTS
N/A
===========================================================================*/
void loc_eng_ni_init(loc_eng_data_s_type &loc_eng_data, GpsNiExtCallbacks *callbacks)
{
ENTRY_LOG_CALLFLOW();
if(callbacks == NULL)
EXIT_LOG(%s, "loc_eng_ni_init: failed, cb is NULL");
else if (NULL == callbacks->notify_cb) {
EXIT_LOG(%s, "loc_eng_ni_init: failed, no cb.");
} else if (NULL != loc_eng_data.ni_notify_cb) {
EXIT_LOG(%s, "loc_eng_ni_init: already inited.");
} else {
loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data;
loc_eng_ni_data_p->sessionEs.respTimeLeft = 0;
loc_eng_ni_data_p->sessionEs.respRecvd = FALSE;
loc_eng_ni_data_p->sessionEs.rawRequest = NULL;
loc_eng_ni_data_p->sessionEs.reqID = 0;
pthread_cond_init(&loc_eng_ni_data_p->sessionEs.tCond, NULL);
pthread_mutex_init(&loc_eng_ni_data_p->sessionEs.tLock, NULL);
loc_eng_ni_data_p->session.respTimeLeft = 0;
loc_eng_ni_data_p->session.respRecvd = FALSE;
loc_eng_ni_data_p->session.rawRequest = NULL;
loc_eng_ni_data_p->session.reqID = 0;
pthread_cond_init(&loc_eng_ni_data_p->session.tCond, NULL);
pthread_mutex_init(&loc_eng_ni_data_p->session.tLock, NULL);
loc_eng_data.ni_notify_cb = callbacks->notify_cb;
EXIT_LOG(%s, VOID_RET);
}
}
/*===========================================================================
FUNCTION loc_eng_ni_respond
DESCRIPTION
This function receives user response from upper layer framework
DEPENDENCIES
NONE
RETURN VALUE
None
SIDE EFFECTS
N/A
===========================================================================*/
void loc_eng_ni_respond(loc_eng_data_s_type &loc_eng_data,
int notif_id, LocGpsUserResponseType user_response)
{
ENTRY_LOG_CALLFLOW();
loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data;
loc_eng_ni_session_s_type* pSession = NULL;
if (NULL == loc_eng_data.ni_notify_cb) {
EXIT_LOG(%s, "loc_eng_ni_init hasn't happened yet.");
return;
}
if (notif_id == loc_eng_ni_data_p->sessionEs.reqID &&
NULL != loc_eng_ni_data_p->sessionEs.rawRequest) {
pSession = &loc_eng_ni_data_p->sessionEs;
// ignore any SUPL NI non-Es session if a SUPL NI ES is accepted
if (user_response == LOC_GPS_NI_RESPONSE_ACCEPT &&
NULL != loc_eng_ni_data_p->session.rawRequest) {
pthread_mutex_lock(&loc_eng_ni_data_p->session.tLock);
loc_eng_ni_data_p->session.resp = LOC_GPS_NI_RESPONSE_IGNORE;
loc_eng_ni_data_p->session.respRecvd = TRUE;
pthread_cond_signal(&loc_eng_ni_data_p->session.tCond);
pthread_mutex_unlock(&loc_eng_ni_data_p->session.tLock);
}
} else if (notif_id == loc_eng_ni_data_p->session.reqID &&
NULL != loc_eng_ni_data_p->session.rawRequest) {
pSession = &loc_eng_ni_data_p->session;
}
if (pSession) {
LOC_LOGI("loc_eng_ni_respond: send user response %d for notif %d", user_response, notif_id);
pthread_mutex_lock(&pSession->tLock);
pSession->resp = user_response;
pSession->respRecvd = TRUE;
pthread_cond_signal(&pSession->tCond);
pthread_mutex_unlock(&pSession->tLock);
}
else {
LOC_LOGE("loc_eng_ni_respond: notif_id %d not an active session", notif_id);
}
EXIT_LOG(%s, VOID_RET);
}

View file

@ -1,59 +0,0 @@
/* Copyright (c) 2009,2011,2014 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef LOC_ENG_NI_H
#define LOC_ENG_NI_H
#include <stdbool.h>
#include <LocEngAdapter.h>
#define LOC_NI_NO_RESPONSE_TIME 20 /* secs */
#define LOC_NI_NOTIF_KEY_ADDRESS "Address"
#define LOC_GPS_NI_RESPONSE_IGNORE 4
typedef struct {
pthread_t thread; /* NI thread */
int respTimeLeft; /* examine time for NI response */
bool respRecvd; /* NI User reponse received or not from Java layer*/
void* rawRequest;
int reqID; /* ID to check against response */
LocGpsUserResponseType resp;
pthread_cond_t tCond;
pthread_mutex_t tLock;
LocEngAdapter* adapter;
} loc_eng_ni_session_s_type;
typedef struct {
loc_eng_ni_session_s_type session; /* SUPL NI Session */
loc_eng_ni_session_s_type sessionEs; /* Emergency SUPL NI Session */
int reqIDCounter;
} loc_eng_ni_data_s_type;
#endif /* LOC_ENG_NI_H */

File diff suppressed because it is too large Load diff

View file

@ -1,42 +0,0 @@
/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef LOC_ENG_NMEA_H
#define LOC_ENG_NMEA_H
#include <gps_extended.h>
#define NMEA_SENTENCE_MAX_LENGTH 200
void loc_eng_nmea_send(char *pNmea, int length, loc_eng_data_s_type *loc_eng_data_p);
int loc_eng_nmea_put_checksum(char *pNmea, int maxSize);
void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p, const LocGnssSvStatus &svStatus, const GpsLocationExtended &locationExtended);
void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, const UlpLocation &location, const GpsLocationExtended &locationExtended, unsigned char generate_nmea);
#endif // LOC_ENG_NMEA_H

View file

@ -1,219 +0,0 @@
/* Copyright (c) 2009-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#define LOG_NDDEBUG 0
#define LOG_TAG "LocSvc_eng"
#include <loc_eng.h>
#include <MsgTask.h>
#include <platform_lib_includes.h>
using namespace loc_core;
struct LocEngRequestXtraServer : public LocMsg {
LocEngAdapter* mAdapter;
inline LocEngRequestXtraServer(LocEngAdapter* adapter) :
LocMsg(), mAdapter(adapter)
{
locallog();
}
inline virtual void proc() const {
mAdapter->requestXtraServer();
}
inline void locallog() const {
LOC_LOGV("LocEngRequestXtraServer");
}
inline virtual void log() const {
locallog();
}
};
struct LocEngInjectXtraData : public LocMsg {
LocEngAdapter* mAdapter;
char* mData;
const int mLen;
inline LocEngInjectXtraData(LocEngAdapter* adapter,
char* data, int len):
LocMsg(), mAdapter(adapter),
mData(new char[len]), mLen(len)
{
memcpy((void*)mData, (void*)data, len);
locallog();
}
inline ~LocEngInjectXtraData()
{
delete[] mData;
}
inline virtual void proc() const {
mAdapter->setXtraData(mData, mLen);
}
inline void locallog() const {
LOC_LOGV("length: %d\n data: %p", mLen, mData);
}
inline virtual void log() const {
locallog();
}
};
struct LocEngSetXtraVersionCheck : public LocMsg {
LocEngAdapter *mAdapter;
int mCheck;
inline LocEngSetXtraVersionCheck(LocEngAdapter* adapter,
int check):
mAdapter(adapter), mCheck(check) {}
inline virtual void proc() const {
locallog();
mAdapter->setXtraVersionCheck(mCheck);
}
inline void locallog() const {
LOC_LOGD("%s:%d]: mCheck: %d",
__func__, __LINE__, mCheck);
}
inline virtual void log() const {
locallog();
}
};
/*===========================================================================
FUNCTION loc_eng_xtra_init
DESCRIPTION
Initialize XTRA module.
DEPENDENCIES
N/A
RETURN VALUE
0: success
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_xtra_init (loc_eng_data_s_type &loc_eng_data,
GpsXtraExtCallbacks* callbacks)
{
int ret_val = -1;
loc_eng_xtra_data_s_type *xtra_module_data_ptr;
ENTRY_LOG();
if(!loc_eng_data.adapter->mSupportsTimeInjection
|| loc_eng_data.adapter->hasNativeXtraClient()) {
LOC_LOGD("XTRA is already supported. disable it here.\n");
EXIT_LOG(%d, 1); // return 1 denote failure
return 1;
}
if(callbacks == NULL) {
LOC_LOGE("loc_eng_xtra_init: failed, cb is NULL");
} else {
xtra_module_data_ptr = &loc_eng_data.xtra_module_data;
xtra_module_data_ptr->download_request_cb = callbacks->download_request_cb;
xtra_module_data_ptr->report_xtra_server_cb = callbacks->report_xtra_server_cb;
ret_val = 0;
}
EXIT_LOG(%d, ret_val);
return ret_val;
}
/*===========================================================================
FUNCTION loc_eng_xtra_inject_data
DESCRIPTION
Injects XTRA file into the engine but buffers the data if engine is busy.
DEPENDENCIES
N/A
RETURN VALUE
0
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_xtra_inject_data(loc_eng_data_s_type &loc_eng_data,
char* data, int length)
{
ENTRY_LOG();
LocEngAdapter* adapter = loc_eng_data.adapter;
adapter->sendMsg(new LocEngInjectXtraData(adapter, data, length));
EXIT_LOG(%d, 0);
return 0;
}
/*===========================================================================
FUNCTION loc_eng_xtra_request_server
DESCRIPTION
Request the Xtra server url from the modem
DEPENDENCIES
N/A
RETURN VALUE
0
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_xtra_request_server(loc_eng_data_s_type &loc_eng_data)
{
ENTRY_LOG();
LocEngAdapter* adapter = loc_eng_data.adapter;
adapter->sendMsg(new LocEngRequestXtraServer(adapter));
EXIT_LOG(%d, 0);
return 0;
}
/*===========================================================================
FUNCTION loc_eng_xtra_version_check
DESCRIPTION
Injects the enable/disable value for checking XTRA version
that is specified in gps.conf
DEPENDENCIES
N/A
RETURN VALUE
none
SIDE EFFECTS
N/A
===========================================================================*/
void loc_eng_xtra_version_check(loc_eng_data_s_type &loc_eng_data,
int check)
{
ENTRY_LOG();
LocEngAdapter *adapter = loc_eng_data.adapter;
adapter->sendMsg(new LocEngSetXtraVersionCheck(adapter, check));
EXIT_LOG(%d, 0);
}

View file

@ -1,45 +0,0 @@
/* Copyright (c) 2009,2011 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef LOC_ENG_XTRA_H
#define LOC_ENG_XTRA_H
// Module data
typedef struct
{
// loc_eng_ioctl_cb_data_s_type ioctl_cb_data;
loc_gps_xtra_download_request download_request_cb;
report_xtra_server report_xtra_server_cb;
// XTRA data buffer
char *xtra_data_for_injection; // NULL if no pending data
int xtra_data_len;
} loc_eng_xtra_data_s_type;
#endif // LOC_ENG_XTRA_H

41
location/Android.mk Normal file
View file

@ -0,0 +1,41 @@
ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
ifneq ($(BUILD_TINY_ANDROID),true)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := liblocation_api
LOCAL_MODULE_OWNER := qti
LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := \
libutils \
libcutils \
libgps.utils \
libdl \
liblog
LOCAL_SRC_FILES += \
LocationAPI.cpp \
LocationAPIClientBase.cpp
LOCAL_CFLAGS += \
-fno-short-enums
LOCAL_C_INCLUDES:= \
$(TARGET_OUT_HEADERS)/gps.utils
LOCAL_COPY_HEADERS_TO:= liblocation_api/
LOCAL_COPY_HEADERS:= \
LocationAPI.h \
LocationAPIClientBase.h \
location_interface.h
LOCAL_PRELINK_MODULE := false
include $(BUILD_SHARED_LIBRARY)
endif # not BUILD_TINY_ANDROID
endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE

675
location/LocationAPI.cpp Normal file
View file

@ -0,0 +1,675 @@
/* Copyright (c) 2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define LOG_TAG "LocSvc_LocationAPI"
#include <location_interface.h>
#include <dlfcn.h>
#include <log_util.h>
#include <pthread.h>
#include <map>
typedef void* (getLocationInterface)();
typedef std::map<LocationAPI*, LocationCallbacks> LocationClientMap;
typedef struct {
LocationClientMap clientData;
LocationControlAPI* controlAPI;
LocationControlCallbacks controlCallbacks;
GnssInterface* gnssInterface;
GeofenceInterface* geofenceInterface;
FlpInterface* flpInterface;
} LocationAPIData;
static LocationAPIData gData = {};
static pthread_mutex_t gDataMutex = PTHREAD_MUTEX_INITIALIZER;
static bool gGnssLoadFailed = false;
static bool gFlpLoadFailed = false;
static bool gGeofenceLoadFailed = false;
static bool needsGnssTrackingInfo(LocationCallbacks& locationCallbacks)
{
return (locationCallbacks.gnssLocationInfoCb != nullptr ||
locationCallbacks.gnssSvCb != nullptr ||
locationCallbacks.gnssNmeaCb != nullptr ||
locationCallbacks.gnssMeasurementsCb != nullptr);
}
static bool isGnssClient(LocationCallbacks& locationCallbacks)
{
return (locationCallbacks.gnssNiCb != nullptr ||
locationCallbacks.trackingCb != nullptr ||
locationCallbacks.gnssMeasurementsCb != nullptr);
}
static bool isFlpClient(LocationCallbacks& locationCallbacks)
{
return (locationCallbacks.trackingCb != nullptr ||
locationCallbacks.batchingCb != nullptr);
}
static bool isGeofenceClient(LocationCallbacks& locationCallbacks)
{
return (locationCallbacks.geofenceBreachCb != nullptr ||
locationCallbacks.geofenceStatusCb != nullptr);
}
static void* loadLocationInterface(const char* library, const char* name) {
LOC_LOGD("%s]: loading %s::%s ...", __func__, library, name);
if (NULL == library || NULL == name) {
return NULL;
}
getLocationInterface* getter = NULL;
const char *error;
dlerror();
void *handle = dlopen(library, RTLD_NOW);
if (NULL == handle || (error = dlerror()) != NULL) {
LOC_LOGW("dlopen for %s failed, error = %s", library, error);
} else {
getter = (getLocationInterface*)dlsym(handle, name);
if ((error = dlerror()) != NULL) {
LOC_LOGW("dlsym for %s::%s failed, error = %s", library, name, error);
getter = NULL;
}
}
if (NULL == getter) {
return (void*)getter;
} else {
return (*getter)();
}
}
LocationAPI*
LocationAPI::createInstance(LocationCallbacks& locationCallbacks)
{
if (nullptr == locationCallbacks.capabilitiesCb ||
nullptr == locationCallbacks.responseCb ||
nullptr == locationCallbacks.collectiveResponseCb) {
return NULL;
}
LocationAPI* newLocationAPI = new LocationAPI();
bool requestedCapabilities = false;
pthread_mutex_lock(&gDataMutex);
if (isGnssClient(locationCallbacks)) {
if (NULL == gData.gnssInterface && !gGnssLoadFailed) {
gData.gnssInterface =
(GnssInterface*)loadLocationInterface("libgnss.so", "getGnssInterface");
if (NULL == gData.gnssInterface) {
gGnssLoadFailed = true;
LOC_LOGW("%s:%d]: No gnss interface available", __func__, __LINE__);
} else {
gData.gnssInterface->initialize();
}
}
if (NULL != gData.gnssInterface) {
gData.gnssInterface->addClient(newLocationAPI, locationCallbacks);
if (!requestedCapabilities) {
gData.gnssInterface->requestCapabilities(newLocationAPI);
requestedCapabilities = true;
}
}
}
if (isFlpClient(locationCallbacks)) {
if (NULL == gData.flpInterface && !gFlpLoadFailed) {
gData.flpInterface =
(FlpInterface*)loadLocationInterface("libflp.so", "getFlpInterface");
if (NULL == gData.flpInterface) {
gFlpLoadFailed = true;
LOC_LOGW("%s:%d]: No flp interface available", __func__, __LINE__);
} else {
gData.flpInterface->initialize();
}
}
if (NULL != gData.flpInterface) {
gData.flpInterface->addClient(newLocationAPI, locationCallbacks);
if (!requestedCapabilities) {
gData.flpInterface->requestCapabilities(newLocationAPI);
requestedCapabilities = true;
}
}
}
if (isGeofenceClient(locationCallbacks)) {
if (NULL == gData.geofenceInterface && !gGeofenceLoadFailed) {
gData.geofenceInterface =
(GeofenceInterface*)loadLocationInterface("libgeofence.so", "getGeofenceInterface");
if (NULL == gData.geofenceInterface) {
gGeofenceLoadFailed = true;
LOC_LOGW("%s:%d]: No geofence interface available", __func__, __LINE__);
} else {
gData.geofenceInterface->initialize();
}
}
if (NULL != gData.geofenceInterface) {
gData.geofenceInterface->addClient(newLocationAPI, locationCallbacks);
if (!requestedCapabilities) {
gData.geofenceInterface->requestCapabilities(newLocationAPI);
requestedCapabilities = true;
}
}
}
gData.clientData[newLocationAPI] = locationCallbacks;
pthread_mutex_unlock(&gDataMutex);
return newLocationAPI;
}
void
LocationAPI::destroy()
{
delete this;
}
LocationAPI::LocationAPI()
{
LOC_LOGD("LOCATION API CONSTRUCTOR");
}
LocationAPI::~LocationAPI()
{
LOC_LOGD("LOCATION API DESTRUCTOR");
pthread_mutex_lock(&gDataMutex);
auto it = gData.clientData.find(this);
if (it != gData.clientData.end()) {
size_t gnssClientCount = 0;
size_t flpClientCount = 0;
size_t geofenceClientCount = 0;
for (auto it2=gData.clientData.begin(); it2 != gData.clientData.end(); ++it2) {
if (isGnssClient(it2->second)) {
gnssClientCount++;
}
if (isFlpClient(it2->second)) {
flpClientCount++;
}
if (isGeofenceClient(it2->second)) {
geofenceClientCount++;
}
}
if (isGnssClient(it->second) && NULL != gData.gnssInterface) {
gData.gnssInterface->removeClient(it->first);
if (1 == gnssClientCount && NULL == gData.controlAPI) {
gData.gnssInterface->deinitialize();
}
}
if (isFlpClient(it->second) && NULL != gData.flpInterface) {
gData.flpInterface->removeClient(it->first);
if (1 == flpClientCount) {
gData.flpInterface->deinitialize();
}
}
if (isGeofenceClient(it->second) && NULL != gData.geofenceInterface) {
gData.geofenceInterface->removeClient(it->first);
if (1 == geofenceClientCount) {
gData.geofenceInterface->deinitialize();
}
}
gData.clientData.erase(it);
} else {
LOC_LOGE("%s:%d]: Location API client %p not found in client data",
__func__, __LINE__, this);
}
pthread_mutex_unlock(&gDataMutex);
}
void
LocationAPI::updateCallbacks(LocationCallbacks& locationCallbacks)
{
if (nullptr == locationCallbacks.capabilitiesCb ||
nullptr == locationCallbacks.responseCb ||
nullptr == locationCallbacks.collectiveResponseCb) {
return;
}
pthread_mutex_lock(&gDataMutex);
if (isGnssClient(locationCallbacks)) {
if (NULL == gData.gnssInterface && !gGnssLoadFailed) {
gData.gnssInterface =
(GnssInterface*)loadLocationInterface("libgnss.so", "getGnssInterface");
if (NULL == gData.gnssInterface) {
gGnssLoadFailed = true;
LOC_LOGW("%s:%d]: No gnss interface available", __func__, __LINE__);
} else {
gData.gnssInterface->initialize();
}
}
if (NULL != gData.gnssInterface) {
// either adds new Client or updates existing Client
gData.gnssInterface->addClient(this, locationCallbacks);
}
}
if (isFlpClient(locationCallbacks)) {
if (NULL == gData.flpInterface && !gFlpLoadFailed) {
gData.flpInterface =
(FlpInterface*)loadLocationInterface("libflp.so", "getFlpInterface");
if (NULL == gData.flpInterface) {
gFlpLoadFailed = true;
LOC_LOGW("%s:%d]: No flp interface available", __func__, __LINE__);
} else {
gData.flpInterface->initialize();
}
}
if (NULL != gData.flpInterface) {
// either adds new Client or updates existing Client
gData.flpInterface->addClient(this, locationCallbacks);
}
}
if (isGeofenceClient(locationCallbacks)) {
if (NULL == gData.geofenceInterface && !gGeofenceLoadFailed) {
gData.geofenceInterface =
(GeofenceInterface*)loadLocationInterface("libgeofence.so", "getGeofenceInterface");
if (NULL == gData.geofenceInterface) {
gGeofenceLoadFailed = true;
LOC_LOGW("%s:%d]: No geofence interface available", __func__, __LINE__);
} else {
gData.geofenceInterface->initialize();
}
}
if (NULL != gData.geofenceInterface) {
// either adds new Client or updates existing Client
gData.geofenceInterface->addClient(this, locationCallbacks);
}
}
gData.clientData[this] = locationCallbacks;
pthread_mutex_unlock(&gDataMutex);
}
uint32_t
LocationAPI::startTracking(LocationOptions& locationOptions)
{
uint32_t id = 0;
pthread_mutex_lock(&gDataMutex);
auto it = gData.clientData.find(this);
if (it != gData.clientData.end()) {
if (gData.flpInterface != NULL && locationOptions.minDistance > 0) {
id = gData.flpInterface->startTracking(this, locationOptions);
} else if (gData.gnssInterface != NULL && needsGnssTrackingInfo(it->second)) {
id = gData.gnssInterface->startTracking(this, locationOptions);
} else if (gData.flpInterface != NULL) {
id = gData.flpInterface->startTracking(this, locationOptions);
} else if (gData.gnssInterface != NULL) {
id = gData.gnssInterface->startTracking(this, locationOptions);
} else {
LOC_LOGE("%s:%d]: No gnss/flp interface available for Location API client %p ",
__func__, __LINE__, this);
}
} else {
LOC_LOGE("%s:%d]: Location API client %p not found in client data",
__func__, __LINE__, this);
}
pthread_mutex_unlock(&gDataMutex);
return id;
}
void
LocationAPI::stopTracking(uint32_t id)
{
pthread_mutex_lock(&gDataMutex);
auto it = gData.clientData.find(this);
if (it != gData.clientData.end()) {
// we don't know if tracking was started on flp or gnss, so we call stop on both, where
// stopTracking call to the incorrect interface will fail without response back to client
if (gData.gnssInterface != NULL) {
gData.gnssInterface->stopTracking(this, id);
}
if (gData.flpInterface != NULL) {
gData.flpInterface->stopTracking(this, id);
}
if (gData.flpInterface != NULL && gData.gnssInterface != NULL) {
LOC_LOGE("%s:%d]: No gnss/flp interface available for Location API client %p ",
__func__, __LINE__, this);
}
} else {
LOC_LOGE("%s:%d]: Location API client %p not found in client data",
__func__, __LINE__, this);
}
pthread_mutex_unlock(&gDataMutex);
}
void
LocationAPI::updateTrackingOptions(uint32_t id, LocationOptions& locationOptions)
{
pthread_mutex_lock(&gDataMutex);
auto it = gData.clientData.find(this);
if (it != gData.clientData.end()) {
// we don't know if tracking was started on flp or gnss, so we call update on both, where
// updateTracking call to the incorrect interface will fail without response back to client
if (gData.gnssInterface != NULL) {
gData.gnssInterface->updateTrackingOptions(this, id, locationOptions);
}
if (gData.flpInterface != NULL) {
gData.flpInterface->updateTrackingOptions(this, id, locationOptions);
}
if (gData.flpInterface != NULL && gData.gnssInterface != NULL) {
LOC_LOGE("%s:%d]: No gnss/flp interface available for Location API client %p ",
__func__, __LINE__, this);
}
} else {
LOC_LOGE("%s:%d]: Location API client %p not found in client data",
__func__, __LINE__, this);
}
pthread_mutex_unlock(&gDataMutex);
}
uint32_t
LocationAPI::startBatching(LocationOptions& locationOptions)
{
uint32_t id = 0;
pthread_mutex_lock(&gDataMutex);
if (gData.flpInterface != NULL) {
id = gData.flpInterface->startBatching(this, locationOptions);
} else {
LOC_LOGE("%s:%d]: No flp interface available for Location API client %p ",
__func__, __LINE__, this);
}
pthread_mutex_unlock(&gDataMutex);
return id;
}
void
LocationAPI::stopBatching(uint32_t id)
{
pthread_mutex_lock(&gDataMutex);
if (gData.flpInterface != NULL) {
gData.flpInterface->stopBatching(this, id);
} else {
LOC_LOGE("%s:%d]: No flp interface available for Location API client %p ",
__func__, __LINE__, this);
}
pthread_mutex_unlock(&gDataMutex);
}
void
LocationAPI::updateBatchingOptions(uint32_t id, LocationOptions& locationOptions)
{
pthread_mutex_lock(&gDataMutex);
if (gData.flpInterface != NULL) {
gData.flpInterface->updateBatchingOptions(this,
id,
locationOptions);
} else {
LOC_LOGE("%s:%d]: No flp interface available for Location API client %p ",
__func__, __LINE__, this);
}
pthread_mutex_unlock(&gDataMutex);
}
void
LocationAPI::getBatchedLocations(uint32_t id, size_t count)
{
pthread_mutex_lock(&gDataMutex);
if (gData.flpInterface != NULL) {
gData.flpInterface->getBatchedLocations(this, id, count);
} else {
LOC_LOGE("%s:%d]: No flp interface available for Location API client %p ",
__func__, __LINE__, this);
}
pthread_mutex_unlock(&gDataMutex);
}
uint32_t*
LocationAPI::addGeofences(size_t count, GeofenceOption* options, GeofenceInfo* info)
{
uint32_t* ids = NULL;
pthread_mutex_lock(&gDataMutex);
if (gData.geofenceInterface != NULL) {
ids = gData.geofenceInterface->addGeofences(this, count, options, info);
} else {
LOC_LOGE("%s:%d]: No geofence interface available for Location API client %p ",
__func__, __LINE__, this);
}
pthread_mutex_unlock(&gDataMutex);
return ids;
}
void
LocationAPI::removeGeofences(size_t count, uint32_t* ids)
{
pthread_mutex_lock(&gDataMutex);
if (gData.geofenceInterface != NULL) {
gData.geofenceInterface->removeGeofences(this, count, ids);
} else {
LOC_LOGE("%s:%d]: No geofence interface available for Location API client %p ",
__func__, __LINE__, this);
}
pthread_mutex_unlock(&gDataMutex);
}
void
LocationAPI::modifyGeofences(size_t count, uint32_t* ids, GeofenceOption* options)
{
pthread_mutex_lock(&gDataMutex);
if (gData.geofenceInterface != NULL) {
gData.geofenceInterface->modifyGeofences(this, count, ids, options);
} else {
LOC_LOGE("%s:%d]: No geofence interface available for Location API client %p ",
__func__, __LINE__, this);
}
pthread_mutex_unlock(&gDataMutex);
}
void
LocationAPI::pauseGeofences(size_t count, uint32_t* ids)
{
pthread_mutex_lock(&gDataMutex);
if (gData.geofenceInterface != NULL) {
gData.geofenceInterface->pauseGeofences(this, count, ids);
} else {
LOC_LOGE("%s:%d]: No geofence interface available for Location API client %p ",
__func__, __LINE__, this);
}
pthread_mutex_unlock(&gDataMutex);
}
void
LocationAPI::resumeGeofences(size_t count, uint32_t* ids)
{
pthread_mutex_lock(&gDataMutex);
if (gData.geofenceInterface != NULL) {
gData.geofenceInterface->resumeGeofences(this, count, ids);
} else {
LOC_LOGE("%s:%d]: No geofence interface available for Location API client %p ",
__func__, __LINE__, this);
}
pthread_mutex_unlock(&gDataMutex);
}
void
LocationAPI::gnssNiResponse(uint32_t id, GnssNiResponse response)
{
pthread_mutex_lock(&gDataMutex);
if (gData.gnssInterface != NULL) {
gData.gnssInterface->gnssNiResponse(this, id, response);
} else {
LOC_LOGE("%s:%d]: No gnss interface available for Location API client %p ",
__func__, __LINE__, this);
}
pthread_mutex_unlock(&gDataMutex);
}
LocationControlAPI*
LocationControlAPI::createInstance(LocationControlCallbacks& locationControlCallbacks)
{
LocationControlAPI* controlAPI = NULL;
pthread_mutex_lock(&gDataMutex);
if (nullptr != locationControlCallbacks.responseCb && NULL == gData.controlAPI) {
if (NULL == gData.gnssInterface && !gGnssLoadFailed) {
gData.gnssInterface =
(GnssInterface*)loadLocationInterface("libgnss.so", "getGnssInterface");
if (NULL == gData.gnssInterface) {
gGnssLoadFailed = true;
LOC_LOGW("%s:%d]: No gnss interface available", __func__, __LINE__);
} else {
gData.gnssInterface->initialize();
}
}
if (NULL != gData.gnssInterface) {
gData.controlAPI = new LocationControlAPI();
gData.controlCallbacks = locationControlCallbacks;
gData.gnssInterface->setControlCallbacks(locationControlCallbacks);
controlAPI = gData.controlAPI;
}
}
pthread_mutex_unlock(&gDataMutex);
return controlAPI;
}
void
LocationControlAPI::destroy()
{
delete this;
}
LocationControlAPI::LocationControlAPI()
{
LOC_LOGD("LOCATION CONTROL API CONSTRUCTOR");
}
LocationControlAPI::~LocationControlAPI()
{
LOC_LOGD("LOCATION CONTROL API DESTRUCTOR");
pthread_mutex_lock(&gDataMutex);
size_t gnssClientCount = 0;
for (auto it=gData.clientData.begin(); it != gData.clientData.end(); ++it) {
if (isGnssClient(it->second)) {
gnssClientCount++;
}
}
if (gData.gnssInterface != NULL && 0 == gnssClientCount) {
//@todo: we might want to call gData.gnssInterface.disable before deinitialize?
gData.gnssInterface->deinitialize();
}
gData.controlAPI = NULL;
pthread_mutex_unlock(&gDataMutex);
}
uint32_t
LocationControlAPI::enable(LocationTechnologyType techType)
{
uint32_t id = 0;
pthread_mutex_lock(&gDataMutex);
if (gData.gnssInterface != NULL) {
id = gData.gnssInterface->enable(techType);
} else {
LOC_LOGE("%s:%d]: No gnss interface available for Location Control API client %p ",
__func__, __LINE__, this);
}
pthread_mutex_unlock(&gDataMutex);
return id;
}
void
LocationControlAPI::disable(uint32_t id)
{
pthread_mutex_lock(&gDataMutex);
if (gData.gnssInterface != NULL) {
gData.gnssInterface->disable(id);
} else {
LOC_LOGE("%s:%d]: No gnss interface available for Location Control API client %p ",
__func__, __LINE__, this);
}
pthread_mutex_unlock(&gDataMutex);
}
uint32_t*
LocationControlAPI::gnssUpdateConfig(GnssConfig config)
{
uint32_t* ids = NULL;
pthread_mutex_lock(&gDataMutex);
if (gData.gnssInterface != NULL) {
ids = gData.gnssInterface->gnssUpdateConfig(config);
} else {
LOC_LOGE("%s:%d]: No gnss interface available for Location Control API client %p ",
__func__, __LINE__, this);
}
pthread_mutex_unlock(&gDataMutex);
return ids;
}
uint32_t
LocationControlAPI::gnssDeleteAidingData(GnssAidingData& data)
{
uint32_t id = 0;
pthread_mutex_lock(&gDataMutex);
if (gData.gnssInterface != NULL) {
id = gData.gnssInterface->gnssDeleteAidingData(data);
} else {
LOC_LOGE("%s:%d]: No gnss interface available for Location Control API client %p ",
__func__, __LINE__, this);
}
pthread_mutex_unlock(&gDataMutex);
return id;
}

866
location/LocationAPI.h Normal file
View file

@ -0,0 +1,866 @@
/* Copyright (c) 2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef LOCATION_H
#define LOCATION_H
#include <stdint.h>
#include <functional>
#define GNSS_NI_REQUESTOR_MAX 256
#define GNSS_NI_MESSAGE_ID_MAX 2048
#define GNSS_SV_MAX 64
#define GNSS_MEASUREMENTS_MAX 64
typedef enum {
LOCATION_ERROR_SUCCESS = 0,
LOCATION_ERROR_GENERAL_FAILURE,
LOCATION_ERROR_CALLBACK_MISSING,
LOCATION_ERROR_INVALID_PARAMETER,
LOCATION_ERROR_ID_EXISTS,
LOCATION_ERROR_ID_UNKNOWN,
LOCATION_ERROR_ALREADY_STARTED,
LOCATION_ERROR_GEOFENCES_AT_MAX,
LOCATION_ERROR_NOT_SUPPORTED
} LocationError;
// Flags to indicate which values are valid in a Location
typedef uint16_t LocationFlagsMask;
typedef enum {
LOCATION_HAS_LAT_LONG_BIT = (1<<0), // location has valid latitude and longitude
LOCATION_HAS_ALTITUDE_BIT = (1<<1), // location has valid altitude
LOCATION_HAS_SPEED_BIT = (1<<2), // location has valid speed
LOCATION_HAS_BEARING_BIT = (1<<3), // location has valid bearing
LOCATION_HAS_ACCURACY_BIT = (1<<4), // location has valid accuracy
} LocationFlagsBits;
typedef uint16_t LocationTechnologyMask;
typedef enum {
LOCATION_TECHNOLOGY_GNSS_BIT = (1<<0), // location was calculated using GNSS
LOCATION_TECHNOLOGY_CELL_BIT = (1<<1), // location was calculated using Cell
LOCATION_TECHNOLOGY_WIFI_BIT = (1<<2), // location was calculated using WiFi
LOCATION_TECHNOLOGY_SENSORS_BIT = (1<<3), // location was calculated using Sensors
} LocationTechnologyBits;
typedef enum {
LOCATION_RELIABILITY_NOT_SET = 0,
LOCATION_RELIABILITY_VERY_LOW,
LOCATION_RELIABILITY_LOW,
LOCATION_RELIABILITY_MEDIUM,
LOCATION_RELIABILITY_HIGH,
} LocationReliability;
typedef uint32_t GnssLocationInfoFlagMask;
typedef enum {
GNSS_LOCATION_INFO_ALTITUDE_MEAN_SEA_LEVEL_BIT = (1<<0), // valid altitude mean sea level
GNSS_LOCATION_INFO_DOP_BIT = (1<<1), // valid pdop, hdop, and vdop
GNSS_LOCATION_INFO_MAGNETIC_DEVIATION_BIT = (1<<2), // valid magnetic deviation
GNSS_LOCATION_INFO_VER_ACCURACY_BIT = (1<<3), // valid vertical accuracy
GNSS_LOCATION_INFO_SPEED_ACCURACY_BIT = (1<<4), // valid speed accuracy
GNSS_LOCATION_INFO_BEARING_ACCURACY_BIT = (1<<5), // valid bearing accuracy
GNSS_LOCATION_INFO_HOR_RELIABILITY_BIT = (1<<6), // valid horizontal reliability
GNSS_LOCATION_INFO_VER_RELIABILITY_BIT = (1<<7), // valid vertical reliability
GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_SEMI_MAJOR_BIT = (1<<8), // valid elipsode semi major
GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_SEMI_MINOR_BIT = (1<<9), // valid elipsode semi minor
GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_AZIMUTH_BIT = (1<<10),// valid accuracy elipsode azimuth
} GnssLocationInfoFlagBits;
typedef enum {
GEOFENCE_BREACH_ENTER = 0,
GEOFENCE_BREACH_EXIT,
GEOFENCE_BREACH_DWELL_IN,
GEOFENCE_BREACH_DWELL_OUT,
GEOFENCE_BREACH_UNKNOWN,
} GeofenceBreachType;
typedef uint16_t GeofenceBreachTypeMask;
typedef enum {
GEOFENCE_BREACH_ENTER_BIT = (1<<0),
GEOFENCE_BREACH_EXIT_BIT = (1<<1),
GEOFENCE_BREACH_DWELL_IN_BIT = (1<<2),
GEOFENCE_BREACH_DWELL_OUT_BIT = (1<<3),
} GeofenceBreachTypeBits;
typedef enum {
GEOFENCE_STATUS_AVAILABILE_NO = 0,
GEOFENCE_STATUS_AVAILABILE_YES,
} GeofenceStatusAvailable;
typedef uint32_t LocationCapabilitiesMask;
typedef enum {
// supports startTracking API with minInterval param
LOCATION_CAPABILITIES_TIME_BASED_TRACKING_BIT = (1<<0),
// supports startBatching API with minInterval param
LOCATION_CAPABILITIES_TIME_BASED_BATCHING_BIT = (1<<1),
// supports startTracking API with minDistance param
LOCATION_CAPABILITIES_DISTANCE_BASED_TRACKING_BIT = (1<<2),
// supports startBatching API with minDistance param
LOCATION_CAPABILITIES_DISTANCE_BASED_BATCHING_BIT = (1<<3),
// supports addGeofences API
LOCATION_CAPABILITIES_GEOFENCE_BIT = (1<<4),
// supports GnssMeasurementsCallback
LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT = (1<<5),
// supports startTracking/startBatching API with LocationOptions.mode of MSB (Ms Based)
LOCATION_CAPABILITIES_GNSS_MSB_BIT = (1<<6),
// supports startTracking/startBatching API with LocationOptions.mode of MSA (MS Assisted)
LOCATION_CAPABILITIES_GNSS_MSA_BIT = (1<<7),
} LocationCapabilitiesBits;
typedef enum {
LOCATION_TECHNOLOGY_TYPE_GNSS = 0,
} LocationTechnologyType;
// Configures how GPS is locked when GPS is disabled (through GnssDisable)
typedef enum {
GNSS_CONFIG_GPS_LOCK_NONE = 0, // gps is not locked when GPS is disabled (GnssDisable)
GNSS_CONFIG_GPS_LOCK_MO, // gps mobile originated (MO) is locked when GPS is disabled
GNSS_CONFIG_GPS_LOCK_NI, // gps network initiated (NI) is locked when GPS is disabled
GNSS_CONFIG_GPS_LOCK_MO_AND_NI,// gps MO and NI is locked when GPS is disabled
} GnssConfigGpsLock;
// SUPL version
typedef enum {
GNSS_CONFIG_SUPL_VERSION_1_0_0 = 1,
GNSS_CONFIG_SUPL_VERSION_2_0_0,
GNSS_CONFIG_SUPL_VERSION_2_0_2,
} GnssConfigSuplVersion;
// LTE Positioning Profile
typedef enum {
GNSS_CONFIG_LPP_PROFILE_RRLP_ON_LTE = 0, // RRLP on LTE (Default)
GNSS_CONFIG_LPP_PROFILE_USER_PLANE, // LPP User Plane (UP) on LTE
GNSS_CONFIG_LPP_PROFILE_CONTROL_PLANE, // LPP_Control_Plane (CP)
GNSS_CONFIG_LPP_PROFILE_USER_PLANE_AND_CONTROL_PLANE, // Both LPP UP and CP
} GnssConfigLppProfile;
// Technology for LPPe Control Plane
typedef uint16_t GnssConfigLppeControlPlaneMask;
typedef enum {
GNSS_CONFIG_LPPE_CONTROL_PLANE_DBH_BIT = (1<<0), // DBH
GNSS_CONFIG_LPPE_CONTROL_PLANE_WLAN_AP_MEASUREMENTS_BIT = (1<<1), // WLAN_AP_MEASUREMENTS
} GnssConfigLppeControlPlaneBits;
// Technology for LPPe User Plane
typedef uint16_t GnssConfigLppeUserPlaneMask;
typedef enum {
GNSS_CONFIG_LPPE_USER_PLANE_DBH_BIT = (1<<0), // DBH
GNSS_CONFIG_LPPE_USER_PLANE_WLAN_AP_MEASUREMENTS_BIT = (1<<1), // WLAN_AP_MEASUREMENTS
} GnssConfigLppeUserPlaneBits;
// Positioning Protocol on A-GLONASS system
typedef uint16_t GnssConfigAGlonassPositionProtocolMask;
typedef enum {
GNSS_CONFIG_RRC_CONTROL_PLANE_BIT = (1<<0), // RRC Control Plane
GNSS_CONFIG_RRLP_USER_PLANE_BIT = (1<<1), // RRLP User Plane
GNSS_CONFIG_LLP_USER_PLANE_BIT = (1<<2), // LPP User Plane
GNSS_CONFIG_LLP_CONTROL_PLANE_BIT = (1<<3), // LPP Control Plane
} GnssConfigAGlonassPositionProtocolBits;
typedef enum {
GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_NO = 0,
GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_YES,
} GnssConfigEmergencyPdnForEmergencySupl;
typedef enum {
GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_NO = 0,
GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_YES,
} GnssConfigSuplEmergencyServices;
typedef uint16_t GnssConfigSuplModeMask;
typedef enum {
GNSS_CONFIG_SUPL_MODE_MSB = (1<<0),
GNSS_CONFIG_SUPL_MODE_MSA = (1<<1),
} GnssConfigSuplModeBits;
typedef uint32_t GnssConfigFlagsMask;
typedef enum {
GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT = (1<<0),
GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT = (1<<1),
GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT = (1<<2),
GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT = (1<<3),
GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT = (1<<4),
GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT = (1<<5),
GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT = (1<<6),
GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT = (1<<7),
GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT = (1<<8),
GNSS_CONFIG_FLAGS_SUPL_MODE_BIT = (1<<9),
} GnssConfigFlagsBits;
typedef enum {
GNSS_NI_ENCODING_TYPE_NONE = 0,
GNSS_NI_ENCODING_TYPE_GSM_DEFAULT,
GNSS_NI_ENCODING_TYPE_UTF8,
GNSS_NI_ENCODING_TYPE_UCS2,
} GnssNiEncodingType;
typedef enum {
GNSS_NI_TYPE_VOICE = 0,
GNSS_NI_TYPE_SUPL,
GNSS_NI_TYPE_CONTROL_PLANE,
GNSS_NI_TYPE_EMERGENCY_SUPL
} GnssNiType;
typedef uint16_t GnssNiOptionsMask;
typedef enum {
GNSS_NI_OPTIONS_NOTIFICATION = (1<<0),
GNSS_NI_OPTIONS_VERIFICATION = (1<<1),
GNSS_NI_OPTIONS_PRIVACY_OVERRIDE = (1<<2),
} GnssNiOptionsBits;
typedef enum {
GNSS_NI_RESPONSE_ACCEPT = 1,
GNSS_NI_RESPONSE_DENY,
GNSS_NI_RESPONSE_NO_RESPONSE,
GNSS_NI_RESPONSE_IGNORE,
} GnssNiResponse;
typedef enum {
GNSS_SV_TYPE_UNKNOWN = 0,
GNSS_SV_TYPE_GPS,
GNSS_SV_TYPE_SBAS,
GNSS_SV_TYPE_GLONASS,
GNSS_SV_TYPE_QZSS,
GNSS_SV_TYPE_BEIDOU,
GNSS_SV_TYPE_GALILEO,
} GnssSvType;
typedef uint16_t GnssSvOptionsMask;
typedef enum {
GNSS_SV_OPTIONS_HAS_EPHEMER_BIT = (1<<0),
GNSS_SV_OPTIONS_HAS_ALMANAC_BIT = (1<<1),
GNSS_SV_OPTIONS_USED_IN_FIX_BIT = (1<<2),
} GnssSvOptionsBits;
typedef enum {
GNSS_ASSISTANCE_TYPE_SUPL = 0,
GNSS_ASSISTANCE_TYPE_C2K,
} GnssAssistanceType;
typedef enum {
GNSS_SUPL_MODE_STANDALONE = 0,
GNSS_SUPL_MODE_MSB,
GNSS_SUPL_MODE_MSA,
} GnssSuplMode;
typedef uint16_t GnssMeasurementsAdrStateMask;
typedef enum {
GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_UNKNOWN = 0,
GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_VALID_BIT = (1<<0),
GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_RESET_BIT = (1<<1),
GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_CYCLE_SLIP_BIT = (1<<2),
} GnssMeasurementsAdrStateBits;
typedef uint32_t GnssMeasurementsDataFlagsMask;
typedef enum {
GNSS_MEASUREMENTS_DATA_SV_ID_BIT = (1<<0),
GNSS_MEASUREMENTS_DATA_SV_TYPE_BIT = (1<<1),
GNSS_MEASUREMENTS_DATA_STATE_BIT = (1<<2),
GNSS_MEASUREMENTS_DATA_RECEIVED_SV_TIME_BIT = (1<<3),
GNSS_MEASUREMENTS_DATA_RECEIVED_SV_TIME_UNCERTAINTY_BIT = (1<<4),
GNSS_MEASUREMENTS_DATA_CARRIER_TO_NOISE_BIT = (1<<5),
GNSS_MEASUREMENTS_DATA_PSEUDORANGE_RATE_BIT = (1<<6),
GNSS_MEASUREMENTS_DATA_PSEUDORANGE_RATE_UNCERTAINTY_BIT = (1<<7),
GNSS_MEASUREMENTS_DATA_ADR_STATE_BIT = (1<<8),
GNSS_MEASUREMENTS_DATA_ADR_BIT = (1<<9),
GNSS_MEASUREMENTS_DATA_ADR_UNCERTAINTY_BIT = (1<<10),
GNSS_MEASUREMENTS_DATA_CARRIER_FREQUENCY_BIT = (1<<11),
GNSS_MEASUREMENTS_DATA_CARRIER_CYCLES_BIT = (1<<12),
GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_BIT = (1<<13),
GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_UNCERTAINTY_BIT = (1<<14),
GNSS_MEASUREMENTS_DATA_MULTIPATH_INDICATOR_BIT = (1<<15),
GNSS_MEASUREMENTS_DATA_SIGNAL_TO_NOISE_RATIO_BIT = (1<<16),
} GnssMeasurementsDataFlagsBits;
typedef uint32_t GnssMeasurementsStateMask;
typedef enum {
GNSS_MEASUREMENTS_STATE_UNKNOWN_BIT = 0,
GNSS_MEASUREMENTS_STATE_CODE_LOCK_BIT = (1<<0),
GNSS_MEASUREMENTS_STATE_BIT_SYNC_BIT = (1<<1),
GNSS_MEASUREMENTS_STATE_SUBFRAME_SYNC_BIT = (1<<2),
GNSS_MEASUREMENTS_STATE_TOW_DECODED_BIT = (1<<3),
GNSS_MEASUREMENTS_STATE_MSEC_AMBIGUOUS_BIT = (1<<4),
GNSS_MEASUREMENTS_STATE_SYMBOL_SYNC_BIT = (1<<5),
GNSS_MEASUREMENTS_STATE_GLO_STRING_SYNC_BIT = (1<<6),
GNSS_MEASUREMENTS_STATE_GLO_TOD_DECODED_BIT = (1<<7),
GNSS_MEASUREMENTS_STATE_BDS_D2_BIT_SYNC_BIT = (1<<8),
GNSS_MEASUREMENTS_STATE_BDS_D2_SUBFRAME_SYNC_BIT = (1<<9),
GNSS_MEASUREMENTS_STATE_GAL_E1BC_CODE_LOCK_BIT = (1<<10),
GNSS_MEASUREMENTS_STATE_GAL_E1C_2ND_CODE_LOCK_BIT = (1<<11),
GNSS_MEASUREMENTS_STATE_GAL_E1B_PAGE_SYNC_BIT = (1<<12),
GNSS_MEASUREMENTS_STATE_SBAS_SYNC_BIT = (1<<13),
} GnssMeasurementsStateBits;
typedef enum {
GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_UNKNOWN = 0,
GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_PRESENT,
GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_NOT_PRESENT,
} GnssMeasurementsMultipathIndicator;
typedef uint32_t GnssMeasurementsClockFlagsMask;
typedef enum {
GNSS_MEASUREMENTS_CLOCK_FLAGS_LEAP_SECOND_BIT = (1<<0),
GNSS_MEASUREMENTS_CLOCK_FLAGS_TIME_BIT = (1<<1),
GNSS_MEASUREMENTS_CLOCK_FLAGS_TIME_UNCERTAINTY_BIT = (1<<2),
GNSS_MEASUREMENTS_CLOCK_FLAGS_FULL_BIAS_BIT = (1<<3),
GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_BIT = (1<<4),
GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_UNCERTAINTY_BIT = (1<<5),
GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_BIT = (1<<6),
GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_UNCERTAINTY_BIT = (1<<7),
GNSS_MEASUREMENTS_CLOCK_FLAGS_HW_CLOCK_DISCONTINUITY_COUNT_BIT = (1<<8),
} GnssMeasurementsClockFlagsBits;
typedef uint32_t GnssAidingDataSvMask;
typedef enum {
GNSS_AIDING_DATA_SV_EPHEMERIS = (1<<0), // ephemeris
GNSS_AIDING_DATA_SV_ALMANAC = (1<<1), // almanac
GNSS_AIDING_DATA_SV_HEALTH = (1<<2), // health
GNSS_AIDING_DATA_SV_DIRECTION = (1<<3), // direction
GNSS_AIDING_DATA_SV_STEER = (1<<4), // steer
GNSS_AIDING_DATA_SV_ALMANAC_CORR = (1<<5), // almanac correction
GNSS_AIDING_DATA_SV_BLACKLIST = (1<<6), // blacklist SVs
GNSS_AIDING_DATA_SV_SA_DATA = (1<<7), // sensitivity assistance data
GNSS_AIDING_DATA_SV_NO_EXIST = (1<<8), // SV does not exist
GNSS_AIDING_DATA_SV_IONOSPHERE = (1<<9), // ionosphere correction
GNSS_AIDING_DATA_SV_TIME = (1<<10),// reset satellite time
} GnssAidingDataSvBits;
typedef uint32_t GnssAidingDataSvTypeMask;
typedef enum {
GNSS_AIDING_DATA_SV_TYPE_GPS = (1<<0),
GNSS_AIDING_DATA_SV_TYPE_GLONASS = (1<<1),
GNSS_AIDING_DATA_SV_TYPE_QZSS = (1<<2),
GNSS_AIDING_DATA_SV_TYPE_BEIDOU = (1<<3),
GNSS_AIDING_DATA_SV_TYPE_GALILEO = (1<<4),
} GnssAidingDataSvTypeBits;
typedef struct {
GnssAidingDataSvMask svMask; // bitwise OR of GnssAidingDataSvBits
GnssAidingDataSvTypeMask svTypeMask; // bitwise OR of GnssAidingDataSvTypeBits
} GnssAidingDataSv;
typedef uint32_t GnssAidingDataCommonMask;
typedef enum {
GNSS_AIDING_DATA_COMMON_POSITION = (1<<0), // position estimate
GNSS_AIDING_DATA_COMMON_TIME = (1<<1), // reset all clock values
GNSS_AIDING_DATA_COMMON_UTC = (1<<2), // UTC estimate
GNSS_AIDING_DATA_COMMON_RTI = (1<<3), // RTI
GNSS_AIDING_DATA_COMMON_FREQ_BIAS_EST = (1<<4), // frequency bias estimate
GNSS_AIDING_DATA_COMMON_CELLDB = (1<<5), // all celldb info
} GnssAidingDataCommonBits;
typedef struct {
GnssAidingDataCommonMask mask; // bitwise OR of GnssAidingDataCommonBits
} GnssAidingDataCommon;
typedef struct {
bool deleteAll; // if true, delete all aiding data and ignore other params
GnssAidingDataSv sv; // SV specific aiding data
GnssAidingDataCommon common; // common aiding data
} GnssAidingData;
typedef struct {
size_t size; // set to sizeof(Location)
LocationFlagsMask flags; // bitwise OR of LocationFlagsBits to mark which params are valid
uint64_t timestamp; // UTC timestamp for location fix, milliseconds since January 1, 1970
double latitude; // in degrees
double longitude; // in degrees
double altitude; // in meters above the WGS 84 reference ellipsoid
float speed; // in meters per second
float bearing; // in degrees; range [0, 360)
float accuracy; // in meters
LocationTechnologyMask techMask;
} Location;
typedef struct {
size_t size; // set to sizeof(LocationOptions)
uint32_t minInterval; // in milliseconds
uint32_t minDistance; // in meters. if minDistance > 0, gnssSvCallback/gnssNmeaCallback/
// gnssMeasurementsCallback may not be called
GnssSuplMode mode; // Standalone/MS-Based/MS-Assisted
} LocationOptions;
typedef struct {
size_t size; // set to sizeof(GeofenceOption)
GeofenceBreachTypeMask breachTypeMask; // bitwise OR of GeofenceBreachTypeBits
uint32_t responsiveness; // in milliseconds
uint32_t dwellTime; // in seconds
} GeofenceOption;
typedef struct {
size_t size; // set to sizeof(GeofenceInfo)
double latitude; // in degrees
double longitude; // in degrees
double radius; // in meters
} GeofenceInfo;
typedef struct {
size_t size; // set to sizeof(GeofenceBreachNotification)
size_t count; // number of ids in array
uint32_t* ids; // array of ids that have breached
Location location; // location associated with breach
GeofenceBreachType type; // type of breach
uint64_t timestamp; // timestamp of breach
} GeofenceBreachNotification;
typedef struct {
size_t size; // set to sizeof(GeofenceBreachNotification)
GeofenceStatusAvailable available; // GEOFENCE_STATUS_AVAILABILE_NO/_YES
LocationTechnologyType techType; // GNSS
} GeofenceStatusNotification;
typedef struct {
size_t size; // set to sizeof(GnssLocationInfo)
GnssLocationInfoFlagMask flags; // bitwise OR of GnssLocationInfoBits for param validity
float altitudeMeanSeaLevel; // altitude wrt mean sea level
float pdop; // position dilusion of precision
float hdop; // horizontal dilusion of precision
float vdop; // vertical dilusion of precision
float magneticDeviation; // magnetic deviation
float verAccuracy; // vertical accuracy in meters
float speedAccuracy; // speed accuracy in meters/second
float bearingAccuracy; // bearing accuracy in degrees (0 to 359.999)
LocationReliability horReliability; // horizontal reliability
LocationReliability verReliability; // vertical reliability
float horUncEllipseSemiMajor; // horizontal elliptical accuracy semi-major axis
float horUncEllipseSemiMinor; // horizontal elliptical accuracy semi-minor axis
float horUncEllipseOrientAzimuth; // horizontal elliptical accuracy azimuth
} GnssLocationInfoNotification;
typedef struct {
size_t size; // set to sizeof(GnssNiNotification)
GnssNiType type; // type of NI (Voice, SUPL, Control Plane)
GnssNiOptionsMask options; // bitwise OR of GnssNiOptionsBits
uint32_t timeout; // time (seconds) to wait for user input
GnssNiResponse timeoutResponse; // the response that should be sent when timeout expires
char requestor[GNSS_NI_REQUESTOR_MAX]; // the requestor that is making the request
GnssNiEncodingType requestorEncoding; // the encoding type for requestor
char message[GNSS_NI_MESSAGE_ID_MAX]; // the message to show user
GnssNiEncodingType messageEncoding; // the encoding type for message
char extras[GNSS_NI_MESSAGE_ID_MAX];
} GnssNiNotification;
typedef struct {
size_t size; // set to sizeof(GnssSv)
uint16_t svId; // Unique Identifier
GnssSvType type; // type of SV (GPS, SBAS, GLONASS, QZSS, BEIDOU, GALILEO)
float cN0Dbhz; // signal strength
float elevation; // elevation of SV (in degrees)
float azimuth; // azimuth of SV (in degrees)
GnssSvOptionsMask gnssSvOptionsMask; // Bitwise OR of GnssSvOptionsBits
} GnssSv;
typedef struct {
size_t size; // set to sizeof(GnssConfigSetAssistanceServer)
GnssAssistanceType type; // SUPL or C2K
const char* hostName; // null terminated string
uint32_t port; // port of server
} GnssConfigSetAssistanceServer;
typedef struct {
size_t size; // set to sizeof(GnssMeasurementsData)
GnssMeasurementsDataFlagsMask flags; // bitwise OR of GnssMeasurementsDataFlagsBits
int16_t svId;
GnssSvType svType;
double timeOffsetNs;
GnssMeasurementsStateMask stateMask; // bitwise OR of GnssMeasurementsStateBits
int64_t receivedSvTimeNs;
int64_t receivedSvTimeUncertaintyNs;
double carrierToNoiseDbHz;
double pseudorangeRateMps;
double pseudorangeRateUncertaintyMps;
GnssMeasurementsAdrStateMask adrStateMask; // bitwise OR of GnssMeasurementsAdrStateBits
double adrMeters;
double adrUncertaintyMeters;
float carrierFrequencyHz;
int64_t carrierCycles;
double carrierPhase;
double carrierPhaseUncertainty;
GnssMeasurementsMultipathIndicator multipathIndicator;
double signalToNoiseRatioDb;
} GnssMeasurementsData;
typedef struct {
size_t size; // set to sizeof(GnssMeasurementsClock)
GnssMeasurementsClockFlagsMask flags; // bitwise OR of GnssMeasurementsClockFlagsBits
int16_t leapSecond;
int64_t timeNs;
double timeUncertaintyNs;
int64_t fullBiasNs;
double biasNs;
double biasUncertaintyNs;
double driftNsps;
double driftUncertaintyNsps;
uint32_t hwClockDiscontinuityCount;
} GnssMeasurementsClock;
typedef struct {
size_t size; // set to sizeof(GnssSvNotification)
size_t count; // number of SVs in the GnssSv array
GnssSv gnssSvs[GNSS_SV_MAX]; // information on a number of SVs
} GnssSvNotification;
typedef struct {
size_t size; // set to sizeof(GnssNmeaNotification)
uint64_t timestamp; // timestamp
const char* nmea; // nmea text
size_t length; // length of the nmea text
} GnssNmeaNotification;
typedef struct {
size_t size; // set to sizeof(GnssMeasurementsNotification)
size_t count; // number of items in GnssMeasurements array
GnssMeasurementsData measurements[GNSS_MEASUREMENTS_MAX];
GnssMeasurementsClock clock; // clock
} GnssMeasurementsNotification;
typedef struct {
size_t size; // set to sizeof(GnssConfig)
GnssConfigFlagsMask flags; // bitwise OR of GnssConfigFlagsBits to mark which params are valid
GnssConfigGpsLock gpsLock;
GnssConfigSuplVersion suplVersion;
GnssConfigSetAssistanceServer assistanceServer;
GnssConfigLppProfile lppProfile;
GnssConfigLppeControlPlaneMask lppeControlPlaneMask;
GnssConfigLppeUserPlaneMask lppeUserPlaneMask;
GnssConfigAGlonassPositionProtocolMask aGlonassPositionProtocolMask;
GnssConfigEmergencyPdnForEmergencySupl emergencyPdnForEmergencySupl;
GnssConfigSuplEmergencyServices suplEmergencyServices;
GnssConfigSuplModeMask suplModeMask; //bitwise OR of GnssConfigSuplModeBits
} GnssConfig;
/* Provides the capabilities of the system
capabilities callback is called once soon after createInstance is called */
typedef std::function<void(
LocationCapabilitiesMask capabilitiesMask // bitwise OR of LocationCapabilitiesBits
)> capabilitiesCallback;
/* Used by tracking, batching, and miscellanous APIs
responseCallback is called for every Tracking, Batching API, and Miscellanous API */
typedef std::function<void(
LocationError err, // if not SUCCESS, then id is not valid
uint32_t id // id to be associated to the request
)> responseCallback;
/* Used by APIs that gets more than one LocationError in it's response
collectiveResponseCallback is called for every geofence API call.
ids array and LocationError array are only valid until collectiveResponseCallback returns. */
typedef std::function<void(
size_t count, // number of locations in arrays
LocationError* errs, // array of LocationError associated to the request
uint32_t* ids // array of ids to be associated to the request
)> collectiveResponseCallback;
/* Used for startTracking API, optional can be NULL
trackingCallback is called when delivering a location in a tracking session
broadcasted to all clients, no matter if a session has started by client */
typedef std::function<void(
Location location
)> trackingCallback;
/* Used for startBatching API, optional can be NULL
batchingCallback is called when delivering locations in a batching session.
broadcasted to all clients, no matter if a session has started by client */
typedef std::function<void(
size_t count, // number of locations in array
Location* location // array of locations
)> batchingCallback;
/* Gives GNSS Location information, optional can be NULL
gnssLocationInfoCallback is called only during a tracking session
broadcasted to all clients, no matter if a session has started by client */
typedef std::function<void(
GnssLocationInfoNotification gnssLocationInfoNotification
)> gnssLocationInfoCallback;
/* Used for addGeofences API, optional can be NULL
geofenceBreachCallback is called when any number of geofences have a state change */
typedef std::function<void(
GeofenceBreachNotification geofenceBreachNotification
)> geofenceBreachCallback;
/* Used for addGeofences API, optional can be NULL
geofenceStatusCallback is called when any number of geofences have a status change */
typedef std::function<void(
GeofenceStatusNotification geofenceStatusNotification
)> geofenceStatusCallback;
/* Network Initiated request, optional can be NULL
This callback should be responded to by calling gnssNiResponse */
typedef std::function<void(
uint32_t id, // id that should be used to respond by calling gnssNiResponse
GnssNiNotification gnssNiNotification
)> gnssNiCallback;
/* Gives GNSS SV information, optional can be NULL
gnssSvCallback is called only during a tracking session
broadcasted to all clients, no matter if a session has started by client */
typedef std::function<void(
GnssSvNotification gnssSvNotification
)> gnssSvCallback;
/* Gives GNSS NMEA data, optional can be NULL
gnssNmeaCallback is called only during a tracking session
broadcasted to all clients, no matter if a session has started by client */
typedef std::function<void(
GnssNmeaNotification gnssNmeaNotification
)> gnssNmeaCallback;
/* Gives GNSS Measurements information, optional can be NULL
gnssMeasurementsCallback is called only during a tracking session
broadcasted to all clients, no matter if a session has started by client */
typedef std::function<void(
GnssMeasurementsNotification gnssMeasurementsNotification
)> gnssMeasurementsCallback;
typedef struct {
size_t size; // set to sizeof(LocationCallbacks)
capabilitiesCallback capabilitiesCb; // mandatory
responseCallback responseCb; // mandatory
collectiveResponseCallback collectiveResponseCb; // mandatory
trackingCallback trackingCb; // optional
batchingCallback batchingCb; // optional
geofenceBreachCallback geofenceBreachCb; // optional
geofenceStatusCallback geofenceStatusCb; // optional
gnssLocationInfoCallback gnssLocationInfoCb; // optional
gnssNiCallback gnssNiCb; // optional
gnssSvCallback gnssSvCb; // optional
gnssNmeaCallback gnssNmeaCb; // optional
gnssMeasurementsCallback gnssMeasurementsCb; // optional
} LocationCallbacks;
class LocationAPI
{
private:
LocationAPI();
~LocationAPI();
public:
/* creates an instance to LocationAPI object.
Will return NULL if mandatory parameters are invalid or if the maximum number
of instances have been reached */
static LocationAPI* createInstance(LocationCallbacks&);
/* destroy/cleans up the instance, which should be called when LocationAPI object is
no longer needed. LocationAPI* returned from createInstance will no longer valid
after destroy is called */
void destroy();
/* updates/changes the callbacks that will be called.
mandatory callbacks must be present for callbacks to be successfully updated
no return value */
void updateCallbacks(LocationCallbacks&);
/* ================================== TRACKING ================================== */
/* startTracking starts a tracking session, which returns a session id that will be
used by the other tracking APIs and also in the responseCallback to match command
with response. locations are reported on the trackingCallback passed in createInstance
periodically according to LocationOptions.
responseCallback returns:
LOCATION_ERROR_SUCCESS if session was successfully started
LOCATION_ERROR_ALREADY_STARTED if a startTracking session is already in progress
LOCATION_ERROR_CALLBACK_MISSING if no trackingCallback was passed in createInstance
LOCATION_ERROR_INVALID_PARAMETER if LocationOptions parameter is invalid */
uint32_t startTracking(LocationOptions&); // returns session id
/* stopTracking stops a tracking session associated with id parameter.
responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_ID_UNKNOWN if id is not associated with a tracking session */
void stopTracking(uint32_t id);
/* updateTrackingOptions changes the LocationOptions of a tracking session associated with id
responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if LocationOptions parameters are invalid
LOCATION_ERROR_ID_UNKNOWN if id is not associated with a tracking session */
void updateTrackingOptions(uint32_t id, LocationOptions&);
/* ================================== BATCHING ================================== */
/* startBatching starts a batching session, which returns a session id that will be
used by the other batching APIs and also in the responseCallback to match command
with response. locations are reported on the batchingCallback passed in createInstance
periodically according to LocationOptions. A batching session starts tracking on
the low power processor and delivers them in batches by the batchingCallback when
the batch is full or when getBatchedLocations is called. This allows for the processor
that calls this API to sleep when the low power processor can batch locations in the
backgroup and wake up the processor calling the API only when the batch is full, thus
saving power
responseCallback returns:
LOCATION_ERROR_SUCCESS if session was successful
LOCATION_ERROR_ALREADY_STARTED if a startBatching session is already in progress
LOCATION_ERROR_CALLBACK_MISSING if no batchingCallback was passed in createInstance
LOCATION_ERROR_INVALID_PARAMETER if a parameter is invalid
LOCATION_ERROR_NOT_SUPPORTED if batching is not supported */
uint32_t startBatching(LocationOptions&); // returns session id
/* stopBatching stops a batching session associated with id parameter.
responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_ID_UNKNOWN if id is not associated with batching session */
void stopBatching(uint32_t id);
/* updateBatchingOptions changes the LocationOptions of a batching session associated with id
responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if LocationOptions parameters are invalid
LOCATION_ERROR_ID_UNKNOWN if id is not associated with a batching session */
void updateBatchingOptions(uint32_t id, LocationOptions&);
/* getBatchedLocations gets a number of locations that are currently stored/batched
on the low power processor, delivered by the batchingCallback passed in createInstance.
Location are then deleted from the batch stored on the low power processor.
responseCallback returns:
LOCATION_ERROR_SUCCESS if successful, will be followed by batchingCallback call
LOCATION_ERROR_CALLBACK_MISSING if no batchingCallback was passed in createInstance
LOCATION_ERROR_ID_UNKNOWN if id is not associated with a batching session */
void getBatchedLocations(uint32_t id, size_t count);
/* ================================== GEOFENCE ================================== */
/* addGeofences adds any number of geofences and returns an array of geofence ids that
will be used by the other geofence APIs and also in the collectiveResponseCallback to
match command with response. The geofenceBreachCallback will deliver the status of each
geofence according to the GeofenceOption for each. The geofence id array returned will
be valid until the collectiveResponseCallback is called and has returned.
collectiveResponseCallback returns:
LOCATION_ERROR_SUCCESS if session was successful
LOCATION_ERROR_CALLBACK_MISSING if no geofenceBreachCallback
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
LOCATION_ERROR_NOT_SUPPORTED if geofence is not supported */
uint32_t* addGeofences(size_t count, GeofenceOption*, GeofenceInfo*); // returns id array
/* removeGeofences removes any number of geofences. Caller should delete ids array after
removeGeofences returneds.
collectiveResponseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session */
void removeGeofences(size_t count, uint32_t* ids);
/* modifyGeofences modifies any number of geofences. Caller should delete ids array after
modifyGeofences returns.
collectiveResponseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid */
void modifyGeofences(size_t count, uint32_t* ids, GeofenceOption* options);
/* pauseGeofences pauses any number of geofences, which is similar to removeGeofences,
only that they can be resumed at any time. Caller should delete ids array after
pauseGeofences returns.
collectiveResponseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session */
void pauseGeofences(size_t count, uint32_t* ids);
/* resumeGeofences resumes any number of geofences that are currently paused. Caller should
delete ids array after resumeGeofences returns.
collectiveResponseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session */
void resumeGeofences(size_t count, uint32_t* ids);
/* ================================== GNSS ====================================== */
/* gnssNiResponse is called in response to a gnssNiCallback.
responseCallback returns:
LOCATION_ERROR_SUCCESS if session was successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters in GnssNiResponse are invalid
LOCATION_ERROR_ID_UNKNOWN if id does not match a gnssNiCallback */
void gnssNiResponse(uint32_t id, GnssNiResponse response);
};
typedef struct {
size_t size; // set to sizeof(LocationControlCallbacks)
responseCallback responseCb; // mandatory
collectiveResponseCallback collectiveResponseCb; // mandatory
} LocationControlCallbacks;
class LocationControlAPI
{
private:
LocationControlAPI();
~LocationControlAPI();
public:
/* creates an instance to LocationControlAPI object.
Will return NULL if mandatory parameters are invalid or if the maximum number
of instances have been reached. Only once instance allowed */
static LocationControlAPI* createInstance(LocationControlCallbacks&);
/* destroy/cleans up the instance, which should be called when LocationControlAPI object is
no longer needed. LocationControlAPI* returned from createInstance will no longer valid
after destroy is called */
void destroy();
/* enable will enable specific location technology to be used for calculation locations and
will effectively start a control session if call is successful, which returns a session id
that will be returned in responseCallback to match command with response. The session id is
also needed to call the disable command.
This effect is global for all clients of LocationAPI
responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_ALREADY_STARTED if an enable was already called for this techType
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
LOCATION_ERROR_GENERAL_FAILURE if failure for any other reason */
uint32_t enable(LocationTechnologyType techType);
/* disable will disable specific location technology to be used for calculation locations and
effectively ends the control session if call is successful.
id parameter is the session id that was returned in enable responseCallback for techType.
The session id is no longer valid after disable's responseCallback returns success.
This effect is global for all clients of LocationAPI
responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_ID_UNKNOWN if id was not returned from responseCallback from enable
LOCATION_ERROR_GENERAL_FAILURE if failure for any other reason */
void disable(uint32_t id);
/* gnssUpdateConfig updates the gnss specific configuration, which returns a session id array
with an id for each of the bits set in GnssConfig.flags, order from low bits to high bits.
The response for each config that is set will be returned in collectiveResponseCallback.
The session id array returned will be valid until the collectiveResponseCallback is called
and has returned. This effect is global for all clients of LocationAPI
collectiveResponseCallback returns:
LOCATION_ERROR_SUCCESS if session was successful
LOCATION_ERROR_INVALID_PARAMETER if any other parameters are invalid
LOCATION_ERROR_GENERAL_FAILURE if failure for any other reason */
uint32_t* gnssUpdateConfig(GnssConfig config);
/* delete specific gnss aiding data for testing, which returns a session id
that will be returned in responseCallback to match command with response.
Only allowed in userdebug builds. This effect is global for all clients of LocationAPI
responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
LOCATION_ERROR_NOT_SUPPORTED if build is not userdebug */
uint32_t gnssDeleteAidingData(GnssAidingData& data);
};
#endif /* LOCATION_H */

View file

@ -0,0 +1,769 @@
/* Copyright (c) 2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define LOG_NDDEBUG 0
#define LOG_TAG "LocSvc_APIClientBase"
#include <log_util.h>
#include <loc_cfg.h>
#include "LocationAPIClientBase.h"
#define FLP_CONF_FILE "/etc/flp.conf"
LocationAPIClientBase::LocationAPIClientBase() :
mTrackingCallback(nullptr),
mBatchingCallback(nullptr),
mGeofenceBreachCallback(nullptr),
mLocationAPI(nullptr),
mLocationControlAPI(nullptr),
mBatchSize(-1)
{
// use recursive mutex, in case callback come from the same thread
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&mMutex, &attr);
for (int i = 0; i < REQUEST_MAX; i++) {
mRequestQueues[i] = nullptr;
}
memset(&mConfig, 0, sizeof(GnssConfig));
}
void LocationAPIClientBase::locAPISetCallbacks(LocationCallbacks& locationCallbacks)
{
if (locationCallbacks.geofenceBreachCb != nullptr) {
mGeofenceBreachCallback = locationCallbacks.geofenceBreachCb;
locationCallbacks.geofenceBreachCb =
[this](GeofenceBreachNotification geofenceBreachNotification) {
beforeGeofenceBreachCb(geofenceBreachNotification);
};
}
locationCallbacks.capabilitiesCb =
[this](LocationCapabilitiesMask capabilitiesMask) {
onCapabilitiesCb(capabilitiesMask);
};
locationCallbacks.responseCb = [this](LocationError error, uint32_t id) {
onResponseCb(error, id);
};
locationCallbacks.collectiveResponseCb =
[this](size_t count, LocationError* errors, uint32_t* ids) {
onCollectiveResponseCb(count, errors, ids);
};
if (mLocationAPI == nullptr ) {
mLocationAPI = LocationAPI::createInstance(locationCallbacks);
} else {
mLocationAPI->updateCallbacks(locationCallbacks);
}
if (mLocationControlAPI == nullptr) {
LocationControlCallbacks locationControlCallbacks;
locationControlCallbacks.size = sizeof(LocationControlCallbacks);
locationControlCallbacks.responseCb =
[this](LocationError error, uint32_t id) {
onCtrlResponseCb(error, id);
};
locationControlCallbacks.collectiveResponseCb =
[this](size_t count, LocationError* errors, uint32_t* ids) {
onCtrlCollectiveResponseCb(count, errors, ids);
};
mLocationControlAPI = LocationControlAPI::createInstance(locationControlCallbacks);
}
}
LocationAPIClientBase::~LocationAPIClientBase()
{
if (mLocationAPI) {
mLocationAPI->destroy();
mLocationAPI = nullptr;
}
if (mLocationControlAPI) {
mLocationControlAPI->destroy();
mLocationControlAPI = nullptr;
}
pthread_mutex_lock(&mMutex);
for (int i = 0; i < REQUEST_MAX; i++) {
if (mRequestQueues[i]) {
delete mRequestQueues[i];
mRequestQueues[i] = nullptr;
}
}
pthread_mutex_unlock(&mMutex);
pthread_mutex_destroy(&mMutex);
}
uint32_t LocationAPIClientBase::locAPIStartTracking(LocationOptions& options)
{
uint32_t retVal = LOCATION_ERROR_GENERAL_FAILURE;
if (mLocationAPI) {
pthread_mutex_lock(&mMutex);
RequestQueue* requests = mRequestQueues[REQUEST_TRACKING];
if (requests) {
delete requests;
}
uint32_t session = mLocationAPI->startTracking(options);
LOC_LOGI("%s:%d] start new session: %d", __FUNCTION__, __LINE__, session);
// onResponseCb might be called from other thread immediately after
// startTracking returns, so we are not going to unlock mutex
// until StartTrackingRequest is pushed into mRequestQueues[REQUEST_TRACKING]
requests = new RequestQueue(session);
requests->push(new StartTrackingRequest(*this));
mRequestQueues[REQUEST_TRACKING] = requests;
pthread_mutex_unlock(&mMutex);
retVal = LOCATION_ERROR_SUCCESS;
}
return retVal;
}
void LocationAPIClientBase::locAPIStopTracking()
{
if (mLocationAPI) {
pthread_mutex_lock(&mMutex);
uint32_t session = -1;
RequestQueue* requests = mRequestQueues[REQUEST_TRACKING];
if (requests) {
session = requests->getSession();
requests->push(new StopTrackingRequest(*this));
mLocationAPI->stopTracking(session);
}
pthread_mutex_unlock(&mMutex);
}
}
void LocationAPIClientBase::locAPIUpdateTrackingOptions(LocationOptions& options)
{
if (mLocationAPI) {
pthread_mutex_lock(&mMutex);
uint32_t session = -1;
RequestQueue* requests = mRequestQueues[REQUEST_TRACKING];
if (requests) {
session = requests->getSession();
requests->push(new UpdateTrackingOptionsRequest(*this));
mLocationAPI->updateTrackingOptions(session, options);
}
pthread_mutex_unlock(&mMutex);
}
}
int32_t LocationAPIClientBase::locAPIGetBatchSize()
{
if (mBatchSize == -1) {
const loc_param_s_type flp_conf_param_table[] =
{
{"BATCH_SIZE", &mBatchSize, nullptr, 'n'},
};
UTIL_READ_CONF(FLP_CONF_FILE, flp_conf_param_table);
if (mBatchSize < 0) {
// set mBatchSize to 0 if we got an illegal value from config file
mBatchSize = 0;
}
}
return mBatchSize;
}
uint32_t LocationAPIClientBase::locAPIStartSession(uint32_t id, uint32_t sessionMode,
LocationOptions& options)
{
uint32_t retVal = LOCATION_ERROR_GENERAL_FAILURE;
if (mLocationAPI) {
pthread_mutex_lock(&mMutex);
if (mSessionMap.find(id) != mSessionMap.end()) {
LOC_LOGE("%s:%d] session %d has already started.", __FUNCTION__, __LINE__, id);
retVal = LOCATION_ERROR_ALREADY_STARTED;
} else {
uint32_t trackingSession = 0;
uint32_t batchingSession = 0;
if (sessionMode == SESSION_MODE_ON_FIX) {
RequestQueue* requests = mRequestQueues[REQUEST_TRACKING];
if (requests) {
delete requests;
}
trackingSession = mLocationAPI->startTracking(options);
LOC_LOGI("%s:%d] start new session: %d", __FUNCTION__, __LINE__, trackingSession);
requests = new RequestQueue(trackingSession);
requests->push(new StartTrackingRequest(*this));
mRequestQueues[REQUEST_TRACKING] = requests;
} else if (sessionMode == SESSION_MODE_ON_FULL) {
RequestQueue* requests = mRequestQueues[REQUEST_BATCHING];
if (requests) {
delete requests;
}
batchingSession = mLocationAPI->startBatching(options);
LOC_LOGI("%s:%d] start new session: %d", __FUNCTION__, __LINE__, batchingSession);
requests = new RequestQueue(batchingSession);
requests->push(new StartBatchingRequest(*this));
mRequestQueues[REQUEST_BATCHING] = requests;
}
SessionEntity entity;
entity.id = id;
entity.trackingSession = trackingSession;
entity.batchingSession = batchingSession;
entity.sessionMode = sessionMode;
mSessionMap[id] = entity;
retVal = LOCATION_ERROR_SUCCESS;
}
pthread_mutex_unlock(&mMutex);
}
return retVal;
}
uint32_t LocationAPIClientBase::locAPIStopSession(uint32_t id)
{
uint32_t retVal = LOCATION_ERROR_GENERAL_FAILURE;
if (mLocationAPI) {
pthread_mutex_lock(&mMutex);
if (mSessionMap.find(id) != mSessionMap.end()) {
SessionEntity entity = mSessionMap[id];
uint32_t trackingSession = entity.trackingSession;
uint32_t batchingSession = entity.batchingSession;
uint32_t sMode = entity.sessionMode;
mSessionMap.erase(id);
if (sMode == SESSION_MODE_ON_FIX) {
RequestQueue* requests = mRequestQueues[REQUEST_TRACKING];
if (requests) {
requests->push(new StopTrackingRequest(*this));
mLocationAPI->stopTracking(trackingSession);
}
} else if (sMode == SESSION_MODE_ON_FULL) {
RequestQueue* requests = mRequestQueues[REQUEST_BATCHING];
if (requests) {
requests->push(new StopBatchingRequest(*this));
mLocationAPI->stopBatching(batchingSession);
}
}
retVal = LOCATION_ERROR_SUCCESS;
} else {
retVal = LOCATION_ERROR_ID_UNKNOWN;
LOC_LOGE("%s:%d] session %d is not exist.", __FUNCTION__, __LINE__, id);
}
pthread_mutex_unlock(&mMutex);
}
return retVal;
}
uint32_t LocationAPIClientBase::locAPIUpdateSessionOptions(uint32_t id, uint32_t sessionMode,
LocationOptions& options)
{
uint32_t retVal = LOCATION_ERROR_GENERAL_FAILURE;
if (mLocationAPI) {
pthread_mutex_lock(&mMutex);
if (mSessionMap.find(id) != mSessionMap.end()) {
SessionEntity& entity = mSessionMap[id];
uint32_t trackingSession = entity.trackingSession;
uint32_t batchingSession = entity.batchingSession;
uint32_t sMode = entity.sessionMode;
if (sessionMode == SESSION_MODE_ON_FIX) {
if (sMode == SESSION_MODE_ON_FIX) {
RequestQueue* requests = mRequestQueues[REQUEST_TRACKING];
if (requests) {
requests->push(new UpdateTrackingOptionsRequest(*this));
mLocationAPI->updateTrackingOptions(trackingSession, options);
}
} else if (sMode == SESSION_MODE_ON_FULL) {
// stop batching
{
RequestQueue* requests = mRequestQueues[REQUEST_BATCHING];
if (requests) {
requests->push(new StopBatchingRequest(*this));
mLocationAPI->stopBatching(batchingSession);
batchingSession = 0;
}
}
// start tracking
{
RequestQueue* requests = mRequestQueues[REQUEST_TRACKING];
if (requests) {
delete requests;
}
trackingSession = mLocationAPI->startTracking(options);
LOC_LOGI("%s:%d] start new session: %d",
__FUNCTION__, __LINE__, trackingSession);
requests = new RequestQueue(trackingSession);
requests->push(new StartTrackingRequest(*this));
mRequestQueues[REQUEST_TRACKING] = requests;
}
}
} else if (sessionMode == SESSION_MODE_ON_FULL) {
if (sMode == SESSION_MODE_ON_FIX) {
// stop tracking
{
RequestQueue* requests = mRequestQueues[REQUEST_TRACKING];
if (requests) {
requests->push(new StopTrackingRequest(*this));
mLocationAPI->stopTracking(trackingSession);
trackingSession = 0;
}
}
// start batching
{
RequestQueue* requests = mRequestQueues[REQUEST_BATCHING];
if (requests) {
delete requests;
}
batchingSession = mLocationAPI->startBatching(options);
LOC_LOGI("%s:%d] start new session: %d",
__FUNCTION__, __LINE__, batchingSession);
requests = new RequestQueue(batchingSession);
requests->push(new StartBatchingRequest(*this));
mRequestQueues[REQUEST_BATCHING] = requests;
}
} else if (sMode == SESSION_MODE_ON_FULL) {
RequestQueue* requests = mRequestQueues[REQUEST_BATCHING];
requests = mRequestQueues[REQUEST_BATCHING];
if (requests) {
requests->push(new UpdateBatchingOptionsRequest(*this));
mLocationAPI->updateBatchingOptions(batchingSession, options);
}
}
}
entity.trackingSession = trackingSession;
entity.batchingSession = batchingSession;
entity.sessionMode = sessionMode;
retVal = LOCATION_ERROR_SUCCESS;
} else {
retVal = LOCATION_ERROR_ID_UNKNOWN;
LOC_LOGE("%s:%d] session %d is not exist.", __FUNCTION__, __LINE__, id);
}
pthread_mutex_unlock(&mMutex);
}
return retVal;
}
void LocationAPIClientBase::locAPIGetBatchedLocations(size_t count)
{
if (mLocationAPI) {
pthread_mutex_lock(&mMutex);
uint32_t session = -1;
RequestQueue* requests = mRequestQueues[REQUEST_BATCHING];
if (requests) {
session = requests->getSession();
requests->push(new GetBatchedLocationsRequest(*this));
mLocationAPI->getBatchedLocations(session, count);
}
pthread_mutex_unlock(&mMutex);
}
}
uint32_t LocationAPIClientBase::locAPIAddGeofences(
size_t count, uint32_t* ids, GeofenceOption* options, GeofenceInfo* data)
{
uint32_t retVal = LOCATION_ERROR_GENERAL_FAILURE;
if (mLocationAPI) {
pthread_mutex_lock(&mMutex);
RequestQueue* requests = mRequestQueues[REQUEST_GEOFENCE];
if (requests) {
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;
for (size_t i = 0; i < count; i++) {
mGeofenceBiDict.set(ids[i], sessions[i], options[i].breachTypeMask);
}
pthread_mutex_unlock(&mMutex);
retVal = LOCATION_ERROR_SUCCESS;
}
return retVal;
}
void LocationAPIClientBase::locAPIRemoveGeofences(size_t count, uint32_t* ids)
{
if (mLocationAPI) {
uint32_t* sessions = (uint32_t*)malloc(sizeof(uint32_t) * count);
pthread_mutex_lock(&mMutex);
RequestQueue* requests = mRequestQueues[REQUEST_GEOFENCE];
if (requests) {
for (size_t i = 0; i < count; i++) {
sessions[i] = mGeofenceBiDict.getSession(ids[i]);
}
requests->push(new RemoveGeofencesRequest(*this));
mLocationAPI->removeGeofences(count, sessions);
}
pthread_mutex_unlock(&mMutex);
free(sessions);
}
}
void LocationAPIClientBase::locAPIModifyGeofences(
size_t count, uint32_t* ids, GeofenceOption* options)
{
if (mLocationAPI) {
uint32_t* sessions = (uint32_t*)malloc(sizeof(uint32_t) * count);
pthread_mutex_lock(&mMutex);
RequestQueue* requests = mRequestQueues[REQUEST_GEOFENCE];
if (requests) {
for (size_t i = 0; i < count; i++) {
sessions[i] = mGeofenceBiDict.getSession(ids[i]);
mGeofenceBiDict.set(ids[i], sessions[i], options[i].breachTypeMask);
}
requests->push(new ModifyGeofencesRequest(*this));
mLocationAPI->modifyGeofences(count, sessions, options);
}
pthread_mutex_unlock(&mMutex);
free(sessions);
}
}
void LocationAPIClientBase::locAPIPauseGeofences(size_t count, uint32_t* ids)
{
if (mLocationAPI) {
uint32_t* sessions = (uint32_t*)malloc(sizeof(uint32_t) * count);
pthread_mutex_lock(&mMutex);
RequestQueue* requests = mRequestQueues[REQUEST_GEOFENCE];
if (requests) {
for (size_t i = 0; i < count; i++) {
sessions[i] = mGeofenceBiDict.getSession(ids[i]);
}
requests->push(new PauseGeofencesRequest(*this));
mLocationAPI->pauseGeofences(count, sessions);
}
pthread_mutex_unlock(&mMutex);
free(sessions);
}
}
void LocationAPIClientBase::locAPIResumeGeofences(
size_t count, uint32_t* ids, GeofenceBreachTypeMask* mask)
{
if (mLocationAPI) {
uint32_t* sessions = (uint32_t*)malloc(sizeof(uint32_t) * count);
pthread_mutex_lock(&mMutex);
RequestQueue* requests = mRequestQueues[REQUEST_GEOFENCE];
if (requests) {
for (size_t i = 0; i < count; i++) {
sessions[i] = mGeofenceBiDict.getSession(ids[i]);
if (mask) {
mGeofenceBiDict.set(ids[i], sessions[i], mask[i]);
}
}
requests->push(new ResumeGeofencesRequest(*this));
mLocationAPI->resumeGeofences(count, sessions);
}
pthread_mutex_unlock(&mMutex);
free(sessions);
}
}
void LocationAPIClientBase::locAPIRemoveAllGeofences()
{
if (mLocationAPI) {
std::vector<uint32_t> sessionsVec = mGeofenceBiDict.getAllSessions();
size_t count = sessionsVec.size();
uint32_t* sessions = (uint32_t*)malloc(sizeof(uint32_t) * count);
pthread_mutex_lock(&mMutex);
RequestQueue* requests = mRequestQueues[REQUEST_GEOFENCE];
if (requests) {
for (size_t i = 0; i < count; i++) {
sessions[i] = sessionsVec[i];
}
requests->push(new RemoveGeofencesRequest(*this));
mLocationAPI->removeGeofences(count, sessions);
}
pthread_mutex_unlock(&mMutex);
free(sessions);
}
}
void LocationAPIClientBase::locAPIGnssNiResponse(uint32_t id, GnssNiResponse response)
{
uint32_t session = 0;
if (mLocationAPI) {
pthread_mutex_lock(&mMutex);
RequestQueue* requests = mRequestQueues[REQUEST_NIRESPONSE];
if (requests) {
delete requests;
}
uint32_t session = id;
mLocationAPI->gnssNiResponse(id, response);
LOC_LOGI("%s:%d] start new session: %d", __FUNCTION__, __LINE__, session);
requests = new RequestQueue(session);
requests->push(new GnssNiResponseRequest(*this));
mRequestQueues[REQUEST_NIRESPONSE] = requests;
pthread_mutex_unlock(&mMutex);
}
}
uint32_t LocationAPIClientBase::locAPIGnssDeleteAidingData(GnssAidingData& data)
{
uint32_t retVal = LOCATION_ERROR_GENERAL_FAILURE;
if (mLocationControlAPI) {
pthread_mutex_lock(&mMutex);
RequestQueue* requests = mRequestQueues[REQUEST_DELETEAIDINGDATA];
if (requests) {
delete requests;
}
uint32_t session = mLocationControlAPI->gnssDeleteAidingData(data);
LOC_LOGI("%s:%d] start new session: %d", __FUNCTION__, __LINE__, session);
requests = new RequestQueue(session);
requests->push(new GnssDeleteAidingDataRequest(*this));
mRequestQueues[REQUEST_DELETEAIDINGDATA] = requests;
pthread_mutex_unlock(&mMutex);
retVal = LOCATION_ERROR_SUCCESS;
}
return retVal;
}
uint32_t LocationAPIClientBase::locAPIEnable(LocationTechnologyType techType)
{
uint32_t retVal = LOCATION_ERROR_GENERAL_FAILURE;
if (mLocationControlAPI) {
pthread_mutex_lock(&mMutex);
RequestQueue* requests = mRequestQueues[REQUEST_CONTROL];
if (requests) {
delete requests;
}
uint32_t session = mLocationControlAPI->enable(techType);
LOC_LOGI("%s:%d] start new session: %d", __FUNCTION__, __LINE__, session);
requests = new RequestQueue(session);
requests->push(new EnableRequest(*this));
mRequestQueues[REQUEST_CONTROL] = requests;
pthread_mutex_unlock(&mMutex);
retVal = LOCATION_ERROR_SUCCESS;
}
return retVal;
}
void LocationAPIClientBase::locAPIDisable()
{
if (mLocationControlAPI) {
pthread_mutex_lock(&mMutex);
uint32_t session = -1;
RequestQueue* requests = mRequestQueues[REQUEST_CONTROL];
if (requests) {
session = requests->getSession();
requests->push(new DisableRequest(*this));
mLocationControlAPI->disable(session);
}
pthread_mutex_unlock(&mMutex);
}
}
uint32_t LocationAPIClientBase::locAPIGnssUpdateConfig(GnssConfig config)
{
uint32_t retVal = LOCATION_ERROR_GENERAL_FAILURE;
if (memcmp(&mConfig, &config, sizeof(GnssConfig)) == 0) {
LOC_LOGE("%s:%d] GnssConfig is identical to previous call", __FUNCTION__, __LINE__);
return retVal;
}
if (mLocationControlAPI) {
pthread_mutex_lock(&mMutex);
memcpy(&mConfig, &config, sizeof(GnssConfig));
uint32_t session = -1;
RequestQueue* requests = mRequestQueues[REQUEST_CONTROL];
if (requests) {
session = requests->getSession();
requests->push(new GnssUpdateConfigRequest(*this));
uint32_t* idArray = mLocationControlAPI->gnssUpdateConfig(config);
LOC_LOGV("%s:%d] gnssUpdateConfig return array: %p", __FUNCTION__, __LINE__, idArray);
}
pthread_mutex_unlock(&mMutex);
retVal = LOCATION_ERROR_SUCCESS;
}
return retVal;
}
void LocationAPIClientBase::beforeGeofenceBreachCb(
GeofenceBreachNotification geofenceBreachNotification)
{
if (mGeofenceBreachCallback == nullptr)
return;
uint32_t* ids = (uint32_t*)malloc(sizeof(uint32_t) * geofenceBreachNotification.count);
uint32_t* backup = geofenceBreachNotification.ids;
size_t n = geofenceBreachNotification.count;
size_t count = 0;
for (size_t i = 0; i < n; i++) {
uint32_t id = mGeofenceBiDict.getId(geofenceBreachNotification.ids[i]);
GeofenceBreachTypeMask type = mGeofenceBiDict.getType(geofenceBreachNotification.ids[i]);
if ((geofenceBreachNotification.type == GEOFENCE_BREACH_ENTER &&
(type & GEOFENCE_BREACH_ENTER_BIT)) ||
(geofenceBreachNotification.type == GEOFENCE_BREACH_EXIT &&
(type & GEOFENCE_BREACH_EXIT_BIT))
) {
ids[count] = id;
count++;
}
}
geofenceBreachNotification.count = count;
geofenceBreachNotification.ids = ids;
mGeofenceBreachCallback(geofenceBreachNotification);
// restore ids
geofenceBreachNotification.ids = backup;
geofenceBreachNotification.count = n;
free(ids);
}
void LocationAPIClientBase::onResponseCb(LocationError error, uint32_t id)
{
if (error != LOCATION_ERROR_SUCCESS) {
LOC_LOGE("%s:%d] ERROR: %d ID: %d", __FUNCTION__, __LINE__, error, id);
} else {
LOC_LOGV("%s:%d] error: %d id: %d", __FUNCTION__, __LINE__, error, id);
}
LocationAPIRequest* request = getRequestBySession(id);
if (request) {
request->onResponse(error);
delete request;
}
}
void LocationAPIClientBase::onCollectiveResponseCb(
size_t count, LocationError* errors, uint32_t* ids)
{
for (size_t i = 0; i < count; i++) {
if (errors[i] != LOCATION_ERROR_SUCCESS) {
LOC_LOGE("%s:%d] ERROR: %d ID: %d", __FUNCTION__, __LINE__, errors[i], ids[i]);
} else {
LOC_LOGV("%s:%d] error: %d id: %d", __FUNCTION__, __LINE__, errors[i], ids[i]);
}
}
LocationAPIRequest* request = nullptr;
if (count > 0 && ids)
request = getRequestBySession(ids[0]);
if (!request)
request = getGeofencesRequest();
if (request) {
request->onCollectiveResponse(count, errors, ids);
delete request;
}
}
void LocationAPIClientBase::onCtrlResponseCb(LocationError error, uint32_t id)
{
if (error != LOCATION_ERROR_SUCCESS) {
LOC_LOGE("%s:%d] ERROR: %d ID: %d", __FUNCTION__, __LINE__, error, id);
} else {
LOC_LOGV("%s:%d] error: %d id: %d", __FUNCTION__, __LINE__, error, id);
}
LocationAPIRequest* request = getRequestBySession(id);
if (request) {
request->onResponse(error);
delete request;
}
}
void LocationAPIClientBase::onCtrlCollectiveResponseCb(
size_t count, LocationError* errors, uint32_t* ids)
{
for (size_t i = 0; i < count; i++) {
if (errors[i] != LOCATION_ERROR_SUCCESS) {
LOC_LOGE("%s:%d] ERROR: %d ID: %d", __FUNCTION__, __LINE__, errors[i], ids[i]);
} else {
LOC_LOGV("%s:%d] error: %d id: %d", __FUNCTION__, __LINE__, errors[i], ids[i]);
}
}
LocationAPIRequest* request = nullptr;
if (count > 0 && ids)
request = getRequestBySession(ids[0]);
if (request) {
request->onCollectiveResponse(count, errors, ids);
delete request;
}
}
LocationAPIClientBase::LocationAPIRequest*
LocationAPIClientBase::getRequestBySession(uint32_t session)
{
pthread_mutex_lock(&mMutex);
LocationAPIRequest* request = nullptr;
for (int i = 0; i < REQUEST_MAX; i++) {
if (i != REQUEST_GEOFENCE &&
mRequestQueues[i] &&
mRequestQueues[i]->getSession() == session) {
request = mRequestQueues[i]->pop();
break;
}
}
pthread_mutex_unlock(&mMutex);
return request;
}
LocationAPIClientBase::LocationAPIRequest*
LocationAPIClientBase::getGeofencesRequest()
{
pthread_mutex_lock(&mMutex);
LocationAPIRequest* request = nullptr;
if (mRequestQueues[REQUEST_GEOFENCE]) {
request = mRequestQueues[REQUEST_GEOFENCE]->pop();
}
pthread_mutex_unlock(&mMutex);
return request;
}

View file

@ -0,0 +1,457 @@
/* Copyright (c) 2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef LOCATION_API_CLINET_BASE_H
#define LOCATION_API_CLINET_BASE_H
#include <stdint.h>
#include <stdlib.h>
#include <pthread.h>
#include <queue>
#include <map>
#include "LocationAPI.h"
enum SESSION_MODE {
SESSION_MODE_NONE = 0,
SESSION_MODE_ON_FULL,
SESSION_MODE_ON_FIX,
};
enum REQUEST_TYPE {
REQUEST_TRACKING = 0,
REQUEST_BATCHING,
REQUEST_GEOFENCE,
REQUEST_NIRESPONSE,
REQUEST_DELETEAIDINGDATA,
REQUEST_CONTROL,
REQUEST_MAX,
};
class LocationAPIClientBase
{
public:
LocationAPIClientBase();
virtual ~LocationAPIClientBase();
LocationAPIClientBase(const LocationAPIClientBase&) = delete;
LocationAPIClientBase& operator=(const LocationAPIClientBase&) = delete;
void locAPISetCallbacks(LocationCallbacks& locationCallbacks);
// LocationAPI
uint32_t locAPIStartTracking(LocationOptions& options);
void locAPIStopTracking();
void locAPIUpdateTrackingOptions(LocationOptions& options);
int32_t locAPIGetBatchSize();
uint32_t locAPIStartSession(uint32_t id, uint32_t sessionMode,
LocationOptions& options);
uint32_t locAPIStopSession(uint32_t id);
uint32_t locAPIUpdateSessionOptions(uint32_t id, uint32_t sessionMode,
LocationOptions& options);
void locAPIGetBatchedLocations(size_t count);
uint32_t locAPIAddGeofences(size_t count, uint32_t* ids,
GeofenceOption* options, GeofenceInfo* data);
void locAPIRemoveGeofences(size_t count, uint32_t* ids);
void locAPIModifyGeofences(size_t count, uint32_t* ids, GeofenceOption* options);
void locAPIPauseGeofences(size_t count, uint32_t* ids);
void locAPIResumeGeofences(size_t count, uint32_t* ids, GeofenceBreachTypeMask* mask);
void locAPIRemoveAllGeofences();
void locAPIGnssNiResponse(uint32_t id, GnssNiResponse response);
uint32_t locAPIGnssDeleteAidingData(GnssAidingData& data);
uint32_t locAPIEnable(LocationTechnologyType techType);
void locAPIDisable();
uint32_t locAPIGnssUpdateConfig(GnssConfig config);
// callbacks
void onResponseCb(LocationError error, uint32_t id);
void onCollectiveResponseCb(size_t count, LocationError* errors, uint32_t* ids);
void onCtrlResponseCb(LocationError error, uint32_t id);
void onCtrlCollectiveResponseCb(size_t count, LocationError* errors, uint32_t* ids);
void beforeGeofenceBreachCb(GeofenceBreachNotification geofenceBreachNotification);
inline virtual void onCapabilitiesCb(LocationCapabilitiesMask /*capabilitiesMask*/) {}
inline virtual void onGnssNmeaCb(GnssNmeaNotification /*gnssNmeaNotification*/) {}
inline virtual void onGnssMeasurementsCb(
GnssMeasurementsNotification /*gnssMeasurementsNotification*/) {}
inline virtual void onTrackingCb(Location /*location*/) {}
inline virtual void onGnssSvCb(GnssSvNotification /*gnssSvNotification*/) {}
inline virtual void onStartTrackingCb(LocationError /*error*/) {}
inline virtual void onStopTrackingCb(LocationError /*error*/) {}
inline virtual void onUpdateTrackingOptionsCb(LocationError /*error*/) {}
inline virtual void onGnssLocationInfoCb(
GnssLocationInfoNotification /*gnssLocationInfoNotification*/) {}
inline virtual void onBatchingCb(size_t /*count*/, Location* /*location*/) {}
inline virtual void onStartBatchingCb(LocationError /*error*/) {}
inline virtual void onStopBatchingCb(LocationError /*error*/) {}
inline virtual void onUpdateBatchingOptionsCb(LocationError /*error*/) {}
inline virtual void onGetBatchedLocationsCb(LocationError /*error*/) {}
inline virtual void onGeofenceBreachCb(
GeofenceBreachNotification /*geofenceBreachNotification*/) {}
inline virtual void onGeofenceStatusCb(
GeofenceStatusNotification /*geofenceStatusNotification*/) {}
inline virtual void onAddGeofencesCb(
size_t /*count*/, LocationError* /*errors*/, uint32_t* /*ids*/) {}
inline virtual void onRemoveGeofencesCb(
size_t /*count*/, LocationError* /*errors*/, uint32_t* /*ids*/) {}
inline virtual void onModifyGeofencesCb(
size_t /*count*/, LocationError* /*errors*/, uint32_t* /*ids*/) {}
inline virtual void onPauseGeofencesCb(
size_t /*count*/, LocationError* /*errors*/, uint32_t* /*ids*/) {}
inline virtual void onResumeGeofencesCb(
size_t /*count*/, LocationError* /*errors*/, uint32_t* /*ids*/) {}
inline virtual void onGnssNiCb(uint32_t /*id*/, GnssNiNotification /*gnssNiNotification*/) {}
inline virtual void onGnssNiResponseCb(LocationError /*error*/) {}
inline virtual void onGnssDeleteAidingDataCb(LocationError /*error*/) {}
inline virtual void onEnableCb(LocationError /*error*/) {}
inline virtual void onDisableCb(LocationError /*error*/) {}
inline virtual void onGnssUpdateConfigCb(
size_t /*count*/, LocationError* /*errors*/, uint32_t* /*ids*/) {}
private:
// private inner classes
typedef struct {
uint32_t id;
uint32_t trackingSession;
uint32_t batchingSession;
uint32_t sessionMode;
} SessionEntity;
class BiDict {
public:
BiDict() {
pthread_mutex_init(&mBiDictMutex, nullptr);
}
~BiDict() {
pthread_mutex_destroy(&mBiDictMutex);
}
bool hasId(uint32_t id) {
pthread_mutex_lock(&mBiDictMutex);
bool ret = (mForwardMap.find(id) != mForwardMap.end());
pthread_mutex_unlock(&mBiDictMutex);
return ret;
}
void set(uint32_t id, uint32_t session, uint32_t type) {
pthread_mutex_lock(&mBiDictMutex);
mForwardMap[id] = session;
mBackwardMap[session] = id;
mTypeMap[session] = type;
pthread_mutex_unlock(&mBiDictMutex);
}
void clear() {
pthread_mutex_lock(&mBiDictMutex);
mForwardMap.clear();
mBackwardMap.clear();
mTypeMap.clear();
pthread_mutex_unlock(&mBiDictMutex);
}
void rmById(uint32_t id) {
pthread_mutex_lock(&mBiDictMutex);
mBackwardMap.erase(mForwardMap[id]);
mTypeMap.erase(mForwardMap[id]);
mForwardMap.erase(id);
pthread_mutex_unlock(&mBiDictMutex);
}
void rmBySession(uint32_t session) {
pthread_mutex_lock(&mBiDictMutex);
mForwardMap.erase(mBackwardMap[session]);
mBackwardMap.erase(session);
mTypeMap.erase(session);
pthread_mutex_unlock(&mBiDictMutex);
}
uint32_t getId(uint32_t session) {
pthread_mutex_lock(&mBiDictMutex);
uint32_t ret = mBackwardMap[session];
pthread_mutex_unlock(&mBiDictMutex);
return ret;
}
uint32_t getSession(uint32_t id) {
pthread_mutex_lock(&mBiDictMutex);
uint32_t ret = mForwardMap[id];
pthread_mutex_unlock(&mBiDictMutex);
return ret;
}
uint32_t getType(uint32_t session) {
pthread_mutex_lock(&mBiDictMutex);
uint32_t ret = mTypeMap[session];
pthread_mutex_unlock(&mBiDictMutex);
return ret;
}
std::vector<uint32_t> getAllSessions() {
std::vector<uint32_t> ret;
pthread_mutex_lock(&mBiDictMutex);
for (auto it = mBackwardMap.begin(); it != mBackwardMap.end(); it++) {
ret.push_back(it->first);
}
pthread_mutex_unlock(&mBiDictMutex);
return ret;
}
private:
pthread_mutex_t mBiDictMutex;
// mForwarMap mapping id->session
std::map<uint32_t, uint32_t> mForwardMap;
// mBackwardMap mapping session->id
std::map<uint32_t, uint32_t> mBackwardMap;
// mTypeMap mapping session->type
std::map<uint32_t, uint32_t> mTypeMap;
};
class LocationAPIRequest {
public:
LocationAPIRequest(LocationAPIClientBase& API) : mAPI(API) {}
virtual ~LocationAPIRequest() {}
virtual void onResponse(LocationError /*error*/) {};
virtual void onCollectiveResponse(
size_t /*count*/, LocationError* /*errors*/, uint32_t* /*ids*/) {};
LocationAPIClientBase& mAPI;
};
class StartTrackingRequest : public LocationAPIRequest {
public:
StartTrackingRequest(LocationAPIClientBase& API) : LocationAPIRequest(API) {}
inline void onResponse(LocationError error) {
mAPI.onStartTrackingCb(error);
}
};
class StopTrackingRequest : public LocationAPIRequest {
public:
StopTrackingRequest(LocationAPIClientBase& API) : LocationAPIRequest(API) {}
inline void onResponse(LocationError error) {
mAPI.onStopTrackingCb(error);
}
};
class UpdateTrackingOptionsRequest : public LocationAPIRequest {
public:
UpdateTrackingOptionsRequest(LocationAPIClientBase& API) : LocationAPIRequest(API) {}
inline void onResponse(LocationError error) {
mAPI.onUpdateTrackingOptionsCb(error);
}
};
class StartBatchingRequest : public LocationAPIRequest {
public:
StartBatchingRequest(LocationAPIClientBase& API) : LocationAPIRequest(API) {}
inline void onResponse(LocationError error) {
mAPI.onStartBatchingCb(error);
}
};
class StopBatchingRequest : public LocationAPIRequest {
public:
StopBatchingRequest(LocationAPIClientBase& API) : LocationAPIRequest(API) {}
inline void onResponse(LocationError error) {
mAPI.onStopBatchingCb(error);
}
};
class UpdateBatchingOptionsRequest : public LocationAPIRequest {
public:
UpdateBatchingOptionsRequest(LocationAPIClientBase& API) : LocationAPIRequest(API) {}
inline void onResponse(LocationError error) {
mAPI.onUpdateBatchingOptionsCb(error);
}
};
class GetBatchedLocationsRequest : public LocationAPIRequest {
public:
GetBatchedLocationsRequest(LocationAPIClientBase& API) : LocationAPIRequest(API) {}
inline void onResponse(LocationError error) {
mAPI.onGetBatchedLocationsCb(error);
}
};
class AddGeofencesRequest : public LocationAPIRequest {
public:
AddGeofencesRequest(LocationAPIClientBase& API) : LocationAPIRequest(API) {}
inline void onCollectiveResponse(size_t count, LocationError* errors, uint32_t* sessions) {
uint32_t *ids = (uint32_t*)malloc(sizeof(uint32_t) * count);
for (size_t i = 0; i < count; i++) {
ids[i] = mAPI.mGeofenceBiDict.getId(sessions[i]);
}
mAPI.onAddGeofencesCb(count, errors, ids);
free(ids);
}
};
class RemoveGeofencesRequest : public LocationAPIRequest {
public:
RemoveGeofencesRequest(LocationAPIClientBase& API) : LocationAPIRequest(API) {}
inline void onCollectiveResponse(size_t count, LocationError* errors, uint32_t* sessions) {
uint32_t *ids = (uint32_t*)malloc(sizeof(uint32_t) * count);
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);
}
};
class ModifyGeofencesRequest : public LocationAPIRequest {
public:
ModifyGeofencesRequest(LocationAPIClientBase& API) : LocationAPIRequest(API) {}
inline void onCollectiveResponse(size_t count, LocationError* errors, uint32_t* sessions) {
uint32_t *ids = (uint32_t*)malloc(sizeof(uint32_t) * count);
for (size_t i = 0; i < count; i++) {
ids[i] = mAPI.mGeofenceBiDict.getId(sessions[i]);
}
mAPI.onModifyGeofencesCb(count, errors, ids);
free(ids);
}
};
class PauseGeofencesRequest : public LocationAPIRequest {
public:
PauseGeofencesRequest(LocationAPIClientBase& API) : LocationAPIRequest(API) {}
inline void onCollectiveResponse(size_t count, LocationError* errors, uint32_t* sessions) {
uint32_t *ids = (uint32_t*)malloc(sizeof(uint32_t) * count);
for (size_t i = 0; i < count; i++) {
ids[i] = mAPI.mGeofenceBiDict.getId(sessions[i]);
}
mAPI.onPauseGeofencesCb(count, errors, ids);
free(ids);
}
};
class ResumeGeofencesRequest : public LocationAPIRequest {
public:
ResumeGeofencesRequest(LocationAPIClientBase& API) : LocationAPIRequest(API) {}
inline void onCollectiveResponse(size_t count, LocationError* errors, uint32_t* sessions) {
uint32_t *ids = (uint32_t*)malloc(sizeof(uint32_t) * count);
for (size_t i = 0; i < count; i++) {
ids[i] = mAPI.mGeofenceBiDict.getId(sessions[i]);
}
mAPI.onResumeGeofencesCb(count, errors, ids);
free(ids);
}
};
class GnssNiResponseRequest : public LocationAPIRequest {
public:
GnssNiResponseRequest(LocationAPIClientBase& API) : LocationAPIRequest(API) {}
inline void onResponse(LocationError error) {
mAPI.onGnssNiResponseCb(error);
}
};
class GnssDeleteAidingDataRequest : public LocationAPIRequest {
public:
GnssDeleteAidingDataRequest(LocationAPIClientBase& API) : LocationAPIRequest(API) {}
inline void onResponse(LocationError error) {
mAPI.onGnssDeleteAidingDataCb(error);
}
};
class EnableRequest : public LocationAPIRequest {
public:
EnableRequest(LocationAPIClientBase& API) : LocationAPIRequest(API) {}
inline void onResponse(LocationError error) {
mAPI.onEnableCb(error);
}
};
class DisableRequest : public LocationAPIRequest {
public:
DisableRequest(LocationAPIClientBase& API) : LocationAPIRequest(API) {}
inline void onResponse(LocationError error) {
mAPI.onDisableCb(error);
}
};
class GnssUpdateConfigRequest : public LocationAPIRequest {
public:
GnssUpdateConfigRequest(LocationAPIClientBase& API) : LocationAPIRequest(API) {}
inline void onCollectiveResponse(size_t count, LocationError* errors, uint32_t* ids) {
mAPI.onGnssUpdateConfigCb(count, errors, ids);
}
};
class RequestQueue {
public:
RequestQueue(uint32_t session): mSession(session) {
}
~RequestQueue() {
LocationAPIRequest* request = nullptr;
while (!mQueue.empty()) {
request = mQueue.front();
mQueue.pop();
delete request;
}
}
void push(LocationAPIRequest* request) {
mQueue.push(request);
}
LocationAPIRequest* pop() {
LocationAPIRequest* request = nullptr;
if (!mQueue.empty()) {
request = mQueue.front();
mQueue.pop();
}
return request;
}
uint32_t getSession() { return mSession; }
private:
uint32_t mSession;
std::queue<LocationAPIRequest*> mQueue;
};
LocationAPIRequest* getRequestBySession(uint32_t session);
LocationAPIRequest* getGeofencesRequest();
private:
pthread_mutex_t mMutex;
trackingCallback mTrackingCallback;
batchingCallback mBatchingCallback;
geofenceBreachCallback mGeofenceBreachCallback;
LocationAPI* mLocationAPI;
LocationControlAPI* mLocationControlAPI;
BiDict mGeofenceBiDict;
RequestQueue* mRequestQueues[REQUEST_MAX];
std::map<uint32_t, SessionEntity> mSessionMap;
int32_t mBatchSize;
GnssConfig mConfig;
};
#endif /* LOCATION_API_CLINET_BASE_H */

View file

@ -0,0 +1,86 @@
/* Copyright (c) 2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef LOCATION_INTERFACE_H
#define LOCATION_INTERFACE_H
#include <LocationAPI.h>
struct GnssInterface {
size_t size;
void (*initialize)(void);
void (*deinitialize)(void);
void (*addClient)(LocationAPI* client, const LocationCallbacks& callbacks);
void (*removeClient)(LocationAPI* client);
void (*requestCapabilities)(LocationAPI* client);
uint32_t (*startTracking)(LocationAPI* client, LocationOptions& options);
void (*updateTrackingOptions)(LocationAPI* client, uint32_t id, LocationOptions& options);
void (*stopTracking)(LocationAPI* client, uint32_t id);
void (*gnssNiResponse)(LocationAPI* client, uint32_t id, GnssNiResponse response);
void (*setControlCallbacks)(LocationControlCallbacks& controlCallbacks);
uint32_t (*enable)(LocationTechnologyType techType);
void (*disable)(uint32_t id);
uint32_t* (*gnssUpdateConfig)(GnssConfig config);
uint32_t (*gnssDeleteAidingData)(GnssAidingData& data);
void (*injectLocation)(double latitude, double longitude, float accuracy);
void (*injectTime)(int64_t time, int64_t timeReference, int32_t uncertainty);
};
struct FlpInterface {
size_t size;
void (*initialize)(void);
void (*deinitialize)(void);
void (*addClient)(LocationAPI* client, const LocationCallbacks& callbacks);
void (*removeClient)(LocationAPI* client);
void (*requestCapabilities)(LocationAPI* client);
uint32_t (*startTracking)(LocationAPI* client, LocationOptions& options);
void (*updateTrackingOptions)(LocationAPI* client, uint32_t id, LocationOptions& options);
void (*stopTracking)(LocationAPI* client, uint32_t id);
uint32_t (*startBatching)(LocationAPI* client, LocationOptions&);
void (*stopBatching)(LocationAPI* client, uint32_t id);
void (*updateBatchingOptions)(LocationAPI* client, uint32_t id, LocationOptions&);
void (*getBatchedLocations)(LocationAPI* client, uint32_t id, size_t count);
void (*getPowerStateChanges)(void* powerStateCb);
};
struct GeofenceInterface {
size_t size;
void (*initialize)(void);
void (*deinitialize)(void);
void (*addClient)(LocationAPI* client, const LocationCallbacks& callbacks);
void (*removeClient)(LocationAPI* client);
void (*requestCapabilities)(LocationAPI* client);
uint32_t* (*addGeofences)(LocationAPI* client, size_t count, GeofenceOption*, GeofenceInfo*);
void (*removeGeofences)(LocationAPI* client, size_t count, uint32_t* ids);
void (*modifyGeofences)(LocationAPI* client, size_t count, uint32_t* ids,
GeofenceOption* options);
void (*pauseGeofences)(LocationAPI* client, size_t count, uint32_t* ids);
void (*resumeGeofences)(LocationAPI* client, size_t count, uint32_t* ids);
};
#endif /* LOCATION_INTERFACE_H */

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2013,2015 The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2013, 2015, 2017The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -82,7 +82,6 @@ void MsgTask::prerun() {
}
bool MsgTask::run() {
LOC_LOGV("MsgTask::loop() listening ...\n");
LocMsg* msg;
msq_q_err_type result = msg_q_rcv((void*)mQ, (void **)&msg);
if (eMSG_Q_SUCCESS != result) {

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011,2014 The Linux Foundation. All rights reserved.
/* Copyright (c) 2011, 2014, 2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -108,7 +108,6 @@ linked_list_err_type linked_list_destroy(void** list_data)
===========================================================================*/
linked_list_err_type linked_list_add(void* list_data, void *data_obj, void (*dealloc)(void*))
{
LOC_LOGV("%s: Adding to list data_obj = 0x%08X\n", __FUNCTION__, data_obj);
if( list_data == NULL )
{
LOC_LOGE("%s: Invalid list parameter!\n", __FUNCTION__);
@ -160,7 +159,6 @@ linked_list_err_type linked_list_add(void* list_data, void *data_obj, void (*dea
===========================================================================*/
linked_list_err_type linked_list_remove(void* list_data, void **data_obj)
{
LOC_LOGV("%s: Removing from list\n", __FUNCTION__);
if( list_data == NULL )
{
LOC_LOGE("%s: Invalid list parameter!\n", __FUNCTION__);
@ -267,7 +265,6 @@ linked_list_err_type linked_list_search(void* list_data, void **data_p,
bool (*equal)(void* data_0, void* data),
void* data_0, bool rm_if_found)
{
LOC_LOGV("%s: Search the list\n", __FUNCTION__);
if( list_data == NULL || NULL == equal )
{
LOC_LOGE("%s: Invalid list parameter! list_data %p equal %p\n",

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2012,2014 The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2012, 2014, 2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -241,8 +241,6 @@ msq_q_err_type msg_q_rcv(void* msg_q_data, void** msg_obj)
msg_q* p_msg_q = (msg_q*)msg_q_data;
LOC_LOGV("%s: Waiting on message\n", __FUNCTION__);
pthread_mutex_lock(&p_msg_q->list_mutex);
if( p_msg_q->unblocked )