diff options
author | Dante Russo <drusso@codeaurora.org> | 2017-02-28 16:45:47 -0800 |
---|---|---|
committer | Dante Russo <drusso@codeaurora.org> | 2017-02-28 16:47:50 -0800 |
commit | c85c8ff673e4347cea911b353de120f639b39b83 (patch) | |
tree | 5fe203230801cf76dc1823b6d05a44ea94663883 /core | |
parent | 4bb940c0679ab23c9b8954bcb9ad8da5ede093cd (diff) | |
download | gps-c85c8ff673e4347cea911b353de120f639b39b83.tar.gz |
LocationAPI implementation
Implementation of LocationAPI into gps hal
to be a common API that is called into by platform
specific APIs.
Change-Id: Ie5a7bd217d4ae2175ad49e6aca2fb6ecd4702f3b
CRs-fixed: 1112712
Diffstat (limited to 'core')
-rw-r--r-- | core/Android.mk | 6 | ||||
-rw-r--r-- | core/ContextBase.cpp | 114 | ||||
-rw-r--r-- | core/ContextBase.h | 6 | ||||
-rw-r--r-- | core/LocAdapterBase.cpp | 47 | ||||
-rw-r--r-- | core/LocAdapterBase.h | 77 | ||||
-rw-r--r-- | core/LocAdapterProxyBase.h | 15 | ||||
-rw-r--r-- | core/LocApiBase.cpp | 122 | ||||
-rw-r--r-- | core/LocApiBase.h | 55 | ||||
-rw-r--r-- | core/LocDualContext.cpp | 5 | ||||
-rw-r--r-- | core/UlpProxyBase.h | 43 | ||||
-rw-r--r-- | core/gps_extended.h | 12 | ||||
-rw-r--r-- | core/gps_extended_c.h | 6 | ||||
-rw-r--r-- | core/loc_core_log.h | 8 |
13 files changed, 326 insertions, 190 deletions
diff --git a/core/Android.mk b/core/Android.mk index 319a02a..53dcb6b 100644 --- a/core/Android.mk +++ b/core/Android.mk @@ -6,7 +6,7 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := libloc_core -LOCAL_MODULE_OWNER := qcom +LOCAL_MODULE_OWNER := qti LOCAL_MODULE_TAGS := optional @@ -37,8 +37,8 @@ LOCAL_CFLAGS += \ LOCAL_C_INCLUDES:= \ $(TARGET_OUT_HEADERS)/gps.utils \ - $(TARGET_OUT_HEADERS)/libflp \ - $(TARGET_OUT_HEADERS)/libloc_pla + $(TARGET_OUT_HEADERS)/libloc_pla \ + $(TARGET_OUT_HEADERS)/liblocation_api LOCAL_COPY_HEADERS_TO:= libloc_core/ LOCAL_COPY_HEADERS:= \ diff --git a/core/ContextBase.cpp b/core/ContextBase.cpp index 1ae8482..a9858e2 100644 --- a/core/ContextBase.cpp +++ b/core/ContextBase.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014,2016-2017 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -40,8 +40,116 @@ namespace loc_core { -loc_gps_cfg_s_type ContextBase::mGps_conf {0}; -loc_sap_cfg_s_type ContextBase::mSap_conf {0}; +loc_gps_cfg_s_type ContextBase::mGps_conf {}; +loc_sap_cfg_s_type ContextBase::mSap_conf {}; + +const loc_param_s_type ContextBase::mGps_conf_table[] = +{ + {"GPS_LOCK", &mGps_conf.GPS_LOCK, NULL, 'n'}, + {"SUPL_VER", &mGps_conf.SUPL_VER, NULL, 'n'}, + {"LPP_PROFILE", &mGps_conf.LPP_PROFILE, NULL, 'n'}, + {"A_GLONASS_POS_PROTOCOL_SELECT", &mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT, NULL, 'n'}, + {"LPPE_CP_TECHNOLOGY", &mGps_conf.LPPE_CP_TECHNOLOGY, NULL, 'n'}, + {"LPPE_UP_TECHNOLOGY", &mGps_conf.LPPE_UP_TECHNOLOGY, NULL, 'n'}, + {"AGPS_CERT_WRITABLE_MASK", &mGps_conf.AGPS_CERT_WRITABLE_MASK, NULL, 'n'}, + {"SUPL_MODE", &mGps_conf.SUPL_MODE, NULL, 'n'}, + {"SUPL_ES", &mGps_conf.SUPL_ES, NULL, 'n'}, + {"INTERMEDIATE_POS", &mGps_conf.INTERMEDIATE_POS, NULL, 'n'}, + {"ACCURACY_THRES", &mGps_conf.ACCURACY_THRES, NULL, 'n'}, + {"NMEA_PROVIDER", &mGps_conf.NMEA_PROVIDER, NULL, 'n'}, + {"CAPABILITIES", &mGps_conf.CAPABILITIES, NULL, 'n'}, + {"XTRA_VERSION_CHECK", &mGps_conf.XTRA_VERSION_CHECK, NULL, 'n'}, + {"XTRA_SERVER_1", &mGps_conf.XTRA_SERVER_1, NULL, 's'}, + {"XTRA_SERVER_2", &mGps_conf.XTRA_SERVER_2, NULL, 's'}, + {"XTRA_SERVER_3", &mGps_conf.XTRA_SERVER_3, NULL, 's'}, + {"USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL", &mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL, NULL, 'n'}, + {"AGPS_CONFIG_INJECT", &mGps_conf.AGPS_CONFIG_INJECT, NULL, 'n'}, + {"EXTERNAL_DR_ENABLED", &mGps_conf.EXTERNAL_DR_ENABLED, NULL, 'n'}, +}; + +const loc_param_s_type ContextBase::mSap_conf_table[] = +{ + {"GYRO_BIAS_RANDOM_WALK", &mSap_conf.GYRO_BIAS_RANDOM_WALK, &mSap_conf.GYRO_BIAS_RANDOM_WALK_VALID, 'f'}, + {"ACCEL_RANDOM_WALK_SPECTRAL_DENSITY", &mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY, &mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'}, + {"ANGLE_RANDOM_WALK_SPECTRAL_DENSITY", &mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY, &mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'}, + {"RATE_RANDOM_WALK_SPECTRAL_DENSITY", &mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY, &mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'}, + {"VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY", &mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY, &mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'}, + {"SENSOR_ACCEL_BATCHES_PER_SEC", &mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC, NULL, 'n'}, + {"SENSOR_ACCEL_SAMPLES_PER_BATCH", &mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH, NULL, 'n'}, + {"SENSOR_GYRO_BATCHES_PER_SEC", &mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC, NULL, 'n'}, + {"SENSOR_GYRO_SAMPLES_PER_BATCH", &mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH, NULL, 'n'}, + {"SENSOR_ACCEL_BATCHES_PER_SEC_HIGH", &mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH, NULL, 'n'}, + {"SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH", &mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH, NULL, 'n'}, + {"SENSOR_GYRO_BATCHES_PER_SEC_HIGH", &mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH, NULL, 'n'}, + {"SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH", &mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH, NULL, 'n'}, + {"SENSOR_CONTROL_MODE", &mSap_conf.SENSOR_CONTROL_MODE, NULL, 'n'}, + {"SENSOR_USAGE", &mSap_conf.SENSOR_USAGE, NULL, 'n'}, + {"SENSOR_ALGORITHM_CONFIG_MASK", &mSap_conf.SENSOR_ALGORITHM_CONFIG_MASK, NULL, 'n'}, + {"SENSOR_PROVIDER", &mSap_conf.SENSOR_PROVIDER, NULL, 'n'} +}; + +void ContextBase::readConfig() +{ + /*Defaults for gps.conf*/ + mGps_conf.INTERMEDIATE_POS = 0; + mGps_conf.ACCURACY_THRES = 0; + mGps_conf.NMEA_PROVIDER = 0; + mGps_conf.GPS_LOCK = 0; + mGps_conf.SUPL_VER = 0x10000; + mGps_conf.SUPL_MODE = 0x3; + mGps_conf.SUPL_ES = 0; + mGps_conf.CAPABILITIES = 0x7; + /* LTE Positioning Profile configuration is disable by default*/ + mGps_conf.LPP_PROFILE = 0; + /*By default no positioning protocol is selected on A-GLONASS system*/ + mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT = 0; + /*XTRA version check is disabled by default*/ + mGps_conf.XTRA_VERSION_CHECK=0; + /*Use emergency PDN by default*/ + mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL = 1; + /* By default no LPPe CP technology is enabled*/ + mGps_conf.LPPE_CP_TECHNOLOGY = 0; + /* By default no LPPe UP technology is enabled*/ + mGps_conf.LPPE_UP_TECHNOLOGY = 0; + + /*Defaults for sap.conf*/ + mSap_conf.GYRO_BIAS_RANDOM_WALK = 0; + mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC = 2; + mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH = 5; + mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC = 2; + mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH = 5; + mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH = 4; + mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH = 25; + mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH = 4; + mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH = 25; + mSap_conf.SENSOR_CONTROL_MODE = 0; /* AUTO */ + mSap_conf.SENSOR_USAGE = 0; /* Enabled */ + mSap_conf.SENSOR_ALGORITHM_CONFIG_MASK = 0; /* INS Disabled = FALSE*/ + /* Values MUST be set by OEMs in configuration for sensor-assisted + navigation to work. There are NO default values */ + mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY = 0; + mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY = 0; + mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY = 0; + mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY = 0; + mSap_conf.GYRO_BIAS_RANDOM_WALK_VALID = 0; + mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0; + mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0; + mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0; + mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0; + /* default provider is SSC */ + mSap_conf.SENSOR_PROVIDER = 1; + + /* None of the 10 slots for agps certificates are writable by default */ + mGps_conf.AGPS_CERT_WRITABLE_MASK = 0; + + /* inject supl config to modem with config values from config.xml or gps.conf, default 1 */ + mGps_conf.AGPS_CONFIG_INJECT = 1; + + const char* GPS_CONF_FILE = "/etc/gps.conf"; + const char* SAP_CONF_FILE = "/etc/sap.conf"; + UTIL_READ_CONF(GPS_CONF_FILE, mGps_conf_table); + UTIL_READ_CONF(SAP_CONF_FILE, mSap_conf_table); +} uint32_t ContextBase::getCarrierCapabilities() { #define carrierMSA (uint32_t)0x2 diff --git a/core/ContextBase.h b/core/ContextBase.h index 87d2acf..83de999 100644 --- a/core/ContextBase.h +++ b/core/ContextBase.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2017, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -34,6 +34,7 @@ #include <MsgTask.h> #include <LocApiBase.h> #include <LBSProxyBase.h> +#include <loc_cfg.h> #define MAX_XTRA_SERVER_URL_LENGTH 256 @@ -105,6 +106,8 @@ class LocAdapterBase; class ContextBase { static LBSProxyBase* getLBSProxy(const char* libName); LocApiBase* createLocApi(LOC_API_ADAPTER_EVENT_MASK_T excludedMask); + static const loc_param_s_type mGps_conf_table[]; + static const loc_param_s_type mSap_conf_table[]; protected: const LBSProxyBase* mLBSProxy; const MsgTask* mMsgTask; @@ -135,6 +138,7 @@ public: static loc_gps_cfg_s_type mGps_conf; static loc_sap_cfg_s_type mSap_conf; + void readConfig(); static uint32_t getCarrierCapabilities(); }; diff --git a/core/LocAdapterBase.cpp b/core/LocAdapterBase.cpp index 166fd91..27132b7 100644 --- a/core/LocAdapterBase.cpp +++ b/core/LocAdapterBase.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014, 2016-2017The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -50,6 +50,16 @@ LocAdapterBase::LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask, mLocApi->addAdapter(this); } +uint32_t LocAdapterBase::mSessionIdCounter(1); + +uint32_t LocAdapterBase::generateSessionId() +{ + if (++mSessionIdCounter == 0xFFFFFFFF) + mSessionIdCounter = 1; + + return mSessionIdCounter; +} + void LocAdapterBase::handleEngineUpEvent() { if (mLocAdapterProxyBase) { @@ -65,32 +75,31 @@ void LocAdapterBase::handleEngineDownEvent() } void LocAdapterBase:: - reportPosition(UlpLocation &location, - GpsLocationExtended &locationExtended, - void* locationExt, - enum loc_sess_status status, - LocPosTechMask loc_technology_mask) { - if (mLocAdapterProxyBase == NULL || - !mLocAdapterProxyBase->reportPosition(location, - locationExtended, - status, - loc_technology_mask)) { + reportPositionEvent(const UlpLocation& location, + const GpsLocationExtended& locationExtended, + enum loc_sess_status status, + LocPosTechMask loc_technology_mask, + bool fromUlp) { + if (mLocAdapterProxyBase != NULL) { + mLocAdapterProxyBase->reportPositionEvent((UlpLocation&)location, + (GpsLocationExtended&)locationExtended, + status, + loc_technology_mask); + } else { DEFAULT_IMPL() } } void LocAdapterBase:: - reportSv(LocGnssSvStatus &svStatus, - GpsLocationExtended &locationExtended, - void* svExt) + reportSvEvent(const GnssSvNotification& svNotify, bool fromUlp) DEFAULT_IMPL() void LocAdapterBase:: - reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet) + reportSvMeasurementEvent(GnssSvMeasurementSet &svMeasurementSet) DEFAULT_IMPL() void LocAdapterBase:: - reportSvPolynomial(GnssSvPolynomial &svPolynomial) + reportSvPolynomialEvent(GnssSvPolynomial &svPolynomial) DEFAULT_IMPL() void LocAdapterBase:: @@ -99,7 +108,7 @@ DEFAULT_IMPL() void LocAdapterBase:: - reportNmea(const char* nmea, int length) + reportNmeaEvent(const char* nmea, size_t length, bool fromUlp) DEFAULT_IMPL() bool LocAdapterBase:: @@ -140,11 +149,11 @@ bool LocAdapterBase:: DEFAULT_IMPL(false) bool LocAdapterBase:: - requestNiNotify(LocGpsNiNotification ¬ify, const void* data) + requestNiNotifyEvent(GnssNiNotification ¬ify, const void* data) DEFAULT_IMPL(false) void LocAdapterBase:: - reportGnssMeasurementData(LocGnssData &gnssMeasurementData) + reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& measurementsNotify) DEFAULT_IMPL() bool LocAdapterBase:: diff --git a/core/LocAdapterBase.h b/core/LocAdapterBase.h index f3ec489..824a340 100644 --- a/core/LocAdapterBase.h +++ b/core/LocAdapterBase.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2014,2016 The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014, 2016-2017 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -32,19 +32,39 @@ #include <gps_extended.h> #include <UlpProxyBase.h> #include <ContextBase.h> +#include <LocationAPI.h> +#include <map> + +typedef struct LocationSessionKey { + LocationAPI* client; + uint32_t id; + inline LocationSessionKey(LocationAPI* _client, uint32_t _id) : + client(_client), id(_id) {} +} LocationSessionKey; +inline bool operator <(LocationSessionKey const& left, LocationSessionKey const& right) { + return left.id < right.id || (left.id == right.id && left.client < right.client); +} +inline bool operator ==(LocationSessionKey const& left, LocationSessionKey const& right) { + return left.id == right.id && left.client == right.client; +} +inline bool operator !=(LocationSessionKey const& left, LocationSessionKey const& right) { + return left.id != right.id || left.client != right.client; +} +typedef std::map<LocationSessionKey, LocationOptions> LocationSessionMap; namespace loc_core { class LocAdapterProxyBase; class LocAdapterBase { +private: + static uint32_t mSessionIdCounter; protected: LOC_API_ADAPTER_EVENT_MASK_T mEvtMask; ContextBase* mContext; LocApiBase* mLocApi; LocAdapterProxyBase* mLocAdapterProxyBase; const MsgTask* mMsgTask; - inline LocAdapterBase(const MsgTask* msgTask) : mEvtMask(0), mContext(NULL), mLocApi(NULL), mLocAdapterProxyBase(NULL), mMsgTask(msgTask) {} @@ -70,11 +90,19 @@ public: } inline void updateEvtMask(LOC_API_ADAPTER_EVENT_MASK_T event, - loc_registration_mask_status isEnabled) + loc_registration_mask_status status) { - mEvtMask = - isEnabled == LOC_REGISTRATION_MASK_ENABLED ? (mEvtMask|event):(mEvtMask&~event); - + switch(status) { + case (LOC_REGISTRATION_MASK_ENABLED): + mEvtMask = mEvtMask | event; + break; + case (LOC_REGISTRATION_MASK_DISABLED): + mEvtMask = mEvtMask &~ event; + break; + case (LOC_REGISTRATION_MASK_SET): + mEvtMask = event; + break; + } mLocApi->updateEvtMask(); } @@ -82,33 +110,33 @@ public: return mLocApi->isFeatureSupported(featureVal); } + uint32_t generateSessionId(); + // This will be overridden by the individual adapters // if necessary. - inline virtual void setUlpProxy(UlpProxyBase* ulp) { + inline virtual void setUlpProxyCommand(UlpProxyBase* ulp) { (void)ulp; } virtual void handleEngineUpEvent(); virtual void handleEngineDownEvent(); - inline virtual void setPositionModeInt(LocPosMode& posMode) { + inline virtual void setPositionModeCommand(LocPosMode& posMode) { (void)posMode; } - virtual void startFixInt() {} - virtual void stopFixInt() {} - virtual void getZppInt() {} - virtual void reportPosition(UlpLocation &location, - GpsLocationExtended &locationExtended, - void* locationExt, - enum loc_sess_status status, - LocPosTechMask loc_technology_mask); - virtual void reportSv(LocGnssSvStatus &svStatus, - GpsLocationExtended &locationExtended, - void* svExt); - virtual void reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet); - virtual void reportSvPolynomial(GnssSvPolynomial &svPolynomial); + virtual void startTrackingCommand() {} + virtual void stopTrackingCommand() {} + virtual void getZppCommand() {} + virtual void reportPositionEvent(const UlpLocation& location, + const GpsLocationExtended& locationExtended, + enum loc_sess_status status, + LocPosTechMask loc_technology_mask, + bool fromUlp=false); + virtual void reportSvEvent(const GnssSvNotification& svNotify, bool fromUlp=false); + virtual void reportNmeaEvent(const char* nmea, size_t length, bool fromUlp=false); + virtual void reportSvMeasurementEvent(GnssSvMeasurementSet &svMeasurementSet); + virtual void reportSvPolynomialEvent(GnssSvPolynomial &svPolynomial); virtual void reportStatus(LocGpsStatusValue status); - virtual void reportNmea(const char* nmea, int length); virtual bool reportXtraServer(const char* url1, const char* url2, const char* url3, const int maxlength); virtual bool requestXtraData(); @@ -119,11 +147,10 @@ public: virtual bool requestSuplES(int connHandle); virtual bool reportDataCallOpened(); virtual bool reportDataCallClosed(); - virtual bool requestNiNotify(LocGpsNiNotification ¬ify, - const void* data); + virtual bool requestNiNotifyEvent(GnssNiNotification ¬ify, const void* data); inline virtual bool isInSession() { return false; } ContextBase* getContext() const { return mContext; } - virtual void reportGnssMeasurementData(LocGnssData &gnssMeasurementData); + virtual void reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& measurementsNotify); virtual bool reportWwanZppFix(LocGpsLocation &zppLoc); }; diff --git a/core/LocAdapterProxyBase.h b/core/LocAdapterProxyBase.h index 82cba6b..044f59b 100644 --- a/core/LocAdapterProxyBase.h +++ b/core/LocAdapterProxyBase.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2014 The Linux Foundation. All rights reserved. +/* Copyright (c) 2014, 2016-2017 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -51,22 +51,25 @@ protected: mLocAdapterBase->updateEvtMask(event,isEnabled); } + inline uint32_t generateSessionId() { + return mLocAdapterBase->generateSessionId(); + } public: inline ContextBase* getContext() const { return mLocAdapterBase->getContext(); } + inline virtual void handleEngineUpEvent() {}; inline virtual void handleEngineDownEvent() {}; - inline virtual bool reportPosition(UlpLocation &location, - GpsLocationExtended &locationExtended, - enum loc_sess_status status, - LocPosTechMask loc_technology_mask) { + inline virtual void reportPositionEvent(UlpLocation &location, + GpsLocationExtended &locationExtended, + enum loc_sess_status status, + LocPosTechMask loc_technology_mask) { (void)location; (void)locationExtended; (void)status; (void)loc_technology_mask; - return false; } }; diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp index 4cc8cb8..3bbbf8f 100644 --- a/core/LocApiBase.cpp +++ b/core/LocApiBase.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2014,2016 The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014, 2016-2017 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -227,14 +227,13 @@ void LocApiBase::handleEngineDownEvent() TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineDownEvent()); } -void LocApiBase::reportPosition(UlpLocation &location, - GpsLocationExtended &locationExtended, - void* locationExt, +void LocApiBase::reportPosition(UlpLocation& location, + GpsLocationExtended& locationExtended, enum loc_sess_status status, LocPosTechMask loc_technology_mask) { // print the location info before delivering - LOC_LOGV("flags: %d\n source: %d\n latitude: %f\n longitude: %f\n " + LOC_LOGD("flags: %d\n source: %d\n latitude: %f\n longitude: %f\n " "altitude: %f\n speed: %f\n bearing: %f\n accuracy: %f\n " "timestamp: %lld\n rawDataSize: %d\n rawData: %p\n " "Session status: %d\n Technology mask: %u\n " @@ -251,11 +250,8 @@ void LocApiBase::reportPosition(UlpLocation &location, locationExtended.gnss_sv_used_ids.gal_sv_used_ids_mask); // loop through adapters, and deliver to all adapters. TO_ALL_LOCADAPTERS( - mLocAdapters[i]->reportPosition(location, - locationExtended, - locationExt, - status, - loc_technology_mask) + mLocAdapters[i]->reportPositionEvent(location, locationExtended, + status, loc_technology_mask) ); } @@ -265,9 +261,7 @@ void LocApiBase::reportWwanZppFix(LocGpsLocation &zppLoc) TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportWwanZppFix(zppLoc)); } -void LocApiBase::reportSv(LocGnssSvStatus &svStatus, - GpsLocationExtended &locationExtended, - void* svExt) +void LocApiBase::reportSv(GnssSvNotification& svNotify) { const char* constellationString[] = { "Unknown", "GPS", "SBAS", "GLONASS", "QZSS", "BEIDOU", "GALILEO" }; @@ -276,27 +270,25 @@ void LocApiBase::reportSv(LocGnssSvStatus &svStatus, LOC_LOGV("num sv: %d\n" " sv: constellation svid cN0" " elevation azimuth flags", - svStatus.num_svs); - for (int i = 0; i < svStatus.num_svs && i < LOC_GNSS_MAX_SVS; i++) { - if (svStatus.gnss_sv_list[i].constellation > + svNotify.count); + for (int i = 0; i < svNotify.count && i < LOC_GNSS_MAX_SVS; i++) { + if (svNotify.gnssSvs[i].type > sizeof(constellationString) / sizeof(constellationString[0]) - 1) { - svStatus.gnss_sv_list[i].constellation = 0; + svNotify.gnssSvs[i].type = GNSS_SV_TYPE_UNKNOWN; } LOC_LOGV(" %03d: %*s %02d %f %f %f 0x%02X", i, 13, - constellationString[svStatus.gnss_sv_list[i].constellation], - svStatus.gnss_sv_list[i].svid, - svStatus.gnss_sv_list[i].c_n0_dbhz, - svStatus.gnss_sv_list[i].elevation, - svStatus.gnss_sv_list[i].azimuth, - svStatus.gnss_sv_list[i].flags); + constellationString[svNotify.gnssSvs[i].type], + svNotify.gnssSvs[i].svId, + svNotify.gnssSvs[i].cN0Dbhz, + svNotify.gnssSvs[i].elevation, + svNotify.gnssSvs[i].azimuth, + svNotify.gnssSvs[i].gnssSvOptionsMask); } // loop through adapters, and deliver to all adapters. TO_ALL_LOCADAPTERS( - mLocAdapters[i]->reportSv(svStatus, - locationExtended, - svExt) + mLocAdapters[i]->reportSvEvent(svNotify) ); } @@ -304,7 +296,7 @@ void LocApiBase::reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet) { // loop through adapters, and deliver to all adapters. TO_ALL_LOCADAPTERS( - mLocAdapters[i]->reportSvMeasurement(svMeasurementSet) + mLocAdapters[i]->reportSvMeasurementEvent(svMeasurementSet) ); } @@ -312,7 +304,7 @@ void LocApiBase::reportSvPolynomial(GnssSvPolynomial &svPolynomial) { // loop through adapters, and deliver to all adapters. TO_ALL_LOCADAPTERS( - mLocAdapters[i]->reportSvPolynomial(svPolynomial) + mLocAdapters[i]->reportSvPolynomialEvent(svPolynomial) ); } @@ -325,7 +317,7 @@ void LocApiBase::reportStatus(LocGpsStatusValue status) void LocApiBase::reportNmea(const char* nmea, int length) { // loop through adapters, and deliver to all adapters. - TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportNmea(nmea, length)); + TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportNmeaEvent(nmea, length)); } void LocApiBase::reportXtraServer(const char* url1, const char* url2, @@ -384,10 +376,10 @@ void LocApiBase::reportDataCallClosed() TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportDataCallClosed()); } -void LocApiBase::requestNiNotify(LocGpsNiNotification ¬ify, const void* data) +void LocApiBase::requestNiNotify(GnssNiNotification ¬ify, const void* data) { // loop through adapters, and deliver to the first handling adapter. - TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestNiNotify(notify, data)); + TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestNiNotifyEvent(notify, data)); } void LocApiBase::saveSupportedMsgList(uint64_t supportedMsgList) @@ -406,10 +398,10 @@ void* LocApiBase :: getSibling() LocApiProxyBase* LocApiBase :: getLocApiProxy() DEFAULT_IMPL(NULL) -void LocApiBase::reportGnssMeasurementData(LocGnssData &gnssMeasurementData) +void LocApiBase::reportGnssMeasurementData(GnssMeasurementsNotification& measurementsNotify) { // loop through adapters, and deliver to all adapters. - TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssMeasurementData(gnssMeasurementData)); + TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssMeasurementDataEvent(measurementsNotify)); } enum loc_api_adapter_err LocApiBase:: @@ -428,9 +420,9 @@ enum loc_api_adapter_err LocApiBase:: stopFix() DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) -enum loc_api_adapter_err LocApiBase:: - deleteAidingData(LocGpsAidingData f) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) +LocationError LocApiBase:: + deleteAidingData(const GnssAidingData& data) +DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) enum loc_api_adapter_err LocApiBase:: enableData(int enable) @@ -469,31 +461,29 @@ enum loc_api_adapter_err LocApiBase:: setPositionMode(const LocPosMode& posMode) DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) -enum loc_api_adapter_err LocApiBase:: +LocationError LocApiBase:: setServer(const char* url, int len) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) +DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) -enum loc_api_adapter_err LocApiBase:: - setServer(unsigned int ip, int port, - LocServerType type) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) +LocationError LocApiBase:: + setServer(unsigned int ip, int port, LocServerType type) +DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) -enum loc_api_adapter_err LocApiBase:: - informNiResponse(LocGpsUserResponseType userResponse, - const void* passThroughData) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) +LocationError LocApiBase:: + informNiResponse(GnssNiResponse userResponse, const void* passThroughData) +DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) -enum loc_api_adapter_err LocApiBase:: - setSUPLVersion(uint32_t version) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) +LocationError LocApiBase:: + setSUPLVersion(GnssConfigSuplVersion version) +DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) enum loc_api_adapter_err LocApiBase:: setNMEATypes (uint32_t typesMask) DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) -enum loc_api_adapter_err LocApiBase:: - setLPPConfig(uint32_t profile) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) +LocationError LocApiBase:: + setLPPConfig(GnssConfigLppProfile profile) +DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) enum loc_api_adapter_err LocApiBase:: setSensorControlConfig(int sensorUsage, @@ -526,13 +516,17 @@ enum loc_api_adapter_err LocApiBase:: int algorithmConfig) DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) -enum loc_api_adapter_err LocApiBase:: - setAGLONASSProtocol(unsigned long aGlonassProtocol) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) +LocationError LocApiBase:: + setAGLONASSProtocol(GnssConfigAGlonassPositionProtocolMask aGlonassProtocol) +DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) -enum loc_api_adapter_err LocApiBase:: - setLPPeProtocol(unsigned long lppeCP, unsigned long lppeUP) - DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) +LocationError LocApiBase:: + setLPPeProtocolCp(GnssConfigLppeControlPlaneMask lppeCP) +DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) + +LocationError LocApiBase:: + setLPPeProtocolUp(GnssConfigLppeUserPlaneMask lppeUP) +DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) enum loc_api_adapter_err LocApiBase:: getWwanZppFix() @@ -573,9 +567,9 @@ void LocApiBase:: releaseDataServiceClient() DEFAULT_IMPL() -int LocApiBase:: - setGpsLock(LOC_GPS_LOCK_MASK lock) -DEFAULT_IMPL(-1) +LocationError LocApiBase:: + setGpsLock(GnssConfigGpsLock lock) +DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) void LocApiBase:: installAGpsCert(const LocDerEncodedCertificate* pData, @@ -587,9 +581,9 @@ int LocApiBase:: getGpsLock() DEFAULT_IMPL(-1) -enum loc_api_adapter_err LocApiBase:: - setXtraVersionCheck(enum xtra_version_check check) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) +LocationError LocApiBase:: + setXtraVersionCheck(uint32_t check) +DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) bool LocApiBase:: gnssConstellationConfig() diff --git a/core/LocApiBase.h b/core/LocApiBase.h index 9127a2e..86610e7 100644 --- a/core/LocApiBase.h +++ b/core/LocApiBase.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2014, 2016 The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014, 2016-2017 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -32,6 +32,7 @@ #include <stddef.h> #include <ctype.h> #include <gps_extended.h> +#include <LocationAPI.h> #include <MsgTask.h> #include <platform_lib_log_util.h> @@ -102,22 +103,18 @@ public: inline void sendMsg(const LocMsg* msg) const { mMsgTask->sendMsg(msg); } - void addAdapter(LocAdapterBase* adapter); void removeAdapter(LocAdapterBase* adapter); // upward calls void handleEngineUpEvent(); void handleEngineDownEvent(); - void reportPosition(UlpLocation &location, - GpsLocationExtended &locationExtended, - void* locationExt, + void reportPosition(UlpLocation& location, + GpsLocationExtended& locationExtended, enum loc_sess_status status, LocPosTechMask loc_technology_mask = LOC_POS_TECH_MASK_DEFAULT); - void reportSv(LocGnssSvStatus &svStatus, - GpsLocationExtended &locationExtended, - void* svExt); + void reportSv(GnssSvNotification& svNotify); void reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet); void reportSvPolynomial(GnssSvPolynomial &svPolynomial); void reportStatus(LocGpsStatusValue status); @@ -132,9 +129,9 @@ public: void requestSuplES(int connHandle); void reportDataCallOpened(); void reportDataCallClosed(); - void requestNiNotify(LocGpsNiNotification ¬ify, const void* data); + void requestNiNotify(GnssNiNotification ¬ify, const void* data); void saveSupportedMsgList(uint64_t supportedMsgList); - void reportGnssMeasurementData(LocGnssData &gnssMeasurementData); + void reportGnssMeasurementData(GnssMeasurementsNotification& measurementsNotify); void saveSupportedFeatureList(uint8_t *featureList); void reportWwanZppFix(LocGpsLocation &zppLoc); @@ -148,8 +145,8 @@ public: startFix(const LocPosMode& posMode); virtual enum loc_api_adapter_err stopFix(); - virtual enum loc_api_adapter_err - deleteAidingData(LocGpsAidingData f); + virtual LocationError + deleteAidingData(const GnssAidingData& data); virtual enum loc_api_adapter_err enableData(int enable); virtual enum loc_api_adapter_err @@ -168,19 +165,17 @@ public: atlCloseStatus(int handle, int is_succ); virtual enum loc_api_adapter_err setPositionMode(const LocPosMode& posMode); - virtual enum loc_api_adapter_err + virtual LocationError setServer(const char* url, int len); - virtual enum loc_api_adapter_err + virtual LocationError setServer(unsigned int ip, int port, LocServerType type); - virtual enum loc_api_adapter_err - informNiResponse(LocGpsUserResponseType userResponse, const void* passThroughData); - virtual enum loc_api_adapter_err - setSUPLVersion(uint32_t version); + virtual LocationError + informNiResponse(GnssNiResponse userResponse, const void* passThroughData); + virtual LocationError setSUPLVersion(GnssConfigSuplVersion version); virtual enum loc_api_adapter_err setNMEATypes (uint32_t typesMask); - virtual enum loc_api_adapter_err - setLPPConfig(uint32_t profile); + virtual LocationError setLPPConfig(GnssConfigLppProfile profile); virtual enum loc_api_adapter_err setSensorControlConfig(int sensorUsage, int sensorProvider); virtual enum loc_api_adapter_err @@ -205,10 +200,10 @@ public: int gyroSamplesPerBatchHigh, int gyroBatchesPerSecHigh, int algorithmConfig); - virtual enum loc_api_adapter_err - setAGLONASSProtocol(unsigned long aGlonassProtocol); - virtual enum loc_api_adapter_err - setLPPeProtocol(unsigned long lppeCP, unsigned long lppeUP); + virtual LocationError + setAGLONASSProtocol(GnssConfigAGlonassPositionProtocolMask aGlonassProtocol); + virtual LocationError setLPPeProtocolCp(GnssConfigLppeControlPlaneMask lppeCP); + virtual LocationError setLPPeProtocolUp(GnssConfigLppeUserPlaneMask lppeUP); virtual enum loc_api_adapter_err getWwanZppFix(); virtual enum loc_api_adapter_err @@ -238,15 +233,10 @@ public: return (messageChecker & mSupportedMsg) == messageChecker; } } + void updateEvtMask(); - /*Values for lock - 1 = Do not lock any position sessions - 2 = Lock MI position sessions - 3 = Lock MT position sessions - 4 = Lock all position sessions - */ - virtual int setGpsLock(LOC_GPS_LOCK_MASK lock); + virtual LocationError setGpsLock(GnssConfigGpsLock lock); /* Returns Current value of GPS Lock on success @@ -254,8 +244,7 @@ public: */ virtual int getGpsLock(void); - virtual enum loc_api_adapter_err setXtraVersionCheck(enum xtra_version_check check); - + virtual LocationError setXtraVersionCheck(uint32_t check); /* Check if the modem support the service */ diff --git a/core/LocDualContext.cpp b/core/LocDualContext.cpp index 74b2903..fd465e9 100644 --- a/core/LocDualContext.cpp +++ b/core/LocDualContext.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014, 2016-2017 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -44,8 +44,7 @@ LocDualContext::mFgExclMask = 0; // excluded events for background clients const LOC_API_ADAPTER_EVENT_MASK_T LocDualContext::mBgExclMask = - (LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT | - LOC_API_ADAPTER_BIT_SATELLITE_REPORT | + (LOC_API_ADAPTER_BIT_SATELLITE_REPORT | LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT | LOC_API_ADAPTER_BIT_NMEA_POSITION_REPORT | LOC_API_ADAPTER_BIT_IOCTL_REPORT | diff --git a/core/UlpProxyBase.h b/core/UlpProxyBase.h index d30e9cc..8863b66 100644 --- a/core/UlpProxyBase.h +++ b/core/UlpProxyBase.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved. +/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -30,7 +30,8 @@ #define ULP_PROXY_BASE_H #include <gps_extended.h> -#include "fused_location_extended.h" +#include <LocationAPI.h> + namespace loc_core { class LocAdapterBase; @@ -51,24 +52,18 @@ public: return false; } - inline virtual bool reportPosition(UlpLocation &location, - GpsLocationExtended &locationExtended, - void* locationExt, + inline virtual bool reportPosition(const UlpLocation &location, + const GpsLocationExtended &locationExtended, enum loc_sess_status status, LocPosTechMask loc_technology_mask) { (void)location; (void)locationExtended; - (void)locationExt; (void)status; (void)loc_technology_mask; return false; } - inline virtual bool reportSv(LocGnssSvStatus &svStatus, - GpsLocationExtended &locationExtended, - void* svExt) { - (void)svStatus; - (void)locationExtended; - (void)svExt; + inline virtual bool reportSv(const GnssSvNotification& svNotify) { + (void)svNotify; return false; } inline virtual bool reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet) { @@ -94,17 +89,21 @@ public: (void)capabilities; } - inline virtual bool reportBatchingSession(FlpExtBatchOptions &options, - bool active) { - - (void)options; - (void)active; - return false; + inline virtual bool reportBatchingSession(const LocationOptions& options, bool active) + { + (void)options; + (void)active; + return false; } - inline virtual bool reportPositions(const FlpExtLocation* locations, - int32_t number_of_locations) { - (void)locations; - (void)number_of_locations; + inline virtual bool reportPositions(const UlpLocation* ulpLocations, + const GpsLocationExtended* extendedLocations, + const uint32_t* techMasks, + const size_t count) + { + (void)ulpLocations; + (void)extendedLocations; + (void)techMasks; + (void)count; return false; } inline virtual bool reportDeleteAidingData(LocGpsAidingData aidingData) diff --git a/core/gps_extended.h b/core/gps_extended.h index 5255da1..dc6ad1e 100644 --- a/core/gps_extended.h +++ b/core/gps_extended.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. +/* Copyright (c) 2013-2017 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -29,19 +29,21 @@ #ifndef GPS_EXTENDED_H #define GPS_EXTENDED_H -#include <gps_extended_c.h> /** * @file * @brief C++ declarations for GPS types */ +#include <gps_extended_c.h> +#if defined(USE_GLIB) || defined(OFF_TARGET) +#include <string.h> +#endif + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -#if defined(USE_GLIB) || defined(OFF_TARGET) -#include <string.h> -#endif + struct LocPosMode { diff --git a/core/gps_extended_c.h b/core/gps_extended_c.h index 3985e99..55fd03e 100644 --- a/core/gps_extended_c.h +++ b/core/gps_extended_c.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2015, 2016 The Linux Foundation. All rights reserved. +/* Copyright (c) 2013-2017 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -34,6 +34,7 @@ #include <stdlib.h> #include <string.h> #include <loc_gps.h> +#include <LocationAPI.h> #include <time.h> /** @@ -88,7 +89,8 @@ extern "C" { enum loc_registration_mask_status { LOC_REGISTRATION_MASK_ENABLED, - LOC_REGISTRATION_MASK_DISABLED + LOC_REGISTRATION_MASK_DISABLED, + LOC_REGISTRATION_MASK_SET }; typedef enum { diff --git a/core/loc_core_log.h b/core/loc_core_log.h index 4fe8d3f..2beb687 100644 --- a/core/loc_core_log.h +++ b/core/loc_core_log.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2013, 2016-2017 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -30,14 +30,14 @@ #ifndef LOC_CORE_LOG_H #define LOC_CORE_LOG_H +#include <ctype.h> +#include <gps_extended.h> + #ifdef __cplusplus extern "C" { #endif -#include <ctype.h> -#include <gps_extended.h> - const char* loc_get_gps_status_name(LocGpsStatusValue gps_status); const char* loc_get_position_mode_name(LocGpsPositionMode mode); const char* loc_get_position_recurrence_name(LocGpsPositionRecurrence recur); |