From 4bb940c0679ab23c9b8954bcb9ad8da5ede093cd Mon Sep 17 00:00:00 2001 From: Baili Feng Date: Wed, 19 Oct 2016 10:58:29 +0800 Subject: [PATCH] Decouple libhardware usage on LE for gnss models Remove all usage of gps.h and fused_location.h from all gnss models except gps/fpl hal librarys Change-Id: I90ba233c6bbe5c31a4cacceeb981833719c871f2 CRs-Fixed: 1067953 --- configure.ac | 10 - core/Android.mk | 1 + core/LocAdapterBase.cpp | 12 +- core/LocAdapterBase.h | 12 +- core/LocApiBase.cpp | 28 +- core/LocApiBase.h | 26 +- core/Makefile.am | 1 + core/UlpProxyBase.h | 6 +- core/gps_extended.h | 6 +- core/gps_extended_c.h | 62 +- core/loc_core_log.cpp | 102 +- core/loc_core_log.h | 18 +- core/loc_gps.h | 2205 +++++++++++++++++ loc-hal.pc.in | 2 +- loc_api/Makefile.am | 21 +- .../libloc_api-rpc-glue/rpc_inc/LocApiRpc.h | 12 +- .../libloc_api-rpc-glue/src/LocApiRpc.cpp | 100 +- loc_api/libloc_api_50001/Android.mk | 4 +- loc_api/libloc_api_50001/LocEngAdapter.cpp | 16 +- loc_api/libloc_api_50001/LocEngAdapter.h | 29 +- loc_api/libloc_api_50001/Makefile.am | 140 +- loc_api/libloc_api_50001/gps_converter.cpp | 255 ++ loc_api/libloc_api_50001/gps_converter.h | 69 + loc_api/libloc_api_50001/gps_interface.cpp | 1196 +++++++++ loc_api/libloc_api_50001/loc.cpp | 199 +- loc_api/libloc_api_50001/loc.h | 21 +- loc_api/libloc_api_50001/loc_eng.cpp | 150 +- loc_api/libloc_api_50001/loc_eng.h | 38 +- loc_api/libloc_api_50001/loc_eng_agps.cpp | 30 +- loc_api/libloc_api_50001/loc_eng_agps.h | 11 +- .../loc_eng_dmn_conn_handler.cpp | 12 +- .../loc_eng_dmn_conn_handler.h | 2 - loc_api/libloc_api_50001/loc_eng_msg.h | 17 +- loc_api/libloc_api_50001/loc_eng_ni.cpp | 26 +- loc_api/libloc_api_50001/loc_eng_ni.h | 4 +- loc_api/libloc_api_50001/loc_eng_nmea.cpp | 60 +- loc_api/libloc_api_50001/loc_eng_nmea.h | 3 +- loc_api/libloc_api_50001/loc_eng_xtra.h | 4 +- utils/loc_target.cpp | 1 - 39 files changed, 4293 insertions(+), 618 deletions(-) create mode 100644 core/loc_gps.h create mode 100644 loc_api/libloc_api_50001/gps_converter.cpp create mode 100644 loc_api/libloc_api_50001/gps_converter.h create mode 100644 loc_api/libloc_api_50001/gps_interface.cpp diff --git a/configure.ac b/configure.ac index 4ef39eed..4d14c4fc 100644 --- a/configure.ac +++ b/configure.ac @@ -45,16 +45,6 @@ PKG_CHECK_MODULES([LOCPLA], [loc-pla]) AC_SUBST([LOCPLA_CFLAGS]) AC_SUBST([LOCPLA_LIBS]) -AC_ARG_WITH([libhardware_includes], - AC_HELP_STRING([--with-libhardware-includes=@<:@dir@:>@], - [Specify the location of the libhardware headers]), - [libhardware_incdir=$withval], - with_libhardware_includes=no) - -if test "x$with_libhardware_includes" != "xno"; then - CPPFLAGS="${CPPFLAGS} -I${libhardware_incdir}" -fi - AC_ARG_WITH([core_includes], AC_HELP_STRING([--with-core-includes=@<:@dir@:>@], [Specify the location of the core headers]), diff --git a/core/Android.mk b/core/Android.mk index f8f84ce6..319a02a8 100644 --- a/core/Android.mk +++ b/core/Android.mk @@ -48,6 +48,7 @@ LOCAL_COPY_HEADERS:= \ LocDualContext.h \ LBSProxyBase.h \ UlpProxyBase.h \ + loc_gps.h \ gps_extended_c.h \ gps_extended.h \ loc_core_log.h \ diff --git a/core/LocAdapterBase.cpp b/core/LocAdapterBase.cpp index 899ad847..166fd910 100644 --- a/core/LocAdapterBase.cpp +++ b/core/LocAdapterBase.cpp @@ -80,7 +80,7 @@ void LocAdapterBase:: } void LocAdapterBase:: - reportSv(GnssSvStatus &svStatus, + reportSv(LocGnssSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt) DEFAULT_IMPL() @@ -94,7 +94,7 @@ void LocAdapterBase:: DEFAULT_IMPL() void LocAdapterBase:: - reportStatus(GpsStatusValue status) + reportStatus(LocGpsStatusValue status) DEFAULT_IMPL() @@ -120,7 +120,7 @@ bool LocAdapterBase:: DEFAULT_IMPL(false) bool LocAdapterBase:: - requestATL(int connHandle, AGpsType agps_type) + requestATL(int connHandle, LocAGpsType agps_type) DEFAULT_IMPL(false) bool LocAdapterBase:: @@ -140,15 +140,15 @@ bool LocAdapterBase:: DEFAULT_IMPL(false) bool LocAdapterBase:: - requestNiNotify(GpsNiNotification ¬ify, const void* data) + requestNiNotify(LocGpsNiNotification ¬ify, const void* data) DEFAULT_IMPL(false) void LocAdapterBase:: - reportGnssMeasurementData(GnssData &gnssMeasurementData) + reportGnssMeasurementData(LocGnssData &gnssMeasurementData) DEFAULT_IMPL() bool LocAdapterBase:: - reportWwanZppFix(GpsLocation &zppLoc) + reportWwanZppFix(LocGpsLocation &zppLoc) DEFAULT_IMPL(false) } // namespace loc_core diff --git a/core/LocAdapterBase.h b/core/LocAdapterBase.h index 0b1d3d94..f3ec4890 100644 --- a/core/LocAdapterBase.h +++ b/core/LocAdapterBase.h @@ -102,29 +102,29 @@ public: void* locationExt, enum loc_sess_status status, LocPosTechMask loc_technology_mask); - virtual void reportSv(GnssSvStatus &svStatus, + virtual void reportSv(LocGnssSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt); virtual void reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet); virtual void reportSvPolynomial(GnssSvPolynomial &svPolynomial); - virtual void reportStatus(GpsStatusValue status); + 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 requestLocation(); - virtual bool requestATL(int connHandle, AGpsType agps_type); + virtual bool requestATL(int connHandle, LocAGpsType agps_type); virtual bool releaseATL(int connHandle); virtual bool requestSuplES(int connHandle); virtual bool reportDataCallOpened(); virtual bool reportDataCallClosed(); - virtual bool requestNiNotify(GpsNiNotification ¬ify, + virtual bool requestNiNotify(LocGpsNiNotification ¬ify, const void* data); inline virtual bool isInSession() { return false; } ContextBase* getContext() const { return mContext; } - virtual void reportGnssMeasurementData(GnssData &gnssMeasurementData); - virtual bool reportWwanZppFix(GpsLocation &zppLoc); + virtual void reportGnssMeasurementData(LocGnssData &gnssMeasurementData); + virtual bool reportWwanZppFix(LocGpsLocation &zppLoc); }; } // namespace loc_core diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp index 35041f61..4cc8cb8d 100644 --- a/core/LocApiBase.cpp +++ b/core/LocApiBase.cpp @@ -259,13 +259,13 @@ void LocApiBase::reportPosition(UlpLocation &location, ); } -void LocApiBase::reportWwanZppFix(GpsLocation &zppLoc) +void LocApiBase::reportWwanZppFix(LocGpsLocation &zppLoc) { // loop through adapters, and deliver to the first handling adapter. TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportWwanZppFix(zppLoc)); } -void LocApiBase::reportSv(GnssSvStatus &svStatus, +void LocApiBase::reportSv(LocGnssSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt) { @@ -277,7 +277,7 @@ void LocApiBase::reportSv(GnssSvStatus &svStatus, " sv: constellation svid cN0" " elevation azimuth flags", svStatus.num_svs); - for (int i = 0; i < svStatus.num_svs && i < GNSS_MAX_SVS; i++) { + for (int i = 0; i < svStatus.num_svs && i < LOC_GNSS_MAX_SVS; i++) { if (svStatus.gnss_sv_list[i].constellation > sizeof(constellationString) / sizeof(constellationString[0]) - 1) { svStatus.gnss_sv_list[i].constellation = 0; @@ -316,7 +316,7 @@ void LocApiBase::reportSvPolynomial(GnssSvPolynomial &svPolynomial) ); } -void LocApiBase::reportStatus(GpsStatusValue status) +void LocApiBase::reportStatus(LocGpsStatusValue status) { // loop through adapters, and deliver to all adapters. TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportStatus(status)); @@ -354,7 +354,7 @@ void LocApiBase::requestLocation() TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestLocation()); } -void LocApiBase::requestATL(int connHandle, AGpsType agps_type) +void LocApiBase::requestATL(int connHandle, LocAGpsType agps_type) { // loop through adapters, and deliver to the first handling adapter. TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestATL(connHandle, agps_type)); @@ -384,7 +384,7 @@ void LocApiBase::reportDataCallClosed() TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportDataCallClosed()); } -void LocApiBase::requestNiNotify(GpsNiNotification ¬ify, const void* data) +void LocApiBase::requestNiNotify(LocGpsNiNotification ¬ify, const void* data) { // loop through adapters, and deliver to the first handling adapter. TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestNiNotify(notify, data)); @@ -406,7 +406,7 @@ void* LocApiBase :: getSibling() LocApiProxyBase* LocApiBase :: getLocApiProxy() DEFAULT_IMPL(NULL) -void LocApiBase::reportGnssMeasurementData(GnssData &gnssMeasurementData) +void LocApiBase::reportGnssMeasurementData(LocGnssData &gnssMeasurementData) { // loop through adapters, and deliver to all adapters. TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssMeasurementData(gnssMeasurementData)); @@ -429,7 +429,7 @@ enum loc_api_adapter_err LocApiBase:: DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) enum loc_api_adapter_err LocApiBase:: - deleteAidingData(GpsAidingData f) + deleteAidingData(LocGpsAidingData f) DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) enum loc_api_adapter_err LocApiBase:: @@ -445,7 +445,7 @@ enum loc_api_adapter_err LocApiBase:: DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) enum loc_api_adapter_err LocApiBase:: - setTime(GpsUtcTime time, int64_t timeReference, int uncertainty) + setTime(LocGpsUtcTime time, int64_t timeReference, int uncertainty) DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) enum loc_api_adapter_err LocApiBase:: @@ -458,7 +458,7 @@ DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) enum loc_api_adapter_err LocApiBase:: atlOpenStatus(int handle, int is_succ, char* apn, - AGpsBearerType bear, AGpsType agpsType) + AGpsBearerType bear, LocAGpsType agpsType) DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) enum loc_api_adapter_err LocApiBase:: @@ -479,7 +479,7 @@ enum loc_api_adapter_err LocApiBase:: DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) enum loc_api_adapter_err LocApiBase:: - informNiResponse(GpsUserResponseType userResponse, + informNiResponse(LocGpsUserResponseType userResponse, const void* passThroughData) DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) @@ -539,14 +539,14 @@ enum loc_api_adapter_err LocApiBase:: DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) enum loc_api_adapter_err LocApiBase:: - getBestAvailableZppFix(GpsLocation& zppLoc) + getBestAvailableZppFix(LocGpsLocation& zppLoc) { memset(&zppLoc, 0, sizeof(zppLoc)); DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) } enum loc_api_adapter_err LocApiBase:: - getBestAvailableZppFix(GpsLocation & zppLoc, LocPosTechMask & tech_mask) + getBestAvailableZppFix(LocGpsLocation & zppLoc, LocPosTechMask & tech_mask) { memset(&zppLoc, 0, sizeof(zppLoc)); memset(&tech_mask, 0, sizeof(tech_mask)); @@ -578,7 +578,7 @@ int LocApiBase:: DEFAULT_IMPL(-1) void LocApiBase:: - installAGpsCert(const DerEncodedCertificate* pData, + installAGpsCert(const LocDerEncodedCertificate* pData, size_t length, uint32_t slotBitMask) DEFAULT_IMPL() diff --git a/core/LocApiBase.h b/core/LocApiBase.h index 2d0cc8c6..9127a2ea 100644 --- a/core/LocApiBase.h +++ b/core/LocApiBase.h @@ -115,28 +115,28 @@ public: enum loc_sess_status status, LocPosTechMask loc_technology_mask = LOC_POS_TECH_MASK_DEFAULT); - void reportSv(GnssSvStatus &svStatus, + void reportSv(LocGnssSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt); void reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet); void reportSvPolynomial(GnssSvPolynomial &svPolynomial); - void reportStatus(GpsStatusValue status); + void reportStatus(LocGpsStatusValue status); void reportNmea(const char* nmea, int length); void reportXtraServer(const char* url1, const char* url2, const char* url3, const int maxlength); void requestXtraData(); void requestTime(); void requestLocation(); - void requestATL(int connHandle, AGpsType agps_type); + void requestATL(int connHandle, LocAGpsType agps_type); void releaseATL(int connHandle); void requestSuplES(int connHandle); void reportDataCallOpened(); void reportDataCallClosed(); - void requestNiNotify(GpsNiNotification ¬ify, const void* data); + void requestNiNotify(LocGpsNiNotification ¬ify, const void* data); void saveSupportedMsgList(uint64_t supportedMsgList); - void reportGnssMeasurementData(GnssData &gnssMeasurementData); + void reportGnssMeasurementData(LocGnssData &gnssMeasurementData); void saveSupportedFeatureList(uint8_t *featureList); - void reportWwanZppFix(GpsLocation &zppLoc); + void reportWwanZppFix(LocGpsLocation &zppLoc); // downward calls // All below functions are to be defined by adapter specific modules: @@ -149,7 +149,7 @@ public: virtual enum loc_api_adapter_err stopFix(); virtual enum loc_api_adapter_err - deleteAidingData(GpsAidingData f); + deleteAidingData(LocGpsAidingData f); virtual enum loc_api_adapter_err enableData(int enable); virtual enum loc_api_adapter_err @@ -157,13 +157,13 @@ public: virtual enum loc_api_adapter_err injectPosition(double latitude, double longitude, float accuracy); virtual enum loc_api_adapter_err - setTime(GpsUtcTime time, int64_t timeReference, int uncertainty); + setTime(LocGpsUtcTime time, int64_t timeReference, int uncertainty); 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, AGpsType agpsType); + 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 @@ -174,7 +174,7 @@ public: setServer(unsigned int ip, int port, LocServerType type); virtual enum loc_api_adapter_err - informNiResponse(GpsUserResponseType userResponse, const void* passThroughData); + informNiResponse(LocGpsUserResponseType userResponse, const void* passThroughData); virtual enum loc_api_adapter_err setSUPLVersion(uint32_t version); virtual enum loc_api_adapter_err @@ -212,15 +212,15 @@ public: virtual enum loc_api_adapter_err getWwanZppFix(); virtual enum loc_api_adapter_err - getBestAvailableZppFix(GpsLocation & zppLoc); + getBestAvailableZppFix(LocGpsLocation & zppLoc); virtual enum loc_api_adapter_err - getBestAvailableZppFix(GpsLocation & zppLoc, LocPosTechMask & tech_mask); + getBestAvailableZppFix(LocGpsLocation & zppLoc, LocPosTechMask & tech_mask); virtual int initDataServiceClient(bool isDueToSsr); virtual int openAndStartDataCall(); virtual void stopDataCall(); virtual void closeDataCall(); virtual void releaseDataServiceClient(); - virtual void installAGpsCert(const DerEncodedCertificate* pData, + virtual void installAGpsCert(const LocDerEncodedCertificate* pData, size_t length, uint32_t slotBitMask); inline virtual void setInSession(bool inSession) { diff --git a/core/Makefile.am b/core/Makefile.am index 341153ad..b3d833f6 100644 --- a/core/Makefile.am +++ b/core/Makefile.am @@ -12,6 +12,7 @@ libloc_core_la_h_sources = \ LocDualContext.h \ LBSProxyBase.h \ UlpProxyBase.h \ + loc_gps.h \ gps_extended_c.h \ gps_extended.h \ loc_core_log.h \ diff --git a/core/UlpProxyBase.h b/core/UlpProxyBase.h index 7f896a67..d30e9cc5 100644 --- a/core/UlpProxyBase.h +++ b/core/UlpProxyBase.h @@ -63,7 +63,7 @@ public: (void)loc_technology_mask; return false; } - inline virtual bool reportSv(GnssSvStatus &svStatus, + inline virtual bool reportSv(LocGnssSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt) { (void)svStatus; @@ -81,7 +81,7 @@ public: (void)svPolynomial; return false; } - inline virtual bool reportStatus(GpsStatusValue status) { + inline virtual bool reportStatus(LocGpsStatusValue status) { (void)status; return false; @@ -107,7 +107,7 @@ public: (void)number_of_locations; return false; } - inline virtual bool reportDeleteAidingData(GpsAidingData aidingData) + inline virtual bool reportDeleteAidingData(LocGpsAidingData aidingData) { (void)aidingData; return false; diff --git a/core/gps_extended.h b/core/gps_extended.h index 9460d4ee..5255da1a 100644 --- a/core/gps_extended.h +++ b/core/gps_extended.h @@ -46,14 +46,14 @@ extern "C" { struct LocPosMode { LocPositionMode mode; - GpsPositionRecurrence recurrence; + LocGpsPositionRecurrence recurrence; uint32_t min_interval; uint32_t preferred_accuracy; uint32_t preferred_time; bool share_position; char credentials[14]; char provider[8]; - LocPosMode(LocPositionMode m, GpsPositionRecurrence recr, + LocPosMode(LocPositionMode m, LocGpsPositionRecurrence recr, uint32_t gap, uint32_t accu, uint32_t time, bool sp, const char* cred, const char* prov) : mode(m), recurrence(recr), @@ -73,7 +73,7 @@ struct LocPosMode inline LocPosMode() : mode(LOC_POSITION_MODE_MS_BASED), - recurrence(GPS_POSITION_RECURRENCE_PERIODIC), + recurrence(LOC_GPS_POSITION_RECURRENCE_PERIODIC), min_interval(GPS_DEFAULT_FIX_INTERVAL_MS), preferred_accuracy(50), preferred_time(120000), share_position(true) { diff --git a/core/gps_extended_c.h b/core/gps_extended_c.h index 7da69a93..3985e994 100644 --- a/core/gps_extended_c.h +++ b/core/gps_extended_c.h @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include /** @@ -47,14 +47,14 @@ extern "C" { /** Location has valid source information. */ #define LOCATION_HAS_SOURCE_INFO 0x0020 -/** GpsLocation has valid "is indoor?" flag */ -#define GPS_LOCATION_HAS_IS_INDOOR 0x0040 -/** GpsLocation has valid floor number */ -#define GPS_LOCATION_HAS_FLOOR_NUMBER 0x0080 -/** GpsLocation has valid map URL*/ -#define GPS_LOCATION_HAS_MAP_URL 0x0100 -/** GpsLocation has valid map index */ -#define GPS_LOCATION_HAS_MAP_INDEX 0x0200 +/** LocGpsLocation has valid "is indoor?" flag */ +#define LOC_GPS_LOCATION_HAS_IS_INDOOR 0x0040 +/** LocGpsLocation has valid floor number */ +#define LOC_GPS_LOCATION_HAS_FLOOR_NUMBER 0x0080 +/** LocGpsLocation has valid map URL*/ +#define LOC_GPS_LOCATION_HAS_MAP_URL 0x0100 +/** LocGpsLocation has valid map index */ +#define LOC_GPS_LOCATION_HAS_MAP_INDEX 0x0200 /** Sizes for indoor fields */ #define GPS_LOCATION_MAP_URL_SIZE 400 @@ -81,10 +81,10 @@ extern "C" { #define ULP_MAX_NMEA_STRING_SIZE 201 /*Emergency SUPL*/ -#define GPS_NI_TYPE_EMERGENCY_SUPL 4 +#define LOC_GPS_NI_TYPE_EMERGENCY_SUPL 4 -#define AGPS_CERTIFICATE_MAX_LENGTH 2000 -#define AGPS_CERTIFICATE_MAX_SLOTS 10 +#define LOC_AGPS_CERTIFICATE_MAX_LENGTH 2000 +#define LOC_AGPS_CERTIFICATE_MAX_SLOTS 10 enum loc_registration_mask_status { LOC_REGISTRATION_MASK_ENABLED, @@ -99,7 +99,7 @@ typedef enum { typedef struct { /** set to sizeof(UlpLocation) */ size_t size; - GpsLocation gpsLocation; + LocGpsLocation gpsLocation; /* Provider indicator for HYBRID or GPS */ uint16_t position_source; /*allows HAL to pass additional information related to the location */ @@ -121,13 +121,13 @@ typedef struct { /** AGPS type */ typedef int16_t AGpsExtType; -#define AGPS_TYPE_INVALID -1 -#define AGPS_TYPE_ANY 0 -#define AGPS_TYPE_SUPL 1 -#define AGPS_TYPE_C2K 2 -#define AGPS_TYPE_WWAN_ANY 3 -#define AGPS_TYPE_WIFI 4 -#define AGPS_TYPE_SUPL_ES 5 +#define LOC_AGPS_TYPE_INVALID -1 +#define LOC_AGPS_TYPE_ANY 0 +#define LOC_AGPS_TYPE_SUPL 1 +#define LOC_AGPS_TYPE_C2K 2 +#define LOC_AGPS_TYPE_WWAN_ANY 3 +#define LOC_AGPS_TYPE_WIFI 4 +#define LOC_AGPS_TYPE_SUPL_ES 5 /** SSID length */ #define SSID_BUF_SIZE (32+1) @@ -140,13 +140,13 @@ typedef int16_t AGpsBearerType; /** GPS extended callback structure. */ typedef struct { - /** set to sizeof(GpsCallbacks) */ + /** set to sizeof(LocGpsCallbacks) */ size_t size; - gps_set_capabilities set_capabilities_cb; - gps_acquire_wakelock acquire_wakelock_cb; - gps_release_wakelock release_wakelock_cb; - gps_create_thread create_thread_cb; - gps_request_utc_time request_utc_time_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_gps_request_utc_time request_utc_time_cb; } GpsExtCallbacks; /** Callback to report the xtra server url to the client. @@ -157,8 +157,8 @@ typedef void (* report_xtra_server)(const char*, const char*, const char*); /** Callback structure for the XTRA interface. */ typedef struct { - gps_xtra_download_request download_request_cb; - gps_create_thread create_thread_cb; + loc_gps_xtra_download_request download_request_cb; + loc_gps_create_thread create_thread_cb; report_xtra_server report_xtra_server_cb; } GpsXtraExtCallbacks; @@ -168,7 +168,7 @@ typedef struct { size_t size; AGpsExtType type; - AGpsStatusValue status; + LocAGpsStatusValue status; uint32_t ipv4_addr; struct sockaddr_storage addr; char ssid[SSID_BUF_SIZE]; @@ -183,11 +183,11 @@ typedef void (* agps_status_extended)(AGpsExtStatus* status); /** Callback structure for the AGPS interface. */ typedef struct { agps_status_extended status_cb; - gps_create_thread create_thread_cb; + loc_gps_create_thread create_thread_cb; } AGpsExtCallbacks; -typedef void (*loc_ni_notify_callback)(GpsNiNotification *notification, bool esEnalbed); +typedef void (*loc_ni_notify_callback)(LocGpsNiNotification *notification, bool esEnalbed); /** GPS NI callback structure. */ typedef struct { diff --git a/core/loc_core_log.cpp b/core/loc_core_log.cpp index 4556fae3..620d1b0a 100644 --- a/core/loc_core_log.cpp +++ b/core/loc_core_log.cpp @@ -51,16 +51,16 @@ void LocPosMode::logv() const /* GPS status names */ static const loc_name_val_s_type gps_status_name[] = { - NAME_VAL( GPS_STATUS_NONE ), - NAME_VAL( GPS_STATUS_SESSION_BEGIN ), - NAME_VAL( GPS_STATUS_SESSION_END ), - NAME_VAL( GPS_STATUS_ENGINE_ON ), - NAME_VAL( GPS_STATUS_ENGINE_OFF ), + NAME_VAL( LOC_GPS_STATUS_NONE ), + NAME_VAL( LOC_GPS_STATUS_SESSION_BEGIN ), + NAME_VAL( LOC_GPS_STATUS_SESSION_END ), + NAME_VAL( LOC_GPS_STATUS_ENGINE_ON ), + NAME_VAL( LOC_GPS_STATUS_ENGINE_OFF ), }; static const int gps_status_num = sizeof(gps_status_name) / sizeof(loc_name_val_s_type); /* Find Android GPS status name */ -const char* loc_get_gps_status_name(GpsStatusValue gps_status) +const char* loc_get_gps_status_name(LocGpsStatusValue gps_status) { return loc_get_name_from_val(gps_status_name, gps_status_num, (long) gps_status); @@ -81,7 +81,7 @@ static const loc_name_val_s_type loc_eng_position_modes[] = }; static const int loc_eng_position_mode_num = sizeof(loc_eng_position_modes) / sizeof(loc_name_val_s_type); -const char* loc_get_position_mode_name(GpsPositionMode mode) +const char* loc_get_position_mode_name(LocGpsPositionMode mode) { return loc_get_name_from_val(loc_eng_position_modes, loc_eng_position_mode_num, (long) mode); } @@ -90,12 +90,12 @@ const char* loc_get_position_mode_name(GpsPositionMode mode) static const loc_name_val_s_type loc_eng_position_recurrences[] = { - NAME_VAL( GPS_POSITION_RECURRENCE_PERIODIC ), - NAME_VAL( GPS_POSITION_RECURRENCE_SINGLE ) + NAME_VAL( LOC_GPS_POSITION_RECURRENCE_PERIODIC ), + NAME_VAL( LOC_GPS_POSITION_RECURRENCE_SINGLE ) }; static const int loc_eng_position_recurrence_num = sizeof(loc_eng_position_recurrences) / sizeof(loc_name_val_s_type); -const char* loc_get_position_recurrence_name(GpsPositionRecurrence recur) +const char* loc_get_position_recurrence_name(LocGpsPositionRecurrence recur) { return loc_get_name_from_val(loc_eng_position_recurrences, loc_eng_position_recurrence_num, (long) recur); } @@ -104,23 +104,23 @@ const char* loc_get_position_recurrence_name(GpsPositionRecurrence recur) static const loc_name_val_s_type loc_eng_aiding_data_bits[] = { - NAME_VAL( GPS_DELETE_EPHEMERIS ), - NAME_VAL( GPS_DELETE_ALMANAC ), - NAME_VAL( GPS_DELETE_POSITION ), - NAME_VAL( GPS_DELETE_TIME ), - NAME_VAL( GPS_DELETE_IONO ), - NAME_VAL( GPS_DELETE_UTC ), - NAME_VAL( GPS_DELETE_HEALTH ), - NAME_VAL( GPS_DELETE_SVDIR ), - NAME_VAL( GPS_DELETE_SVSTEER ), - NAME_VAL( GPS_DELETE_SADATA ), - NAME_VAL( GPS_DELETE_RTI ), - NAME_VAL( GPS_DELETE_CELLDB_INFO ), - NAME_VAL( GPS_DELETE_ALL) + NAME_VAL( LOC_GPS_DELETE_EPHEMERIS ), + NAME_VAL( LOC_GPS_DELETE_ALMANAC ), + NAME_VAL( LOC_GPS_DELETE_POSITION ), + NAME_VAL( LOC_GPS_DELETE_TIME ), + NAME_VAL( LOC_GPS_DELETE_IONO ), + NAME_VAL( LOC_GPS_DELETE_UTC ), + NAME_VAL( LOC_GPS_DELETE_HEALTH ), + NAME_VAL( LOC_GPS_DELETE_SVDIR ), + NAME_VAL( LOC_GPS_DELETE_SVSTEER ), + NAME_VAL( LOC_GPS_DELETE_SADATA ), + NAME_VAL( LOC_GPS_DELETE_RTI ), + NAME_VAL( LOC_GPS_DELETE_CELLDB_INFO ), + NAME_VAL( LOC_GPS_DELETE_ALL) }; static const int loc_eng_aiding_data_bit_num = sizeof(loc_eng_aiding_data_bits) / sizeof(loc_name_val_s_type); -const char* loc_get_aiding_data_mask_names(GpsAidingData data) +const char* loc_get_aiding_data_mask_names(LocGpsAidingData data) { return NULL; } @@ -128,15 +128,15 @@ const char* loc_get_aiding_data_mask_names(GpsAidingData data) static const loc_name_val_s_type loc_eng_agps_types[] = { - NAME_VAL( AGPS_TYPE_INVALID ), - NAME_VAL( AGPS_TYPE_ANY ), - NAME_VAL( AGPS_TYPE_SUPL ), - NAME_VAL( AGPS_TYPE_C2K ), - NAME_VAL( AGPS_TYPE_WWAN_ANY ) + NAME_VAL( LOC_AGPS_TYPE_INVALID ), + NAME_VAL( LOC_AGPS_TYPE_ANY ), + NAME_VAL( LOC_AGPS_TYPE_SUPL ), + NAME_VAL( LOC_AGPS_TYPE_C2K ), + NAME_VAL( LOC_AGPS_TYPE_WWAN_ANY ) }; static const int loc_eng_agps_type_num = sizeof(loc_eng_agps_types) / sizeof(loc_name_val_s_type); -const char* loc_get_agps_type_name(AGpsType type) +const char* loc_get_agps_type_name(LocAGpsType type) { return loc_get_name_from_val(loc_eng_agps_types, loc_eng_agps_type_num, (long) type); } @@ -144,14 +144,14 @@ const char* loc_get_agps_type_name(AGpsType type) static const loc_name_val_s_type loc_eng_ni_types[] = { - NAME_VAL( GPS_NI_TYPE_VOICE ), - NAME_VAL( GPS_NI_TYPE_UMTS_SUPL ), - NAME_VAL( GPS_NI_TYPE_UMTS_CTRL_PLANE ), - NAME_VAL( GPS_NI_TYPE_EMERGENCY_SUPL ) + NAME_VAL( LOC_GPS_NI_TYPE_VOICE ), + NAME_VAL( LOC_GPS_NI_TYPE_UMTS_SUPL ), + NAME_VAL( LOC_GPS_NI_TYPE_UMTS_CTRL_PLANE ), + NAME_VAL( LOC_GPS_NI_TYPE_EMERGENCY_SUPL ) }; static const int loc_eng_ni_type_num = sizeof(loc_eng_ni_types) / sizeof(loc_name_val_s_type); -const char* loc_get_ni_type_name(GpsNiType type) +const char* loc_get_ni_type_name(LocGpsNiType type) { return loc_get_name_from_val(loc_eng_ni_types, loc_eng_ni_type_num, (long) type); } @@ -159,13 +159,13 @@ const char* loc_get_ni_type_name(GpsNiType type) static const loc_name_val_s_type loc_eng_ni_responses[] = { - NAME_VAL( GPS_NI_RESPONSE_ACCEPT ), - NAME_VAL( GPS_NI_RESPONSE_DENY ), - NAME_VAL( GPS_NI_RESPONSE_DENY ) + NAME_VAL( LOC_GPS_NI_RESPONSE_ACCEPT ), + NAME_VAL( LOC_GPS_NI_RESPONSE_DENY ), + NAME_VAL( LOC_GPS_NI_RESPONSE_DENY ) }; static const int loc_eng_ni_reponse_num = sizeof(loc_eng_ni_responses) / sizeof(loc_name_val_s_type); -const char* loc_get_ni_response_name(GpsUserResponseType response) +const char* loc_get_ni_response_name(LocGpsUserResponseType response) { return loc_get_name_from_val(loc_eng_ni_responses, loc_eng_ni_reponse_num, (long) response); } @@ -173,15 +173,15 @@ const char* loc_get_ni_response_name(GpsUserResponseType response) static const loc_name_val_s_type loc_eng_ni_encodings[] = { - NAME_VAL( GPS_ENC_NONE ), - NAME_VAL( GPS_ENC_SUPL_GSM_DEFAULT ), - NAME_VAL( GPS_ENC_SUPL_UTF8 ), - NAME_VAL( GPS_ENC_SUPL_UCS2 ), - NAME_VAL( GPS_ENC_UNKNOWN ) + NAME_VAL( LOC_GPS_ENC_NONE ), + NAME_VAL( LOC_GPS_ENC_SUPL_GSM_DEFAULT ), + NAME_VAL( LOC_GPS_ENC_SUPL_UTF8 ), + NAME_VAL( LOC_GPS_ENC_SUPL_UCS2 ), + NAME_VAL( LOC_GPS_ENC_UNKNOWN ) }; static const int loc_eng_ni_encoding_num = sizeof(loc_eng_ni_encodings) / sizeof(loc_name_val_s_type); -const char* loc_get_ni_encoding_name(GpsNiEncodingType encoding) +const char* loc_get_ni_encoding_name(LocGpsNiEncodingType encoding) { return loc_get_name_from_val(loc_eng_ni_encodings, loc_eng_ni_encoding_num, (long) encoding); } @@ -229,15 +229,15 @@ const char* loc_get_position_sess_status_name(enum loc_sess_status status) static const loc_name_val_s_type loc_eng_agps_status_names[] = { - NAME_VAL( GPS_REQUEST_AGPS_DATA_CONN ), - NAME_VAL( GPS_RELEASE_AGPS_DATA_CONN ), - NAME_VAL( GPS_AGPS_DATA_CONNECTED ), - NAME_VAL( GPS_AGPS_DATA_CONN_DONE ), - NAME_VAL( GPS_AGPS_DATA_CONN_FAILED ) + NAME_VAL( LOC_GPS_REQUEST_AGPS_DATA_CONN ), + NAME_VAL( LOC_GPS_RELEASE_AGPS_DATA_CONN ), + NAME_VAL( LOC_GPS_AGPS_DATA_CONNECTED ), + NAME_VAL( LOC_GPS_AGPS_DATA_CONN_DONE ), + NAME_VAL( LOC_GPS_AGPS_DATA_CONN_FAILED ) }; static const int loc_eng_agps_status_num = sizeof(loc_eng_agps_status_names) / sizeof(loc_name_val_s_type); -const char* loc_get_agps_status_name(AGpsStatusValue status) +const char* loc_get_agps_status_name(LocAGpsStatusValue status) { return loc_get_name_from_val(loc_eng_agps_status_names, loc_eng_agps_status_num, (long) status); } diff --git a/core/loc_core_log.h b/core/loc_core_log.h index 8a1825ac..4fe8d3f2 100644 --- a/core/loc_core_log.h +++ b/core/loc_core_log.h @@ -38,18 +38,18 @@ extern "C" #include #include -const char* loc_get_gps_status_name(GpsStatusValue gps_status); -const char* loc_get_position_mode_name(GpsPositionMode mode); -const char* loc_get_position_recurrence_name(GpsPositionRecurrence recur); -const char* loc_get_aiding_data_mask_names(GpsAidingData data); -const char* loc_get_agps_type_name(AGpsType type); -const char* loc_get_ni_type_name(GpsNiType type); -const char* loc_get_ni_response_name(GpsUserResponseType response); -const char* loc_get_ni_encoding_name(GpsNiEncodingType encoding); +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); +const char* loc_get_aiding_data_mask_names(LocGpsAidingData data); +const char* loc_get_agps_type_name(LocAGpsType type); +const char* loc_get_ni_type_name(LocGpsNiType type); +const char* loc_get_ni_response_name(LocGpsUserResponseType response); +const char* loc_get_ni_encoding_name(LocGpsNiEncodingType encoding); const char* loc_get_agps_bear_name(AGpsBearerType bear); const char* loc_get_server_type_name(LocServerType type); const char* loc_get_position_sess_status_name(enum loc_sess_status status); -const char* loc_get_agps_status_name(AGpsStatusValue status); +const char* loc_get_agps_status_name(LocAGpsStatusValue status); #ifdef __cplusplus } diff --git a/core/loc_gps.h b/core/loc_gps.h new file mode 100644 index 00000000..cdb1af67 --- /dev/null +++ b/core/loc_gps.h @@ -0,0 +1,2205 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef LOC_GPS_H +#define LOC_GPS_H + +#include +#include +#include +#include +#include +#include + +__BEGIN_DECLS + +#define LOC_FLP_STATUS_LOCATION_AVAILABLE 0 +#define LOC_FLP_STATUS_LOCATION_UNAVAILABLE 1 +#define LOC_CAPABILITY_GNSS (1U<<0) +#define LOC_CAPABILITY_WIFI (1U<<1) +#define LOC_CAPABILITY_CELL (1U<<3) + +/** Milliseconds since January 1, 1970 */ +typedef int64_t LocGpsUtcTime; + +/** Maximum number of SVs for loc_gps_sv_status_callback(). */ +#define LOC_GPS_MAX_SVS 32 +/** Maximum number of SVs for loc_gps_sv_status_callback(). */ +#define LOC_GNSS_MAX_SVS 64 + +/** Maximum number of Measurements in loc_gps_measurement_callback(). */ +#define LOC_GPS_MAX_MEASUREMENT 32 + +/** Maximum number of Measurements in loc_gnss_measurement_callback(). */ +#define LOC_GNSS_MAX_MEASUREMENT 64 + +/** Requested operational mode for GPS operation. */ +typedef uint32_t LocGpsPositionMode; +/* IMPORTANT: Note that the following values must match + * constants in GpsLocationProvider.java. */ +/** Mode for running GPS standalone (no assistance). */ +#define LOC_GPS_POSITION_MODE_STANDALONE 0 +/** AGPS MS-Based mode. */ +#define LOC_GPS_POSITION_MODE_MS_BASED 1 +/** + * AGPS MS-Assisted mode. This mode is not maintained by the platform anymore. + * It is strongly recommended to use LOC_GPS_POSITION_MODE_MS_BASED instead. + */ +#define LOC_GPS_POSITION_MODE_MS_ASSISTED 2 + +/** Requested recurrence mode for GPS operation. */ +typedef uint32_t LocGpsPositionRecurrence; +/* IMPORTANT: Note that the following values must match + * constants in GpsLocationProvider.java. */ +/** Receive GPS fixes on a recurring basis at a specified period. */ +#define LOC_GPS_POSITION_RECURRENCE_PERIODIC 0 +/** Request a single shot GPS fix. */ +#define LOC_GPS_POSITION_RECURRENCE_SINGLE 1 + +/** GPS status event values. */ +typedef uint16_t LocGpsStatusValue; +/* IMPORTANT: Note that the following values must match + * constants in GpsLocationProvider.java. */ +/** GPS status unknown. */ +#define LOC_GPS_STATUS_NONE 0 +/** GPS has begun navigating. */ +#define LOC_GPS_STATUS_SESSION_BEGIN 1 +/** GPS has stopped navigating. */ +#define LOC_GPS_STATUS_SESSION_END 2 +/** GPS has powered on but is not navigating. */ +#define LOC_GPS_STATUS_ENGINE_ON 3 +/** GPS is powered off. */ +#define LOC_GPS_STATUS_ENGINE_OFF 4 + +/** Flags to indicate which values are valid in a LocGpsLocation. */ +typedef uint16_t LocGpsLocationFlags; +/* IMPORTANT: Note that the following values must match + * constants in GpsLocationProvider.java. */ +/** LocGpsLocation has valid latitude and longitude. */ +#define LOC_GPS_LOCATION_HAS_LAT_LONG 0x0001 +/** LocGpsLocation has valid altitude. */ +#define LOC_GPS_LOCATION_HAS_ALTITUDE 0x0002 +/** LocGpsLocation has valid speed. */ +#define LOC_GPS_LOCATION_HAS_SPEED 0x0004 +/** LocGpsLocation has valid bearing. */ +#define LOC_GPS_LOCATION_HAS_BEARING 0x0008 +/** LocGpsLocation has valid accuracy. */ +#define LOC_GPS_LOCATION_HAS_ACCURACY 0x0010 + +/** Flags for the loc_gps_set_capabilities callback. */ + +/** + * GPS HAL schedules fixes for LOC_GPS_POSITION_RECURRENCE_PERIODIC mode. If this is + * not set, then the framework will use 1000ms for min_interval and will start + * and call start() and stop() to schedule the GPS. + */ +#define LOC_GPS_CAPABILITY_SCHEDULING (1 << 0) +/** GPS supports MS-Based AGPS mode */ +#define LOC_GPS_CAPABILITY_MSB (1 << 1) +/** GPS supports MS-Assisted AGPS mode */ +#define LOC_GPS_CAPABILITY_MSA (1 << 2) +/** GPS supports single-shot fixes */ +#define LOC_GPS_CAPABILITY_SINGLE_SHOT (1 << 3) +/** GPS supports on demand time injection */ +#define LOC_GPS_CAPABILITY_ON_DEMAND_TIME (1 << 4) +/** GPS supports Geofencing */ +#define LOC_GPS_CAPABILITY_GEOFENCING (1 << 5) +/** GPS supports Measurements. */ +#define LOC_GPS_CAPABILITY_MEASUREMENTS (1 << 6) +/** GPS supports Navigation Messages */ +#define LOC_GPS_CAPABILITY_NAV_MESSAGES (1 << 7) + +/** + * Flags used to specify which aiding data to delete when calling + * delete_aiding_data(). + */ +typedef uint16_t LocGpsAidingData; +/* IMPORTANT: Note that the following values must match + * constants in GpsLocationProvider.java. */ +#define LOC_GPS_DELETE_EPHEMERIS 0x0001 +#define LOC_GPS_DELETE_ALMANAC 0x0002 +#define LOC_GPS_DELETE_POSITION 0x0004 +#define LOC_GPS_DELETE_TIME 0x0008 +#define LOC_GPS_DELETE_IONO 0x0010 +#define LOC_GPS_DELETE_UTC 0x0020 +#define LOC_GPS_DELETE_HEALTH 0x0040 +#define LOC_GPS_DELETE_SVDIR 0x0080 +#define LOC_GPS_DELETE_SVSTEER 0x0100 +#define LOC_GPS_DELETE_SADATA 0x0200 +#define LOC_GPS_DELETE_RTI 0x0400 +#define LOC_GPS_DELETE_CELLDB_INFO 0x8000 +#define LOC_GPS_DELETE_ALL 0xFFFF + +/** AGPS type */ +typedef uint16_t LocAGpsType; +#define LOC_AGPS_TYPE_SUPL 1 +#define LOC_AGPS_TYPE_C2K 2 + +typedef uint16_t LocAGpsSetIDType; +#define LOC_AGPS_SETID_TYPE_NONE 0 +#define LOC_AGPS_SETID_TYPE_IMSI 1 +#define LOC_AGPS_SETID_TYPE_MSISDN 2 + +typedef uint16_t LocApnIpType; +#define LOC_APN_IP_INVALID 0 +#define LOC_APN_IP_IPV4 1 +#define LOC_APN_IP_IPV6 2 +#define LOC_APN_IP_IPV4V6 3 + +/** + * String length constants + */ +#define LOC_GPS_NI_SHORT_STRING_MAXLEN 256 +#define LOC_GPS_NI_LONG_STRING_MAXLEN 2048 + +/** + * LocGpsNiType constants + */ +typedef uint32_t LocGpsNiType; +#define LOC_GPS_NI_TYPE_VOICE 1 +#define LOC_GPS_NI_TYPE_UMTS_SUPL 2 +#define LOC_GPS_NI_TYPE_UMTS_CTRL_PLANE 3 +/*Emergency SUPL*/ +#define LOC_GPS_NI_TYPE_EMERGENCY_SUPL 4 + +/** + * LocGpsNiNotifyFlags constants + */ +typedef uint32_t LocGpsNiNotifyFlags; +/** NI requires notification */ +#define LOC_GPS_NI_NEED_NOTIFY 0x0001 +/** NI requires verification */ +#define LOC_GPS_NI_NEED_VERIFY 0x0002 +/** NI requires privacy override, no notification/minimal trace */ +#define LOC_GPS_NI_PRIVACY_OVERRIDE 0x0004 + +/** + * GPS NI responses, used to define the response in + * NI structures + */ +typedef int LocGpsUserResponseType; +#define LOC_GPS_NI_RESPONSE_ACCEPT 1 +#define LOC_GPS_NI_RESPONSE_DENY 2 +#define LOC_GPS_NI_RESPONSE_NORESP 3 + +/** + * NI data encoding scheme + */ +typedef int LocGpsNiEncodingType; +#define LOC_GPS_ENC_NONE 0 +#define LOC_GPS_ENC_SUPL_GSM_DEFAULT 1 +#define LOC_GPS_ENC_SUPL_UTF8 2 +#define LOC_GPS_ENC_SUPL_UCS2 3 +#define LOC_GPS_ENC_UNKNOWN -1 + +/** AGPS status event values. */ +typedef uint16_t LocAGpsStatusValue; +/** GPS requests data connection for AGPS. */ +#define LOC_GPS_REQUEST_AGPS_DATA_CONN 1 +/** GPS releases the AGPS data connection. */ +#define LOC_GPS_RELEASE_AGPS_DATA_CONN 2 +/** AGPS data connection initiated */ +#define LOC_GPS_AGPS_DATA_CONNECTED 3 +/** AGPS data connection completed */ +#define LOC_GPS_AGPS_DATA_CONN_DONE 4 +/** AGPS data connection failed */ +#define LOC_GPS_AGPS_DATA_CONN_FAILED 5 + +typedef uint16_t LocAGpsRefLocationType; +#define LOC_AGPS_REF_LOCATION_TYPE_GSM_CELLID 1 +#define LOC_AGPS_REF_LOCATION_TYPE_UMTS_CELLID 2 +#define LOC_AGPS_REF_LOCATION_TYPE_MAC 3 +#define LOC_AGPS_REF_LOCATION_TYPE_LTE_CELLID 4 + +/* Deprecated, to be removed in the next Android release. */ +#define LOC_AGPS_REG_LOCATION_TYPE_MAC 3 + +/** Network types for update_network_state "type" parameter */ +#define LOC_AGPS_RIL_NETWORK_TYPE_MOBILE 0 +#define LOC_AGPS_RIL_NETWORK_TYPE_WIFI 1 +#define LOC_AGPS_RIL_NETWORK_TYPE_MOBILE_MMS 2 +#define LOC_AGPS_RIL_NETWORK_TYPE_MOBILE_SUPL 3 +#define LOC_AGPS_RIL_NETWORK_TTYPE_MOBILE_DUN 4 +#define LOC_AGPS_RIL_NETWORK_TTYPE_MOBILE_HIPRI 5 +#define LOC_AGPS_RIL_NETWORK_TTYPE_WIMAX 6 + +/* The following typedef together with its constants below are deprecated, and + * will be removed in the next release. */ +typedef uint16_t LocGpsClockFlags; +#define LOC_GPS_CLOCK_HAS_LEAP_SECOND (1<<0) +#define LOC_GPS_CLOCK_HAS_TIME_UNCERTAINTY (1<<1) +#define LOC_GPS_CLOCK_HAS_FULL_BIAS (1<<2) +#define LOC_GPS_CLOCK_HAS_BIAS (1<<3) +#define LOC_GPS_CLOCK_HAS_BIAS_UNCERTAINTY (1<<4) +#define LOC_GPS_CLOCK_HAS_DRIFT (1<<5) +#define LOC_GPS_CLOCK_HAS_DRIFT_UNCERTAINTY (1<<6) + +/** + * Flags to indicate what fields in LocGnssClock are valid. + */ +typedef uint16_t LocGnssClockFlags; +/** A valid 'leap second' is stored in the data structure. */ +#define LOC_GNSS_CLOCK_HAS_LEAP_SECOND (1<<0) +/** A valid 'time uncertainty' is stored in the data structure. */ +#define LOC_GNSS_CLOCK_HAS_TIME_UNCERTAINTY (1<<1) +/** A valid 'full bias' is stored in the data structure. */ +#define LOC_GNSS_CLOCK_HAS_FULL_BIAS (1<<2) +/** A valid 'bias' is stored in the data structure. */ +#define LOC_GNSS_CLOCK_HAS_BIAS (1<<3) +/** A valid 'bias uncertainty' is stored in the data structure. */ +#define LOC_GNSS_CLOCK_HAS_BIAS_UNCERTAINTY (1<<4) +/** A valid 'drift' is stored in the data structure. */ +#define LOC_GNSS_CLOCK_HAS_DRIFT (1<<5) +/** A valid 'drift uncertainty' is stored in the data structure. */ +#define LOC_GNSS_CLOCK_HAS_DRIFT_UNCERTAINTY (1<<6) + +/* The following typedef together with its constants below are deprecated, and + * will be removed in the next release. */ +typedef uint8_t LocGpsClockType; +#define LOC_GPS_CLOCK_TYPE_UNKNOWN 0 +#define LOC_GPS_CLOCK_TYPE_LOCAL_HW_TIME 1 +#define LOC_GPS_CLOCK_TYPE_GPS_TIME 2 + +/* The following typedef together with its constants below are deprecated, and + * will be removed in the next release. */ +typedef uint32_t LocGpsMeasurementFlags; +#define LOC_GPS_MEASUREMENT_HAS_SNR (1<<0) +#define LOC_GPS_MEASUREMENT_HAS_ELEVATION (1<<1) +#define LOC_GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY (1<<2) +#define LOC_GPS_MEASUREMENT_HAS_AZIMUTH (1<<3) +#define LOC_GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY (1<<4) +#define LOC_GPS_MEASUREMENT_HAS_PSEUDORANGE (1<<5) +#define LOC_GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY (1<<6) +#define LOC_GPS_MEASUREMENT_HAS_CODE_PHASE (1<<7) +#define LOC_GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY (1<<8) +#define LOC_GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY (1<<9) +#define LOC_GPS_MEASUREMENT_HAS_CARRIER_CYCLES (1<<10) +#define LOC_GPS_MEASUREMENT_HAS_CARRIER_PHASE (1<<11) +#define LOC_GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY (1<<12) +#define LOC_GPS_MEASUREMENT_HAS_BIT_NUMBER (1<<13) +#define LOC_GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT (1<<14) +#define LOC_GPS_MEASUREMENT_HAS_DOPPLER_SHIFT (1<<15) +#define LOC_GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY (1<<16) +#define LOC_GPS_MEASUREMENT_HAS_USED_IN_FIX (1<<17) +#define LOC_GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE (1<<18) + +/** + * Flags to indicate what fields in LocGnssMeasurement are valid. + */ +typedef uint32_t LocGnssMeasurementFlags; +/** A valid 'snr' is stored in the data structure. */ +#define LOC_GNSS_MEASUREMENT_HAS_SNR (1<<0) +/** A valid 'carrier frequency' is stored in the data structure. */ +#define LOC_GNSS_MEASUREMENT_HAS_CARRIER_FREQUENCY (1<<9) +/** A valid 'carrier cycles' is stored in the data structure. */ +#define LOC_GNSS_MEASUREMENT_HAS_CARRIER_CYCLES (1<<10) +/** A valid 'carrier phase' is stored in the data structure. */ +#define LOC_GNSS_MEASUREMENT_HAS_CARRIER_PHASE (1<<11) +/** A valid 'carrier phase uncertainty' is stored in the data structure. */ +#define LOC_GNSS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY (1<<12) + +/* The following typedef together with its constants below are deprecated, and + * will be removed in the next release. */ +typedef uint8_t LocGpsLossOfLock; +#define LOC_GPS_LOSS_OF_LOCK_UNKNOWN 0 +#define LOC_GPS_LOSS_OF_LOCK_OK 1 +#define LOC_GPS_LOSS_OF_LOCK_CYCLE_SLIP 2 + +/* The following typedef together with its constants below are deprecated, and + * will be removed in the next release. Use LocGnssMultipathIndicator instead. + */ +typedef uint8_t LocGpsMultipathIndicator; +#define LOC_GPS_MULTIPATH_INDICATOR_UNKNOWN 0 +#define LOC_GPS_MULTIPATH_INDICATOR_DETECTED 1 +#define LOC_GPS_MULTIPATH_INDICATOR_NOT_USED 2 + +/** + * Enumeration of available values for the GNSS Measurement's multipath + * indicator. + */ +typedef uint8_t LocGnssMultipathIndicator; +/** The indicator is not available or unknown. */ +#define LOC_GNSS_MULTIPATH_INDICATOR_UNKNOWN 0 +/** The measurement is indicated to be affected by multipath. */ +#define LOC_GNSS_MULTIPATH_INDICATOR_PRESENT 1 +/** The measurement is indicated to be not affected by multipath. */ +#define LOC_GNSS_MULTIPATH_INDICATOR_NOT_PRESENT 2 + +/* The following typedef together with its constants below are deprecated, and + * will be removed in the next release. */ +typedef uint16_t LocGpsMeasurementState; +#define LOC_GPS_MEASUREMENT_STATE_UNKNOWN 0 +#define LOC_GPS_MEASUREMENT_STATE_CODE_LOCK (1<<0) +#define LOC_GPS_MEASUREMENT_STATE_BIT_SYNC (1<<1) +#define LOC_GPS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2) +#define LOC_GPS_MEASUREMENT_STATE_TOW_DECODED (1<<3) +#define LOC_GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS (1<<4) + +/** + * Flags indicating the GNSS measurement state. + * + * The expected behavior here is for GPS HAL to set all the flags that applies. + * For example, if the state for a satellite is only C/A code locked and bit + * synchronized, and there is still millisecond ambiguity, the state should be + * set as: + * + * LOC_GNSS_MEASUREMENT_STATE_CODE_LOCK | LOC_GNSS_MEASUREMENT_STATE_BIT_SYNC | + * LOC_GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS + * + * If GNSS is still searching for a satellite, the corresponding state should be + * set to LOC_GNSS_MEASUREMENT_STATE_UNKNOWN(0). + */ +typedef uint32_t LocGnssMeasurementState; +#define LOC_GNSS_MEASUREMENT_STATE_UNKNOWN 0 +#define LOC_GNSS_MEASUREMENT_STATE_CODE_LOCK (1<<0) +#define LOC_GNSS_MEASUREMENT_STATE_BIT_SYNC (1<<1) +#define LOC_GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2) +#define LOC_GNSS_MEASUREMENT_STATE_TOW_DECODED (1<<3) +#define LOC_GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS (1<<4) +#define LOC_GNSS_MEASUREMENT_STATE_SYMBOL_SYNC (1<<5) +#define LOC_GNSS_MEASUREMENT_STATE_GLO_STRING_SYNC (1<<6) +#define LOC_GNSS_MEASUREMENT_STATE_GLO_TOD_DECODED (1<<7) +#define LOC_GNSS_MEASUREMENT_STATE_BDS_D2_BIT_SYNC (1<<8) +#define LOC_GNSS_MEASUREMENT_STATE_BDS_D2_SUBFRAME_SYNC (1<<9) +#define LOC_GNSS_MEASUREMENT_STATE_GAL_E1BC_CODE_LOCK (1<<10) +#define LOC_GNSS_MEASUREMENT_STATE_GAL_E1C_2ND_CODE_LOCK (1<<11) +#define LOC_GNSS_MEASUREMENT_STATE_GAL_E1B_PAGE_SYNC (1<<12) +#define LOC_GNSS_MEASUREMENT_STATE_SBAS_SYNC (1<<13) + +/* The following typedef together with its constants below are deprecated, and + * will be removed in the next release. */ +typedef uint16_t LocGpsAccumulatedDeltaRangeState; +#define LOC_GPS_ADR_STATE_UNKNOWN 0 +#define LOC_GPS_ADR_STATE_VALID (1<<0) +#define LOC_GPS_ADR_STATE_RESET (1<<1) +#define LOC_GPS_ADR_STATE_CYCLE_SLIP (1<<2) + +/** + * Flags indicating the Accumulated Delta Range's states. + */ +typedef uint16_t LocGnssAccumulatedDeltaRangeState; +#define LOC_GNSS_ADR_STATE_UNKNOWN 0 +#define LOC_GNSS_ADR_STATE_VALID (1<<0) +#define LOC_GNSS_ADR_STATE_RESET (1<<1) +#define LOC_GNSS_ADR_STATE_CYCLE_SLIP (1<<2) + +#if 0 +/* The following typedef together with its constants below are deprecated, and + * will be removed in the next release. */ +typedef uint8_t GpsNavigationMessageType; +#define GPS_NAVIGATION_MESSAGE_TYPE_UNKNOWN 0 +#define GPS_NAVIGATION_MESSAGE_TYPE_L1CA 1 +#define GPS_NAVIGATION_MESSAGE_TYPE_L2CNAV 2 +#define GPS_NAVIGATION_MESSAGE_TYPE_L5CNAV 3 +#define GPS_NAVIGATION_MESSAGE_TYPE_CNAV2 4 + +/** + * Enumeration of available values to indicate the GNSS Navigation message + * types. + * + * For convenience, first byte is the LocGnssConstellationType on which that signal + * is typically transmitted + */ +typedef int16_t GnssNavigationMessageType; + +#define GNSS_NAVIGATION_MESSAGE_TYPE_UNKNOWN 0 +/** GPS L1 C/A message contained in the structure. */ +#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L1CA 0x0101 +/** GPS L2-CNAV message contained in the structure. */ +#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L2CNAV 0x0102 +/** GPS L5-CNAV message contained in the structure. */ +#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L5CNAV 0x0103 +/** GPS CNAV-2 message contained in the structure. */ +#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_CNAV2 0x0104 +/** Glonass L1 CA message contained in the structure. */ +#define GNSS_NAVIGATION_MESSAGE_TYPE_GLO_L1CA 0x0301 +/** Beidou D1 message contained in the structure. */ +#define GNSS_NAVIGATION_MESSAGE_TYPE_BDS_D1 0x0501 +/** Beidou D2 message contained in the structure. */ +#define GNSS_NAVIGATION_MESSAGE_TYPE_BDS_D2 0x0502 +/** Galileo I/NAV message contained in the structure. */ +#define GNSS_NAVIGATION_MESSAGE_TYPE_GAL_I 0x0601 +/** Galileo F/NAV message contained in the structure. */ +#define GNSS_NAVIGATION_MESSAGE_TYPE_GAL_F 0x0602 + +/** + * Status of Navigation Message + * When a message is received properly without any parity error in its navigation words, the + * status should be set to NAV_MESSAGE_STATUS_PARITY_PASSED. But if a message is received + * with words that failed parity check, but GPS is able to correct those words, the status + * should be set to NAV_MESSAGE_STATUS_PARITY_REBUILT. + * No need to send any navigation message that contains words with parity error and cannot be + * corrected. + */ +typedef uint16_t NavigationMessageStatus; +#define NAV_MESSAGE_STATUS_UNKNOWN 0 +#define NAV_MESSAGE_STATUS_PARITY_PASSED (1<<0) +#define NAV_MESSAGE_STATUS_PARITY_REBUILT (1<<1) + +/* This constant is deprecated, and will be removed in the next release. */ +#define NAV_MESSAGE_STATUS_UNKONW 0 +#endif + +/** + * Flags that indicate information about the satellite + */ +typedef uint8_t LocGnssSvFlags; +#define LOC_GNSS_SV_FLAGS_NONE 0 +#define LOC_GNSS_SV_FLAGS_HAS_EPHEMERIS_DATA (1 << 0) +#define LOC_GNSS_SV_FLAGS_HAS_ALMANAC_DATA (1 << 1) +#define LOC_GNSS_SV_FLAGS_USED_IN_FIX (1 << 2) + +/** + * Constellation type of LocGnssSvInfo + */ +typedef uint8_t LocGnssConstellationType; +#define LOC_GNSS_CONSTELLATION_UNKNOWN 0 +#define LOC_GNSS_CONSTELLATION_GPS 1 +#define LOC_GNSS_CONSTELLATION_SBAS 2 +#define LOC_GNSS_CONSTELLATION_GLONASS 3 +#define LOC_GNSS_CONSTELLATION_QZSS 4 +#define LOC_GNSS_CONSTELLATION_BEIDOU 5 +#define LOC_GNSS_CONSTELLATION_GALILEO 6 + +/** + * Name for the GPS XTRA interface. + */ +#define LOC_GPS_XTRA_INTERFACE "gps-xtra" + +/** + * Name for the GPS DEBUG interface. + */ +#define LOC_GPS_DEBUG_INTERFACE "gps-debug" + +/** + * Name for the AGPS interface. + */ + +#define LOC_AGPS_INTERFACE "agps" + +/** + * Name of the Supl Certificate interface. + */ +#define LOC_SUPL_CERTIFICATE_INTERFACE "supl-certificate" + +/** + * Name for NI interface + */ +#define LOC_GPS_NI_INTERFACE "gps-ni" + +/** + * Name for the AGPS-RIL interface. + */ +#define LOC_AGPS_RIL_INTERFACE "agps_ril" + +/** + * Name for the GPS_Geofencing interface. + */ +#define LOC_GPS_GEOFENCING_INTERFACE "gps_geofencing" + +/** + * Name of the GPS Measurements interface. + */ +#define LOC_GPS_MEASUREMENT_INTERFACE "gps_measurement" + +/** + * Name of the GPS navigation message interface. + */ +#define LOC_GPS_NAVIGATION_MESSAGE_INTERFACE "gps_navigation_message" + +/** + * Name of the GNSS/GPS configuration interface. + */ +#define LOC_GNSS_CONFIGURATION_INTERFACE "gnss_configuration" + +/** Represents a location. */ +typedef struct { + /** set to sizeof(LocGpsLocation) */ + size_t size; + /** Contains LocGpsLocationFlags bits. */ + uint16_t flags; + /** Represents latitude in degrees. */ + double latitude; + /** Represents longitude in degrees. */ + double longitude; + /** + * Represents altitude in meters above the WGS 84 reference ellipsoid. + */ + double altitude; + /** Represents speed in meters per second. */ + float speed; + /** Represents heading in degrees. */ + float bearing; + /** Represents expected accuracy in meters. */ + float accuracy; + /** Timestamp for the location fix. */ + LocGpsUtcTime timestamp; +} LocGpsLocation; + +/** Represents the status. */ +typedef struct { + /** set to sizeof(LocGpsStatus) */ + size_t size; + LocGpsStatusValue status; +} LocGpsStatus; + +/** + * Legacy struct to represents SV information. + * Deprecated, to be removed in the next Android release. + * Use LocGnssSvInfo instead. + */ +typedef struct { + /** set to sizeof(LocGpsSvInfo) */ + size_t size; + /** Pseudo-random number for the SV. */ + int prn; + /** Signal to noise ratio. */ + float snr; + /** Elevation of SV in degrees. */ + float elevation; + /** Azimuth of SV in degrees. */ + float azimuth; +} LocGpsSvInfo; + +typedef struct { + /** set to sizeof(LocGnssSvInfo) */ + size_t size; + + /** + * Pseudo-random number for the SV, or FCN/OSN number for Glonass. The + * distinction is made by looking at constellation field. Values should be + * in the range of: + * + * - GPS: 1-32 + * - SBAS: 120-151, 183-192 + * - GLONASS: 1-24, the orbital slot number (OSN), if known. Or, if not: + * 93-106, the frequency channel number (FCN) (-7 to +6) offset by + 100 + * i.e. report an FCN of -7 as 93, FCN of 0 as 100, and FCN of +6 as 106. + * - QZSS: 193-200 + * - Galileo: 1-36 + * - Beidou: 1-37 + */ + int16_t svid; + + /** + * Defines the constellation of the given SV. Value should be one of those + * LOC_GNSS_CONSTELLATION_* constants + */ + LocGnssConstellationType constellation; + + /** + * Carrier-to-noise density in dB-Hz, typically in the range [0, 63]. + * It contains the measured C/N0 value for the signal at the antenna port. + * + * This is a mandatory value. + */ + float c_n0_dbhz; + + /** Elevation of SV in degrees. */ + float elevation; + + /** Azimuth of SV in degrees. */ + float azimuth; + + /** + * Contains additional data about the given SV. Value should be one of those + * LOC_GNSS_SV_FLAGS_* constants + */ + LocGnssSvFlags flags; + +} LocGnssSvInfo; + +/** + * Legacy struct to represents SV status. + * Deprecated, to be removed in the next Android release. + * Use LocGnssSvStatus instead. + */ +typedef struct { + /** set to sizeof(LocGpsSvStatus) */ + size_t size; + int num_svs; + LocGpsSvInfo sv_list[LOC_GPS_MAX_SVS]; + uint32_t ephemeris_mask; + uint32_t almanac_mask; + uint32_t used_in_fix_mask; +} LocGpsSvStatus; + +/** + * Represents SV status. + */ +typedef struct { + /** set to sizeof(LocGnssSvStatus) */ + size_t size; + + /** Number of GPS SVs currently visible, refers to the SVs stored in sv_list */ + int num_svs; + /** + * Pointer to an array of SVs information for all GNSS constellations, + * except GPS, which is reported using sv_list + */ + LocGnssSvInfo gnss_sv_list[LOC_GNSS_MAX_SVS]; + +} LocGnssSvStatus; + +/* CellID for 2G, 3G and LTE, used in AGPS. */ +typedef struct { + LocAGpsRefLocationType type; + /** Mobile Country Code. */ + uint16_t mcc; + /** Mobile Network Code .*/ + uint16_t mnc; + /** Location Area Code in 2G, 3G and LTE. In 3G lac is discarded. In LTE, + * lac is populated with tac, to ensure that we don't break old clients that + * might rely in the old (wrong) behavior. + */ + uint16_t lac; + /** Cell id in 2G. Utran Cell id in 3G. Cell Global Id EUTRA in LTE. */ + uint32_t cid; + /** Tracking Area Code in LTE. */ + uint16_t tac; + /** Physical Cell id in LTE (not used in 2G and 3G) */ + uint16_t pcid; +} LocAGpsRefLocationCellID; + +typedef struct { + uint8_t mac[6]; +} LocAGpsRefLocationMac; + +/** Represents ref locations */ +typedef struct { + LocAGpsRefLocationType type; + union { + LocAGpsRefLocationCellID cellID; + LocAGpsRefLocationMac mac; + } u; +} LocAGpsRefLocation; + +/** + * Callback with location information. Can only be called from a thread created + * by create_thread_cb. + */ +typedef void (* loc_gps_location_callback)(LocGpsLocation* location); + +/** + * Callback with status information. Can only be called from a thread created by + * create_thread_cb. + */ +typedef void (* loc_gps_status_callback)(LocGpsStatus* status); +/** + * Legacy callback with SV status information. + * Can only be called from a thread created by create_thread_cb. + * + * This callback is deprecated, and will be removed in the next release. Use + * loc_gnss_sv_status_callback() instead. + */ +typedef void (* loc_gps_sv_status_callback)(LocGpsSvStatus* sv_info); + +/** + * Callback with SV status information. + * Can only be called from a thread created by create_thread_cb. + */ +typedef void (* loc_gnss_sv_status_callback)(LocGnssSvStatus* sv_info); + +/** + * Callback for reporting NMEA sentences. Can only be called from a thread + * created by create_thread_cb. + */ +typedef void (* loc_gps_nmea_callback)(LocGpsUtcTime timestamp, const char* nmea, int length); + +/** + * Callback to inform framework of the GPS engine's capabilities. Capability + * parameter is a bit field of LOC_GPS_CAPABILITY_* flags. + */ +typedef void (* loc_gps_set_capabilities)(uint32_t capabilities); + +/** + * Callback utility for acquiring the GPS wakelock. This can be used to prevent + * the CPU from suspending while handling GPS events. + */ +typedef void (* loc_gps_acquire_wakelock)(); + +/** Callback utility for releasing the GPS wakelock. */ +typedef void (* loc_gps_release_wakelock)(); + +/** Callback for requesting NTP time */ +typedef void (* loc_gps_request_utc_time)(); + +/** + * Callback for creating a thread that can call into the Java framework code. + * This must be used to create any threads that report events up to the + * framework. + */ +typedef pthread_t (* loc_gps_create_thread)(const char* name, void (*start)(void *), void* arg); + +/** + * Provides information about how new the underlying GPS/GNSS hardware and + * software is. + * + * This information will be available for Android Test Applications. If a GPS + * HAL does not provide this information, it will be considered "2015 or + * earlier". + * + * If a GPS HAL does provide this information, then newer years will need to + * meet newer CTS standards. E.g. if the date are 2016 or above, then N+ level + * LocGpsMeasurement support will be verified. + */ +typedef struct { + /** Set to sizeof(LocGnssSystemInfo) */ + size_t size; + /* year in which the last update was made to the underlying hardware/firmware + * used to capture GNSS signals, e.g. 2016 */ + uint16_t year_of_hw; +} LocGnssSystemInfo; + +/** + * Callback to inform framework of the engine's hardware version information. + */ +typedef void (*loc_gnss_set_system_info)(const LocGnssSystemInfo* info); + +/** New GPS callback structure. */ +typedef struct { + /** set to sizeof(LocGpsCallbacks) */ + size_t size; + loc_gps_location_callback location_cb; + loc_gps_status_callback status_cb; + loc_gps_sv_status_callback 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_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; +} LocGpsCallbacks; + +/** Represents the standard GPS interface. */ +typedef struct { + /** set to sizeof(LocGpsInterface) */ + size_t size; + /** + * Opens the interface and provides the callback routines + * to the implementation of this interface. + */ + int (*init)( LocGpsCallbacks* callbacks ); + + /** Starts navigating. */ + int (*start)( void ); + + /** Stops navigating. */ + int (*stop)( void ); + + /** Closes the interface. */ + void (*cleanup)( void ); + + /** Injects the current time. */ + int (*inject_time)(LocGpsUtcTime time, int64_t timeReference, + int uncertainty); + + /** + * Injects current location from another location provider (typically cell + * ID). Latitude and longitude are measured in degrees expected accuracy is + * measured in meters + */ + int (*inject_location)(double latitude, double longitude, float accuracy); + + /** + * Specifies that the next call to start will not use the + * information defined in the flags. LOC_GPS_DELETE_ALL is passed for + * a cold start. + */ + void (*delete_aiding_data)(LocGpsAidingData flags); + + /** + * min_interval represents the time between fixes in milliseconds. + * preferred_accuracy represents the requested fix accuracy in meters. + * preferred_time represents the requested time to first fix in milliseconds. + * + * 'mode' parameter should be one of LOC_GPS_POSITION_MODE_MS_BASED + * or LOC_GPS_POSITION_MODE_STANDALONE. + * It is allowed by the platform (and it is recommended) to fallback to + * LOC_GPS_POSITION_MODE_MS_BASED if LOC_GPS_POSITION_MODE_MS_ASSISTED is passed in, and + * LOC_GPS_POSITION_MODE_MS_BASED is supported. + */ + int (*set_position_mode)(LocGpsPositionMode mode, LocGpsPositionRecurrence recurrence, + uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time); + + /** Get a pointer to extension information. */ + const void* (*get_extension)(const char* name); +} LocGpsInterface; + +/** + * Callback to request the client to download XTRA data. The client should + * download XTRA data and inject it by calling inject_xtra_data(). Can only be + * called from a thread created by create_thread_cb. + */ +typedef void (* loc_gps_xtra_download_request)(); + +/** Callback structure for the XTRA interface. */ +typedef struct { + loc_gps_xtra_download_request download_request_cb; + loc_gps_create_thread create_thread_cb; +} LocGpsXtraCallbacks; + +/** Extended interface for XTRA support. */ +typedef struct { + /** set to sizeof(LocGpsXtraInterface) */ + size_t size; + /** + * Opens the XTRA interface and provides the callback routines + * to the implementation of this interface. + */ + int (*init)( LocGpsXtraCallbacks* callbacks ); + /** Injects XTRA data into the GPS. */ + int (*inject_xtra_data)( char* data, int length ); +} LocGpsXtraInterface; + +#if 0 +/** Extended interface for DEBUG support. */ +typedef struct { + /** set to sizeof(LocGpsDebugInterface) */ + size_t size; + + /** + * This function should return any information that the native + * implementation wishes to include in a bugreport. + */ + size_t (*get_internal_state)(char* buffer, size_t bufferSize); +} LocGpsDebugInterface; +#endif + +/* + * Represents the status of AGPS augmented to support IPv4 and IPv6. + */ +typedef struct { + /** set to sizeof(LocAGpsStatus) */ + size_t size; + + LocAGpsType type; + LocAGpsStatusValue status; + + /** + * Must be set to a valid IPv4 address if the field 'addr' contains an IPv4 + * address, or set to INADDR_NONE otherwise. + */ + uint32_t ipaddr; + + /** + * Must contain the IPv4 (AF_INET) or IPv6 (AF_INET6) address to report. + * Any other value of addr.ss_family will be rejected. + */ + struct sockaddr_storage addr; +} LocAGpsStatus; + +/** + * Callback with AGPS status information. Can only be called from a thread + * created by create_thread_cb. + */ +typedef void (* loc_agps_status_callback)(LocAGpsStatus* status); + +/** Callback structure for the AGPS interface. */ +typedef struct { + loc_agps_status_callback status_cb; + loc_gps_create_thread create_thread_cb; +} LocAGpsCallbacks; + +/** + * Extended interface for AGPS support, it is augmented to enable to pass + * extra APN data. + */ +typedef struct { + /** set to sizeof(LocAGpsInterface) */ + size_t size; + + /** + * Opens the AGPS interface and provides the callback routines to the + * implementation of this interface. + */ + void (*init)(LocAGpsCallbacks* callbacks); + /** + * Deprecated. + * If the HAL supports LocAGpsInterface_v2 this API will not be used, see + * data_conn_open_with_apn_ip_type for more information. + */ + int (*data_conn_open)(const char* apn); + /** + * Notifies that the AGPS data connection has been closed. + */ + int (*data_conn_closed)(); + /** + * Notifies that a data connection is not available for AGPS. + */ + int (*data_conn_failed)(); + /** + * Sets the hostname and port for the AGPS server. + */ + int (*set_server)(LocAGpsType type, const char* hostname, int port); + + /** + * Notifies that a data connection is available and sets the name of the + * APN, and its IP type, to be used for SUPL connections. + */ + int (*data_conn_open_with_apn_ip_type)( + const char* apn, + LocApnIpType apnIpType); +} LocAGpsInterface; + +/** Error codes associated with certificate operations */ +#define LOC_AGPS_CERTIFICATE_OPERATION_SUCCESS 0 +#define LOC_AGPS_CERTIFICATE_ERROR_GENERIC -100 +#define LOC_AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES -101 + +/** A data structure that represents an X.509 certificate using DER encoding */ +typedef struct { + size_t length; + u_char* data; +} LocDerEncodedCertificate; + +/** + * A type definition for SHA1 Fingerprints used to identify X.509 Certificates + * The Fingerprint is a digest of the DER Certificate that uniquely identifies it. + */ +typedef struct { + u_char data[20]; +} LocSha1CertificateFingerprint; + +/** AGPS Interface to handle SUPL certificate operations */ +typedef struct { + /** set to sizeof(LocSuplCertificateInterface) */ + size_t size; + + /** + * Installs a set of Certificates used for SUPL connections to the AGPS server. + * If needed the HAL should find out internally any certificates that need to be removed to + * accommodate the certificates to install. + * The certificates installed represent a full set of valid certificates needed to connect to + * AGPS SUPL servers. + * The list of certificates is required, and all must be available at the same time, when trying + * to establish a connection with the AGPS Server. + * + * Parameters: + * certificates - A pointer to an array of DER encoded certificates that are need to be + * installed in the HAL. + * length - The number of certificates to install. + * Returns: + * LOC_AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully + * LOC_AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES if the HAL cannot store the number of + * certificates attempted to be installed, the state of the certificates stored should + * remain the same as before on this error case. + * + * IMPORTANT: + * If needed the HAL should find out internally the set of certificates that need to be + * removed to accommodate the certificates to install. + */ + int (*install_certificates) ( const LocDerEncodedCertificate* certificates, size_t length ); + + /** + * Notifies the HAL that a list of certificates used for SUPL connections are revoked. It is + * expected that the given set of certificates is removed from the internal store of the HAL. + * + * Parameters: + * fingerprints - A pointer to an array of SHA1 Fingerprints to identify the set of + * certificates to revoke. + * length - The number of fingerprints provided. + * Returns: + * LOC_AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully. + * + * IMPORTANT: + * If any of the certificates provided (through its fingerprint) is not known by the HAL, + * it should be ignored and continue revoking/deleting the rest of them. + */ + int (*revoke_certificates) ( const LocSha1CertificateFingerprint* fingerprints, size_t length ); +} LocSuplCertificateInterface; + +/** Represents an NI request */ +typedef struct { + /** set to sizeof(LocGpsNiNotification) */ + size_t size; + + /** + * An ID generated by HAL to associate NI notifications and UI + * responses + */ + int notification_id; + + /** + * An NI type used to distinguish different categories of NI + * events, such as LOC_GPS_NI_TYPE_VOICE, LOC_GPS_NI_TYPE_UMTS_SUPL, ... + */ + LocGpsNiType ni_type; + + /** + * Notification/verification options, combinations of LocGpsNiNotifyFlags constants + */ + LocGpsNiNotifyFlags notify_flags; + + /** + * Timeout period to wait for user response. + * Set to 0 for no time out limit. + */ + int timeout; + + /** + * Default response when time out. + */ + LocGpsUserResponseType default_response; + + /** + * Requestor ID + */ + char requestor_id[LOC_GPS_NI_SHORT_STRING_MAXLEN]; + + /** + * Notification message. It can also be used to store client_id in some cases + */ + char text[LOC_GPS_NI_LONG_STRING_MAXLEN]; + + /** + * Client name decoding scheme + */ + LocGpsNiEncodingType requestor_id_encoding; + + /** + * Client name decoding scheme + */ + LocGpsNiEncodingType text_encoding; + + /** + * A pointer to extra data. Format: + * key_1 = value_1 + * key_2 = value_2 + */ + char extras[LOC_GPS_NI_LONG_STRING_MAXLEN]; + +} LocGpsNiNotification; + +/** + * Callback with NI notification. Can only be called from a thread created by + * create_thread_cb. + */ +typedef void (*loc_gps_ni_notify_callback)(LocGpsNiNotification *notification); + +/** GPS NI callback structure. */ +typedef struct +{ + /** + * Sends the notification request from HAL to GPSLocationProvider. + */ + loc_gps_ni_notify_callback notify_cb; + loc_gps_create_thread create_thread_cb; +} LocGpsNiCallbacks; + +/** + * Extended interface for Network-initiated (NI) support. + */ +typedef struct +{ + /** set to sizeof(LocGpsNiInterface) */ + size_t size; + + /** Registers the callbacks for HAL to use. */ + void (*init) (LocGpsNiCallbacks *callbacks); + + /** Sends a response to HAL. */ + void (*respond) (int notif_id, LocGpsUserResponseType user_response); +} LocGpsNiInterface; + +#define LOC_AGPS_RIL_REQUEST_SETID_IMSI (1<<0L) +#define LOC_AGPS_RIL_REQUEST_SETID_MSISDN (1<<1L) + +#define LOC_AGPS_RIL_REQUEST_REFLOC_CELLID (1<<0L) +#define LOC_AGPS_RIL_REQUEST_REFLOC_MAC (1<<1L) + +typedef void (*loc_agps_ril_request_set_id)(uint32_t flags); +typedef void (*loc_agps_ril_request_ref_loc)(uint32_t flags); + +typedef struct { + loc_agps_ril_request_set_id request_setid; + loc_agps_ril_request_ref_loc request_refloc; + loc_gps_create_thread create_thread_cb; +} LocAGpsRilCallbacks; + +/** Extended interface for AGPS_RIL support. */ +typedef struct { + /** set to sizeof(LocAGpsRilInterface) */ + size_t size; + /** + * Opens the AGPS interface and provides the callback routines + * to the implementation of this interface. + */ + void (*init)( LocAGpsRilCallbacks* callbacks ); + + /** + * Sets the reference location. + */ + void (*set_ref_location) (const LocAGpsRefLocation *agps_reflocation, size_t sz_struct); + /** + * Sets the set ID. + */ + void (*set_set_id) (LocAGpsSetIDType type, const char* setid); + + /** + * Send network initiated message. + */ + void (*ni_message) (uint8_t *msg, size_t len); + + /** + * Notify GPS of network status changes. + * These parameters match values in the android.net.NetworkInfo class. + */ + void (*update_network_state) (int connected, int type, int roaming, const char* extra_info); + + /** + * Notify GPS of network status changes. + * These parameters match values in the android.net.NetworkInfo class. + */ + void (*update_network_availability) (int avaiable, const char* apn); +} LocAGpsRilInterface; + +/** + * GPS Geofence. + * There are 3 states associated with a Geofence: Inside, Outside, Unknown. + * There are 3 transitions: ENTERED, EXITED, UNCERTAIN. + * + * An example state diagram with confidence level: 95% and Unknown time limit + * set as 30 secs is shown below. (confidence level and Unknown time limit are + * explained latter) + * ____________________________ + * | Unknown (30 secs) | + * """""""""""""""""""""""""""" + * ^ | | ^ + * UNCERTAIN| |ENTERED EXITED| |UNCERTAIN + * | v v | + * ________ EXITED _________ + * | Inside | -----------> | Outside | + * | | <----------- | | + * """""""" ENTERED """"""""" + * + * Inside state: We are 95% confident that the user is inside the geofence. + * Outside state: We are 95% confident that the user is outside the geofence + * Unknown state: Rest of the time. + * + * The Unknown state is better explained with an example: + * + * __________ + * | c| + * | ___ | _______ + * | |a| | | b | + * | """ | """"""" + * | | + * """""""""" + * In the diagram above, "a" and "b" are 2 geofences and "c" is the accuracy + * circle reported by the GPS subsystem. Now with regard to "b", the system is + * confident that the user is outside. But with regard to "a" is not confident + * whether it is inside or outside the geofence. If the accuracy remains the + * same for a sufficient period of time, the UNCERTAIN transition would be + * triggered with the state set to Unknown. If the accuracy improves later, an + * appropriate transition should be triggered. This "sufficient period of time" + * is defined by the parameter in the add_geofence_area API. + * In other words, Unknown state can be interpreted as a state in which the + * GPS subsystem isn't confident enough that the user is either inside or + * outside the Geofence. It moves to Unknown state only after the expiry of the + * timeout. + * + * The geofence callback needs to be triggered for the ENTERED and EXITED + * transitions, when the GPS system is confident that the user has entered + * (Inside state) or exited (Outside state) the Geofence. An implementation + * which uses a value of 95% as the confidence is recommended. The callback + * should be triggered only for the transitions requested by the + * add_geofence_area call. + * + * Even though the diagram and explanation talks about states and transitions, + * the callee is only interested in the transistions. The states are mentioned + * here for illustrative purposes. + * + * Startup Scenario: When the device boots up, if an application adds geofences, + * and then we get an accurate GPS location fix, it needs to trigger the + * appropriate (ENTERED or EXITED) transition for every Geofence it knows about. + * By default, all the Geofences will be in the Unknown state. + * + * When the GPS system is unavailable, loc_gps_geofence_status_callback should be + * called to inform the upper layers of the same. Similarly, when it becomes + * available the callback should be called. This is a global state while the + * UNKNOWN transition described above is per geofence. + * + * An important aspect to note is that users of this API (framework), will use + * other subsystems like wifi, sensors, cell to handle Unknown case and + * hopefully provide a definitive state transition to the third party + * application. GPS Geofence will just be a signal indicating what the GPS + * subsystem knows about the Geofence. + * + */ +#define LOC_GPS_GEOFENCE_ENTERED (1<<0L) +#define LOC_GPS_GEOFENCE_EXITED (1<<1L) +#define LOC_GPS_GEOFENCE_UNCERTAIN (1<<2L) + +#define LOC_GPS_GEOFENCE_UNAVAILABLE (1<<0L) +#define LOC_GPS_GEOFENCE_AVAILABLE (1<<1L) + +#define LOC_GPS_GEOFENCE_OPERATION_SUCCESS 0 +#define LOC_GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES -100 +#define LOC_GPS_GEOFENCE_ERROR_ID_EXISTS -101 +#define LOC_GPS_GEOFENCE_ERROR_ID_UNKNOWN -102 +#define LOC_GPS_GEOFENCE_ERROR_INVALID_TRANSITION -103 +#define LOC_GPS_GEOFENCE_ERROR_GENERIC -149 + +/** + * The callback associated with the geofence. + * Parameters: + * geofence_id - The id associated with the add_geofence_area. + * location - The current GPS location. + * transition - Can be one of LOC_GPS_GEOFENCE_ENTERED, LOC_GPS_GEOFENCE_EXITED, + * LOC_GPS_GEOFENCE_UNCERTAIN. + * timestamp - Timestamp when the transition was detected. + * + * The callback should only be called when the caller is interested in that + * particular transition. For instance, if the caller is interested only in + * ENTERED transition, then the callback should NOT be called with the EXITED + * transition. + * + * IMPORTANT: If a transition is triggered resulting in this callback, the GPS + * subsystem will wake up the application processor, if its in suspend state. + */ +typedef void (*loc_gps_geofence_transition_callback) (int32_t geofence_id, LocGpsLocation* location, + int32_t transition, LocGpsUtcTime timestamp); + +/** + * The callback associated with the availability of the GPS system for geofencing + * monitoring. If the GPS system determines that it cannot monitor geofences + * because of lack of reliability or unavailability of the GPS signals, it will + * call this callback with LOC_GPS_GEOFENCE_UNAVAILABLE parameter. + * + * Parameters: + * status - LOC_GPS_GEOFENCE_UNAVAILABLE or LOC_GPS_GEOFENCE_AVAILABLE. + * last_location - Last known location. + */ +typedef void (*loc_gps_geofence_status_callback) (int32_t status, LocGpsLocation* last_location); + +/** + * The callback associated with the add_geofence call. + * + * Parameter: + * geofence_id - Id of the geofence. + * status - LOC_GPS_GEOFENCE_OPERATION_SUCCESS + * LOC_GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES - geofence limit has been reached. + * LOC_GPS_GEOFENCE_ERROR_ID_EXISTS - geofence with id already exists + * LOC_GPS_GEOFENCE_ERROR_INVALID_TRANSITION - the monitorTransition contains an + * invalid transition + * LOC_GPS_GEOFENCE_ERROR_GENERIC - for other errors. + */ +typedef void (*loc_gps_geofence_add_callback) (int32_t geofence_id, int32_t status); + +/** + * The callback associated with the remove_geofence call. + * + * Parameter: + * geofence_id - Id of the geofence. + * status - LOC_GPS_GEOFENCE_OPERATION_SUCCESS + * LOC_GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id + * LOC_GPS_GEOFENCE_ERROR_GENERIC for others. + */ +typedef void (*loc_gps_geofence_remove_callback) (int32_t geofence_id, int32_t status); + + +/** + * The callback associated with the pause_geofence call. + * + * Parameter: + * geofence_id - Id of the geofence. + * status - LOC_GPS_GEOFENCE_OPERATION_SUCCESS + * LOC_GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id + * LOC_GPS_GEOFENCE_ERROR_INVALID_TRANSITION - + * when monitor_transitions is invalid + * LOC_GPS_GEOFENCE_ERROR_GENERIC for others. + */ +typedef void (*loc_gps_geofence_pause_callback) (int32_t geofence_id, int32_t status); + +/** + * The callback associated with the resume_geofence call. + * + * Parameter: + * geofence_id - Id of the geofence. + * status - LOC_GPS_GEOFENCE_OPERATION_SUCCESS + * LOC_GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id + * LOC_GPS_GEOFENCE_ERROR_GENERIC for others. + */ +typedef void (*loc_gps_geofence_resume_callback) (int32_t geofence_id, int32_t status); + +typedef struct { + loc_gps_geofence_transition_callback geofence_transition_callback; + loc_gps_geofence_status_callback geofence_status_callback; + loc_gps_geofence_add_callback geofence_add_callback; + loc_gps_geofence_remove_callback geofence_remove_callback; + loc_gps_geofence_pause_callback geofence_pause_callback; + loc_gps_geofence_resume_callback geofence_resume_callback; + loc_gps_create_thread create_thread_cb; +} LocGpsGeofenceCallbacks; + +/** Extended interface for GPS_Geofencing support */ +typedef struct { + /** set to sizeof(LocGpsGeofencingInterface) */ + size_t size; + + /** + * Opens the geofence interface and provides the callback routines + * to the implementation of this interface. + */ + void (*init)( LocGpsGeofenceCallbacks* callbacks ); + + /** + * Add a geofence area. This api currently supports circular geofences. + * Parameters: + * geofence_id - The id for the geofence. If a geofence with this id + * already exists, an error value (LOC_GPS_GEOFENCE_ERROR_ID_EXISTS) + * should be returned. + * latitude, longtitude, radius_meters - The lat, long and radius + * (in meters) for the geofence + * last_transition - The current state of the geofence. For example, if + * the system already knows that the user is inside the geofence, + * this will be set to LOC_GPS_GEOFENCE_ENTERED. In most cases, it + * will be LOC_GPS_GEOFENCE_UNCERTAIN. + * monitor_transition - Which transitions to monitor. Bitwise OR of + * LOC_GPS_GEOFENCE_ENTERED, LOC_GPS_GEOFENCE_EXITED and + * LOC_GPS_GEOFENCE_UNCERTAIN. + * notification_responsiveness_ms - Defines the best-effort description + * of how soon should the callback be called when the transition + * associated with the Geofence is triggered. For instance, if set + * to 1000 millseconds with LOC_GPS_GEOFENCE_ENTERED, the callback + * should be called 1000 milliseconds within entering the geofence. + * This parameter is defined in milliseconds. + * NOTE: This is not to be confused with the rate that the GPS is + * polled at. It is acceptable to dynamically vary the rate of + * sampling the GPS for power-saving reasons; thus the rate of + * sampling may be faster or slower than this. + * unknown_timer_ms - The time limit after which the UNCERTAIN transition + * should be triggered. This parameter is defined in milliseconds. + * See above for a detailed explanation. + */ + void (*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); + + /** + * Pause monitoring a particular geofence. + * Parameters: + * geofence_id - The id for the geofence. + */ + void (*pause_geofence) (int32_t geofence_id); + + /** + * Resume monitoring a particular geofence. + * Parameters: + * geofence_id - The id for the geofence. + * monitor_transitions - Which transitions to monitor. Bitwise OR of + * LOC_GPS_GEOFENCE_ENTERED, LOC_GPS_GEOFENCE_EXITED and + * LOC_GPS_GEOFENCE_UNCERTAIN. + * This supersedes the value associated provided in the + * add_geofence_area call. + */ + void (*resume_geofence) (int32_t geofence_id, int monitor_transitions); + + /** + * Remove a geofence area. After the function returns, no notifications + * should be sent. + * Parameter: + * geofence_id - The id for the geofence. + */ + void (*remove_geofence_area) (int32_t geofence_id); +} LocGpsGeofencingInterface; + +/** + * Legacy struct to represent an estimate of the GPS clock time. + * Deprecated, to be removed in the next Android release. + * Use LocGnssClock instead. + */ +typedef struct { + /** set to sizeof(LocGpsClock) */ + size_t size; + LocGpsClockFlags flags; + int16_t leap_second; + LocGpsClockType type; + int64_t time_ns; + double time_uncertainty_ns; + int64_t full_bias_ns; + double bias_ns; + double bias_uncertainty_ns; + double drift_nsps; + double drift_uncertainty_nsps; +} LocGpsClock; + +/** + * Represents an estimate of the GPS clock time. + */ +typedef struct { + /** set to sizeof(LocGnssClock) */ + size_t size; + + /** + * A set of flags indicating the validity of the fields in this data + * structure. + */ + LocGnssClockFlags flags; + + /** + * Leap second data. + * The sign of the value is defined by the following equation: + * utc_time_ns = time_ns - (full_bias_ns + bias_ns) - leap_second * + * 1,000,000,000 + * + * If the data is available 'flags' must contain LOC_GNSS_CLOCK_HAS_LEAP_SECOND. + */ + int16_t leap_second; + + /** + * The GNSS receiver internal clock value. This is the local hardware clock + * value. + * + * For local hardware clock, this value is expected to be monotonically + * increasing while the hardware clock remains power on. (For the case of a + * HW clock that is not continuously on, see the + * hw_clock_discontinuity_count field). The receiver's estimate of GPS time + * can be derived by substracting the sum of full_bias_ns and bias_ns (when + * available) from this value. + * + * This GPS time is expected to be the best estimate of current GPS time + * that GNSS receiver can achieve. + * + * Sub-nanosecond accuracy can be provided by means of the 'bias_ns' field. + * The value contains the 'time uncertainty' in it. + * + * This field is mandatory. + */ + int64_t time_ns; + + /** + * 1-Sigma uncertainty associated with the clock's time in nanoseconds. + * The uncertainty is represented as an absolute (single sided) value. + * + * If the data is available, 'flags' must contain + * LOC_GNSS_CLOCK_HAS_TIME_UNCERTAINTY. This value is effectively zero (it is + * the reference local clock, by which all other times and time + * uncertainties are measured.) (And thus this field can be not provided, + * per LOC_GNSS_CLOCK_HAS_TIME_UNCERTAINTY flag, or provided & set to 0.) + */ + double time_uncertainty_ns; + + /** + * The difference between hardware clock ('time' field) inside GPS receiver + * and the true GPS time since 0000Z, January 6, 1980, in nanoseconds. + * + * The sign of the value is defined by the following equation: + * local estimate of GPS time = time_ns - (full_bias_ns + bias_ns) + * + * This value is mandatory if the receiver has estimated GPS time. If the + * computed time is for a non-GPS constellation, the time offset of that + * constellation to GPS has to be applied to fill this value. The error + * estimate for the sum of this and the bias_ns is the bias_uncertainty_ns, + * and the caller is responsible for using this uncertainty (it can be very + * large before the GPS time has been solved for.) If the data is available + * 'flags' must contain LOC_GNSS_CLOCK_HAS_FULL_BIAS. + */ + int64_t full_bias_ns; + + /** + * Sub-nanosecond bias. + * The error estimate for the sum of this and the full_bias_ns is the + * bias_uncertainty_ns + * + * If the data is available 'flags' must contain LOC_GNSS_CLOCK_HAS_BIAS. If GPS + * has computed a position fix. This value is mandatory if the receiver has + * estimated GPS time. + */ + double bias_ns; + + /** + * 1-Sigma uncertainty associated with the local estimate of GPS time (clock + * bias) in nanoseconds. The uncertainty is represented as an absolute + * (single sided) value. + * + * If the data is available 'flags' must contain + * LOC_GNSS_CLOCK_HAS_BIAS_UNCERTAINTY. This value is mandatory if the receiver + * has estimated GPS time. + */ + double bias_uncertainty_ns; + + /** + * The clock's drift in nanoseconds (per second). + * + * A positive value means that the frequency is higher than the nominal + * frequency, and that the (full_bias_ns + bias_ns) is growing more positive + * over time. + * + * The value contains the 'drift uncertainty' in it. + * If the data is available 'flags' must contain LOC_GNSS_CLOCK_HAS_DRIFT. + * + * This value is mandatory if the receiver has estimated GNSS time + */ + double drift_nsps; + + /** + * 1-Sigma uncertainty associated with the clock's drift in nanoseconds (per second). + * The uncertainty is represented as an absolute (single sided) value. + * + * If the data is available 'flags' must contain + * LOC_GNSS_CLOCK_HAS_DRIFT_UNCERTAINTY. If GPS has computed a position fix this + * field is mandatory and must be populated. + */ + double drift_uncertainty_nsps; + + /** + * When there are any discontinuities in the HW clock, this field is + * mandatory. + * + * A "discontinuity" is meant to cover the case of a switch from one source + * of clock to another. A single free-running crystal oscillator (XO) + * should generally not have any discontinuities, and this can be set and + * left at 0. + * + * If, however, the time_ns value (HW clock) is derived from a composite of + * sources, that is not as smooth as a typical XO, or is otherwise stopped & + * restarted, then this value shall be incremented each time a discontinuity + * occurs. (E.g. this value may start at zero at device boot-up and + * increment each time there is a change in clock continuity. In the + * unlikely event that this value reaches full scale, rollover (not + * clamping) is required, such that this value continues to change, during + * subsequent discontinuity events.) + * + * While this number stays the same, between LocGnssClock reports, it can be + * safely assumed that the time_ns value has been running continuously, e.g. + * derived from a single, high quality clock (XO like, or better, that's + * typically used during continuous GNSS signal sampling.) + * + * It is expected, esp. during periods where there are few GNSS signals + * available, that the HW clock be discontinuity-free as long as possible, + * as this avoids the need to use (waste) a GNSS measurement to fully + * re-solve for the GPS clock bias and drift, when using the accompanying + * measurements, from consecutive LocGnssData reports. + */ + uint32_t hw_clock_discontinuity_count; + +} LocGnssClock; + +/** + * Legacy struct to represent a GPS Measurement, it contains raw and computed + * information. + * Deprecated, to be removed in the next Android release. + * Use LocGnssMeasurement instead. + */ +typedef struct { + /** set to sizeof(LocGpsMeasurement) */ + size_t size; + LocGpsMeasurementFlags flags; + int8_t prn; + double time_offset_ns; + LocGpsMeasurementState state; + int64_t received_gps_tow_ns; + int64_t received_gps_tow_uncertainty_ns; + double c_n0_dbhz; + double pseudorange_rate_mps; + double pseudorange_rate_uncertainty_mps; + LocGpsAccumulatedDeltaRangeState accumulated_delta_range_state; + double accumulated_delta_range_m; + double accumulated_delta_range_uncertainty_m; + double pseudorange_m; + double pseudorange_uncertainty_m; + double code_phase_chips; + double code_phase_uncertainty_chips; + float carrier_frequency_hz; + int64_t carrier_cycles; + double carrier_phase; + double carrier_phase_uncertainty; + LocGpsLossOfLock loss_of_lock; + int32_t bit_number; + int16_t time_from_last_bit_ms; + double doppler_shift_hz; + double doppler_shift_uncertainty_hz; + LocGpsMultipathIndicator multipath_indicator; + double snr_db; + double elevation_deg; + double elevation_uncertainty_deg; + double azimuth_deg; + double azimuth_uncertainty_deg; + bool used_in_fix; +} LocGpsMeasurement; + +/** + * Represents a GNSS Measurement, it contains raw and computed information. + * + * Independence - All signal measurement information (e.g. sv_time, + * pseudorange_rate, multipath_indicator) reported in this struct should be + * based on GNSS signal measurements only. You may not synthesize measurements + * by calculating or reporting expected measurements based on known or estimated + * position, velocity, or time. + */ +typedef struct { + /** set to sizeof(LocGnssMeasurement) */ + size_t size; + + /** A set of flags indicating the validity of the fields in this data structure. */ + LocGnssMeasurementFlags flags; + + /** + * Satellite vehicle ID number, as defined in LocGnssSvInfo::svid + * This is a mandatory value. + */ + int16_t svid; + + /** + * Defines the constellation of the given SV. Value should be one of those + * LOC_GNSS_CONSTELLATION_* constants + */ + LocGnssConstellationType constellation; + + /** + * Time offset at which the measurement was taken in nanoseconds. + * The reference receiver's time is specified by LocGpsData::clock::time_ns and should be + * interpreted in the same way as indicated by LocGpsClock::type. + * + * The sign of time_offset_ns is given by the following equation: + * measurement time = LocGpsClock::time_ns + time_offset_ns + * + * It provides an individual time-stamp for the measurement, and allows sub-nanosecond accuracy. + * This is a mandatory value. + */ + double time_offset_ns; + + /** + * Per satellite sync state. It represents the current sync state for the associated satellite. + * Based on the sync state, the 'received GPS tow' field should be interpreted accordingly. + * + * This is a mandatory value. + */ + LocGnssMeasurementState state; + + /** + * The received GNSS Time-of-Week at the measurement time, in nanoseconds. + * Ensure that this field is independent (see comment at top of + * LocGnssMeasurement struct.) + * + * For GPS & QZSS, this is: + * Received GPS Time-of-Week at the measurement time, in nanoseconds. + * The value is relative to the beginning of the current GPS week. + * + * Given the highest sync state that can be achieved, per each satellite, valid range + * for this field can be: + * Searching : [ 0 ] : LOC_GNSS_MEASUREMENT_STATE_UNKNOWN + * C/A code lock : [ 0 1ms ] : LOC_GNSS_MEASUREMENT_STATE_CODE_LOCK is set + * Bit sync : [ 0 20ms ] : LOC_GNSS_MEASUREMENT_STATE_BIT_SYNC is set + * Subframe sync : [ 0 6s ] : LOC_GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC is set + * TOW decoded : [ 0 1week ] : LOC_GNSS_MEASUREMENT_STATE_TOW_DECODED is set + * + * Note well: if there is any ambiguity in integer millisecond, + * LOC_GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS should be set accordingly, in the 'state' field. + * + * This value must be populated if 'state' != LOC_GNSS_MEASUREMENT_STATE_UNKNOWN. + * + * For Glonass, this is: + * Received Glonass time of day, at the measurement time in nanoseconds. + * + * Given the highest sync state that can be achieved, per each satellite, valid range for + * this field can be: + * Searching : [ 0 ] : LOC_GNSS_MEASUREMENT_STATE_UNKNOWN + * C/A code lock : [ 0 1ms ] : LOC_GNSS_MEASUREMENT_STATE_CODE_LOCK is set + * Symbol sync : [ 0 10ms ] : LOC_GNSS_MEASUREMENT_STATE_SYMBOL_SYNC is set + * Bit sync : [ 0 20ms ] : LOC_GNSS_MEASUREMENT_STATE_BIT_SYNC is set + * String sync : [ 0 2s ] : LOC_GNSS_MEASUREMENT_STATE_GLO_STRING_SYNC is set + * Time of day : [ 0 1day ] : LOC_GNSS_MEASUREMENT_STATE_GLO_TOD_DECODED is set + * + * For Beidou, this is: + * Received Beidou time of week, at the measurement time in nanoseconds. + * + * Given the highest sync state that can be achieved, per each satellite, valid range for + * this field can be: + * Searching : [ 0 ] : LOC_GNSS_MEASUREMENT_STATE_UNKNOWN + * C/A code lock: [ 0 1ms ] : LOC_GNSS_MEASUREMENT_STATE_CODE_LOCK is set + * Bit sync (D2): [ 0 2ms ] : LOC_GNSS_MEASUREMENT_STATE_BDS_D2_BIT_SYNC is set + * Bit sync (D1): [ 0 20ms ] : LOC_GNSS_MEASUREMENT_STATE_BIT_SYNC is set + * Subframe (D2): [ 0 0.6s ] : LOC_GNSS_MEASUREMENT_STATE_BDS_D2_SUBFRAME_SYNC is set + * Subframe (D1): [ 0 6s ] : LOC_GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC is set + * Time of week : [ 0 1week ] : LOC_GNSS_MEASUREMENT_STATE_TOW_DECODED is set + * + * For Galileo, this is: + * Received Galileo time of week, at the measurement time in nanoseconds. + * + * E1BC code lock : [ 0 4ms ] : LOC_GNSS_MEASUREMENT_STATE_GAL_E1BC_CODE_LOCK is set + * E1C 2nd code lock: [ 0 100ms ] : + * LOC_GNSS_MEASUREMENT_STATE_GAL_E1C_2ND_CODE_LOCK is set + * + * E1B page : [ 0 2s ] : LOC_GNSS_MEASUREMENT_STATE_GAL_E1B_PAGE_SYNC is set + * Time of week: [ 0 1week ] : LOC_GNSS_MEASUREMENT_STATE_TOW_DECODED is set + * + * For SBAS, this is: + * Received SBAS time, at the measurement time in nanoseconds. + * + * Given the highest sync state that can be achieved, per each satellite, + * valid range for this field can be: + * Searching : [ 0 ] : LOC_GNSS_MEASUREMENT_STATE_UNKNOWN + * C/A code lock: [ 0 1ms ] : LOC_GNSS_MEASUREMENT_STATE_CODE_LOCK is set + * Symbol sync : [ 0 2ms ] : LOC_GNSS_MEASUREMENT_STATE_SYMBOL_SYNC is set + * Message : [ 0 1s ] : LOC_GNSS_MEASUREMENT_STATE_SBAS_SYNC is set + */ + int64_t received_sv_time_in_ns; + + /** + * 1-Sigma uncertainty of the Received GPS Time-of-Week in nanoseconds. + * + * This value must be populated if 'state' != LOC_GPS_MEASUREMENT_STATE_UNKNOWN. + */ + int64_t received_sv_time_uncertainty_in_ns; + + /** + * Carrier-to-noise density in dB-Hz, typically in the range [0, 63]. + * It contains the measured C/N0 value for the signal at the antenna port. + * + * This is a mandatory value. + */ + double c_n0_dbhz; + + /** + * Pseudorange rate at the timestamp in m/s. The correction of a given + * Pseudorange Rate value includes corrections for receiver and satellite + * clock frequency errors. Ensure that this field is independent (see + * comment at top of LocGnssMeasurement struct.) + * + * It is mandatory to provide the 'uncorrected' 'pseudorange rate', and provide LocGpsClock's + * 'drift' field as well (When providing the uncorrected pseudorange rate, do not apply the + * corrections described above.) + * + * The value includes the 'pseudorange rate uncertainty' in it. + * A positive 'uncorrected' value indicates that the SV is moving away from the receiver. + * + * The sign of the 'uncorrected' 'pseudorange rate' and its relation to the sign of 'doppler + * shift' is given by the equation: + * pseudorange rate = -k * doppler shift (where k is a constant) + * + * This should be the most accurate pseudorange rate available, based on + * fresh signal measurements from this channel. + * + * It is mandatory that this value be provided at typical carrier phase PRR + * quality (few cm/sec per second of uncertainty, or better) - when signals + * are sufficiently strong & stable, e.g. signals from a GPS simulator at >= + * 35 dB-Hz. + */ + double pseudorange_rate_mps; + + /** + * 1-Sigma uncertainty of the pseudorange_rate_mps. + * The uncertainty is represented as an absolute (single sided) value. + * + * This is a mandatory value. + */ + double pseudorange_rate_uncertainty_mps; + + /** + * Accumulated delta range's state. It indicates whether ADR is reset or there is a cycle slip + * (indicating loss of lock). + * + * This is a mandatory value. + */ + LocGnssAccumulatedDeltaRangeState accumulated_delta_range_state; + + /** + * Accumulated delta range since the last channel reset in meters. + * A positive value indicates that the SV is moving away from the receiver. + * + * The sign of the 'accumulated delta range' and its relation to the sign of 'carrier phase' + * is given by the equation: + * accumulated delta range = -k * carrier phase (where k is a constant) + * + * This value must be populated if 'accumulated delta range state' != LOC_GPS_ADR_STATE_UNKNOWN. + * However, it is expected that the data is only accurate when: + * 'accumulated delta range state' == LOC_GPS_ADR_STATE_VALID. + */ + double accumulated_delta_range_m; + + /** + * 1-Sigma uncertainty of the accumulated delta range in meters. + * This value must be populated if 'accumulated delta range state' != LOC_GPS_ADR_STATE_UNKNOWN. + */ + double accumulated_delta_range_uncertainty_m; + + /** + * Carrier frequency at which codes and messages are modulated, it can be L1 or L2. + * If the field is not set, the carrier frequency is assumed to be L1. + * + * If the data is available, 'flags' must contain + * LOC_GNSS_MEASUREMENT_HAS_CARRIER_FREQUENCY. + */ + float carrier_frequency_hz; + + /** + * The number of full carrier cycles between the satellite and the receiver. + * The reference frequency is given by the field 'carrier_frequency_hz'. + * Indications of possible cycle slips and resets in the accumulation of + * this value can be inferred from the accumulated_delta_range_state flags. + * + * If the data is available, 'flags' must contain + * LOC_GNSS_MEASUREMENT_HAS_CARRIER_CYCLES. + */ + int64_t carrier_cycles; + + /** + * The RF phase detected by the receiver, in the range [0.0, 1.0]. + * This is usually the fractional part of the complete carrier phase measurement. + * + * The reference frequency is given by the field 'carrier_frequency_hz'. + * The value contains the 'carrier-phase uncertainty' in it. + * + * If the data is available, 'flags' must contain + * LOC_GNSS_MEASUREMENT_HAS_CARRIER_PHASE. + */ + double carrier_phase; + + /** + * 1-Sigma uncertainty of the carrier-phase. + * If the data is available, 'flags' must contain + * LOC_GNSS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY. + */ + double carrier_phase_uncertainty; + + /** + * An enumeration that indicates the 'multipath' state of the event. + * + * The multipath Indicator is intended to report the presence of overlapping + * signals that manifest as distorted correlation peaks. + * + * - if there is a distorted correlation peak shape, report that multipath + * is LOC_GNSS_MULTIPATH_INDICATOR_PRESENT. + * - if there is not a distorted correlation peak shape, report + * LOC_GNSS_MULTIPATH_INDICATOR_NOT_PRESENT + * - if signals are too weak to discern this information, report + * LOC_GNSS_MULTIPATH_INDICATOR_UNKNOWN + * + * Example: when doing the standardized overlapping Multipath Performance + * test (3GPP TS 34.171) the Multipath indicator should report + * LOC_GNSS_MULTIPATH_INDICATOR_PRESENT for those signals that are tracked, and + * contain multipath, and LOC_GNSS_MULTIPATH_INDICATOR_NOT_PRESENT for those + * signals that are tracked and do not contain multipath. + */ + LocGnssMultipathIndicator multipath_indicator; + + /** + * Signal-to-noise ratio at correlator output in dB. + * If the data is available, 'flags' must contain LOC_GNSS_MEASUREMENT_HAS_SNR. + * This is the power ratio of the "correlation peak height above the + * observed noise floor" to "the noise RMS". + */ + double snr_db; +} LocGnssMeasurement; + +/** + * Legacy struct to represents a reading of GPS measurements. + * Deprecated, to be removed in the next Android release. + * Use LocGnssData instead. + */ +typedef struct { + /** set to sizeof(LocGpsData) */ + size_t size; + size_t measurement_count; + LocGpsMeasurement measurements[LOC_GPS_MAX_MEASUREMENT]; + + /** The GPS clock time reading. */ + LocGpsClock clock; +} LocGpsData; + +/** + * Represents a reading of GNSS measurements. For devices where LocGnssSystemInfo's + * year_of_hw is set to 2016+, it is mandatory that these be provided, on + * request, when the GNSS receiver is searching/tracking signals. + * + * - Reporting of GPS constellation measurements is mandatory. + * - Reporting of all tracked constellations are encouraged. + */ +typedef struct { + /** set to sizeof(LocGnssData) */ + size_t size; + + /** Number of measurements. */ + size_t measurement_count; + + /** The array of measurements. */ + LocGnssMeasurement measurements[LOC_GNSS_MAX_MEASUREMENT]; + + /** The GPS clock time reading. */ + LocGnssClock clock; +} LocGnssData; + +/** + * The legacy callback for to report measurements from the HAL. + * + * This callback is deprecated, and will be removed in the next release. Use + * loc_gnss_measurement_callback() instead. + * + * Parameters: + * data - A data structure containing the measurements. + */ +typedef void (*loc_gps_measurement_callback) (LocGpsData* data); + +/** + * The callback for to report measurements from the HAL. + * + * Parameters: + * data - A data structure containing the measurements. + */ +typedef void (*loc_gnss_measurement_callback) (LocGnssData* data); + +typedef struct { + /** set to sizeof(LocGpsMeasurementCallbacks) */ + size_t size; + loc_gps_measurement_callback measurement_callback; + loc_gnss_measurement_callback loc_gnss_measurement_callback; +} LocGpsMeasurementCallbacks; + +#define LOC_GPS_MEASUREMENT_OPERATION_SUCCESS 0 +#define LOC_GPS_MEASUREMENT_ERROR_ALREADY_INIT -100 +#define LOC_GPS_MEASUREMENT_ERROR_GENERIC -101 + +/** + * Extended interface for GPS Measurements support. + */ +typedef struct { + /** Set to sizeof(LocGpsMeasurementInterface) */ + size_t size; + + /** + * Initializes the interface and registers the callback routines with the HAL. + * After a successful call to 'init' the HAL must begin to provide updates at its own phase. + * + * Status: + * LOC_GPS_MEASUREMENT_OPERATION_SUCCESS + * LOC_GPS_MEASUREMENT_ERROR_ALREADY_INIT - if a callback has already been registered without a + * corresponding call to 'close' + * LOC_GPS_MEASUREMENT_ERROR_GENERIC - if any other error occurred, it is expected that the HAL + * will not generate any updates upon returning this error code. + */ + int (*init) (LocGpsMeasurementCallbacks* callbacks); + + /** + * Stops updates from the HAL, and unregisters the callback routines. + * After a call to stop, the previously registered callbacks must be considered invalid by the + * HAL. + * If stop is invoked without a previous 'init', this function should perform no work. + */ + void (*close) (); + +} LocGpsMeasurementInterface; + +#if 0 +/** + * Legacy struct to represents a GPS navigation message (or a fragment of it). + * Deprecated, to be removed in the next Android release. + * Use GnssNavigationMessage instead. + */ +typedef struct { + /** set to sizeof(GpsNavigationMessage) */ + size_t size; + int8_t prn; + GpsNavigationMessageType type; + NavigationMessageStatus status; + int16_t message_id; + int16_t submessage_id; + size_t data_length; + uint8_t* data; +} GpsNavigationMessage; + +/** Represents a GPS navigation message (or a fragment of it). */ +typedef struct { + /** set to sizeof(GnssNavigationMessage) */ + size_t size; + + /** + * Satellite vehicle ID number, as defined in LocGnssSvInfo::svid + * This is a mandatory value. + */ + int16_t svid; + + /** + * The type of message contained in the structure. + * This is a mandatory value. + */ + GnssNavigationMessageType type; + + /** + * The status of the received navigation message. + * No need to send any navigation message that contains words with parity error and cannot be + * corrected. + */ + NavigationMessageStatus status; + + /** + * Message identifier. It provides an index so the complete Navigation + * Message can be assembled. + * + * - For GPS L1 C/A subframe 4 and 5, this value corresponds to the 'frame + * id' of the navigation message, in the range of 1-25 (Subframe 1, 2, 3 + * does not contain a 'frame id' and this value can be set to -1.) + * + * - For Glonass L1 C/A, this refers to the frame ID, in the range of 1-5. + * + * - For BeiDou D1, this refers to the frame number in the range of 1-24 + * + * - For Beidou D2, this refers to the frame number, in the range of 1-120 + * + * - For Galileo F/NAV nominal frame structure, this refers to the subframe + * number, in the range of 1-12 + * + * - For Galileo I/NAV nominal frame structure, this refers to the subframe + * number in the range of 1-24 + */ + int16_t message_id; + + /** + * Sub-message identifier. If required by the message 'type', this value + * contains a sub-index within the current message (or frame) that is being + * transmitted. + * + * - For GPS L1 C/A, BeiDou D1 & BeiDou D2, the submessage id corresponds to + * the subframe number of the navigation message, in the range of 1-5. + * + * - For Glonass L1 C/A, this refers to the String number, in the range from + * 1-15 + * + * - For Galileo F/NAV, this refers to the page type in the range 1-6 + * + * - For Galileo I/NAV, this refers to the word type in the range 1-10+ + */ + int16_t submessage_id; + + /** + * The length of the data (in bytes) contained in the current message. + * If this value is different from zero, 'data' must point to an array of the same size. + * e.g. for L1 C/A the size of the sub-frame will be 40 bytes (10 words, 30 bits/word). + * + * This is a mandatory value. + */ + size_t data_length; + + /** + * The data of the reported GPS message. The bytes (or words) specified + * using big endian format (MSB first). + * + * - For GPS L1 C/A, Beidou D1 & Beidou D2, each subframe contains 10 30-bit + * words. Each word (30 bits) should be fit into the last 30 bits in a + * 4-byte word (skip B31 and B32), with MSB first, for a total of 40 + * bytes, covering a time period of 6, 6, and 0.6 seconds, respectively. + * + * - For Glonass L1 C/A, each string contains 85 data bits, including the + * checksum. These bits should be fit into 11 bytes, with MSB first (skip + * B86-B88), covering a time period of 2 seconds. + * + * - For Galileo F/NAV, each word consists of 238-bit (sync & tail symbols + * excluded). Each word should be fit into 30-bytes, with MSB first (skip + * B239, B240), covering a time period of 10 seconds. + * + * - For Galileo I/NAV, each page contains 2 page parts, even and odd, with + * a total of 2x114 = 228 bits, (sync & tail excluded) that should be fit + * into 29 bytes, with MSB first (skip B229-B232). + */ + uint8_t* data; + +} GnssNavigationMessage; + +/** + * The legacy callback to report an available fragment of a GPS navigation + * messages from the HAL. + * + * This callback is deprecated, and will be removed in the next release. Use + * gnss_navigation_message_callback() instead. + * + * Parameters: + * message - The GPS navigation submessage/subframe representation. + */ +typedef void (*gps_navigation_message_callback) (GpsNavigationMessage* message); + +/** + * The callback to report an available fragment of a GPS navigation messages from the HAL. + * + * Parameters: + * message - The GPS navigation submessage/subframe representation. + */ +typedef void (*gnss_navigation_message_callback) (GnssNavigationMessage* message); + +typedef struct { + /** set to sizeof(GpsNavigationMessageCallbacks) */ + size_t size; + gps_navigation_message_callback navigation_message_callback; + gnss_navigation_message_callback gnss_navigation_message_callback; +} GpsNavigationMessageCallbacks; + +#define GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS 0 +#define GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT -100 +#define GPS_NAVIGATION_MESSAGE_ERROR_GENERIC -101 + +/** + * Extended interface for GPS navigation message reporting support. + */ +typedef struct { + /** Set to sizeof(GpsNavigationMessageInterface) */ + size_t size; + + /** + * Initializes the interface and registers the callback routines with the HAL. + * After a successful call to 'init' the HAL must begin to provide updates as they become + * available. + * + * Status: + * GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS + * GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT - if a callback has already been registered + * without a corresponding call to 'close'. + * GPS_NAVIGATION_MESSAGE_ERROR_GENERIC - if any other error occurred, it is expected that + * the HAL will not generate any updates upon returning this error code. + */ + int (*init) (GpsNavigationMessageCallbacks* callbacks); + + /** + * Stops updates from the HAL, and unregisters the callback routines. + * After a call to stop, the previously registered callbacks must be considered invalid by the + * HAL. + * If stop is invoked without a previous 'init', this function should perform no work. + */ + void (*close) (); + +} GpsNavigationMessageInterface; +#endif + +/** + * Interface for passing GNSS configuration contents from platform to HAL. + */ +typedef struct { + /** Set to sizeof(LocGnssConfigurationInterface) */ + size_t size; + + /** + * Deliver GNSS configuration contents to HAL. + * Parameters: + * config_data - a pointer to a char array which holds what usually is expected from + file(/etc/gps.conf), i.e., a sequence of UTF8 strings separated by '\n'. + * length - total number of UTF8 characters in configuraiton data. + * + * IMPORTANT: + * GPS HAL should expect this function can be called multiple times. And it may be + * called even when GpsLocationProvider is already constructed and enabled. GPS HAL + * should maintain the existing requests for various callback regardless the change + * in configuration data. + */ + void (*configuration_update) (const char* config_data, int32_t length); +} LocGnssConfigurationInterface; + +__END_DECLS + +#endif /* LOC_GPS_H */ + diff --git a/loc-hal.pc.in b/loc-hal.pc.in index 36cd4e7d..92e83414 100644 --- a/loc-hal.pc.in +++ b/loc-hal.pc.in @@ -6,5 +6,5 @@ includedir=@includedir@ Name: loc-hal Description: QTI GPS Loc HAL Version: @VERSION -Libs: -L${libdir} -lgps_utils_so -lloc_core -lloc_eng_so -lgps_default_so -lloc_ds_api -lloc_api_v02 +Libs: -L${libdir} -lgps_utils_so -lloc_core -lloc_eng_so -lloc_ds_api -lloc_api_v02 Cflags: -I${includedir} -I${includedir}/loc-hal/utils -I${includedir}/loc-hal/core -I${includedir}/loc-hal diff --git a/loc_api/Makefile.am b/loc_api/Makefile.am index 46480974..23ccc35e 100644 --- a/loc_api/Makefile.am +++ b/loc_api/Makefile.am @@ -20,6 +20,7 @@ libloc_eng_so_la_h_sources = \ 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 \ @@ -47,24 +48,6 @@ endif libloc_eng_so_la_LIBADD = -lstdc++ -ldl -llog $(LOCPLA_LIBS) ../utils/libgps_utils_so.la ../core/libloc_core.la - -libgps_default_so_la_SOURCES = \ - libloc_api_50001/loc.cpp \ - libloc_api_50001/gps.c - -if USE_GLIB -libgps_default_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@ -libgps_default_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 -libgps_default_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@ -else -libgps_default_so_la_CFLAGS = $(AM_CFLAGS) -libgps_default_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0 -libgps_default_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) -endif - -libgps_default_so_la_LIBADD = -lstdc++ -llog $(LOCPLA_LIBS) ../utils/libgps_utils_so.la ../core/libloc_core.la -ldl libloc_eng_so.la - - libloc_ds_api_CFLAGS = \ $(QMIF_CFLAGS) \ $(QMI_CFLAGS) \ @@ -134,4 +117,4 @@ library_include_HEADERS = \ library_includedir = $(pkgincludedir) #Create and Install libraries -lib_LTLIBRARIES = libloc_eng_so.la libgps_default_so.la libloc_ds_api.la libloc_api_v02.la +lib_LTLIBRARIES = libloc_eng_so.la libloc_ds_api.la libloc_api_v02.la diff --git a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc/LocApiRpc.h b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc/LocApiRpc.h index 13557c97..b2b4e2ab 100644 --- a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc/LocApiRpc.h +++ b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc/LocApiRpc.h @@ -51,8 +51,8 @@ private: 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 GpsNiEncodingType convertNiEncodingType(int loc_encoding); - static int NIEventFillVerfiyType(GpsNiNotification ¬if, + static LocGpsNiEncodingType convertNiEncodingType(int loc_encoding); + static int NIEventFillVerfiyType(LocGpsNiNotification ¬if, rpc_loc_ni_notify_verify_e_type notif_priv); void reportPosition(const rpc_loc_parsed_position_s_type *location_report_ptr); @@ -93,13 +93,13 @@ public: virtual enum loc_api_adapter_err enableData(int enable, boolean force); virtual enum loc_api_adapter_err - setTime(GpsUtcTime time, int64_t timeReference, int uncertainty); + 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(GpsAidingData f); + deleteAidingData(LocGpsAidingData f); virtual enum loc_api_adapter_err - informNiResponse(GpsUserResponseType userResponse, const void* passThroughData); + 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 @@ -113,7 +113,7 @@ public: virtual enum loc_api_adapter_err requestXtraServer(); virtual enum loc_api_adapter_err - atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bear, AGpsType agpsType); + 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 diff --git a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpc.cpp b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpc.cpp index f4b0ebf4..f0f84b50 100644 --- a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpc.cpp +++ b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpc.cpp @@ -423,10 +423,10 @@ LocApiRpc::setPositionMode(const LocPosMode& posMode) } switch (fixCriteria->recurrence) { - case GPS_POSITION_RECURRENCE_SINGLE: + case LOC_GPS_POSITION_RECURRENCE_SINGLE: fix_criteria_ptr->recurrence_type = RPC_LOC_SINGLE_FIX; break; - case GPS_POSITION_RECURRENCE_PERIODIC: + case LOC_GPS_POSITION_RECURRENCE_PERIODIC: default: fix_criteria_ptr->recurrence_type = RPC_LOC_PERIODIC_FIX; break; @@ -443,7 +443,7 @@ LocApiRpc::setPositionMode(const LocPosMode& posMode) } enum loc_api_adapter_err -LocApiRpc::setTime(GpsUtcTime time, int64_t timeReference, int uncertainty) +LocApiRpc::setTime(LocGpsUtcTime time, int64_t timeReference, int uncertainty) { rpc_loc_ioctl_data_u_type ioctl_data; rpc_loc_assist_data_time_s_type *time_info_ptr; @@ -508,7 +508,7 @@ LocApiRpc::injectPosition(double latitude, double longitude, float accuracy) } enum loc_api_adapter_err -LocApiRpc::informNiResponse(GpsUserResponseType userResponse, +LocApiRpc::informNiResponse(LocGpsUserResponseType userResponse, const void* passThroughData) { rpc_loc_ioctl_data_u_type data; @@ -520,15 +520,15 @@ LocApiRpc::informNiResponse(GpsUserResponseType userResponse, rpc_loc_ni_user_resp_e_type resp; switch (userResponse) { - case GPS_NI_RESPONSE_ACCEPT: + case LOC_GPS_NI_RESPONSE_ACCEPT: data.rpc_loc_ioctl_data_u_type_u.user_verify_resp.user_resp = RPC_LOC_NI_LCS_NOTIFY_VERIFY_ACCEPT; break; - case GPS_NI_RESPONSE_DENY: + case LOC_GPS_NI_RESPONSE_DENY: data.rpc_loc_ioctl_data_u_type_u.user_verify_resp.user_resp = RPC_LOC_NI_LCS_NOTIFY_VERIFY_DENY; break; - case GPS_NI_RESPONSE_NORESP: + case LOC_GPS_NI_RESPONSE_NORESP: default: data.rpc_loc_ioctl_data_u_type_u.user_verify_resp.user_resp = RPC_LOC_NI_LCS_NOTIFY_VERIFY_NORESP; @@ -672,7 +672,7 @@ LocApiRpc::enableData(int enable, boolean force) } enum loc_api_adapter_err -LocApiRpc::deleteAidingData(GpsAidingData bits) +LocApiRpc::deleteAidingData(LocGpsAidingData bits) { rpc_loc_ioctl_data_u_type ioctl_data = {RPC_LOC_IOCTL_DELETE_ASSIST_DATA, {0}}; ioctl_data.rpc_loc_ioctl_data_u_type_u.assist_data_delete.type = bits; @@ -707,7 +707,7 @@ void LocApiRpc::reportPosition(const rpc_loc_parsed_position_s_type *location_re (location_report_ptr->latitude != 0 || location_report_ptr->longitude != 0)) { - location.gpsLocation.flags |= GPS_LOCATION_HAS_LAT_LONG; + location.gpsLocation.flags |= LOC_GPS_LOCATION_HAS_LAT_LONG; location.gpsLocation.latitude = location_report_ptr->latitude; location.gpsLocation.longitude = location_report_ptr->longitude; @@ -720,28 +720,28 @@ void LocApiRpc::reportPosition(const rpc_loc_parsed_position_s_type *location_re // Altitude if (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_ALTITUDE_WRT_ELLIPSOID ) { - location.gpsLocation.flags |= GPS_LOCATION_HAS_ALTITUDE; + location.gpsLocation.flags |= LOC_GPS_LOCATION_HAS_ALTITUDE; location.gpsLocation.altitude = location_report_ptr->altitude_wrt_ellipsoid; } // Speed if (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_SPEED_HORIZONTAL) { - location.gpsLocation.flags |= GPS_LOCATION_HAS_SPEED; + location.gpsLocation.flags |= LOC_GPS_LOCATION_HAS_SPEED; location.gpsLocation.speed = location_report_ptr->speed_horizontal; } // Heading if (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_HEADING) { - location.gpsLocation.flags |= GPS_LOCATION_HAS_BEARING; + location.gpsLocation.flags |= LOC_GPS_LOCATION_HAS_BEARING; location.gpsLocation.bearing = location_report_ptr->heading; } // Uncertainty (circular) if ( (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_HOR_UNC_CIRCULAR) ) { - location.gpsLocation.flags |= GPS_LOCATION_HAS_ACCURACY; + location.gpsLocation.flags |= LOC_GPS_LOCATION_HAS_ACCURACY; location.gpsLocation.accuracy = location_report_ptr->hor_unc_circular; } @@ -816,9 +816,9 @@ void LocApiRpc::reportSv(const rpc_loc_gnss_info_s_type *gnss_report_ptr) if (gnss_report_ptr->valid_mask & RPC_LOC_GNSS_INFO_VALID_SV_COUNT) { num_svs_max = gnss_report_ptr->sv_count; - if (num_svs_max > GPS_MAX_SVS) + if (num_svs_max > LOC_GPS_MAX_SVS) { - num_svs_max = GPS_MAX_SVS; + num_svs_max = LOC_GPS_MAX_SVS; } } @@ -833,7 +833,7 @@ void LocApiRpc::reportSv(const rpc_loc_gnss_info_s_type *gnss_report_ptr) { if (sv_info_ptr->system == RPC_LOC_SV_SYSTEM_GPS) { - SvStatus.sv_list[SvStatus.num_svs].size = sizeof(GpsSvInfo); + SvStatus.sv_list[SvStatus.num_svs].size = sizeof(LocGpsSvInfo); SvStatus.sv_list[SvStatus.num_svs].prn = sv_info_ptr->prn; // We only have the data field to report gps eph and alm mask @@ -923,17 +923,17 @@ void LocApiRpc::reportStatus(const rpc_loc_status_event_s_type *status_report_pt if (status_report_ptr->event == RPC_LOC_STATUS_EVENT_ENGINE_STATE) { if (status_report_ptr->payload.rpc_loc_status_event_payload_u_type_u.engine_state == RPC_LOC_ENGINE_STATE_ON) { - LocApiBase::reportStatus(GPS_STATUS_ENGINE_ON); - LocApiBase::reportStatus(GPS_STATUS_SESSION_BEGIN); + LocApiBase::reportStatus(LOC_GPS_STATUS_ENGINE_ON); + LocApiBase::reportStatus(LOC_GPS_STATUS_SESSION_BEGIN); } else if (status_report_ptr->payload.rpc_loc_status_event_payload_u_type_u.engine_state == RPC_LOC_ENGINE_STATE_OFF) { - LocApiBase::reportStatus(GPS_STATUS_SESSION_END); - LocApiBase::reportStatus(GPS_STATUS_ENGINE_OFF); + LocApiBase::reportStatus(LOC_GPS_STATUS_SESSION_END); + LocApiBase::reportStatus(LOC_GPS_STATUS_ENGINE_OFF); } else { - LocApiBase::reportStatus(GPS_STATUS_NONE); + LocApiBase::reportStatus(LOC_GPS_STATUS_NONE); } } @@ -1079,12 +1079,12 @@ LocApiRpc::requestXtraServer() } enum loc_api_adapter_err -LocApiRpc::atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bearer, AGpsType agpsType) +LocApiRpc::atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bearer, LocAGpsType agpsType) { rpc_loc_server_open_status_e_type open_status = is_succ ? RPC_LOC_SERVER_OPEN_SUCCESS : RPC_LOC_SERVER_OPEN_FAIL; rpc_loc_ioctl_data_u_type ioctl_data; - if (AGPS_TYPE_INVALID == agpsType) { + if (LOC_AGPS_TYPE_INVALID == agpsType) { rpc_loc_server_open_status_s_type *conn_open_status_ptr = &ioctl_data.rpc_loc_ioctl_data_u_type_u.conn_open_status; @@ -1176,7 +1176,7 @@ LocApiRpc::atlCloseStatus(int handle, int is_succ) void LocApiRpc::ATLEvent(const rpc_loc_server_request_s_type *server_request_ptr) { int connHandle; - AGpsType agps_type; + LocAGpsType agps_type; LOC_LOGV("RPC_LOC_EVENT_ASSISTANCE_DATA_REQUEST event %s)", loc_get_event_atl_open_name(server_request_ptr->event)); @@ -1186,18 +1186,18 @@ void LocApiRpc::ATLEvent(const rpc_loc_server_request_s_type *server_request_ptr connHandle = server_request_ptr->payload.rpc_loc_server_request_u_type_u.multi_open_req.conn_handle; if (server_request_ptr->payload.rpc_loc_server_request_u_type_u.multi_open_req.connection_type == RPC_LOC_SERVER_CONNECTION_LBS) { - agps_type = AGPS_TYPE_SUPL; - LOC_LOGV("ATLEvent: event - RPC_LOC_SERVER_REQUEST_MULTI_OPEN\n type - AGPS_TYPE_SUPL\n handle - %d", connHandle); + agps_type = LOC_AGPS_TYPE_SUPL; + LOC_LOGV("ATLEvent: event - RPC_LOC_SERVER_REQUEST_MULTI_OPEN\n type - LOC_AGPS_TYPE_SUPL\n handle - %d", connHandle); } else { - agps_type = AGPS_TYPE_WWAN_ANY; - LOC_LOGV("ATLEvent: event - RPC_LOC_SERVER_REQUEST_MULTI_OPEN\n type - AGPS_TYPE_WWAN_ANY\n handle - %d", connHandle); + agps_type = LOC_AGPS_TYPE_WWAN_ANY; + LOC_LOGV("ATLEvent: event - RPC_LOC_SERVER_REQUEST_MULTI_OPEN\n type - LOC_AGPS_TYPE_WWAN_ANY\n handle - %d", connHandle); } requestATL(connHandle, agps_type); break; case RPC_LOC_SERVER_REQUEST_OPEN: connHandle = server_request_ptr->payload.rpc_loc_server_request_u_type_u.open_req.conn_handle; LOC_LOGV("ATLEvent: event - RPC_LOC_SERVER_REQUEST_OPEN\n handle - %d", connHandle); - requestATL(connHandle, AGPS_TYPE_INVALID); + requestATL(connHandle, LOC_AGPS_TYPE_INVALID); break; case RPC_LOC_SERVER_REQUEST_CLOSE: connHandle = server_request_ptr->payload.rpc_loc_server_request_u_type_u.close_req.conn_handle; @@ -1211,7 +1211,7 @@ void LocApiRpc::ATLEvent(const rpc_loc_server_request_s_type *server_request_ptr void LocApiRpc::NIEvent(const rpc_loc_ni_event_s_type *ni_req) { - GpsNiNotification notif = {0}; + LocGpsNiNotification notif = {0}; switch (ni_req->event) { @@ -1220,7 +1220,7 @@ void LocApiRpc::NIEvent(const rpc_loc_ni_event_s_type *ni_req) const rpc_loc_ni_vx_notify_verify_req_s_type *vx_req = &ni_req->payload.rpc_loc_ni_event_payload_u_type_u.vx_req; LOC_LOGI("VX Notification"); - notif.ni_type = GPS_NI_TYPE_VOICE; + notif.ni_type = LOC_GPS_NI_TYPE_VOICE; // Requestor ID hexcode(notif.requestor_id, sizeof notif.requestor_id, vx_req->requester_id.requester_id, @@ -1236,7 +1236,7 @@ void LocApiRpc::NIEvent(const rpc_loc_ni_event_s_type *ni_req) const rpc_loc_ni_umts_cp_notify_verify_req_s_type *umts_cp_req = &ni_req->payload.rpc_loc_ni_event_payload_u_type_u.umts_cp_req; LOC_LOGI("UMTS CP Notification\n"); - notif.ni_type= GPS_NI_TYPE_UMTS_CTRL_PLANE; // Stores notification text + notif.ni_type= LOC_GPS_NI_TYPE_UMTS_CTRL_PLANE; // Stores notification text #if (AMSS_VERSION==3200) hexcode(notif.text, sizeof notif.text, umts_cp_req->notification_text.notification_text_val, @@ -1289,7 +1289,7 @@ void LocApiRpc::NIEvent(const rpc_loc_ni_event_s_type *ni_req) const rpc_loc_ni_supl_notify_verify_req_s_type *supl_req = &ni_req->payload.rpc_loc_ni_event_payload_u_type_u.supl_req; LOC_LOGI("SUPL Notification\n"); - notif.ni_type = GPS_NI_TYPE_UMTS_SUPL; + notif.ni_type = LOC_GPS_NI_TYPE_UMTS_SUPL; if (supl_req->flags & RPC_LOC_NI_CLIENT_NAME_PRESENT) { @@ -1337,7 +1337,7 @@ void LocApiRpc::NIEvent(const rpc_loc_ni_event_s_type *ni_req) notif.requestor_id_encoding = notif.text_encoding; } else { - notif.text_encoding = notif.requestor_id_encoding = GPS_ENC_UNKNOWN; + notif.text_encoding = notif.requestor_id_encoding = LOC_GPS_ENC_UNKNOWN; } NIEventFillVerfiyType(notif, ni_req->payload.rpc_loc_ni_event_payload_u_type_u.supl_req.notification_priv_type); @@ -1355,30 +1355,30 @@ void LocApiRpc::NIEvent(const rpc_loc_ni_event_s_type *ni_req) requestNiNotify(notif, (const void*)copy); } -int LocApiRpc::NIEventFillVerfiyType(GpsNiNotification ¬if, +int LocApiRpc::NIEventFillVerfiyType(LocGpsNiNotification ¬if, rpc_loc_ni_notify_verify_e_type notif_priv) { switch (notif_priv) { case RPC_LOC_NI_USER_NO_NOTIFY_NO_VERIFY: notif.notify_flags = 0; - notif.default_response = GPS_NI_RESPONSE_NORESP; + notif.default_response = LOC_GPS_NI_RESPONSE_NORESP; return 1; case RPC_LOC_NI_USER_NOTIFY_ONLY: - notif.notify_flags = GPS_NI_NEED_NOTIFY; - notif.default_response = GPS_NI_RESPONSE_NORESP; + notif.notify_flags = LOC_GPS_NI_NEED_NOTIFY; + notif.default_response = LOC_GPS_NI_RESPONSE_NORESP; return 1; case RPC_LOC_NI_USER_NOTIFY_VERIFY_ALLOW_NO_RESP: - notif.notify_flags = GPS_NI_NEED_NOTIFY | GPS_NI_NEED_VERIFY; - notif.default_response = GPS_NI_RESPONSE_ACCEPT; + notif.notify_flags = LOC_GPS_NI_NEED_NOTIFY | LOC_GPS_NI_NEED_VERIFY; + notif.default_response = LOC_GPS_NI_RESPONSE_ACCEPT; return 1; case RPC_LOC_NI_USER_NOTIFY_VERIFY_NOT_ALLOW_NO_RESP: - notif.notify_flags = GPS_NI_NEED_NOTIFY | GPS_NI_NEED_VERIFY; - notif.default_response = GPS_NI_RESPONSE_DENY; + notif.notify_flags = LOC_GPS_NI_NEED_NOTIFY | LOC_GPS_NI_NEED_VERIFY; + notif.default_response = LOC_GPS_NI_RESPONSE_DENY; return 1; case RPC_LOC_NI_USER_PRIVACY_OVERRIDE: - notif.notify_flags = GPS_NI_PRIVACY_OVERRIDE; - notif.default_response = GPS_NI_RESPONSE_NORESP; + notif.notify_flags = LOC_GPS_NI_PRIVACY_OVERRIDE; + notif.default_response = LOC_GPS_NI_RESPONSE_NORESP; return 1; default: return 0; @@ -1399,20 +1399,20 @@ LocApiRpc::setSUPLVersion(uint32_t version) ); } -GpsNiEncodingType LocApiRpc::convertNiEncodingType(int loc_encoding) +LocGpsNiEncodingType LocApiRpc::convertNiEncodingType(int loc_encoding) { switch (loc_encoding) { case RPC_LOC_NI_SUPL_UTF8: - return GPS_ENC_SUPL_UTF8; + return LOC_GPS_ENC_SUPL_UTF8; case RPC_LOC_NI_SUPL_UCS2: - return GPS_ENC_SUPL_UCS2; + return LOC_GPS_ENC_SUPL_UCS2; case RPC_LOC_NI_SUPL_GSM_DEFAULT: - return GPS_ENC_SUPL_GSM_DEFAULT; + return LOC_GPS_ENC_SUPL_GSM_DEFAULT; case RPC_LOC_NI_SS_LANGUAGE_UNSPEC: - return GPS_ENC_SUPL_GSM_DEFAULT; // SS_LANGUAGE_UNSPEC = GSM + return LOC_GPS_ENC_SUPL_GSM_DEFAULT; // SS_LANGUAGE_UNSPEC = GSM default: - return GPS_ENC_UNKNOWN; + return LOC_GPS_ENC_UNKNOWN; } } diff --git a/loc_api/libloc_api_50001/Android.mk b/loc_api/libloc_api_50001/Android.mk index ad14e143..c33bc915 100644 --- a/loc_api/libloc_api_50001/Android.mk +++ b/loc_api/libloc_api_50001/Android.mk @@ -20,6 +20,7 @@ LOCAL_SHARED_LIBRARIES := \ libloc_pla LOCAL_SRC_FILES += \ + loc.cpp \ loc_eng.cpp \ loc_eng_agps.cpp \ loc_eng_xtra.cpp \ @@ -84,7 +85,8 @@ ifneq ($(filter $(TARGET_DEVICE), apq8084 msm8960), false) endif LOCAL_SRC_FILES += \ - loc.cpp \ + gps_interface.cpp \ + gps_converter.cpp \ gps.c LOCAL_CFLAGS += \ diff --git a/loc_api/libloc_api_50001/LocEngAdapter.cpp b/loc_api/libloc_api_50001/LocEngAdapter.cpp index 9db513cc..c312a24e 100644 --- a/loc_api/libloc_api_50001/LocEngAdapter.cpp +++ b/loc_api/libloc_api_50001/LocEngAdapter.cpp @@ -376,14 +376,14 @@ void LocEngAdapter::reportPosition(UlpLocation &location, } } -void LocInternalAdapter::reportSv(GnssSvStatus &svStatus, +void LocInternalAdapter::reportSv(LocGnssSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt){ sendMsg(new LocEngReportSv(mLocEngAdapter, svStatus, locationExtended, svExt)); } -void LocEngAdapter::reportSv(GnssSvStatus &svStatus, +void LocEngAdapter::reportSv(LocGnssSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt) { @@ -422,12 +422,12 @@ void LocEngAdapter::setInSession(bool inSession) } } -void LocInternalAdapter::reportStatus(GpsStatusValue status) +void LocInternalAdapter::reportStatus(LocGpsStatusValue status) { sendMsg(new LocEngReportStatus(mLocEngAdapter, status)); } -void LocEngAdapter::reportStatus(GpsStatusValue status) +void LocEngAdapter::reportStatus(LocGpsStatusValue status) { if (!mUlp->reportStatus(status)) { mInternalAdapter->reportStatus(status); @@ -461,7 +461,7 @@ bool LocEngAdapter::reportXtraServer(const char* url1, } inline -bool LocEngAdapter::requestATL(int connHandle, AGpsType agps_type) +bool LocEngAdapter::requestATL(int connHandle, LocAGpsType agps_type) { if (mSupportsAgpsRequests) { sendMsg(new LocEngRequestATL(mOwner, @@ -498,7 +498,7 @@ bool LocEngAdapter::requestTime() } inline -bool LocEngAdapter::requestNiNotify(GpsNiNotification ¬if, const void* data) +bool LocEngAdapter::requestNiNotify(LocGpsNiNotification ¬if, const void* data) { if (mSupportsAgpsRequests) { notif.size = sizeof(notif); @@ -545,7 +545,7 @@ void LocEngAdapter::handleEngineUpEvent() sendMsg(new LocEngUp(mOwner)); } -enum loc_api_adapter_err LocEngAdapter::setTime(GpsUtcTime time, +enum loc_api_adapter_err LocEngAdapter::setTime(LocGpsUtcTime time, int64_t timeReference, int uncertainty) { @@ -588,7 +588,7 @@ enum loc_api_adapter_err LocEngAdapter::setXtraVersionCheck(int check) return ret; } -void LocEngAdapter::reportGnssMeasurementData(GnssData &gnssMeasurementData) +void LocEngAdapter::reportGnssMeasurementData(LocGnssData &gnssMeasurementData) { sendMsg(new LocEngReportGnssMeasurement(mOwner, gnssMeasurementData)); diff --git a/loc_api/libloc_api_50001/LocEngAdapter.h b/loc_api/libloc_api_50001/LocEngAdapter.h index 7afdd001..e341651d 100644 --- a/loc_api/libloc_api_50001/LocEngAdapter.h +++ b/loc_api/libloc_api_50001/LocEngAdapter.h @@ -30,7 +30,6 @@ #define LOC_API_ENG_ADAPTER_H #include -#include #include #include #include @@ -54,10 +53,10 @@ public: void* locationExt, enum loc_sess_status status, LocPosTechMask loc_technology_mask); - virtual void reportSv(GnssSvStatus &svStatus, + virtual void reportSv(LocGnssSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt); - virtual void reportStatus(GpsStatusValue status); + virtual void reportStatus(LocGpsStatusValue status); virtual void setPositionModeInt(LocPosMode& posMode); virtual void startFixInt(); virtual void stopFixInt(); @@ -87,7 +86,7 @@ public: bool mSupportsAgpsRequests; bool mSupportsPositionInjection; bool mSupportsTimeInjection; - GnssSystemInfo mGnssInfo; + LocGnssSystemInfo mGnssInfo; LocEngAdapter(LOC_API_ADAPTER_EVENT_MASK_T mask, void* owner, ContextBase* context, @@ -143,7 +142,7 @@ public: return mLocApi->stopFix(); } inline enum loc_api_adapter_err - deleteAidingData(GpsAidingData f) + deleteAidingData(LocGpsAidingData f) { return mLocApi->deleteAidingData(f); } @@ -173,7 +172,7 @@ public: return mLocApi->requestXtraServer(); } inline enum loc_api_adapter_err - atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bearer, AGpsType agpsType) + atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bearer, LocAGpsType agpsType) { return mLocApi->atlOpenStatus(handle, is_succ, apn, bearer, agpsType); } @@ -202,7 +201,7 @@ public: return mLocApi->setServer(ip, port, type); } inline enum loc_api_adapter_err - informNiResponse(GpsUserResponseType userResponse, const void* passThroughData) + informNiResponse(LocGpsUserResponseType userResponse, const void* passThroughData) { return mLocApi->informNiResponse(userResponse, passThroughData); } @@ -282,15 +281,15 @@ public: mLocApi->releaseDataServiceClient(); } inline enum loc_api_adapter_err - getZpp(GpsLocation &zppLoc, LocPosTechMask &tech_mask) + getZpp(LocGpsLocation &zppLoc, LocPosTechMask &tech_mask) { return mLocApi->getBestAvailableZppFix(zppLoc, tech_mask); } - enum loc_api_adapter_err setTime(GpsUtcTime time, + 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 DerEncodedCertificate* pData, + inline virtual void installAGpsCert(const LocDerEncodedCertificate* pData, size_t length, uint32_t slotBitMask) { @@ -303,24 +302,24 @@ public: void* locationExt, enum loc_sess_status status, LocPosTechMask loc_technology_mask); - virtual void reportSv(GnssSvStatus &svStatus, + virtual void reportSv(LocGnssSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt); virtual void reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet); virtual void reportSvPolynomial(GnssSvPolynomial &svPolynomial); - virtual void reportStatus(GpsStatusValue status); + 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, AGpsType agps_type); + virtual bool requestATL(int connHandle, LocAGpsType agps_type); virtual bool releaseATL(int connHandle); - virtual bool requestNiNotify(GpsNiNotification ¬ify, const void* data); + virtual bool requestNiNotify(LocGpsNiNotification ¬ify, const void* data); virtual bool requestSuplES(int connHandle); virtual bool reportDataCallOpened(); virtual bool reportDataCallClosed(); - virtual void reportGnssMeasurementData(GnssData &gnssMeasurementData); + virtual void reportGnssMeasurementData(LocGnssData &gnssMeasurementData); inline const LocPosMode& getPositionMode() const {return mFixCriteria;} diff --git a/loc_api/libloc_api_50001/Makefile.am b/loc_api/libloc_api_50001/Makefile.am index c7624272..4c1ccf7d 100644 --- a/loc_api/libloc_api_50001/Makefile.am +++ b/loc_api/libloc_api_50001/Makefile.am @@ -1,78 +1,62 @@ -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_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 - - -libgps_default_so_la_SOURCES = \ - loc.cpp \ - gps.c - -if USE_GLIB -libgps_default_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@ -libgps_default_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 -libgps_default_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@ -else -libgps_default_so_la_CFLAGS = $(AM_CFLAGS) -libgps_default_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0 -libgps_default_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) -endif - -libgps_default_so_la_LIBADD = -lstdc++ -lcutils ../../utils/libgps_utils_so.la -ldl libloc_eng_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 libgps_default_so.la +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 diff --git a/loc_api/libloc_api_50001/gps_converter.cpp b/loc_api/libloc_api_50001/gps_converter.cpp new file mode 100644 index 00000000..1ca23cf0 --- /dev/null +++ b/loc_api/libloc_api_50001/gps_converter.cpp @@ -0,0 +1,255 @@ +/* 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 + +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); +} diff --git a/loc_api/libloc_api_50001/gps_converter.h b/loc_api/libloc_api_50001/gps_converter.h new file mode 100644 index 00000000..fa7c68a3 --- /dev/null +++ b/loc_api/libloc_api_50001/gps_converter.h @@ -0,0 +1,69 @@ +/* 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 +#include +#include + +#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__ diff --git a/loc_api/libloc_api_50001/gps_interface.cpp b/loc_api/libloc_api_50001/gps_interface.cpp new file mode 100644 index 00000000..993874f7 --- /dev/null +++ b/loc_api/libloc_api_50001/gps_interface.cpp @@ -0,0 +1,1196 @@ +/* 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. + * + */ + +#define LOG_NDDEBUG 0 +#define LOG_TAG "GpsInterface" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace loc_core; + +// All functions and variables should be static +// except gps_get_hardware_interface() and get_gps_interface() + +extern "C" const LocGpsInterface* loc_eng_gps_get_hardware_interface (); +extern "C" const LocGpsInterface* loc_eng_get_gps_interface(); + +/*=========================================================================== + Functions and variables for sGpsInterface +===========================================================================*/ +static const LocGpsInterface* pLocGpsInterface = NULL; + +static GpsCallbacks sGpsCallbacks; +static GpsCallbacks* pGpsCallbacks = NULL; + +static void local_gps_location_callback(LocGpsLocation* location); +static void local_gps_sv_status_callback(LocGpsSvStatus* sv_status); +static void local_gps_status_callback(LocGpsStatus* status); +static void local_gps_nmea_callback(LocGpsUtcTime timestamp, const char* nmea, int length); +static void local_gps_set_capabilities(uint32_t capabilities); +static void local_gps_acquire_wakelock(); +static void local_gps_release_wakelock(); +static pthread_t local_gps_create_thread(const char* name, void (*start)(void *), void* arg); +static void local_gps_request_utc_time(); +static void local_gnss_set_system_info(const LocGnssSystemInfo* info); +static void local_gnss_sv_status_callback(LocGnssSvStatus* sv_info); + +static LocGpsCallbacks sLocGpsCallbacks = { + sizeof(LocGpsCallbacks), + local_gps_location_callback, + local_gps_status_callback, + local_gps_sv_status_callback, + local_gps_nmea_callback, + local_gps_set_capabilities, + local_gps_acquire_wakelock, + local_gps_release_wakelock, + local_gps_create_thread, + local_gps_request_utc_time, + local_gnss_set_system_info, + local_gnss_sv_status_callback, +}; + +static int loc_init(GpsCallbacks* callbacks); +static int loc_start(); +static int loc_stop(); +static void loc_cleanup(); +static int loc_inject_time(GpsUtcTime time, int64_t timeReference, int uncertainty); +static int loc_inject_location(double latitude, double longitude, float accuracy); +static void loc_delete_aiding_data(GpsAidingData f); +static int loc_set_position_mode(GpsPositionMode mode, GpsPositionRecurrence recurrence, + uint32_t min_interval, uint32_t preferred_accuracy, + uint32_t preferred_time); +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 sGpsXtraInterface +===========================================================================*/ +static const LocGpsXtraInterface* pLocGpsXtraInterface = NULL; + +static GpsXtraCallbacks sGpsXtraCallbacks; +static GpsXtraCallbacks* pGpsXtraCallbacks = NULL; + +static void local_gps_xtra_download_request(); +static pthread_t local_gps_xtra_create_thread(const char* name, void (*start)(void *), void* arg); + +static LocGpsXtraCallbacks sLocGpsXtraCallbacks = { + local_gps_xtra_download_request, + local_gps_xtra_create_thread +}; + +static int loc_xtra_init(GpsXtraCallbacks* callbacks); +static int loc_xtra_inject_data(char* data, int length); + +static const GpsXtraInterface sGpsXtraInterface = { + sizeof(GpsXtraInterface), + loc_xtra_init, + loc_xtra_inject_data +}; + +/*=========================================================================== + Functions and variables for sAGpsInterface +===========================================================================*/ +static const LocAGpsInterface* pLocAGpsInterface = NULL; + +static AGpsCallbacks sAGpsCallbacks; +static AGpsCallbacks* pAGpsCallbacks = NULL; + +static void local_agps_status_callback(LocAGpsStatus* status); +static pthread_t local_agps_create_thread(const char* name, void (*start)(void *), void* arg); + +static LocAGpsCallbacks sLocAGpsCallbacks = { + local_agps_status_callback, + local_agps_create_thread +}; + +static void loc_agps_init(AGpsCallbacks* callbacks); +static int loc_agps_open(const char* apn); +static int loc_agps_closed(); +static int loc_agps_open_failed(); +static int loc_agps_set_server(AGpsType type, const char *hostname, int port); +static int loc_agps_open_with_apniptype( const char* apn, ApnIpType apnIpType); + +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 SUPL sSuplCertificateInterface +===========================================================================*/ +static const LocSuplCertificateInterface* pLocSuplCertificateInterface = NULL; + +static int loc_agps_install_certificates(const DerEncodedCertificate* certificates, + size_t length); +static int loc_agps_revoke_certificates(const Sha1CertificateFingerprint* fingerprints, + size_t length); + +static const SuplCertificateInterface sSuplCertificateInterface = +{ + sizeof(SuplCertificateInterface), + loc_agps_install_certificates, + loc_agps_revoke_certificates +}; + +/*=========================================================================== + Functions and variables for sGpsNiInterface +===========================================================================*/ +static const LocGpsNiInterface* pLocGpsNiInterface = NULL; + +static GpsNiCallbacks sGpsNiCallbacks; +static GpsNiCallbacks* pGpsNiCallbacks = NULL; + +static void local_gps_ni_notify_callback(LocGpsNiNotification *notification); +static pthread_t local_gps_ni_create_thread(const char* name, void (*start)(void *), void* arg); + +static LocGpsNiCallbacks sLocGpsNiCallbacks = { + local_gps_ni_notify_callback, + local_gps_ni_create_thread +}; + +static void loc_ni_init(GpsNiCallbacks *callbacks); +static void loc_ni_respond(int notif_id, GpsUserResponseType user_response); + +static const GpsNiInterface sGpsNiInterface = +{ + sizeof(GpsNiInterface), + loc_ni_init, + loc_ni_respond, +}; + +/*=========================================================================== + Functions and variables for sAGpsRilInterface +===========================================================================*/ +static const LocAGpsRilInterface* pLocAGpsRilInterface = NULL; + +static void loc_agps_ril_init(AGpsRilCallbacks* callbacks); +static void loc_agps_ril_set_ref_location(const AGpsRefLocation *agps_reflocation, size_t sz_struct); +static void loc_agps_ril_set_set_id(AGpsSetIDType type, const char* setid); +static void loc_agps_ril_ni_message(uint8_t *msg, size_t len); +static void loc_agps_ril_update_network_state(int connected, int type, int roaming, const char* extra_info); +static void loc_agps_ril_update_network_availability(int avaiable, const char* apn); + +static const AGpsRilInterface sAGpsRilInterface = +{ + sizeof(AGpsRilInterface), + loc_agps_ril_init, + loc_agps_ril_set_ref_location, + loc_agps_ril_set_set_id, + loc_agps_ril_ni_message, + loc_agps_ril_update_network_state, + loc_agps_ril_update_network_availability +}; + +/*=========================================================================== + Functions and variables for sGpsGeofencingInterface +===========================================================================*/ +static const LocGpsGeofencingInterface* pLocGpsGeofencingInterface = NULL; + +static GpsGeofenceCallbacks sGpsGeofenceCallbacks; +static GpsGeofenceCallbacks* pGpsGeofenceCallbacks = NULL; + +static void local_gps_geofence_transition_callback(int32_t geofence_id, LocGpsLocation* location, + int32_t transition, LocGpsUtcTime timestamp); +static void local_gps_geofence_status_callback(int32_t status, LocGpsLocation* last_location); +static void local_gps_geofence_add_callback(int32_t geofence_id, int32_t status); +static void local_gps_geofence_remove_callback(int32_t geofence_id, int32_t status); +static void local_gps_geofence_pause_callback(int32_t geofence_id, int32_t status); +static void local_gps_geofence_resume_callback(int32_t geofence_id, int32_t status); +static pthread_t local_geofence_create_thread(const char* name, void (*start)(void *), void* arg); + +static LocGpsGeofenceCallbacks sLocGpsGeofenceCallbacks = +{ + local_gps_geofence_transition_callback, + local_gps_geofence_status_callback, + local_gps_geofence_add_callback, + local_gps_geofence_remove_callback, + local_gps_geofence_pause_callback, + local_gps_geofence_resume_callback, + local_geofence_create_thread +}; + +static void loc_geofence_init(GpsGeofenceCallbacks* callbacks); +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); +static void loc_pause_geofence(int32_t geofence_id); +static void loc_resume_geofence(int32_t geofence_id, int monitor_transitions); +static void loc_remove_geofence_area(int32_t 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 +}; + +/*=========================================================================== + Functions and variables for sGpsMeasurementInterface +===========================================================================*/ +static const LocGpsMeasurementInterface* pLocGpsMeasurementInterface = NULL; + +static GpsMeasurementCallbacks sGpsMeasurementCallbacks; +static GpsMeasurementCallbacks* pGpsMeasurementCallbacks = NULL; + +static void local_gps_measurement_callback(LocGpsData* data); +static void local_gnss_measurement_callback(LocGnssData* data); + +static LocGpsMeasurementCallbacks sLocGpsMeasurementCallbacks = +{ + sizeof(LocGpsMeasurementCallbacks), + local_gps_measurement_callback, + local_gnss_measurement_callback +}; + +static int loc_gps_measurement_init(GpsMeasurementCallbacks* callbacks); +static void loc_gps_measurement_close(); + +static const GpsMeasurementInterface sGpsMeasurementInterface = +{ + sizeof(GpsMeasurementInterface), + loc_gps_measurement_init, + loc_gps_measurement_close +}; + +/*=========================================================================== + Functions and variables for sGnssConfigurationInterface +===========================================================================*/ +static const LocGnssConfigurationInterface* pLocGnssConfigurationInterface = NULL; + +static void loc_configuration_update(const char* config_data, int32_t length); + +static const GnssConfigurationInterface sGnssConfigurationInterface = +{ + sizeof(GnssConfigurationInterface), + loc_configuration_update +}; + + +/*=========================================================================== +FUNCTION gps_get_hardware_interface + +DESCRIPTION + Returns the GPS hardware interaface based on LOC API + if GPS is enabled. + +DEPENDENCIES + None + +RETURN VALUE + 0: success + +SIDE EFFECTS + N/A + +===========================================================================*/ +extern "C" const GpsInterface* gps_get_hardware_interface () +{ + ENTRY_LOG_CALLFLOW(); + const GpsInterface* retVal; + pLocGpsInterface = loc_eng_gps_get_hardware_interface(); + if (NULL != pLocGpsInterface) { + retVal = &sGpsInterface; + } else { + retVal = NULL; + } + EXIT_LOG(%p, retVal); + return retVal; +} + +// for gps.c +extern "C" const GpsInterface* get_gps_interface() +{ + pLocGpsInterface = loc_eng_get_gps_interface(); + return &sGpsInterface; +} + +/*=========================================================================== + Implementation of functions for sGpsInterface +===========================================================================*/ +static void local_gps_location_callback(LocGpsLocation* location) +{ + ENTRY_LOG(); + if (NULL != pGpsCallbacks && NULL != pGpsCallbacks->location_cb) { + GpsLocation loc; + GpsLocation* p_loc = NULL; + if (NULL != location) { + Q2A_GpsLocation(*location, loc); + p_loc = &loc; + } + // We are not sure whether NULL pointer is a legal + // parameter to the original callback functions or not. + // So we should forward NULL pointer at this layer. + pGpsCallbacks->location_cb(p_loc); + } + EXIT_LOG(%s, VOID_RET); +} + +static void local_gps_sv_status_callback(LocGpsSvStatus* sv_status) +{ + ENTRY_LOG(); + if (NULL != pGpsCallbacks && NULL != pGpsCallbacks->sv_status_cb) { + CALLBACK_LOG_CALLFLOW("sv_status_cb -", %d, sv_status->num_svs); + GpsSvStatus st; + GpsSvStatus* p_st = NULL; + if (NULL != sv_status) { + Q2A_GpsSvStatus(*sv_status, st); + p_st = &st; + } + pGpsCallbacks->sv_status_cb(p_st); + } + EXIT_LOG(%s, VOID_RET); +} + +static void local_gps_status_callback(LocGpsStatus* status) +{ + ENTRY_LOG(); + if (NULL != pGpsCallbacks && NULL != pGpsCallbacks->status_cb) { + GpsStatus st; + GpsStatus* p_st = NULL; + if (NULL != status) { + Q2A_GpsStatus(*status, st); + p_st = &st; + } + pGpsCallbacks->status_cb(p_st); + } + EXIT_LOG(%s, VOID_RET); +} + +static void local_gps_nmea_callback(LocGpsUtcTime timestamp, const char* nmea, int length) +{ + ENTRY_LOG(); + if (NULL != pGpsCallbacks && NULL != pGpsCallbacks->nmea_cb) { + pGpsCallbacks->nmea_cb(A2Q_GpsUtcTime(timestamp), nmea, length); + } + EXIT_LOG(%s, VOID_RET); +} + +static void local_gps_set_capabilities(uint32_t capabilities) +{ + ENTRY_LOG(); + if (NULL != pGpsCallbacks && NULL != pGpsCallbacks->set_capabilities_cb) { + pGpsCallbacks->set_capabilities_cb(capabilities); + } + EXIT_LOG(%s, VOID_RET); +} + +static void local_gps_acquire_wakelock() +{ + ENTRY_LOG(); + if (NULL != pGpsCallbacks && NULL != pGpsCallbacks->acquire_wakelock_cb) { + pGpsCallbacks->acquire_wakelock_cb(); + } + EXIT_LOG(%s, VOID_RET); +} + +static void local_gps_release_wakelock() +{ + ENTRY_LOG(); + if (NULL != pGpsCallbacks && NULL != pGpsCallbacks->release_wakelock_cb) { + pGpsCallbacks->release_wakelock_cb(); + } + EXIT_LOG(%s, VOID_RET); +} + +static pthread_t local_gps_create_thread(const char* name, void (*start)(void *), void* arg) +{ + ENTRY_LOG(); + pthread_t retVal = -1; + if (NULL != pGpsCallbacks && NULL != pGpsCallbacks->create_thread_cb) { + retVal = pGpsCallbacks->create_thread_cb(name, start, arg); + } + EXIT_LOG(%d, (int)retVal); + return retVal; +} + +static void local_gps_request_utc_time() +{ + ENTRY_LOG(); + if (NULL != pGpsCallbacks && NULL != pGpsCallbacks->request_utc_time_cb) { + pGpsCallbacks->request_utc_time_cb(); + } + EXIT_LOG(%s, VOID_RET); +} + +static void local_gnss_set_system_info(const LocGnssSystemInfo* info) +{ + ENTRY_LOG(); + if (NULL != pGpsCallbacks && NULL != pGpsCallbacks->set_system_info_cb) { + GnssSystemInfo sysinfo; + GnssSystemInfo* p_sysinfo = NULL; + if (NULL != info) { + Q2A_GnssSystemInfo(*info, sysinfo); + p_sysinfo = &sysinfo; + } + pGpsCallbacks->set_system_info_cb(p_sysinfo); + } + EXIT_LOG(%s, VOID_RET); +} + +static void local_gnss_sv_status_callback(LocGnssSvStatus* sv_info) +{ + ENTRY_LOG(); + if (NULL != pGpsCallbacks && NULL != pGpsCallbacks->gnss_sv_status_cb) { + GnssSvStatus info; + GnssSvStatus* p_info = NULL; + if (NULL != sv_info) { + Q2A_GnssSvStatus(*sv_info, info); + p_info - &info; + } + pGpsCallbacks->gnss_sv_status_cb(p_info); + } + EXIT_LOG(%s, VOID_RET); +} + +static int loc_init(GpsCallbacks* callbacks) +{ + ENTRY_LOG(); + + int retVal = -1; + LocGpsCallbacks* cbs = NULL; + if (NULL != callbacks) { + memcpy(&sGpsCallbacks, callbacks, sizeof(GpsCallbacks)); + pGpsCallbacks = &sGpsCallbacks; + cbs = &sLocGpsCallbacks; + } + + if(NULL != pLocGpsInterface && NULL != pLocGpsInterface->init) { + retVal = pLocGpsInterface->init(cbs); + } + + EXIT_LOG(%d, retVal); + return retVal; +} + +static int loc_start() +{ + ENTRY_LOG(); + int retVal = -1; + if (NULL != pLocGpsInterface && NULL != pLocGpsInterface->start) { + retVal = pLocGpsInterface->start(); + } + EXIT_LOG(%d, retVal); + return retVal; +} + +static int loc_stop() +{ + ENTRY_LOG(); + int retVal = -1; + if (NULL != pLocGpsInterface && NULL != pLocGpsInterface->stop) { + retVal = pLocGpsInterface->stop(); + } + EXIT_LOG(%d, retVal); + return retVal; +} + +static void loc_cleanup() +{ + ENTRY_LOG(); + if (NULL != pLocGpsInterface && NULL != pLocGpsInterface->cleanup) { + pLocGpsInterface->cleanup(); + } + pLocGpsInterface = NULL; + pGpsCallbacks = NULL; + EXIT_LOG(%s, VOID_RET); +} + +static int loc_inject_time(GpsUtcTime time, int64_t timeReference, int uncertainty) +{ + ENTRY_LOG(); + int retVal = -1; + if (NULL != pLocGpsInterface && NULL != pLocGpsInterface->inject_time) { + retVal = pLocGpsInterface->inject_time(A2Q_GpsUtcTime(time), + timeReference, uncertainty); + } + EXIT_LOG(%d, retVal); + return retVal; +} + +static int loc_inject_location(double latitude, double longitude, float accuracy) +{ + ENTRY_LOG(); + int retVal = -1; + if (NULL != pLocGpsInterface && NULL != pLocGpsInterface->inject_location) { + retVal = pLocGpsInterface->inject_location(latitude, longitude, accuracy); + } + EXIT_LOG(%d, retVal); + return retVal; +} + +static void loc_delete_aiding_data(GpsAidingData f) +{ + ENTRY_LOG(); + +#ifndef TARGET_BUILD_VARIANT_USER + if (NULL != pLocGpsInterface && NULL != pLocGpsInterface->delete_aiding_data) { + pLocGpsInterface->delete_aiding_data(A2Q_GpsAidingData(f)); + } +#endif + + EXIT_LOG(%s, VOID_RET); +} + +static int loc_set_position_mode(GpsPositionMode mode, + GpsPositionRecurrence recurrence, + uint32_t min_interval, + uint32_t preferred_accuracy, + uint32_t preferred_time) +{ + ENTRY_LOG(); + int retVal = -1; + if (NULL != pLocGpsInterface && NULL != pLocGpsInterface->set_position_mode) { + retVal = pLocGpsInterface->set_position_mode(A2Q_GpsPositionMode(mode), + A2Q_GpsPositionRecurrence(recurrence), + min_interval, preferred_accuracy, preferred_time); + } + EXIT_LOG(%d, retVal); + return retVal; +} + +const void* loc_get_extension(const char* name) +{ + ENTRY_LOG(); + const void* retVal = NULL; + + LOC_LOGD("%s:%d] For Interface = %s\n",__func__, __LINE__, name); + if (NULL != pLocGpsInterface && NULL != pLocGpsInterface->get_extension) { + if (strcmp(name, GPS_XTRA_INTERFACE) == 0) + { + pLocGpsXtraInterface = (const LocGpsXtraInterface*)pLocGpsInterface-> + get_extension(LOC_GPS_XTRA_INTERFACE); + if (NULL != pLocGpsXtraInterface) { + retVal = &sGpsXtraInterface; + } + } + else if (strcmp(name, AGPS_INTERFACE) == 0) + { + pLocAGpsInterface = (const LocAGpsInterface*)pLocGpsInterface-> + get_extension(LOC_AGPS_INTERFACE); + if (NULL != pLocAGpsInterface) { + retVal = &sAGpsInterface; + } + } + else if (strcmp(name, SUPL_CERTIFICATE_INTERFACE) == 0) + { + pLocSuplCertificateInterface = (const LocSuplCertificateInterface*)pLocGpsInterface-> + get_extension(LOC_SUPL_CERTIFICATE_INTERFACE); + if (NULL != pLocAGpsInterface) { + retVal = &sSuplCertificateInterface; + } + } + else if (strcmp(name, GPS_NI_INTERFACE) == 0) + { + pLocGpsNiInterface = (const LocGpsNiInterface*)pLocGpsInterface-> + get_extension(LOC_GPS_NI_INTERFACE); + if (NULL != pLocGpsNiInterface) { + retVal = &sGpsNiInterface; + } + } + else if (strcmp(name, AGPS_RIL_INTERFACE) == 0) + { + pLocAGpsRilInterface = (const LocAGpsRilInterface*)pLocGpsInterface-> + get_extension(LOC_AGPS_RIL_INTERFACE); + if (NULL != pLocAGpsRilInterface) { + retVal = &sAGpsRilInterface; + } + } + else if (strcmp(name, GPS_GEOFENCING_INTERFACE) == 0) + { + pLocGpsGeofencingInterface = (const LocGpsGeofencingInterface*)pLocGpsInterface-> + get_extension(LOC_GPS_GEOFENCING_INTERFACE); + if (NULL != pLocGpsGeofencingInterface) { + retVal = &sGpsGeofencingInterface; + } + } + else if (strcmp(name, GPS_MEASUREMENT_INTERFACE) == 0) + { + pLocGpsMeasurementInterface = (const LocGpsMeasurementInterface*)pLocGpsInterface-> + get_extension(LOC_GPS_MEASUREMENT_INTERFACE); + if (NULL != pLocGpsMeasurementInterface) { + retVal = &sGpsMeasurementInterface; + } + } + else if (strcmp(name, GNSS_CONFIGURATION_INTERFACE) == 0) + { + pLocGnssConfigurationInterface = (const LocGnssConfigurationInterface*)pLocGpsInterface-> + get_extension(LOC_GNSS_CONFIGURATION_INTERFACE); + if (NULL != pLocGnssConfigurationInterface) { + retVal = &sGnssConfigurationInterface; + } + } + else + { + LOC_LOGE ("get_extension: Invalid interface passed in\n"); + } + } + EXIT_LOG(%p, retVal); + return retVal; +} + +/*=========================================================================== + Implementation of functions for sGpsXtraInterface +===========================================================================*/ +static void local_gps_xtra_download_request() +{ + ENTRY_LOG(); + if (NULL != pGpsXtraCallbacks && NULL != pGpsXtraCallbacks->download_request_cb) { + pGpsXtraCallbacks->download_request_cb(); + } + EXIT_LOG(%s, VOID_RET); +} + +static pthread_t local_gps_xtra_create_thread(const char* name, void (*start)(void *), void* arg) +{ + ENTRY_LOG(); + pthread_t retVal = -1; + if (NULL != pGpsXtraCallbacks && NULL != pGpsXtraCallbacks->create_thread_cb) { + retVal = pGpsXtraCallbacks->create_thread_cb(name, start, arg); + } + EXIT_LOG(%d, (int)retVal); + return retVal; +} + +static int loc_xtra_init(GpsXtraCallbacks* callbacks) +{ + ENTRY_LOG(); + + int retVal = -1; + LocGpsXtraCallbacks* cbs = NULL; + if (NULL != callbacks) + { + memcpy(&sGpsXtraCallbacks, callbacks, sizeof(GpsXtraCallbacks)); + pGpsXtraCallbacks = &sGpsXtraCallbacks; + cbs = &sLocGpsXtraCallbacks; + } + + if (NULL != pLocGpsXtraInterface && NULL != pLocGpsXtraInterface->init) { + retVal = pLocGpsXtraInterface->init(cbs); + } + + EXIT_LOG(%d, retVal); + return retVal; +} + + +static int loc_xtra_inject_data(char* data, int length) +{ + ENTRY_LOG(); + int retVal = -1; + if (NULL != pLocGpsXtraInterface && NULL != pLocGpsXtraInterface->inject_xtra_data) { + retVal = pLocGpsXtraInterface->inject_xtra_data(data, length); + } + EXIT_LOG(%d, retVal); + return retVal; +} + +/*=========================================================================== + Implementation of functions for sAGpsInterface +===========================================================================*/ +static void local_agps_status_callback(LocAGpsStatus* status) +{ + ENTRY_LOG(); + if (NULL != pAGpsCallbacks && NULL != pAGpsCallbacks->status_cb) { + AGpsStatus st; + AGpsStatus* p_st = NULL; + if (NULL != status) + { + Q2A_AGpsStatus(*status, st); + p_st = &st; + } + pAGpsCallbacks->status_cb(p_st); + } + EXIT_LOG(%s, VOID_RET); +} + +static pthread_t local_agps_create_thread(const char* name, void (*start)(void *), void* arg) +{ + ENTRY_LOG(); + pthread_t retVal = -1; + if (NULL != pAGpsCallbacks && NULL != pAGpsCallbacks->create_thread_cb) { + retVal = pAGpsCallbacks->create_thread_cb(name, start, arg); + } + EXIT_LOG(%d, (int)retVal); + return retVal; +} + +static void loc_agps_init(AGpsCallbacks* callbacks) +{ + ENTRY_LOG(); + + LocAGpsCallbacks* cbs = NULL; + if (NULL != callbacks) + { + memcpy(&sAGpsCallbacks, callbacks, sizeof(AGpsCallbacks)); + pAGpsCallbacks = &sAGpsCallbacks; + cbs = &sLocAGpsCallbacks; + } + + if (NULL != pLocAGpsInterface && NULL != pLocAGpsInterface->init) { + pLocAGpsInterface->init(cbs); + } + + EXIT_LOG(%s, VOID_RET); +} + +static int loc_agps_open(const char* apn) +{ + ENTRY_LOG(); + + int retVal = -1; + if (NULL != pLocAGpsInterface && NULL != pLocAGpsInterface->data_conn_open) { + retVal = pLocAGpsInterface->data_conn_open(apn); + } + + EXIT_LOG(%d, retVal); + return retVal; +} + +static int loc_agps_closed() +{ + ENTRY_LOG(); + + int retVal = -1; + if (NULL != pLocAGpsInterface && NULL != pLocAGpsInterface->data_conn_closed) { + retVal = pLocAGpsInterface->data_conn_closed(); + } + + EXIT_LOG(%d, retVal); + return retVal; +} + +int loc_agps_open_failed() +{ + ENTRY_LOG(); + + int retVal = -1; + if (NULL != pLocAGpsInterface && NULL != pLocAGpsInterface->data_conn_failed) { + retVal = pLocAGpsInterface->data_conn_failed(); + } + + EXIT_LOG(%d, retVal); + return retVal; +} + +static int loc_agps_set_server(AGpsType type, const char* hostname, int port) +{ + ENTRY_LOG(); + + int retVal = -1; + if (NULL != pLocAGpsInterface && NULL != pLocAGpsInterface->set_server) { + retVal = pLocAGpsInterface->set_server(A2Q_AGpsType(type), hostname, port); + } + + EXIT_LOG(%d, retVal); + return retVal; +} + +static int loc_agps_open_with_apniptype(const char* apn, ApnIpType apnIpType) +{ + ENTRY_LOG(); + + int retVal = -1; + if (NULL != pLocAGpsInterface && NULL != pLocAGpsInterface->data_conn_open_with_apn_ip_type) { + retVal = pLocAGpsInterface->data_conn_open_with_apn_ip_type(apn, A2Q_ApnIpType(apnIpType)); + } + + EXIT_LOG(%d, retVal); + return retVal; +} + +/*=========================================================================== + Implementation of functions for sSuplCertificateInterface +===========================================================================*/ +static int loc_agps_install_certificates(const DerEncodedCertificate* certificates, + size_t length) +{ + ENTRY_LOG(); + + int retVal = -1; + LocDerEncodedCertificate cert; + LocDerEncodedCertificate* p_cert = NULL; + if (NULL != certificates) { + A2Q_DerEncodedCertificate(*certificates, cert); + p_cert = &cert; + } + + if (NULL != pLocSuplCertificateInterface && + NULL != pLocSuplCertificateInterface->install_certificates) { + retVal = pLocSuplCertificateInterface->install_certificates(p_cert, length); + } + + EXIT_LOG(%d, retVal); + return retVal; +} + +static int loc_agps_revoke_certificates(const Sha1CertificateFingerprint* fingerprints, + size_t length) +{ + ENTRY_LOG(); + LOC_LOGE("%s:%d] agps_revoke_certificates not supported", __func__, __LINE__); + int retVal = AGPS_CERTIFICATE_ERROR_GENERIC; + EXIT_LOG(%d, retVal); + return retVal; +} + +/*=========================================================================== + Implementation of functions for sGpsNiInterface +===========================================================================*/ +static void local_gps_ni_notify_callback(LocGpsNiNotification *notification) +{ + ENTRY_LOG(); + if (NULL != pGpsNiCallbacks && NULL != pGpsNiCallbacks->notify_cb) { + GpsNiNotification notify; + GpsNiNotification* p_notify = NULL; + if (NULL != notification) { + Q2A_GpsNiNotification(*notification, notify); + p_notify = ¬ify; + } + pGpsNiCallbacks->notify_cb(p_notify); + } + EXIT_LOG(%s, VOID_RET); +} + +static pthread_t local_gps_ni_create_thread(const char* name, void (*start)(void *), void* arg) +{ + ENTRY_LOG(); + pthread_t retVal = -1; + if (NULL != pGpsNiCallbacks && NULL != pGpsNiCallbacks->create_thread_cb) { + retVal = pGpsNiCallbacks->create_thread_cb(name, start, arg); + } + EXIT_LOG(%d, (int)retVal); + return retVal; +} + +void loc_ni_init(GpsNiCallbacks *callbacks) +{ + ENTRY_LOG(); + + LocGpsNiCallbacks* cbs = NULL; + if (NULL != callbacks) { + memcpy(&sGpsNiCallbacks, callbacks, sizeof(GpsNiCallbacks)); + pGpsNiCallbacks = &sGpsNiCallbacks; + cbs = &sLocGpsNiCallbacks; + } + + if(NULL != pLocGpsNiInterface && NULL != pLocGpsNiInterface->init) { + pLocGpsNiInterface->init(cbs); + } + + EXIT_LOG(%s, VOID_RET); +} + +void loc_ni_respond(int notif_id, GpsUserResponseType user_response) +{ + ENTRY_LOG(); + + if(NULL != pLocGpsNiInterface && NULL != pLocGpsNiInterface->respond) { + pLocGpsNiInterface->respond(notif_id, A2Q_GpsUserResponseType(user_response)); + } + + EXIT_LOG(%s, VOID_RET); +} + +/*=========================================================================== + Implementation of functions for sAGpsRilInterface +===========================================================================*/ +// Below stub functions are members of sAGpsRilInterface +static void loc_agps_ril_init( AGpsRilCallbacks* callbacks ) {} +static void loc_agps_ril_set_ref_location(const AGpsRefLocation *agps_reflocation, size_t sz_struct) {} +static void loc_agps_ril_set_set_id(AGpsSetIDType type, const char* setid) {} +static void loc_agps_ril_ni_message(uint8_t *msg, size_t len) {} +static void loc_agps_ril_update_network_state(int connected, int type, int roaming, const char* extra_info) {} + +static void loc_agps_ril_update_network_availability(int available, const char* apn) +{ + ENTRY_LOG(); + + if (NULL != pLocAGpsRilInterface && + NULL != pLocAGpsRilInterface->update_network_availability) { + pLocAGpsRilInterface->update_network_availability(available, apn); + } + + EXIT_LOG(%s, VOID_RET); +} + +/*=========================================================================== + Implementation of functions for sGpsGeofencingInterface +===========================================================================*/ +static void local_gps_geofence_transition_callback(int32_t geofence_id, LocGpsLocation* location, + int32_t transition, LocGpsUtcTime timestamp) +{ + ENTRY_LOG(); + if (NULL != pGpsGeofenceCallbacks && NULL != pGpsGeofenceCallbacks->geofence_transition_callback) { + GpsLocation loc; + GpsLocation* p_loc = NULL; + if (NULL != location) + { + Q2A_GpsLocation(*location, loc); + p_loc = &loc; + } + pGpsGeofenceCallbacks->geofence_transition_callback(geofence_id, p_loc, transition, Q2A_GpsUtcTime(timestamp)); + } + EXIT_LOG(%s, VOID_RET); +} + +static void local_gps_geofence_status_callback(int32_t status, LocGpsLocation* last_location) +{ + ENTRY_LOG(); + if (NULL != pGpsGeofenceCallbacks && NULL != pGpsGeofenceCallbacks->geofence_status_callback) { + GpsLocation loc; + GpsLocation* p_loc = NULL; + if (NULL != last_location) + { + Q2A_GpsLocation(*last_location, loc); + p_loc = &loc; + } + pGpsGeofenceCallbacks->geofence_status_callback(status, p_loc); + } + EXIT_LOG(%s, VOID_RET); +} + +static void local_gps_geofence_add_callback(int32_t geofence_id, int32_t status) +{ + ENTRY_LOG(); + if (NULL != pGpsGeofenceCallbacks && NULL != pGpsGeofenceCallbacks->geofence_add_callback) { + pGpsGeofenceCallbacks->geofence_add_callback(geofence_id, status); + } + EXIT_LOG(%s, VOID_RET); +} + +static void local_gps_geofence_remove_callback(int32_t geofence_id, int32_t status) +{ + ENTRY_LOG(); + if (NULL != pGpsGeofenceCallbacks && NULL != pGpsGeofenceCallbacks->geofence_remove_callback) { + pGpsGeofenceCallbacks->geofence_remove_callback(geofence_id, status); + } + EXIT_LOG(%s, VOID_RET); +} + +static void local_gps_geofence_pause_callback(int32_t geofence_id, int32_t status) +{ + ENTRY_LOG(); + if (NULL != pGpsGeofenceCallbacks && NULL != pGpsGeofenceCallbacks->geofence_pause_callback) { + pGpsGeofenceCallbacks->geofence_pause_callback(geofence_id, status); + } + EXIT_LOG(%s, VOID_RET); +} + +static void local_gps_geofence_resume_callback(int32_t geofence_id, int32_t status) +{ + ENTRY_LOG(); + if (NULL != pGpsGeofenceCallbacks && NULL != pGpsGeofenceCallbacks->geofence_resume_callback) { + pGpsGeofenceCallbacks->geofence_resume_callback(geofence_id, status); + } + EXIT_LOG(%s, VOID_RET); +} + +static pthread_t local_geofence_create_thread(const char* name, void (*start)(void *), void* arg) +{ + ENTRY_LOG(); + pthread_t retVal = -1; + if (NULL != pGpsGeofenceCallbacks && NULL != pGpsGeofenceCallbacks->create_thread_cb) { + retVal = pGpsGeofenceCallbacks->create_thread_cb(name, start, arg); + } + EXIT_LOG(%d, (int)retVal); + return retVal; +} + +static void loc_geofence_init(GpsGeofenceCallbacks* callbacks) +{ + ENTRY_LOG(); + if (NULL != pLocGpsGeofencingInterface && NULL != pLocGpsGeofencingInterface->init) { + LocGpsGeofenceCallbacks* cbs = NULL; + if (NULL != callbacks) { + memcpy(&sGpsGeofenceCallbacks, callbacks, sizeof(GpsGeofenceCallbacks)); + pGpsGeofenceCallbacks = &sGpsGeofenceCallbacks; + cbs = &sLocGpsGeofenceCallbacks; + } + pLocGpsGeofencingInterface->init(cbs); + } + EXIT_LOG(%s, VOID_RET); +} + +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) +{ + ENTRY_LOG(); + if (NULL != pLocGpsGeofencingInterface && NULL != pLocGpsGeofencingInterface->add_geofence_area) { + pLocGpsGeofencingInterface->add_geofence_area(geofence_id, latitude, longitude, + radius_meters, last_transition, monitor_transitions, + notification_responsiveness_ms, unknown_timer_ms); + } + EXIT_LOG(%s, VOID_RET); +} + +static void loc_pause_geofence(int32_t geofence_id) +{ + ENTRY_LOG(); + if (NULL != pLocGpsGeofencingInterface && NULL != pLocGpsGeofencingInterface->pause_geofence) { + pLocGpsGeofencingInterface->pause_geofence(geofence_id); + } + EXIT_LOG(%s, VOID_RET); +} + +static void loc_resume_geofence(int32_t geofence_id, int monitor_transitions) +{ + ENTRY_LOG(); + if (NULL != pLocGpsGeofencingInterface && NULL != pLocGpsGeofencingInterface->resume_geofence) { + pLocGpsGeofencingInterface->resume_geofence(geofence_id, monitor_transitions); + } + EXIT_LOG(%s, VOID_RET); +} + +static void loc_remove_geofence_area(int32_t geofence_id) +{ + ENTRY_LOG(); + if (NULL != pLocGpsGeofencingInterface && NULL != pLocGpsGeofencingInterface->remove_geofence_area) { + pLocGpsGeofencingInterface->remove_geofence_area(geofence_id); + } + EXIT_LOG(%s, VOID_RET); +} + +/*=========================================================================== + Implementation of functions for sGpsMeasurementInterface +===========================================================================*/ +static void local_gps_measurement_callback(LocGpsData* data) +{ + ENTRY_LOG(); + if (NULL != pGpsMeasurementCallbacks && NULL != pGpsMeasurementCallbacks->measurement_callback) { + GpsData gps_data; + GpsData* p_gps_data = NULL; + if (NULL != data) + { + Q2A_GpsData(*data, gps_data); + p_gps_data = &gps_data; + } + pGpsMeasurementCallbacks->measurement_callback(p_gps_data); + } + EXIT_LOG(%s, VOID_RET); +} + +static void local_gnss_measurement_callback(LocGnssData* data) +{ + ENTRY_LOG(); + if (NULL != pGpsMeasurementCallbacks && NULL != pGpsMeasurementCallbacks->gnss_measurement_callback) { + GnssData gnss_data; + GnssData* p_gnss_data = NULL; + if (NULL != data) + { + Q2A_GnssData(*data, gnss_data); + p_gnss_data = &gnss_data; + } + pGpsMeasurementCallbacks->gnss_measurement_callback(p_gnss_data); + } + EXIT_LOG(%s, VOID_RET); +} + +static int loc_gps_measurement_init(GpsMeasurementCallbacks* callbacks) +{ + ENTRY_LOG(); + + int retVal = -1; + LocGpsMeasurementCallbacks* cbs = NULL; + if (NULL != callbacks) + { + memcpy(&sGpsMeasurementCallbacks, callbacks, sizeof(GpsMeasurementCallbacks)); + pGpsMeasurementCallbacks = &sGpsMeasurementCallbacks; + cbs = &sLocGpsMeasurementCallbacks; + } + + if (NULL != pLocGpsMeasurementInterface && NULL != pLocGpsMeasurementInterface->init) { + pLocGpsMeasurementInterface->init(cbs); + } + + EXIT_LOG(%d, retVal); + return retVal; +} + +static void loc_gps_measurement_close() +{ + ENTRY_LOG(); + + if (NULL != pLocGpsMeasurementInterface && NULL != pLocGpsMeasurementInterface->close) { + pLocGpsMeasurementInterface->close(); + } + + EXIT_LOG(%s, VOID_RET); +} + +/*=========================================================================== + Implementation of functions for sGnssConfigurationInterface +===========================================================================*/ +static void loc_configuration_update(const char* config_data, int32_t length) +{ + ENTRY_LOG(); + + if (NULL != pLocGnssConfigurationInterface && + NULL != pLocGnssConfigurationInterface->configuration_update) { + pLocGnssConfigurationInterface->configuration_update(config_data, length); + } + + EXIT_LOG(%s, VOID_RET); +} + diff --git a/loc_api/libloc_api_50001/loc.cpp b/loc_api/libloc_api_50001/loc.cpp index 222d5da7..8c021b39 100644 --- a/loc_api/libloc_api_50001/loc.cpp +++ b/loc_api/libloc_api_50001/loc.cpp @@ -30,7 +30,6 @@ #define LOG_NDDEBUG 0 #define LOG_TAG "LocSvc_afw" -#include #include #include #include @@ -48,39 +47,33 @@ using namespace loc_core; -#define LOC_PM_CLIENT_NAME "GPS" +// All functions and variables should be static +// except loc_eng_gps_get_hardware_interface() and loc_eng_get_gps_interface() //Globals defns -static gps_location_callback gps_loc_cb = NULL; -static gps_sv_status_callback gps_sv_cb = NULL; -static gps_ni_notify_callback gps_ni_cb = NULL; +static loc_gps_location_callback gps_loc_cb = NULL; +static loc_gps_sv_status_callback gps_sv_cb = NULL; static void local_loc_cb(UlpLocation* location, void* locExt); -static void local_sv_cb(GpsSvStatus* sv_status, void* svExt); -static void local_ni_cb(GpsNiNotification *notification, bool esEnalbed); +static void local_sv_cb(LocGpsSvStatus* sv_status, void* svExt); -GpsNiExtCallbacks sGpsNiExtCallbacks = { - local_ni_cb -}; - -static const GpsGeofencingInterface* get_geofence_interface(void); +static const LocGpsGeofencingInterface* get_geofence_interface(void); // Function declarations for sLocEngInterface -static int loc_init(GpsCallbacks* callbacks); +static int loc_init(LocGpsCallbacks* callbacks); static int loc_start(); static int loc_stop(); static void loc_cleanup(); -static int loc_inject_time(GpsUtcTime time, int64_t timeReference, int uncertainty); +static int loc_inject_time(LocGpsUtcTime time, int64_t timeReference, int uncertainty); static int loc_inject_location(double latitude, double longitude, float accuracy); -static void loc_delete_aiding_data(GpsAidingData f); -static int loc_set_position_mode(GpsPositionMode mode, GpsPositionRecurrence recurrence, +static void loc_delete_aiding_data(LocGpsAidingData f); +static int loc_set_position_mode(LocGpsPositionMode mode, LocGpsPositionRecurrence recurrence, uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time); static const void* loc_get_extension(const char* name); -// Defines the GpsInterface in gps.h -static const GpsInterface sLocEngInterface = +static const LocGpsInterface sLocEngInterface = { - sizeof(GpsInterface), + sizeof(LocGpsInterface), loc_init, loc_start, loc_stop, @@ -93,16 +86,16 @@ static const GpsInterface sLocEngInterface = }; // Function declarations for sLocEngAGpsInterface -static void loc_agps_init(AGpsCallbacks* callbacks); +static void loc_agps_init(LocAGpsCallbacks* callbacks); static int loc_agps_open(const char* apn); static int loc_agps_closed(); static int loc_agps_open_failed(); -static int loc_agps_set_server(AGpsType type, const char *hostname, int port); -static int loc_agps_open_with_apniptype( const char* apn, ApnIpType apnIpType); +static int loc_agps_set_server(LocAGpsType type, const char *hostname, int port); +static int loc_agps_open_with_apniptype( const char* apn, LocApnIpType apnIpType); -static const AGpsInterface sLocEngAGpsInterface = +static const LocAGpsInterface sLocEngAGpsInterface = { - sizeof(AGpsInterface), + sizeof(LocAGpsInterface), loc_agps_init, loc_agps_open, loc_agps_closed, @@ -111,46 +104,53 @@ static const AGpsInterface sLocEngAGpsInterface = loc_agps_open_with_apniptype }; -static int loc_xtra_init(GpsXtraCallbacks* callbacks); +static int loc_xtra_init(LocGpsXtraCallbacks* callbacks); static int loc_xtra_inject_data(char* data, int length); -static const GpsXtraInterface sLocEngXTRAInterface = +static const LocGpsXtraInterface sLocEngXTRAInterface = { - sizeof(GpsXtraInterface), + sizeof(LocGpsXtraInterface), loc_xtra_init, loc_xtra_inject_data }; -static void loc_ni_init(GpsNiCallbacks *callbacks); -static void loc_ni_respond(int notif_id, GpsUserResponseType user_response); +static loc_gps_ni_notify_callback gps_ni_cb = NULL; +static void local_ni_cb(LocGpsNiNotification *notification, bool esEnalbed); -static const GpsNiInterface sLocEngNiInterface = +static GpsNiExtCallbacks sGpsNiExtCallbacks = { + local_ni_cb +}; + +static void loc_ni_init(LocGpsNiCallbacks *callbacks); +static void loc_ni_respond(int notif_id, LocGpsUserResponseType user_response); + +static const LocGpsNiInterface sLocEngNiInterface = { - sizeof(GpsNiInterface), + sizeof(LocGpsNiInterface), loc_ni_init, loc_ni_respond, }; -static int loc_gps_measurement_init(GpsMeasurementCallbacks* callbacks); +static int loc_gps_measurement_init(LocGpsMeasurementCallbacks* callbacks); static void loc_gps_measurement_close(); -static const GpsMeasurementInterface sLocEngGpsMeasurementInterface = +static const LocGpsMeasurementInterface sLocEngGpsMeasurementInterface = { - sizeof(GpsMeasurementInterface), + sizeof(LocGpsMeasurementInterface), loc_gps_measurement_init, loc_gps_measurement_close }; -static void loc_agps_ril_init( AGpsRilCallbacks* callbacks ); -static void loc_agps_ril_set_ref_location(const AGpsRefLocation *agps_reflocation, size_t sz_struct); -static void loc_agps_ril_set_set_id(AGpsSetIDType type, const char* setid); +static void loc_agps_ril_init( LocAGpsRilCallbacks* callbacks ); +static void loc_agps_ril_set_ref_location(const LocAGpsRefLocation *agps_reflocation, size_t sz_struct); +static void loc_agps_ril_set_set_id(LocAGpsSetIDType type, const char* setid); static void loc_agps_ril_ni_message(uint8_t *msg, size_t len); static void loc_agps_ril_update_network_state(int connected, int type, int roaming, const char* extra_info); static void loc_agps_ril_update_network_availability(int avaiable, const char* apn); -static const AGpsRilInterface sLocEngAGpsRilInterface = +static const LocAGpsRilInterface sLocEngAGpsRilInterface = { - sizeof(AGpsRilInterface), + sizeof(LocAGpsRilInterface), loc_agps_ril_init, loc_agps_ril_set_ref_location, loc_agps_ril_set_set_id, @@ -159,23 +159,23 @@ static const AGpsRilInterface sLocEngAGpsRilInterface = loc_agps_ril_update_network_availability }; -static int loc_agps_install_certificates(const DerEncodedCertificate* certificates, +static int loc_agps_install_certificates(const LocDerEncodedCertificate* certificates, size_t length); -static int loc_agps_revoke_certificates(const Sha1CertificateFingerprint* fingerprints, +static int loc_agps_revoke_certificates(const LocSha1CertificateFingerprint* fingerprints, size_t length); -static const SuplCertificateInterface sLocEngAGpsCertInterface = +static const LocSuplCertificateInterface sLocEngAGpsCertInterface = { - sizeof(SuplCertificateInterface), + sizeof(LocSuplCertificateInterface), loc_agps_install_certificates, loc_agps_revoke_certificates }; static void loc_configuration_update(const char* config_data, int32_t length); -static const GnssConfigurationInterface sLocEngConfigInterface = +static const LocGnssConfigurationInterface sLocEngConfigInterface = { - sizeof(GnssConfigurationInterface), + sizeof(LocGnssConfigurationInterface), loc_configuration_update }; @@ -183,10 +183,10 @@ static loc_eng_data_s_type loc_afw_data; static int gss_fd = -1; static int sGnssType = GNSS_UNKNOWN; /*=========================================================================== -FUNCTION gps_get_hardware_interface +FUNCTION loc_eng_gps_get_hardware_interface DESCRIPTION - Returns the GPS hardware interaface based on LOC API + Returns LocGpsInterface if GPS is enabled. DEPENDENCIES @@ -199,10 +199,10 @@ SIDE EFFECTS N/A ===========================================================================*/ -extern "C" const GpsInterface* gps_get_hardware_interface () +extern "C" const LocGpsInterface* loc_eng_gps_get_hardware_interface () { ENTRY_LOG_CALLFLOW(); - const GpsInterface* ret_val; + const LocGpsInterface* ret_val; char propBuf[PROPERTY_VALUE_MAX]; memset(propBuf, 0, sizeof(propBuf)); @@ -225,8 +225,7 @@ extern "C" const GpsInterface* gps_get_hardware_interface () return ret_val; } -// for gps.c -extern "C" const GpsInterface* get_gps_interface() +extern "C" const LocGpsInterface* loc_eng_get_gps_interface() { unsigned int target = TARGET_DEFAULT; loc_eng_read_config(); @@ -240,7 +239,7 @@ extern "C" const GpsInterface* get_gps_interface() case GNSS_GSS: case GNSS_AUTO: //APQ8064 - gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB); + gps_conf.CAPABILITIES &= ~(LOC_GPS_CAPABILITY_MSA | LOC_GPS_CAPABILITY_MSB); gss_fd = open("/dev/gss", O_RDONLY); if (gss_fd < 0) { LOC_LOGE("GSS open failed: %s\n", strerror(errno)); @@ -256,7 +255,7 @@ extern "C" const GpsInterface* get_gps_interface() return NULL; case GNSS_QCA1530: // qca1530 chip is present - gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB); + gps_conf.CAPABILITIES &= ~(LOC_GPS_CAPABILITY_MSA | LOC_GPS_CAPABILITY_MSB); LOC_LOGD("qca1530 present: CAPABILITIES %0lx\n", gps_conf.CAPABILITIES); break; } @@ -280,7 +279,7 @@ SIDE EFFECTS N/Ax ===========================================================================*/ -static int loc_init(GpsCallbacks* callbacks) +static int loc_init(LocGpsCallbacks* callbacks) { int retVal = -1; unsigned int target = (unsigned int) -1; @@ -453,8 +452,8 @@ SIDE EFFECTS N/A ===========================================================================*/ -static int loc_set_position_mode(GpsPositionMode mode, - GpsPositionRecurrence recurrence, +static int loc_set_position_mode(LocGpsPositionMode mode, + LocGpsPositionRecurrence recurrence, uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time) @@ -463,10 +462,10 @@ static int loc_set_position_mode(GpsPositionMode mode, int ret_val = -1; LocPositionMode locMode; switch (mode) { - case GPS_POSITION_MODE_MS_BASED: + case LOC_GPS_POSITION_MODE_MS_BASED: locMode = LOC_POSITION_MODE_MS_BASED; break; - case GPS_POSITION_MODE_MS_ASSISTED: + case LOC_GPS_POSITION_MODE_MS_ASSISTED: locMode = LOC_POSITION_MODE_MS_ASSISTED; break; default: @@ -502,7 +501,7 @@ SIDE EFFECTS N/A ===========================================================================*/ -static int loc_inject_time(GpsUtcTime time, int64_t timeReference, int uncertainty) +static int loc_inject_time(LocGpsUtcTime time, int64_t timeReference, int uncertainty) { ENTRY_LOG(); int ret_val = 0; @@ -553,7 +552,7 @@ DESCRIPTION will happen when gps engine is turned off. DEPENDENCIES - Assumes the aiding data type specified in GpsAidingData matches with + Assumes the aiding data type specified in LocGpsAidingData matches with LOC API specification. RETURN VALUE @@ -563,7 +562,7 @@ SIDE EFFECTS N/A ===========================================================================*/ -static void loc_delete_aiding_data(GpsAidingData f) +static void loc_delete_aiding_data(LocGpsAidingData f) { ENTRY_LOG(); @@ -574,14 +573,14 @@ static void loc_delete_aiding_data(GpsAidingData f) EXIT_LOG(%s, VOID_RET); } -const GpsGeofencingInterface* get_geofence_interface(void) +static const LocGpsGeofencingInterface* get_geofence_interface(void) { ENTRY_LOG(); void *handle; const char *error; - typedef const GpsGeofencingInterface* (*get_gps_geofence_interface_function) (void); + typedef const LocGpsGeofencingInterface* (*get_gps_geofence_interface_function) (void); get_gps_geofence_interface_function get_gps_geofence_interface; - static const GpsGeofencingInterface* geofence_interface = NULL; + static const LocGpsGeofencingInterface* geofence_interface = NULL; dlerror(); /* Clear any existing error */ @@ -595,7 +594,7 @@ const GpsGeofencingInterface* get_geofence_interface(void) goto exit; } dlerror(); /* Clear any existing error */ - get_gps_geofence_interface = (get_gps_geofence_interface_function)dlsym(handle, "gps_geofence_get_interface"); + get_gps_geofence_interface = (get_gps_geofence_interface_function)dlsym(handle, "loc_gps_geofence_get_interface"); if ((error = dlerror()) != NULL) { LOC_LOGE ("%s, dlsym for get_gps_geofence_interface failed, error = %s\n", __func__, error); goto exit; @@ -633,19 +632,19 @@ const void* loc_get_extension(const char* name) const void* ret_val = NULL; LOC_LOGD("%s:%d] For Interface = %s\n",__func__, __LINE__, name); - if (strcmp(name, GPS_XTRA_INTERFACE) == 0) + if (strcmp(name, LOC_GPS_XTRA_INTERFACE) == 0) { ret_val = &sLocEngXTRAInterface; } - else if (strcmp(name, AGPS_INTERFACE) == 0) + else if (strcmp(name, LOC_AGPS_INTERFACE) == 0) { ret_val = &sLocEngAGpsInterface; } - else if (strcmp(name, GPS_NI_INTERFACE) == 0) + else if (strcmp(name, LOC_GPS_NI_INTERFACE) == 0) { ret_val = &sLocEngNiInterface; } - else if (strcmp(name, AGPS_RIL_INTERFACE) == 0) + else if (strcmp(name, LOC_AGPS_RIL_INTERFACE) == 0) { char baseband[PROPERTY_VALUE_MAX]; platform_lib_abstraction_property_get("ro.baseband", baseband, "msm"); @@ -654,21 +653,21 @@ const void* loc_get_extension(const char* name) ret_val = &sLocEngAGpsRilInterface; } } - else if (strcmp(name, GPS_GEOFENCING_INTERFACE) == 0) + else if (strcmp(name, LOC_GPS_GEOFENCING_INTERFACE) == 0) { - if ((gps_conf.CAPABILITIES | GPS_CAPABILITY_GEOFENCING) == gps_conf.CAPABILITIES ){ + if ((gps_conf.CAPABILITIES | LOC_GPS_CAPABILITY_GEOFENCING) == gps_conf.CAPABILITIES ){ ret_val = get_geofence_interface(); } } - else if (strcmp(name, SUPL_CERTIFICATE_INTERFACE) == 0) + else if (strcmp(name, LOC_SUPL_CERTIFICATE_INTERFACE) == 0) { ret_val = &sLocEngAGpsCertInterface; } - else if (strcmp(name, GNSS_CONFIGURATION_INTERFACE) == 0) + else if (strcmp(name, LOC_GNSS_CONFIGURATION_INTERFACE) == 0) { ret_val = &sLocEngConfigInterface; } - else if (strcmp(name, GPS_MEASUREMENT_INTERFACE) == 0) + else if (strcmp(name, LOC_GPS_MEASUREMENT_INTERFACE) == 0) { ret_val = &sLocEngGpsMeasurementInterface; } @@ -696,7 +695,7 @@ SIDE EFFECTS N/A ===========================================================================*/ -static void loc_agps_init(AGpsCallbacks* callbacks) +static void loc_agps_init(LocAGpsCallbacks* callbacks) { ENTRY_LOG(); loc_eng_agps_init(loc_afw_data, (AGpsExtCallbacks*)callbacks); @@ -723,7 +722,7 @@ SIDE EFFECTS static int loc_agps_open(const char* apn) { ENTRY_LOG(); - AGpsType agpsType = AGPS_TYPE_SUPL; + LocAGpsType agpsType = LOC_AGPS_TYPE_SUPL; AGpsBearerType bearerType = AGPS_APN_BEARER_IPV4; int ret_val = loc_eng_agps_open(loc_afw_data, agpsType, apn, bearerType); @@ -748,20 +747,20 @@ SIDE EFFECTS N/A ===========================================================================*/ -static int loc_agps_open_with_apniptype(const char* apn, ApnIpType apnIpType) +static int loc_agps_open_with_apniptype(const char* apn, LocApnIpType apnIpType) { ENTRY_LOG(); - AGpsType agpsType = AGPS_TYPE_SUPL; + LocAGpsType agpsType = LOC_AGPS_TYPE_SUPL; AGpsBearerType bearerType; switch (apnIpType) { - case APN_IP_IPV4: + case LOC_APN_IP_IPV4: bearerType = AGPS_APN_BEARER_IPV4; break; - case APN_IP_IPV6: + case LOC_APN_IP_IPV6: bearerType = AGPS_APN_BEARER_IPV6; break; - case APN_IP_IPV4V6: + case LOC_APN_IP_IPV4V6: bearerType = AGPS_APN_BEARER_IPV4V6; break; default: @@ -795,7 +794,7 @@ SIDE EFFECTS static int loc_agps_closed() { ENTRY_LOG(); - AGpsType agpsType = AGPS_TYPE_SUPL; + LocAGpsType agpsType = LOC_AGPS_TYPE_SUPL; int ret_val = loc_eng_agps_closed(loc_afw_data, agpsType); EXIT_LOG(%d, ret_val); @@ -822,7 +821,7 @@ SIDE EFFECTS int loc_agps_open_failed() { ENTRY_LOG(); - AGpsType agpsType = AGPS_TYPE_SUPL; + LocAGpsType agpsType = LOC_AGPS_TYPE_SUPL; int ret_val = loc_eng_agps_open_failed(loc_afw_data, agpsType); EXIT_LOG(%d, ret_val); @@ -847,15 +846,15 @@ SIDE EFFECTS N/A ===========================================================================*/ -static int loc_agps_set_server(AGpsType type, const char* hostname, int port) +static int loc_agps_set_server(LocAGpsType type, const char* hostname, int port) { ENTRY_LOG(); LocServerType serverType; switch (type) { - case AGPS_TYPE_SUPL: + case LOC_AGPS_TYPE_SUPL: serverType = LOC_AGPS_SUPL_SERVER; break; - case AGPS_TYPE_C2K: + case LOC_AGPS_TYPE_C2K: serverType = LOC_AGPS_CDMA_PDE_SERVER; break; default: @@ -884,7 +883,7 @@ SIDE EFFECTS N/A ===========================================================================*/ -static int loc_xtra_init(GpsXtraCallbacks* callbacks) +static int loc_xtra_init(LocGpsXtraCallbacks* callbacks) { ENTRY_LOG(); GpsXtraExtCallbacks extCallbacks; @@ -942,7 +941,7 @@ SIDE EFFECTS N/A ===========================================================================*/ -static int loc_gps_measurement_init(GpsMeasurementCallbacks* callbacks) +static int loc_gps_measurement_init(LocGpsMeasurementCallbacks* callbacks) { ENTRY_LOG(); int ret_val = loc_eng_gps_measurement_init(loc_afw_data, @@ -992,7 +991,7 @@ SIDE EFFECTS N/A ===========================================================================*/ -void loc_ni_init(GpsNiCallbacks *callbacks) +void loc_ni_init(LocGpsNiCallbacks *callbacks) { ENTRY_LOG(); gps_ni_cb = callbacks->notify_cb; @@ -1016,7 +1015,7 @@ SIDE EFFECTS N/A ===========================================================================*/ -void loc_ni_respond(int notif_id, GpsUserResponseType user_response) +void loc_ni_respond(int notif_id, LocGpsUserResponseType user_response) { ENTRY_LOG(); loc_eng_ni_respond(loc_afw_data, notif_id, user_response); @@ -1024,9 +1023,9 @@ void loc_ni_respond(int notif_id, GpsUserResponseType user_response) } // Below stub functions are members of sLocEngAGpsRilInterface -static void loc_agps_ril_init( AGpsRilCallbacks* callbacks ) {} -static void loc_agps_ril_set_ref_location(const AGpsRefLocation *agps_reflocation, size_t sz_struct) {} -static void loc_agps_ril_set_set_id(AGpsSetIDType type, const char* setid) {} +static void loc_agps_ril_init( LocAGpsRilCallbacks* callbacks ) {} +static void loc_agps_ril_set_ref_location(const LocAGpsRefLocation *agps_reflocation, size_t sz_struct) {} +static void loc_agps_ril_set_set_id(LocAGpsSetIDType type, const char* setid) {} static void loc_agps_ril_ni_message(uint8_t *msg, size_t len) {} static void loc_agps_ril_update_network_state(int connected, int type, int roaming, const char* extra_info) {} @@ -1054,7 +1053,7 @@ static void loc_agps_ril_update_network_availability(int available, const char* EXIT_LOG(%s, VOID_RET); } -static int loc_agps_install_certificates(const DerEncodedCertificate* certificates, +static int loc_agps_install_certificates(const LocDerEncodedCertificate* certificates, size_t length) { ENTRY_LOG(); @@ -1062,12 +1061,12 @@ static int loc_agps_install_certificates(const DerEncodedCertificate* certificat EXIT_LOG(%d, ret_val); return ret_val; } -static int loc_agps_revoke_certificates(const Sha1CertificateFingerprint* fingerprints, +static int loc_agps_revoke_certificates(const LocSha1CertificateFingerprint* fingerprints, size_t length) { ENTRY_LOG(); - LOC_LOGE("%s:%d]: agps_revoke_certificates not supported"); - int ret_val = AGPS_CERTIFICATE_ERROR_GENERIC; + LOC_LOGE("%s:%d] agps_revoke_certificates not supported", __func__, __LINE__); + int ret_val = LOC_AGPS_CERTIFICATE_ERROR_GENERIC; EXIT_LOG(%d, ret_val); return ret_val; } @@ -1082,7 +1081,7 @@ static void loc_configuration_update(const char* config_data, int32_t length) case GNSS_AUTO: case GNSS_QCA1530: //APQ - gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB); + gps_conf.CAPABILITIES &= ~(LOC_GPS_CAPABILITY_MSA | LOC_GPS_CAPABILITY_MSB); break; } EXIT_LOG(%s, VOID_RET); @@ -1101,7 +1100,7 @@ static void local_loc_cb(UlpLocation* location, void* locExt) EXIT_LOG(%s, VOID_RET); } -static void local_sv_cb(GpsSvStatus* sv_status, void* svExt) +static void local_sv_cb(LocGpsSvStatus* sv_status, void* svExt) { ENTRY_LOG(); if (NULL != gps_sv_cb) { @@ -1111,7 +1110,7 @@ static void local_sv_cb(GpsSvStatus* sv_status, void* svExt) EXIT_LOG(%s, VOID_RET); } -static void local_ni_cb(GpsNiNotification *notification, bool esEnalbed) +static void local_ni_cb(LocGpsNiNotification *notification, bool esEnalbed) { if (NULL != gps_ni_cb) { gps_ni_cb(notification); diff --git a/loc_api/libloc_api_50001/loc.h b/loc_api/libloc_api_50001/loc.h index 8cf77fc9..9edd8c0a 100644 --- a/loc_api/libloc_api_50001/loc.h +++ b/loc_api/libloc_api_50001/loc.h @@ -35,29 +35,28 @@ extern "C" { #endif /* __cplusplus */ #include -#include #include #define XTRA_DATA_MAX_SIZE 100000 /*bytes*/ typedef void (*loc_location_cb_ext) (UlpLocation* location, void* locExt); -typedef void (*loc_sv_status_cb_ext) (GpsSvStatus* sv_status, void* svExt); +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; - gps_status_callback status_cb; + loc_gps_status_callback status_cb; loc_sv_status_cb_ext sv_status_cb; - gps_nmea_callback nmea_cb; - gps_set_capabilities set_capabilities_cb; - gps_acquire_wakelock acquire_wakelock_cb; - gps_release_wakelock release_wakelock_cb; - gps_create_thread create_thread_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; - gps_request_utc_time request_utc_time_cb; - gnss_set_system_info set_system_info_cb; - gnss_sv_status_callback gnss_sv_status_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; } LocCallbacks; #ifdef __cplusplus diff --git a/loc_api/libloc_api_50001/loc_eng.cpp b/loc_api/libloc_api_50001/loc_eng.cpp index 545f3eb2..28ddcf79 100644 --- a/loc_api/libloc_api_50001/loc_eng.cpp +++ b/loc_api/libloc_api_50001/loc_eng.cpp @@ -193,11 +193,11 @@ static int loc_eng_set_server(loc_eng_data_s_type &loc_eng_data, LocServerType type, const char *hostname, int port); // Internal functions static void loc_inform_gps_status(loc_eng_data_s_type &loc_eng_data, - GpsStatusValue status); + LocGpsStatusValue status); static void loc_eng_report_status(loc_eng_data_s_type &loc_eng_data, - GpsStatusValue status); + LocGpsStatusValue status); static void loc_eng_process_conn_request(loc_eng_data_s_type &loc_eng_data, - int connHandle, AGpsType agps_type); + int connHandle, LocAGpsType agps_type); static void loc_eng_agps_close_status(loc_eng_data_s_type &loc_eng_data, int is_succ); static void loc_eng_handle_engine_down(loc_eng_data_s_type &loc_eng_data) ; static void loc_eng_handle_engine_up(loc_eng_data_s_type &loc_eng_data) ; @@ -211,7 +211,7 @@ getAgpsStateMachine(loc_eng_data_s_type& logEng, AGpsExtType agpsType); static void createAgnssNifs(loc_eng_data_s_type& locEng); static int dataCallCb(void *cb_data); static void update_aiding_data_for_deletion(loc_eng_data_s_type& loc_eng_data) { - if (loc_eng_data.engine_status != GPS_STATUS_ENGINE_ON && + if (loc_eng_data.engine_status != LOC_GPS_STATUS_ENGINE_ON && loc_eng_data.aiding_data_for_deletion != 0) { loc_eng_data.adapter->deleteAidingData(loc_eng_data.aiding_data_for_deletion); @@ -229,7 +229,7 @@ static void* noProc(void* data) *********************************************************************/ // case LOC_ENG_MSG_REQUEST_NI: LocEngRequestNi::LocEngRequestNi(void* locEng, - GpsNiNotification ¬if, + LocGpsNiNotification ¬if, const void* data) : LocMsg(), mLocEng(locEng), mNotify(notif), mPayload(data) { locallog(); @@ -347,11 +347,11 @@ void LocEngGetZpp::send() const { struct LocEngSetTime : public LocMsg { LocEngAdapter* mAdapter; - const GpsUtcTime mTime; + const LocGpsUtcTime mTime; const int64_t mTimeReference; const int mUncertainty; inline LocEngSetTime(LocEngAdapter* adapter, - GpsUtcTime t, int64_t tf, int unc) : + LocGpsUtcTime t, int64_t tf, int unc) : LocMsg(), mAdapter(adapter), mTime(t), mTimeReference(tf), mUncertainty(unc) { @@ -804,7 +804,7 @@ void LocEngReportPosition::proc() const { mTechMask)) || (LOC_SESS_INTERMEDIATE == locEng->intermediateFix && !((mLocation.gpsLocation.flags & - GPS_LOCATION_HAS_ACCURACY) && + LOC_GPS_LOCATION_HAS_ACCURACY) && (gps_conf.ACCURACY_THRES != 0) && (mLocation.gpsLocation.accuracy > gps_conf.ACCURACY_THRES)))) { @@ -821,7 +821,7 @@ void LocEngReportPosition::proc() const { // if we have reported this fix if (reported && // and if this is a singleshot - GPS_POSITION_RECURRENCE_SINGLE == + LOC_GPS_POSITION_RECURRENCE_SINGLE == locEng->adapter->getPositionMode().recurrence) { if (LOC_SESS_INTERMEDIATE == mStatus) { // modem could be still working for a final fix, @@ -869,7 +869,7 @@ void LocEngReportPosition::send() const { // case LOC_ENG_MSG_REPORT_SV: LocEngReportSv::LocEngReportSv(LocAdapterBase* adapter, - GnssSvStatus &sv, + LocGnssSvStatus &sv, GpsLocationExtended &locExtended, void* svExt) : LocMsg(), mAdapter(adapter), mSvStatus(sv), @@ -886,8 +886,8 @@ void LocEngReportSv::proc() const { if (locEng->mute_session_state != LOC_MUTE_SESS_IN_SESSION) { - GnssSvStatus gnssSvStatus; - memcpy(&gnssSvStatus,&mSvStatus,sizeof(GnssSvStatus)); + LocGnssSvStatus gnssSvStatus; + memcpy(&gnssSvStatus,&mSvStatus,sizeof(LocGnssSvStatus)); if (adapter->isGnssSvIdUsedInPosAvail()) { GnssSvUsedInPosition gnssSvIdUsedInPosition = @@ -924,18 +924,18 @@ void LocEngReportSv::proc() const { // flag, else clear the USED_IN_FIX flag. if (svUsedIdMask & (1 << (gnssSvId - prnMin))) { - gnssSvStatus.gnss_sv_list[i].flags |= GNSS_SV_FLAGS_USED_IN_FIX; + gnssSvStatus.gnss_sv_list[i].flags |= LOC_GNSS_SV_FLAGS_USED_IN_FIX; } else { - gnssSvStatus.gnss_sv_list[i].flags &= ~GNSS_SV_FLAGS_USED_IN_FIX; + gnssSvStatus.gnss_sv_list[i].flags &= ~LOC_GNSS_SV_FLAGS_USED_IN_FIX; } } } if (locEng->gnss_sv_status_cb != NULL) { LOC_LOGE("Calling gnss_sv_status_cb"); - locEng->gnss_sv_status_cb((GnssSvStatus*)&(gnssSvStatus)); + locEng->gnss_sv_status_cb((LocGnssSvStatus*)&(gnssSvStatus)); } if (locEng->generateNmea) @@ -956,7 +956,7 @@ void LocEngReportSv::send() const { // case LOC_ENG_MSG_REPORT_STATUS: LocEngReportStatus::LocEngReportStatus(LocAdapterBase* adapter, - GpsStatusValue engineStatus) : + LocGpsStatusValue engineStatus) : LocMsg(), mAdapter(adapter), mStatus(engineStatus) { locallog(); @@ -1216,7 +1216,7 @@ void LocEngRequestATL::proc() const { ATLSubscriber s(mID, sm, locEng->adapter, - AGPS_TYPE_INVALID == mType); + LOC_AGPS_TYPE_INVALID == mType); sm->subscribeRsrc((Subscriber*)&s); } else { locEng->adapter->atlOpenStatus(mID, 0, NULL, -1, mType); @@ -1350,7 +1350,7 @@ LocEngRequestTime::LocEngRequestTime(void* locEng) : } void LocEngRequestTime::proc() const { loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; - if (gps_conf.CAPABILITIES & GPS_CAPABILITY_ON_DEMAND_TIME) { + if (gps_conf.CAPABILITIES & LOC_GPS_CAPABILITY_ON_DEMAND_TIME) { if (locEng->request_utc_time_cb != NULL) { locEng->request_utc_time_cb(); } else { @@ -1368,9 +1368,9 @@ inline void LocEngRequestTime::log() const { // case LOC_ENG_MSG_DELETE_AIDING_DATA: struct LocEngDelAidData : public LocMsg { loc_eng_data_s_type* mLocEng; - const GpsAidingData mType; + const LocGpsAidingData mType; inline LocEngDelAidData(loc_eng_data_s_type* locEng, - GpsAidingData f) : + LocGpsAidingData f) : LocMsg(), mLocEng(locEng), mType(f) { locallog(); @@ -1645,14 +1645,14 @@ struct LocEngInstallAGpsCert : public LocMsg { LocEngAdapter* mpAdapter; const size_t mNumberOfCerts; const uint32_t mSlotBitMask; - DerEncodedCertificate* mpData; + LocDerEncodedCertificate* mpData; inline LocEngInstallAGpsCert(LocEngAdapter* adapter, - const DerEncodedCertificate* pData, + const LocDerEncodedCertificate* pData, size_t numberOfCerts, uint32_t slotBitMask) : LocMsg(), mpAdapter(adapter), mNumberOfCerts(numberOfCerts), mSlotBitMask(slotBitMask), - mpData(new DerEncodedCertificate[mNumberOfCerts]) + mpData(new LocDerEncodedCertificate[mNumberOfCerts]) { for (int i=0; i < mNumberOfCerts; i++) { mpData[i].data = new u_char[pData[i].length]; @@ -1694,10 +1694,10 @@ struct LocEngGnssConstellationConfig : public LocMsg { locallog(); } inline virtual void proc() const { - mAdapter->mGnssInfo.size = sizeof(GnssSystemInfo); + mAdapter->mGnssInfo.size = sizeof(LocGnssSystemInfo); if (mAdapter->gnssConstellationConfig()) { LOC_LOGV("Modem supports GNSS measurements\n"); - gps_conf.CAPABILITIES |= GPS_CAPABILITY_MEASUREMENTS; + gps_conf.CAPABILITIES |= LOC_GPS_CAPABILITY_MEASUREMENTS; mAdapter->mGnssInfo.year_of_hw = 2016; } else { mAdapter->mGnssInfo.year_of_hw = 2015; @@ -1714,7 +1714,7 @@ struct LocEngGnssConstellationConfig : public LocMsg { // case LOC_ENG_MSG_REPORT_GNSS_MEASUREMENT: LocEngReportGnssMeasurement::LocEngReportGnssMeasurement(void* locEng, - GnssData &gnssData) : + LocGnssData &gnssData) : LocMsg(), mLocEng(locEng), mGnssData(gnssData) { locallog(); @@ -1725,7 +1725,7 @@ void LocEngReportGnssMeasurement::proc() const { { if (locEng->gnss_measurement_cb != NULL) { LOC_LOGV("Calling gnss_measurement_cb"); - locEng->gnss_measurement_cb((GnssData*)&(mGnssData)); + locEng->gnss_measurement_cb((LocGnssData*)&(mGnssData)); } } } @@ -1734,7 +1734,7 @@ void LocEngReportGnssMeasurement::locallog() const { LOC_LOGV("%s:%d]: Received in GPS HAL." "GNSS Measurements count: %d \n", __func__, __LINE__, mGnssData.measurement_count); - for (int i =0; i< mGnssData.measurement_count && i < GNSS_MAX_SVS; i++) { + for (int i =0; i< mGnssData.measurement_count && i < LOC_GNSS_MAX_SVS; i++) { LOC_LOGV(" GNSS measurement data in GPS HAL: \n" " GPS_HAL => Measurement ID | svid | time_offset_ns | state |" " c_n0_dbhz | pseudorange_rate_mps |" @@ -1835,8 +1835,8 @@ int loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks, callbacks->sv_ext_parser : noProc; loc_eng_data.intermediateFix = gps_conf.INTERMEDIATE_POS; // initial states taken care of by the memset above - // loc_eng_data.engine_status -- GPS_STATUS_NONE; - // loc_eng_data.fix_session_status -- GPS_STATUS_NONE; + // loc_eng_data.engine_status -- LOC_GPS_STATUS_NONE; + // loc_eng_data.fix_session_status -- LOC_GPS_STATUS_NONE; // loc_eng_data.mute_session_state -- LOC_MUTE_SESS_NONE; if ((event & LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT) && (gps_conf.NMEA_PROVIDER == NMEA_PROVIDER_AP)) @@ -1853,7 +1853,7 @@ int loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks, new LocEngAdapter(event, &loc_eng_data, context, (LocThread::tCreate)callbacks->create_thread_cb); - loc_eng_data.adapter->mGnssInfo.size = sizeof(GnssSystemInfo); + loc_eng_data.adapter->mGnssInfo.size = sizeof(LocGnssSystemInfo); loc_eng_data.adapter->mGnssInfo.year_of_hw = 2015; LOC_LOGD("loc_eng_init created client, id = %p\n", loc_eng_data.adapter); @@ -2122,8 +2122,8 @@ int loc_eng_set_position_mode(loc_eng_data_s_type &loc_eng_data, INIT_CHECK(loc_eng_data.adapter, return -1); // The position mode for AUTO/GSS/QCA1530 can only be standalone - if (!(gps_conf.CAPABILITIES & GPS_CAPABILITY_MSB) && - !(gps_conf.CAPABILITIES & GPS_CAPABILITY_MSA) && + if (!(gps_conf.CAPABILITIES & LOC_GPS_CAPABILITY_MSB) && + !(gps_conf.CAPABILITIES & LOC_GPS_CAPABILITY_MSA) && (params.mode != LOC_POSITION_MODE_STANDALONE)) { params.mode = LOC_POSITION_MODE_STANDALONE; LOC_LOGD("Position mode changed to standalone for target with AUTO/GSS/qca1530."); @@ -2155,7 +2155,7 @@ SIDE EFFECTS N/A ===========================================================================*/ -int loc_eng_inject_time(loc_eng_data_s_type &loc_eng_data, GpsUtcTime time, +int loc_eng_inject_time(loc_eng_data_s_type &loc_eng_data, LocGpsUtcTime time, int64_t timeReference, int uncertainty) { ENTRY_LOG_CALLFLOW(); @@ -2213,7 +2213,7 @@ DESCRIPTION will happen when gps engine is turned off. DEPENDENCIES - Assumes the aiding data type specified in GpsAidingData matches with + Assumes the aiding data type specified in LocGpsAidingData matches with LOC API specification. RETURN VALUE @@ -2223,7 +2223,7 @@ SIDE EFFECTS N/A ===========================================================================*/ -void loc_eng_delete_aiding_data(loc_eng_data_s_type &loc_eng_data, GpsAidingData f) +void loc_eng_delete_aiding_data(loc_eng_data_s_type &loc_eng_data, LocGpsAidingData f) { ENTRY_LOG_CALLFLOW(); INIT_CHECK(loc_eng_data.adapter, return); @@ -2253,13 +2253,13 @@ SIDE EFFECTS N/A ===========================================================================*/ -static void loc_inform_gps_status(loc_eng_data_s_type &loc_eng_data, GpsStatusValue status) +static void loc_inform_gps_status(loc_eng_data_s_type &loc_eng_data, LocGpsStatusValue status) { ENTRY_LOG(); if (loc_eng_data.status_cb) { - GpsStatus gs = { sizeof(gs),status }; + LocGpsStatus gs = { sizeof(gs),status }; CALLBACK_LOG_CALLFLOW("status_cb", %s, loc_get_gps_status_name(gs.status)); loc_eng_data.status_cb(&gs); @@ -2305,12 +2305,12 @@ static int dataCallCb(void *cb_data) if(cb_data != NULL) { dsCbData *cbData = (dsCbData *)cb_data; LocEngAdapter *locAdapter = (LocEngAdapter *)cbData->mAdapter; - if(cbData->action == GPS_REQUEST_AGPS_DATA_CONN) { - LOC_LOGD("dataCallCb GPS_REQUEST_AGPS_DATA_CONN\n"); + if(cbData->action == LOC_GPS_REQUEST_AGPS_DATA_CONN) { + LOC_LOGD("dataCallCb LOC_GPS_REQUEST_AGPS_DATA_CONN\n"); ret = locAdapter->openAndStartDataCall(); } - else if(cbData->action == GPS_RELEASE_AGPS_DATA_CONN) { - LOC_LOGD("dataCallCb GPS_RELEASE_AGPS_DATA_CONN\n"); + else if(cbData->action == LOC_GPS_RELEASE_AGPS_DATA_CONN) { + LOC_LOGD("dataCallCb LOC_GPS_RELEASE_AGPS_DATA_CONN\n"); locAdapter->stopDataCall(); } } @@ -2436,7 +2436,7 @@ void loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data, AGpsExtCallbacks* call } static void deleteAidingData(loc_eng_data_s_type &logEng) { - if (logEng.engine_status != GPS_STATUS_ENGINE_ON && + if (logEng.engine_status != LOC_GPS_STATUS_ENGINE_ON && logEng.aiding_data_for_deletion != 0) { logEng.adapter->deleteAidingData(logEng.aiding_data_for_deletion); logEng.aiding_data_for_deletion = 0; @@ -2445,21 +2445,21 @@ static void deleteAidingData(loc_eng_data_s_type &logEng) { // must be called under msg handler context static void createAgnssNifs(loc_eng_data_s_type& locEng) { - bool agpsCapable = ((gps_conf.CAPABILITIES & GPS_CAPABILITY_MSA) || - (gps_conf.CAPABILITIES & GPS_CAPABILITY_MSB)); + bool agpsCapable = ((gps_conf.CAPABILITIES & LOC_GPS_CAPABILITY_MSA) || + (gps_conf.CAPABILITIES & LOC_GPS_CAPABILITY_MSB)); LocEngAdapter* adapter = locEng.adapter; if (NULL != adapter && adapter->mSupportsAgpsRequests) { if (NULL == locEng.internet_nif) { locEng.internet_nif= new AgpsStateMachine(servicerTypeAgps, (void *)locEng.agps_status_cb, - AGPS_TYPE_WWAN_ANY, + LOC_AGPS_TYPE_WWAN_ANY, false); } if (agpsCapable) { if (NULL == locEng.agnss_nif) { locEng.agnss_nif = new AgpsStateMachine(servicerTypeAgps, (void *)locEng.agps_status_cb, - AGPS_TYPE_SUPL, + LOC_AGPS_TYPE_SUPL, false); } if (NULL == locEng.ds_nif && @@ -2478,12 +2478,12 @@ static AgpsStateMachine* getAgpsStateMachine(loc_eng_data_s_type &locEng, AGpsExtType agpsType) { AgpsStateMachine* stateMachine; switch (agpsType) { - case AGPS_TYPE_INVALID: - case AGPS_TYPE_SUPL: { + case LOC_AGPS_TYPE_INVALID: + case LOC_AGPS_TYPE_SUPL: { stateMachine = locEng.agnss_nif; break; } - case AGPS_TYPE_SUPL_ES: { + case LOC_AGPS_TYPE_SUPL_ES: { if (gps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL) { if (NULL == locEng.ds_nif) { createAgnssNifs(locEng); @@ -2797,11 +2797,11 @@ void loc_eng_agps_ril_update_network_availability(loc_eng_data_s_type &loc_eng_d } int loc_eng_agps_install_certificates(loc_eng_data_s_type &loc_eng_data, - const DerEncodedCertificate* certificates, + const LocDerEncodedCertificate* certificates, size_t numberOfCerts) { ENTRY_LOG_CALLFLOW(); - int ret_val = AGPS_CERTIFICATE_OPERATION_SUCCESS; + int ret_val = LOC_AGPS_CERTIFICATE_OPERATION_SUCCESS; uint32_t slotBitMask = gps_conf.AGPS_CERT_WRITABLE_MASK; uint32_t slotCount = 0; @@ -2815,26 +2815,26 @@ int loc_eng_agps_install_certificates(loc_eng_data_s_type &loc_eng_data, if (numberOfCerts == 0) { LOC_LOGE("No certs to install, since numberOfCerts is zero"); - ret_val = AGPS_CERTIFICATE_OPERATION_SUCCESS; + ret_val = LOC_AGPS_CERTIFICATE_OPERATION_SUCCESS; } else if (!adapter) { LOC_LOGE("adapter is null!"); - ret_val = AGPS_CERTIFICATE_ERROR_GENERIC; + ret_val = LOC_AGPS_CERTIFICATE_ERROR_GENERIC; } else if (slotCount < numberOfCerts) { LOC_LOGE("Not enough cert slots (%u) to install %u certs!", slotCount, numberOfCerts); - ret_val = AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES; + ret_val = LOC_AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES; } else { for (int i=0; i < numberOfCerts; ++i) { - if (certificates[i].length > AGPS_CERTIFICATE_MAX_LENGTH) { + if (certificates[i].length > LOC_AGPS_CERTIFICATE_MAX_LENGTH) { LOC_LOGE("cert#(%u) length of %u is too big! greater than %u", - certificates[i].length, AGPS_CERTIFICATE_MAX_LENGTH); - ret_val = AGPS_CERTIFICATE_ERROR_GENERIC; + certificates[i].length, LOC_AGPS_CERTIFICATE_MAX_LENGTH); + ret_val = LOC_AGPS_CERTIFICATE_ERROR_GENERIC; break; } } - if (ret_val == AGPS_CERTIFICATE_OPERATION_SUCCESS) { + if (ret_val == LOC_AGPS_CERTIFICATE_OPERATION_SUCCESS) { adapter->sendMsg(new LocEngInstallAGpsCert(adapter, certificates, numberOfCerts, @@ -2907,11 +2907,11 @@ SIDE EFFECTS N/A ===========================================================================*/ -static void loc_eng_report_status (loc_eng_data_s_type &loc_eng_data, GpsStatusValue status) +static void loc_eng_report_status (loc_eng_data_s_type &loc_eng_data, LocGpsStatusValue status) { ENTRY_LOG(); // Switch from WAIT to MUTE, for "engine on" or "session begin" event - if (status == GPS_STATUS_SESSION_BEGIN || status == GPS_STATUS_ENGINE_ON) + if (status == LOC_GPS_STATUS_SESSION_BEGIN || status == LOC_GPS_STATUS_ENGINE_ON) { if (loc_eng_data.mute_session_state == LOC_MUTE_SESS_WAIT) { @@ -2922,7 +2922,7 @@ static void loc_eng_report_status (loc_eng_data_s_type &loc_eng_data, GpsStatusV // Switch off MUTE session if (loc_eng_data.mute_session_state == LOC_MUTE_SESS_IN_SESSION && - (status == GPS_STATUS_SESSION_END || status == GPS_STATUS_ENGINE_OFF)) + (status == LOC_GPS_STATUS_SESSION_END || status == LOC_GPS_STATUS_ENGINE_OFF)) { LOC_LOGD("loc_eng_report_status: mute_session_state changed from IN SESSION to NONE"); loc_eng_data.mute_session_state = LOC_MUTE_SESS_NONE; @@ -2930,9 +2930,9 @@ static void loc_eng_report_status (loc_eng_data_s_type &loc_eng_data, GpsStatusV // Session End is not reported during Android navigating state boolean navigating = loc_eng_data.adapter->isInSession(); - if (status != GPS_STATUS_NONE && - !(status == GPS_STATUS_SESSION_END && navigating) && - !(status == GPS_STATUS_SESSION_BEGIN && !navigating)) + if (status != LOC_GPS_STATUS_NONE && + !(status == LOC_GPS_STATUS_SESSION_END && navigating) && + !(status == LOC_GPS_STATUS_SESSION_BEGIN && !navigating)) { if (loc_eng_data.mute_session_state != LOC_MUTE_SESS_IN_SESSION) { @@ -2945,13 +2945,13 @@ static void loc_eng_report_status (loc_eng_data_s_type &loc_eng_data, GpsStatusV } // Only keeps ENGINE ON/OFF in engine_status - if (status == GPS_STATUS_ENGINE_ON || status == GPS_STATUS_ENGINE_OFF) + if (status == LOC_GPS_STATUS_ENGINE_ON || status == LOC_GPS_STATUS_ENGINE_OFF) { loc_eng_data.engine_status = status; } // Only keeps SESSION BEGIN/END in fix_session_status - if (status == GPS_STATUS_SESSION_BEGIN || status == GPS_STATUS_SESSION_END) + if (status == LOC_GPS_STATUS_SESSION_BEGIN || status == LOC_GPS_STATUS_SESSION_END) { loc_eng_data.fix_session_status = status; } @@ -2981,7 +2981,7 @@ void loc_eng_handle_engine_down(loc_eng_data_s_type &loc_eng_data) { ENTRY_LOG(); loc_eng_ni_reset_on_engine_restart(loc_eng_data); - loc_eng_report_status(loc_eng_data, GPS_STATUS_ENGINE_OFF); + loc_eng_report_status(loc_eng_data, LOC_GPS_STATUS_ENGINE_OFF); EXIT_LOG(%s, VOID_RET); } @@ -3070,28 +3070,28 @@ SIDE EFFECTS ===========================================================================*/ int loc_eng_gps_measurement_init(loc_eng_data_s_type &loc_eng_data, - GpsMeasurementCallbacks* callbacks) + LocGpsMeasurementCallbacks* callbacks) { ENTRY_LOG_CALLFLOW(); STATE_CHECK((NULL == loc_eng_data.gnss_measurement_cb), "gnss measurement already initialized", - return GPS_MEASUREMENT_ERROR_ALREADY_INIT); + return LOC_GPS_MEASUREMENT_ERROR_ALREADY_INIT); STATE_CHECK((callbacks != NULL), "callbacks can not be NULL", - return GPS_MEASUREMENT_ERROR_GENERIC); + return LOC_GPS_MEASUREMENT_ERROR_GENERIC); STATE_CHECK(loc_eng_data.adapter, - "GpsInterface must be initialized first", - return GPS_MEASUREMENT_ERROR_GENERIC); + "LocGpsInterface must be initialized first", + return LOC_GPS_MEASUREMENT_ERROR_GENERIC); // updated the mask LOC_API_ADAPTER_EVENT_MASK_T event = LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT; loc_eng_data.adapter->updateEvtMask(event, LOC_REGISTRATION_MASK_ENABLED); // set up the callback - loc_eng_data.gnss_measurement_cb = callbacks->gnss_measurement_callback; + loc_eng_data.gnss_measurement_cb = callbacks->loc_gnss_measurement_callback; LOC_LOGD ("%s, event masks updated successfully", __func__); - return GPS_MEASUREMENT_OPERATION_SUCCESS; + return LOC_GPS_MEASUREMENT_OPERATION_SUCCESS; } /*=========================================================================== diff --git a/loc_api/libloc_api_50001/loc_eng.h b/loc_api/libloc_api_50001/loc_eng.h index 9418fa95..d78bef4c 100644 --- a/loc_api/libloc_api_50001/loc_eng.h +++ b/loc_api/libloc_api_50001/loc_eng.h @@ -85,20 +85,20 @@ typedef struct loc_eng_data_s { LocEngAdapter *adapter; loc_location_cb_ext location_cb; - gps_status_callback status_cb; + loc_gps_status_callback status_cb; loc_sv_status_cb_ext sv_status_cb; agps_status_extended agps_status_cb; - gps_nmea_callback nmea_cb; + loc_gps_nmea_callback nmea_cb; loc_ni_notify_callback ni_notify_cb; - gps_set_capabilities set_capabilities_cb; - gps_acquire_wakelock acquire_wakelock_cb; - gps_release_wakelock release_wakelock_cb; - gps_request_utc_time request_utc_time_cb; - gnss_set_system_info set_system_info_cb; - gnss_sv_status_callback gnss_sv_status_cb; - gnss_measurement_callback gnss_measurement_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; - AGpsStatusValue agps_status; + LocAGpsStatusValue agps_status; loc_eng_xtra_data_s_type xtra_module_data; loc_eng_ni_data_s_type loc_eng_ni_data; @@ -109,11 +109,11 @@ typedef struct loc_eng_data_s AgpsStateMachine* ds_nif; // GPS engine status - GpsStatusValue engine_status; - GpsStatusValue fix_session_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 - GpsAidingData aiding_data_for_deletion; + LocGpsAidingData aiding_data_for_deletion; // For muting session broadcast loc_mute_session_e_type mute_session_state; @@ -151,13 +151,13 @@ 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, - GpsUtcTime time, int64_t timeReference, + 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, - GpsAidingData f); + LocGpsAidingData f); int loc_eng_set_position_mode(loc_eng_data_s_type &loc_eng_data, LocPosMode ¶ms); const void* loc_eng_get_extension(loc_eng_data_s_type &loc_eng_data, @@ -177,7 +177,7 @@ int loc_eng_agps_open_failed(loc_eng_data_s_type &loc_eng_data, AGpsExtType agp 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 DerEncodedCertificate* certificates, + const LocDerEncodedCertificate* certificates, size_t length); //loc_eng_xtra functions @@ -192,16 +192,16 @@ void loc_eng_xtra_version_check(loc_eng_data_s_type &loc_eng_data, int check); 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, GpsUserResponseType user_response); + int notif_id, LocGpsUserResponseType user_response); extern void loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data, - const GpsNiNotification *notif, + 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, - GpsMeasurementCallbacks* callbacks); + LocGpsMeasurementCallbacks* callbacks); void loc_eng_gps_measurement_close(loc_eng_data_s_type &loc_eng_data); #ifdef __cplusplus diff --git a/loc_api/libloc_api_50001/loc_eng_agps.cpp b/loc_api/libloc_api_50001/loc_eng_agps.cpp index 43af70fe..93260e3c 100644 --- a/loc_api/libloc_api_50001/loc_eng_agps.cpp +++ b/loc_api/libloc_api_50001/loc_eng_agps.cpp @@ -156,7 +156,7 @@ bool ATLSubscriber::notifyRsrcStatus(Notification ¬ification) case RSRC_DENIED: { AGpsExtType type = mBackwardCompatibleMode ? - AGPS_TYPE_INVALID : mStateMachine->getType(); + LOC_AGPS_TYPE_INVALID : mStateMachine->getType(); ((LocEngAdapter*)mLocAdapter)->atlOpenStatus(ID, 0, (char*)mStateMachine->getAPN(), mStateMachine->getBearer(), @@ -166,7 +166,7 @@ bool ATLSubscriber::notifyRsrcStatus(Notification ¬ification) case RSRC_GRANTED: { AGpsExtType type = mBackwardCompatibleMode ? - AGPS_TYPE_INVALID : mStateMachine->getType(); + LOC_AGPS_TYPE_INVALID : mStateMachine->getType(); ((LocEngAdapter*)mLocAdapter)->atlOpenStatus(ID, 1, (char*)mStateMachine->getAPN(), mStateMachine->getBearer(), @@ -275,7 +275,7 @@ AgpsState* AgpsReleasedState::onRsrcEvent(AgpsRsrcStatus event, void* data) //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(GPS_REQUEST_AGPS_DATA_CONN)) { + if(!mStateMachine->sendRsrcRequest(LOC_GPS_REQUEST_AGPS_DATA_CONN)) { // move the state to PENDING nextState = mPendingState; } @@ -354,13 +354,13 @@ AgpsState* AgpsPendingState::onRsrcEvent(AgpsRsrcStatus event, void* data) nextState = mReleasedState; // tell connecivity service we can release NIF - mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN); + 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(GPS_RELEASE_AGPS_DATA_CONN); + mStateMachine->sendRsrcRequest(LOC_GPS_RELEASE_AGPS_DATA_CONN); } } break; @@ -453,13 +453,13 @@ AgpsState* AgpsAcquiredState::onRsrcEvent(AgpsRsrcStatus event, void* data) nextState = mReleasedState; // tell connecivity service we can release NIF - mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN); + 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(GPS_RELEASE_AGPS_DATA_CONN); + mStateMachine->sendRsrcRequest(LOC_GPS_RELEASE_AGPS_DATA_CONN); } } break; @@ -559,7 +559,7 @@ AgpsState* AgpsReleasingState::onRsrcEvent(AgpsRsrcStatus event, void* data) if (mStateMachine->hasActiveSubscribers()) { nextState = mPendingState; // request from connecivity service for NIF - mStateMachine->sendRsrcRequest(GPS_REQUEST_AGPS_DATA_CONN); + mStateMachine->sendRsrcRequest(LOC_GPS_REQUEST_AGPS_DATA_CONN); } else { nextState = mReleasedState; } @@ -611,7 +611,7 @@ int ExtServicer :: requestRsrc(void *cb_data) int AGpsServicer :: requestRsrc(void *cb_data) { - callbackAGps((AGpsStatus *)cb_data); + callbackAGps((LocAGpsStatus *)cb_data); return 0; } @@ -746,14 +746,14 @@ void AgpsStateMachine::addSubscriber(Subscriber* subscriber) const } } -int AgpsStateMachine::sendRsrcRequest(AGpsStatusValue action) const +int AgpsStateMachine::sendRsrcRequest(LocAGpsStatusValue action) const { Subscriber* s = NULL; Notification notification(Notification::BROADCAST_ACTIVE); linked_list_search(mSubscribers, (void**)&s, hasSubscriber, (void*)¬ification, false); - if ((NULL == s) == (GPS_RELEASE_AGPS_DATA_CONN == action)) { + if ((NULL == s) == (LOC_GPS_RELEASE_AGPS_DATA_CONN == action)) { AGpsExtStatus nifRequest; nifRequest.size = sizeof(nifRequest); nifRequest.type = mType; @@ -827,7 +827,7 @@ err: DSStateMachine :: DSStateMachine(servicerType type, void *cb_func, LocEngAdapter* adapterHandle): - AgpsStateMachine(type, cb_func, AGPS_TYPE_INVALID,false), + AgpsStateMachine(type, cb_func, LOC_AGPS_TYPE_INVALID,false), mLocAdapter(adapterHandle) { LOC_LOGD("%s:%d]: New DSStateMachine\n", __func__, __LINE__); @@ -848,7 +848,7 @@ void DSStateMachine :: retryCallback(void) return; } -int DSStateMachine :: sendRsrcRequest(AGpsStatusValue action) const +int DSStateMachine :: sendRsrcRequest(LocAGpsStatusValue action) const { DSSubscriber* s = NULL; dsCbData cbData; @@ -954,13 +954,13 @@ void DSStateMachine :: informStatus(AgpsRsrcStatus status, int ID) const break; case RSRC_DENIED: ((DSStateMachine *)this)->mRetries = 0; - mLocAdapter->requestATL(ID, AGPS_TYPE_SUPL); + mLocAdapter->requestATL(ID, LOC_AGPS_TYPE_SUPL); break; case RSRC_GRANTED: mLocAdapter->atlOpenStatus(ID, 1, NULL, AGPS_APN_BEARER_INVALID, - AGPS_TYPE_INVALID); + LOC_AGPS_TYPE_INVALID); break; default: LOC_LOGW("DSStateMachine :: informStatus - unknown status"); diff --git a/loc_api/libloc_api_50001/loc_eng_agps.h b/loc_api/libloc_api_50001/loc_eng_agps.h index 58ce0843..ff879f4b 100644 --- a/loc_api/libloc_api_50001/loc_eng_agps.h +++ b/loc_api/libloc_api_50001/loc_eng_agps.h @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -68,7 +67,7 @@ typedef enum { //DS Callback struct typedef struct { LocEngAdapter *mAdapter; - AGpsStatusValue action; + LocAGpsStatusValue action; }dsCbData; // information bundle for subscribers @@ -171,12 +170,12 @@ public: }; class AGpsServicer : public Servicer { - void (*callbackAGps)(AGpsStatus* status); + void (*callbackAGps)(LocAGpsStatus* status); public: int requestRsrc(void *cb_data); AGpsServicer() {} AGpsServicer(void *cb_func) - { callbackAGps = (void(*)(AGpsStatus *))(cb_func); } + { callbackAGps = (void(*)(LocAGpsStatus *))(cb_func); } virtual ~AGpsServicer(){} inline virtual char *whoami() {return (char*)"AGpsServicer";} }; @@ -232,7 +231,7 @@ public: virtual void onRsrcEvent(AgpsRsrcStatus event); // put the data together and send the FW - virtual int sendRsrcRequest(AGpsStatusValue action) const; + virtual int sendRsrcRequest(LocAGpsStatusValue action) const; //if list is empty, linked_list_empty returns 1 //else if list is not empty, returns 0 @@ -260,7 +259,7 @@ public: DSStateMachine(servicerType type, void *cb_func, LocEngAdapter* adapterHandle); - int sendRsrcRequest(AGpsStatusValue action) const; + int sendRsrcRequest(LocAGpsStatusValue action) const; void onRsrcEvent(AgpsRsrcStatus event); void retryCallback(); void informStatus(AgpsRsrcStatus status, int ID) const; diff --git a/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp b/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp index 137f686b..7fbe62ff 100644 --- a/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp +++ b/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp @@ -53,19 +53,19 @@ int loc_eng_dmn_conn_loc_api_server_if_request_handler(struct ctrl_msgbuf *pmsg, case IF_REQUEST_TYPE_SUPL: { LOC_LOGD("IF_REQUEST_TYPE_SUPL"); - type = AGPS_TYPE_SUPL; + type = LOC_AGPS_TYPE_SUPL; break; } case IF_REQUEST_TYPE_WIFI: { LOC_LOGD("IF_REQUEST_TYPE_WIFI"); - type = AGPS_TYPE_WIFI; + type = LOC_AGPS_TYPE_WIFI; break; } case IF_REQUEST_TYPE_ANY: { LOC_LOGD("IF_REQUEST_TYPE_ANY"); - type = AGPS_TYPE_ANY; + type = LOC_AGPS_TYPE_ANY; break; } default: @@ -149,19 +149,19 @@ int loc_eng_dmn_conn_loc_api_server_if_release_handler(struct ctrl_msgbuf *pmsg, case IF_REQUEST_TYPE_SUPL: { LOC_LOGD("IF_REQUEST_TYPE_SUPL"); - type = AGPS_TYPE_SUPL; + type = LOC_AGPS_TYPE_SUPL; break; } case IF_REQUEST_TYPE_WIFI: { LOC_LOGD("IF_REQUEST_TYPE_WIFI"); - type = AGPS_TYPE_WIFI; + type = LOC_AGPS_TYPE_WIFI; break; } case IF_REQUEST_TYPE_ANY: { LOC_LOGD("IF_REQUEST_TYPE_ANY"); - type = AGPS_TYPE_ANY; + type = LOC_AGPS_TYPE_ANY; break; } default: diff --git a/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.h b/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.h index 1c0edd55..f1a51c7a 100644 --- a/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.h +++ b/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.h @@ -33,8 +33,6 @@ #include //for SSID_BUF_SIZE -#include - #ifndef SSID_BUF_SIZE #define SSID_BUF_SIZE (32+1) #endif diff --git a/loc_api/libloc_api_50001/loc_eng_msg.h b/loc_api/libloc_api_50001/loc_eng_msg.h index 2fa9b425..6f335e6b 100644 --- a/loc_api/libloc_api_50001/loc_eng_msg.h +++ b/loc_api/libloc_api_50001/loc_eng_msg.h @@ -30,7 +30,6 @@ #define LOC_ENG_MSG_H -#include #include #include #include @@ -105,11 +104,11 @@ struct LocEngReportPosition : public LocMsg { struct LocEngReportSv : public LocMsg { LocAdapterBase* mAdapter; - const GnssSvStatus mSvStatus; + const LocGnssSvStatus mSvStatus; const GpsLocationExtended mLocationExtended; const void* mSvExt; LocEngReportSv(LocAdapterBase* adapter, - GnssSvStatus &sv, + LocGnssSvStatus &sv, GpsLocationExtended &locExtended, void* svExtended); virtual void proc() const; @@ -120,9 +119,9 @@ struct LocEngReportSv : public LocMsg { struct LocEngReportStatus : public LocMsg { LocAdapterBase* mAdapter; - const GpsStatusValue mStatus; + const LocGpsStatusValue mStatus; LocEngReportStatus(LocAdapterBase* adapter, - GpsStatusValue engineStatus); + LocGpsStatusValue engineStatus); virtual void proc() const; void locallog() const; virtual void log() const; @@ -254,10 +253,10 @@ struct LocEngRequestTime : public LocMsg { struct LocEngRequestNi : public LocMsg { void* mLocEng; - const GpsNiNotification mNotify; + const LocGpsNiNotification mNotify; const void *mPayload; LocEngRequestNi(void* locEng, - GpsNiNotification ¬if, + LocGpsNiNotification ¬if, const void* data); virtual void proc() const; void locallog() const; @@ -291,9 +290,9 @@ struct LocEngGetZpp : public LocMsg { struct LocEngReportGnssMeasurement : public LocMsg { void* mLocEng; - const GnssData mGnssData; + const LocGnssData mGnssData; LocEngReportGnssMeasurement(void* locEng, - GnssData &gnssData); + LocGnssData &gnssData); virtual void proc() const; void locallog() const; virtual void log() const; diff --git a/loc_api/libloc_api_50001/loc_eng_ni.cpp b/loc_api/libloc_api_50001/loc_eng_ni.cpp index 9b454c66..3a7d8fb4 100644 --- a/loc_api/libloc_api_50001/loc_eng_ni.cpp +++ b/loc_api/libloc_api_50001/loc_eng_ni.cpp @@ -62,10 +62,10 @@ static void* ni_thread_proc(void *args); struct LocEngInformNiResponse : public LocMsg { LocEngAdapter* mAdapter; - const GpsUserResponseType mResponse; + const LocGpsUserResponseType mResponse; const void *mPayload; inline LocEngInformNiResponse(LocEngAdapter* adapter, - GpsUserResponseType resp, + LocGpsUserResponseType resp, const void* data) : LocMsg(), mAdapter(adapter), mResponse(resp), mPayload(data) @@ -109,7 +109,7 @@ RETURN VALUE ===========================================================================*/ void loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data, - const GpsNiNotification *notif, + const LocGpsNiNotification *notif, const void* passThrough) { ENTRY_LOG(); @@ -122,7 +122,7 @@ void loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data, return; } - if (notif->ni_type == GPS_NI_TYPE_EMERGENCY_SUPL) { + 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); @@ -153,9 +153,9 @@ void loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data, pSession->adapter = loc_eng_data.adapter; /* Fill in notification */ - ((GpsNiNotification*)notif)->notification_id = pSession->reqID; + ((LocGpsNiNotification*)notif)->notification_id = pSession->reqID; - if (notif->notify_flags == GPS_NI_PRIVACY_OVERRIDE) + if (notif->notify_flags == LOC_GPS_NI_PRIVACY_OVERRIDE) { loc_eng_mute_one_session(loc_eng_data); } @@ -188,7 +188,7 @@ void loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data, } CALLBACK_LOG_CALLFLOW("ni_notify_cb - id", %d, notif->notification_id); - loc_eng_data.ni_notify_cb((GpsNiNotification*)notif, gps_conf.SUPL_ES != 0); + loc_eng_data.ni_notify_cb((LocGpsNiNotification*)notif, gps_conf.SUPL_ES != 0); } EXIT_LOG(%s, VOID_RET); } @@ -224,7 +224,7 @@ static void* ni_thread_proc(void *args) &expire_time); if (rc == ETIMEDOUT) { - pSession->resp = GPS_NI_RESPONSE_NORESP; + 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; } @@ -242,8 +242,8 @@ static void* ni_thread_proc(void *args) LocEngInformNiResponse *msg = NULL; if (NULL != pSession->rawRequest) { - if (pSession->resp != GPS_NI_RESPONSE_IGNORE) { - LOC_LOGD("pSession->resp != GPS_NI_RESPONSE_IGNORE \n"); + 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); @@ -369,7 +369,7 @@ SIDE EFFECTS ===========================================================================*/ void loc_eng_ni_respond(loc_eng_data_s_type &loc_eng_data, - int notif_id, GpsUserResponseType user_response) + 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; @@ -384,10 +384,10 @@ void loc_eng_ni_respond(loc_eng_data_s_type &loc_eng_data, 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 == GPS_NI_RESPONSE_ACCEPT && + 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 = GPS_NI_RESPONSE_IGNORE; + 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); diff --git a/loc_api/libloc_api_50001/loc_eng_ni.h b/loc_api/libloc_api_50001/loc_eng_ni.h index 068f5cdd..afb406fb 100644 --- a/loc_api/libloc_api_50001/loc_eng_ni.h +++ b/loc_api/libloc_api_50001/loc_eng_ni.h @@ -35,7 +35,7 @@ #define LOC_NI_NO_RESPONSE_TIME 20 /* secs */ #define LOC_NI_NOTIF_KEY_ADDRESS "Address" -#define GPS_NI_RESPONSE_IGNORE 4 +#define LOC_GPS_NI_RESPONSE_IGNORE 4 typedef struct { pthread_t thread; /* NI thread */ @@ -43,7 +43,7 @@ typedef struct { bool respRecvd; /* NI User reponse received or not from Java layer*/ void* rawRequest; int reqID; /* ID to check against response */ - GpsUserResponseType resp; + LocGpsUserResponseType resp; pthread_cond_t tCond; pthread_mutex_t tLock; LocEngAdapter* adapter; diff --git a/loc_api/libloc_api_50001/loc_eng_nmea.cpp b/loc_api/libloc_api_50001/loc_eng_nmea.cpp index 6ab4a5f8..e7138b68 100644 --- a/loc_api/libloc_api_50001/loc_eng_nmea.cpp +++ b/loc_api/libloc_api_50001/loc_eng_nmea.cpp @@ -39,7 +39,7 @@ typedef struct loc_nmea_sv_meta_s { char talker[3]; - GnssConstellationType svType; + LocGnssConstellationType svType; uint32_t mask; uint32_t svIdOffset; } loc_nmea_sv_meta; @@ -61,7 +61,7 @@ SIDE EFFECTS ===========================================================================*/ static loc_nmea_sv_meta* loc_nmea_sv_meta_init(loc_eng_data_s_type *loc_eng_data_p, - loc_nmea_sv_meta& sv_meta, GnssConstellationType svType, bool needCombine) + loc_nmea_sv_meta& sv_meta, LocGnssConstellationType svType, bool needCombine) { if (!loc_eng_data_p) return NULL; @@ -72,17 +72,17 @@ static loc_nmea_sv_meta* loc_nmea_sv_meta_init(loc_eng_data_s_type *loc_eng_data switch (svType) { - case GNSS_CONSTELLATION_GPS: + case LOC_GNSS_CONSTELLATION_GPS: sv_meta.talker[1] = 'P'; sv_meta.mask = loc_eng_data_p->gps_used_mask; break; - case GNSS_CONSTELLATION_GLONASS: + case LOC_GNSS_CONSTELLATION_GLONASS: sv_meta.talker[1] = 'L'; sv_meta.mask = loc_eng_data_p->glo_used_mask; // GLONASS SV ids are from 65-96 sv_meta.svIdOffset = GLONASS_SV_ID_OFFSET; break; - case GNSS_CONSTELLATION_GALILEO: + case LOC_GNSS_CONSTELLATION_GALILEO: sv_meta.talker[1] = 'A'; sv_meta.mask = loc_eng_data_p->gal_used_mask; break; @@ -251,7 +251,7 @@ uint32_t loc_eng_nmea_generate_GSA(loc_eng_data_s_type *loc_eng_data_p, mask = mask >> 1; } - if (svUsedCount == 0 && GNSS_CONSTELLATION_GPS != sv_meta_p->svType) + if (svUsedCount == 0 && LOC_GNSS_CONSTELLATION_GPS != sv_meta_p->svType) return 0; if (svUsedCount == 0) @@ -345,7 +345,7 @@ SIDE EFFECTS ===========================================================================*/ void loc_eng_nmea_generate_GSV(loc_eng_data_s_type *loc_eng_data_p, - const GnssSvStatus &svStatus, + const LocGnssSvStatus &svStatus, char* sentence, int bufSize, loc_nmea_sv_meta* sv_meta_p) @@ -500,7 +500,7 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, // ------------------- count = loc_eng_nmea_generate_GSA(loc_eng_data_p, locationExtended, sentence, sizeof(sentence), - loc_nmea_sv_meta_init(loc_eng_data_p, sv_meta, GNSS_CONSTELLATION_GPS, true)); + loc_nmea_sv_meta_init(loc_eng_data_p, sv_meta, LOC_GNSS_CONSTELLATION_GPS, true)); if (count > 0) { svUsedCount += count; @@ -512,7 +512,7 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, // ------------------- count = loc_eng_nmea_generate_GSA(loc_eng_data_p, locationExtended, sentence, sizeof(sentence), - loc_nmea_sv_meta_init(loc_eng_data_p, sv_meta, GNSS_CONSTELLATION_GLONASS, true)); + loc_nmea_sv_meta_init(loc_eng_data_p, sv_meta, LOC_GNSS_CONSTELLATION_GLONASS, true)); if (count > 0) { svUsedCount += count; @@ -524,7 +524,7 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, // ------------------- count = loc_eng_nmea_generate_GSA(loc_eng_data_p, locationExtended, sentence, sizeof(sentence), - loc_nmea_sv_meta_init(loc_eng_data_p, sv_meta, GNSS_CONSTELLATION_GALILEO, true)); + loc_nmea_sv_meta_init(loc_eng_data_p, sv_meta, LOC_GNSS_CONSTELLATION_GALILEO, true)); if (count > 0) { svUsedCount += count; @@ -538,7 +538,7 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, pMarker = sentence; lengthRemaining = sizeof(sentence); - if (location.gpsLocation.flags & GPS_LOCATION_HAS_BEARING) + if (location.gpsLocation.flags & LOC_GPS_LOCATION_HAS_BEARING) { float magTrack = location.gpsLocation.bearing; if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_MAG_DEV) @@ -565,7 +565,7 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, pMarker += length; lengthRemaining -= length; - if (location.gpsLocation.flags & GPS_LOCATION_HAS_SPEED) + if (location.gpsLocation.flags & LOC_GPS_LOCATION_HAS_SPEED) { float speedKnots = location.gpsLocation.speed * (3600.0/1852.0); float speedKmPerHour = location.gpsLocation.speed * 3.6; @@ -585,7 +585,7 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, pMarker += length; lengthRemaining -= length; - if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG)) + if (!(location.gpsLocation.flags & LOC_GPS_LOCATION_HAS_LAT_LONG)) length = snprintf(pMarker, lengthRemaining, "%c", 'N'); // N means no fix else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->adapter->getPositionMode().mode) length = snprintf(pMarker, lengthRemaining, "%c", 'A'); // A means autonomous @@ -613,7 +613,7 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, pMarker += length; lengthRemaining -= length; - if (location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG) + if (location.gpsLocation.flags & LOC_GPS_LOCATION_HAS_LAT_LONG) { double latitude = location.gpsLocation.latitude; double longitude = location.gpsLocation.longitude; @@ -662,7 +662,7 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, pMarker += length; lengthRemaining -= length; - if (location.gpsLocation.flags & GPS_LOCATION_HAS_SPEED) + if (location.gpsLocation.flags & LOC_GPS_LOCATION_HAS_SPEED) { float speedKnots = location.gpsLocation.speed * (3600.0/1852.0); length = snprintf(pMarker, lengthRemaining, "%.1lf,", speedKnots); @@ -680,7 +680,7 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, pMarker += length; lengthRemaining -= length; - if (location.gpsLocation.flags & GPS_LOCATION_HAS_BEARING) + if (location.gpsLocation.flags & LOC_GPS_LOCATION_HAS_BEARING) { length = snprintf(pMarker, lengthRemaining, "%.1lf,", location.gpsLocation.bearing); } @@ -738,7 +738,7 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, pMarker += length; lengthRemaining -= length; - if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG)) + if (!(location.gpsLocation.flags & LOC_GPS_LOCATION_HAS_LAT_LONG)) length = snprintf(pMarker, lengthRemaining, "%c", 'N'); // N means no fix else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->adapter->getPositionMode().mode) length = snprintf(pMarker, lengthRemaining, "%c", 'A'); // A means autonomous @@ -766,7 +766,7 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, pMarker += length; lengthRemaining -= length; - if (location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG) + if (location.gpsLocation.flags & LOC_GPS_LOCATION_HAS_LAT_LONG) { double latitude = location.gpsLocation.latitude; double longitude = location.gpsLocation.longitude; @@ -816,7 +816,7 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, lengthRemaining -= length; char gpsQuality; - if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG)) + if (!(location.gpsLocation.flags & LOC_GPS_LOCATION_HAS_LAT_LONG)) gpsQuality = '0'; // 0 means no fix else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->adapter->getPositionMode().mode) gpsQuality = '1'; // 1 means GPS fix @@ -868,7 +868,7 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, pMarker += length; lengthRemaining -= length; - if ((location.gpsLocation.flags & GPS_LOCATION_HAS_ALTITUDE) && + if ((location.gpsLocation.flags & LOC_GPS_LOCATION_HAS_ALTITUDE) && (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL)) { length = snprintf(pMarker, lengthRemaining, "%.1lf,M,,", @@ -936,7 +936,7 @@ SIDE EFFECTS ===========================================================================*/ void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p, - const GnssSvStatus &svStatus, const GpsLocationExtended &locationExtended) + const LocGnssSvStatus &svStatus, const GpsLocationExtended &locationExtended) { ENTRY_LOG(); @@ -955,29 +955,29 @@ void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p, loc_eng_data_p->glo_used_mask = 0; loc_eng_data_p->gal_used_mask = 0; for(svNumber=1; svNumber <= svCount; svNumber++) { - if (GNSS_CONSTELLATION_GPS == svStatus.gnss_sv_list[svNumber - 1].constellation) + if (LOC_GNSS_CONSTELLATION_GPS == svStatus.gnss_sv_list[svNumber - 1].constellation) { // cache the used in fix mask, as it will be needed to send $GPGSA // during the position report - if (GNSS_SV_FLAGS_USED_IN_FIX == (svStatus.gnss_sv_list[svNumber - 1].flags & GNSS_SV_FLAGS_USED_IN_FIX)) + if (LOC_GNSS_SV_FLAGS_USED_IN_FIX == (svStatus.gnss_sv_list[svNumber - 1].flags & LOC_GNSS_SV_FLAGS_USED_IN_FIX)) { loc_eng_data_p->gps_used_mask |= (1 << (svStatus.gnss_sv_list[svNumber - 1].svid - 1)); } } - else if (GNSS_CONSTELLATION_GLONASS == svStatus.gnss_sv_list[svNumber - 1].constellation) + else if (LOC_GNSS_CONSTELLATION_GLONASS == svStatus.gnss_sv_list[svNumber - 1].constellation) { // cache the used in fix mask, as it will be needed to send $GNGSA // during the position report - if (GNSS_SV_FLAGS_USED_IN_FIX == (svStatus.gnss_sv_list[svNumber - 1].flags & GNSS_SV_FLAGS_USED_IN_FIX)) + if (LOC_GNSS_SV_FLAGS_USED_IN_FIX == (svStatus.gnss_sv_list[svNumber - 1].flags & LOC_GNSS_SV_FLAGS_USED_IN_FIX)) { loc_eng_data_p->glo_used_mask |= (1 << (svStatus.gnss_sv_list[svNumber - 1].svid - 1)); } } - else if (GNSS_CONSTELLATION_GALILEO == svStatus.gnss_sv_list[svNumber - 1].constellation) + else if (LOC_GNSS_CONSTELLATION_GALILEO == svStatus.gnss_sv_list[svNumber - 1].constellation) { // cache the used in fix mask, as it will be needed to send $GAGSA // during the position report - if (GNSS_SV_FLAGS_USED_IN_FIX == (svStatus.gnss_sv_list[svNumber - 1].flags & GNSS_SV_FLAGS_USED_IN_FIX)) + if (LOC_GNSS_SV_FLAGS_USED_IN_FIX == (svStatus.gnss_sv_list[svNumber - 1].flags & LOC_GNSS_SV_FLAGS_USED_IN_FIX)) { loc_eng_data_p->gal_used_mask |= (1 << (svStatus.gnss_sv_list[svNumber - 1].svid - 1)); } @@ -990,21 +990,21 @@ void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p, // ------------------ loc_eng_nmea_generate_GSV(loc_eng_data_p, svStatus, sentence, sizeof(sentence), - loc_nmea_sv_meta_init(loc_eng_data_p, sv_meta, GNSS_CONSTELLATION_GPS, false)); + loc_nmea_sv_meta_init(loc_eng_data_p, sv_meta, LOC_GNSS_CONSTELLATION_GPS, false)); // ------------------ // ------$GLGSV------ // ------------------ loc_eng_nmea_generate_GSV(loc_eng_data_p, svStatus, sentence, sizeof(sentence), - loc_nmea_sv_meta_init(loc_eng_data_p, sv_meta, GNSS_CONSTELLATION_GLONASS, false)); + loc_nmea_sv_meta_init(loc_eng_data_p, sv_meta, LOC_GNSS_CONSTELLATION_GLONASS, false)); // ------------------ // ------$GAGSV------ // ------------------ loc_eng_nmea_generate_GSV(loc_eng_data_p, svStatus, sentence, sizeof(sentence), - loc_nmea_sv_meta_init(loc_eng_data_p, sv_meta, GNSS_CONSTELLATION_GALILEO, false)); + loc_nmea_sv_meta_init(loc_eng_data_p, sv_meta, LOC_GNSS_CONSTELLATION_GALILEO, false)); // For RPC, the DOP are sent during sv report, so cache them diff --git a/loc_api/libloc_api_50001/loc_eng_nmea.h b/loc_api/libloc_api_50001/loc_eng_nmea.h index 066943aa..9480a6ad 100644 --- a/loc_api/libloc_api_50001/loc_eng_nmea.h +++ b/loc_api/libloc_api_50001/loc_eng_nmea.h @@ -30,14 +30,13 @@ #ifndef LOC_ENG_NMEA_H #define LOC_ENG_NMEA_H -#include #include #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 GnssSvStatus &svStatus, const GpsLocationExtended &locationExtended); +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 diff --git a/loc_api/libloc_api_50001/loc_eng_xtra.h b/loc_api/libloc_api_50001/loc_eng_xtra.h index 175f497d..41a006f9 100644 --- a/loc_api/libloc_api_50001/loc_eng_xtra.h +++ b/loc_api/libloc_api_50001/loc_eng_xtra.h @@ -30,13 +30,11 @@ #ifndef LOC_ENG_XTRA_H #define LOC_ENG_XTRA_H -#include - // Module data typedef struct { // loc_eng_ioctl_cb_data_s_type ioctl_cb_data; - gps_xtra_download_request download_request_cb; + loc_gps_xtra_download_request download_request_cb; report_xtra_server report_xtra_server_cb; // XTRA data buffer diff --git a/utils/loc_target.cpp b/utils/loc_target.cpp index 2da2fea0..10168610 100644 --- a/utils/loc_target.cpp +++ b/utils/loc_target.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include "loc_target.h" #include "loc_log.h"