From f7102b858dc849cc94255bc96f95b880dfd93452 Mon Sep 17 00:00:00 2001 From: Fedor917 Date: Thu, 10 Nov 2016 15:53:00 +0700 Subject: Initialising brunch based on davidevinavil device tree (CM14.0 branch) --- gps/core/Android.mk | 6 +- gps/core/ContextBase.cpp | 72 ++-- gps/core/ContextBase.h | 70 ++++ gps/core/LBSProxyBase.h | 21 +- gps/core/LocAdapterBase.cpp | 11 +- gps/core/LocAdapterBase.h | 20 +- gps/core/LocAdapterProxyBase.h | 11 +- gps/core/LocApiBase.cpp | 92 ++++-- gps/core/LocApiBase.h | 37 ++- gps/core/LocDualContext.cpp | 6 +- gps/core/Makefile.am | 46 +++ gps/core/UlpProxyBase.h | 42 ++- gps/core/gps_extended.h | 26 +- gps/core/gps_extended_c.h | 727 ++++++++++++++++++++++++++++++++++++++--- gps/core/loc_core_log.cpp | 2 +- 15 files changed, 1052 insertions(+), 137 deletions(-) create mode 100644 gps/core/Makefile.am (limited to 'gps/core') diff --git a/gps/core/Android.mk b/gps/core/Android.mk index 35a267f..9649f00 100644 --- a/gps/core/Android.mk +++ b/gps/core/Android.mk @@ -19,7 +19,8 @@ LOCAL_SHARED_LIBRARIES := \ libutils \ libcutils \ libgps.utils \ - libdl + libdl \ + libloc_pla LOCAL_SRC_FILES += \ LocApiBase.cpp \ @@ -34,7 +35,8 @@ LOCAL_CFLAGS += \ LOCAL_C_INCLUDES:= \ $(TARGET_OUT_HEADERS)/gps.utils \ - $(TARGET_OUT_HEADERS)/libflp + $(TARGET_OUT_HEADERS)/libflp \ + $(TARGET_OUT_HEADERS)/libloc_pla LOCAL_COPY_HEADERS_TO:= libloc_core/ LOCAL_COPY_HEADERS:= \ diff --git a/gps/core/ContextBase.cpp b/gps/core/ContextBase.cpp index 9f6c4aa..d2f9070 100644 --- a/gps/core/ContextBase.cpp +++ b/gps/core/ContextBase.cpp @@ -35,11 +35,32 @@ #include #include #include -#include +#include #include namespace loc_core { +loc_gps_cfg_s_type ContextBase::mGps_conf {0}; +loc_sap_cfg_s_type ContextBase::mSap_conf {0}; + +uint32_t ContextBase::getCarrierCapabilities() { + #define carrierMSA (uint32_t)0x2 + #define carrierMSB (uint32_t)0x1 + #define gpsConfMSA (uint32_t)0x4 + #define gpsConfMSB (uint32_t)0x2 + uint32_t capabilities = mGps_conf.CAPABILITIES; + if ((mGps_conf.SUPL_MODE & carrierMSA) != carrierMSA) { + capabilities &= ~gpsConfMSA; + } + if ((mGps_conf.SUPL_MODE & carrierMSB) != carrierMSB) { + capabilities &= ~gpsConfMSB; + } + + LOC_LOGV("getCarrierCapabilities: CAPABILITIES %x, SUPL_MODE %x, carrier capabilities %x", + mGps_conf.CAPABILITIES, mGps_conf.SUPL_MODE, capabilities); + return capabilities; +} + LBSProxyBase* ContextBase::getLBSProxy(const char* libName) { LBSProxyBase* proxy = NULL; @@ -52,6 +73,10 @@ LBSProxyBase* ContextBase::getLBSProxy(const char* libName) proxy = (*getter)(); } } + else + { + LOC_LOGW("%s:%d]: FAILED TO LOAD libname: %s\n", __func__, __LINE__, libName); + } if (NULL == proxy) { proxy = new LBSProxyBase(); } @@ -63,30 +88,29 @@ LocApiBase* ContextBase::createLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask) { LocApiBase* locApi = NULL; - // first if can not be MPQ - if (TARGET_MPQ != loc_get_target()) { - if (NULL == (locApi = mLBSProxy->getLocApi(mMsgTask, exMask, this))) { - void *handle = NULL; - //try to see if LocApiV02 is present - if((handle = dlopen("libloc_api_v02.so", RTLD_NOW)) != NULL) { - LOC_LOGD("%s:%d]: libloc_api_v02.so is present", __func__, __LINE__); - getLocApi_t* getter = (getLocApi_t*)dlsym(handle, "getLocApi"); - if(getter != NULL) { - LOC_LOGD("%s:%d]: getter is not NULL for LocApiV02", __func__, __LINE__); - locApi = (*getter)(mMsgTask, exMask, this); - } + if (NULL == (locApi = mLBSProxy->getLocApi(mMsgTask, exMask, this))) { + void *handle = NULL; + //try to see if LocApiV02 is present + if ((handle = dlopen("libloc_api_v02.so", RTLD_NOW)) != NULL) { + LOC_LOGD("%s:%d]: libloc_api_v02.so is present", __func__, __LINE__); + getLocApi_t* getter = (getLocApi_t*) dlsym(handle, "getLocApi"); + if (getter != NULL) { + LOC_LOGD("%s:%d]: getter is not NULL for LocApiV02", __func__, + __LINE__); + locApi = (*getter)(mMsgTask, exMask, this); } - // only RPC is the option now - else { - LOC_LOGD("%s:%d]: libloc_api_v02.so is NOT present. Trying RPC", - __func__, __LINE__); - handle = dlopen("libloc_api-rpc-qc.so", RTLD_NOW); - if (NULL != handle) { - getLocApi_t* getter = (getLocApi_t*)dlsym(handle, "getLocApi"); - if (NULL != getter) { - LOC_LOGD("%s:%d]: getter is not NULL in RPC", __func__, __LINE__); - locApi = (*getter)(mMsgTask, exMask, this); - } + } + // only RPC is the option now + else { + LOC_LOGD("%s:%d]: libloc_api_v02.so is NOT present. Trying RPC", + __func__, __LINE__); + handle = dlopen("libloc_api-rpc-qc.so", RTLD_NOW); + if (NULL != handle) { + getLocApi_t* getter = (getLocApi_t*) dlsym(handle, "getLocApi"); + if (NULL != getter) { + LOC_LOGD("%s:%d]: getter is not NULL in RPC", __func__, + __LINE__); + locApi = (*getter)(mMsgTask, exMask, this); } } } diff --git a/gps/core/ContextBase.h b/gps/core/ContextBase.h index fe0b860..87d2acf 100644 --- a/gps/core/ContextBase.h +++ b/gps/core/ContextBase.h @@ -35,6 +35,69 @@ #include #include +#define MAX_XTRA_SERVER_URL_LENGTH 256 + +/* GPS.conf support */ +/* NOTE: the implementaiton of the parser casts number + fields to 32 bit. To ensure all 'n' fields working, + they must all be 32 bit fields. */ +typedef struct loc_gps_cfg_s +{ + uint32_t INTERMEDIATE_POS; + uint32_t ACCURACY_THRES; + uint32_t SUPL_VER; + uint32_t SUPL_MODE; + uint32_t SUPL_ES; + uint32_t CAPABILITIES; + uint32_t LPP_PROFILE; + uint32_t XTRA_VERSION_CHECK; + char XTRA_SERVER_1[MAX_XTRA_SERVER_URL_LENGTH]; + char XTRA_SERVER_2[MAX_XTRA_SERVER_URL_LENGTH]; + char XTRA_SERVER_3[MAX_XTRA_SERVER_URL_LENGTH]; + uint32_t USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL; + uint32_t NMEA_PROVIDER; + uint32_t GPS_LOCK; + uint32_t A_GLONASS_POS_PROTOCOL_SELECT; + uint32_t AGPS_CERT_WRITABLE_MASK; + uint32_t AGPS_CONFIG_INJECT; + uint32_t LPPE_CP_TECHNOLOGY; + uint32_t LPPE_UP_TECHNOLOGY; + uint32_t EXTERNAL_DR_ENABLED; +} loc_gps_cfg_s_type; + +/* NOTE: the implementaiton of the parser casts number + fields to 32 bit. To ensure all 'n' fields working, + they must all be 32 bit fields. */ +/* Meanwhile, *_valid fields are 8 bit fields, and 'f' + fields are double. Rigid as they are, it is the + the status quo, until the parsing mechanism is + change, that is. */ +typedef struct +{ + uint8_t GYRO_BIAS_RANDOM_WALK_VALID; + double GYRO_BIAS_RANDOM_WALK; + uint32_t SENSOR_ACCEL_BATCHES_PER_SEC; + uint32_t SENSOR_ACCEL_SAMPLES_PER_BATCH; + uint32_t SENSOR_GYRO_BATCHES_PER_SEC; + uint32_t SENSOR_GYRO_SAMPLES_PER_BATCH; + uint32_t SENSOR_ACCEL_BATCHES_PER_SEC_HIGH; + uint32_t SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH; + uint32_t SENSOR_GYRO_BATCHES_PER_SEC_HIGH; + uint32_t SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH; + uint32_t SENSOR_CONTROL_MODE; + uint32_t SENSOR_USAGE; + uint32_t SENSOR_ALGORITHM_CONFIG_MASK; + uint8_t ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID; + double ACCEL_RANDOM_WALK_SPECTRAL_DENSITY; + uint8_t ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID; + double ANGLE_RANDOM_WALK_SPECTRAL_DENSITY; + uint8_t RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID; + double RATE_RANDOM_WALK_SPECTRAL_DENSITY; + uint8_t VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID; + double VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY; + uint32_t SENSOR_PROVIDER; +} loc_sap_cfg_s_type; + namespace loc_core { class LocAdapterBase; @@ -58,6 +121,7 @@ public: inline LocApiProxyBase* getLocApiProxy() { return mLocApiProxy; } inline bool hasAgpsExtendedCapabilities() { return mLBSProxy->hasAgpsExtendedCapabilities(); } inline bool hasCPIExtendedCapabilities() { return mLBSProxy->hasCPIExtendedCapabilities(); } + inline bool hasNativeXtraClient() { return mLBSProxy->hasNativeXtraClient(); } inline void modemPowerVote(bool power) const { return mLBSProxy->modemPowerVote(power); } inline void requestUlp(LocAdapterBase* adapter, unsigned long capabilities) { @@ -67,6 +131,12 @@ public: return mLBSProxy->getIzatDevId(); } inline void sendMsg(const LocMsg *msg) { getMsgTask()->sendMsg(msg); } + + static loc_gps_cfg_s_type mGps_conf; + static loc_sap_cfg_s_type mSap_conf; + + static uint32_t getCarrierCapabilities(); + }; } // namespace loc_core diff --git a/gps/core/LBSProxyBase.h b/gps/core/LBSProxyBase.h index 0faf801..94ddd0f 100644 --- a/gps/core/LBSProxyBase.h +++ b/gps/core/LBSProxyBase.h @@ -43,6 +43,10 @@ class LBSProxyBase { getLocApi(const MsgTask* msgTask, LOC_API_ADAPTER_EVENT_MASK_T exMask, ContextBase* context) const { + + (void)msgTask; + (void)exMask; + (void)context; return NULL; } protected: @@ -50,11 +54,22 @@ protected: public: inline virtual ~LBSProxyBase() {} inline virtual void requestUlp(LocAdapterBase* adapter, - unsigned long capabilities) const {} + unsigned long capabilities) const { + + (void)adapter; + (void)capabilities; + } inline virtual bool hasAgpsExtendedCapabilities() const { return false; } inline virtual bool hasCPIExtendedCapabilities() const { return false; } - inline virtual void modemPowerVote(bool power) const {} - virtual void injectFeatureConfig(ContextBase* context) const {} + inline virtual void modemPowerVote(bool power) const { + + (void)power; + } + virtual void injectFeatureConfig(ContextBase* context) const { + + (void)context; + } + inline virtual bool hasNativeXtraClient() const { return false; } inline virtual IzatDevId_t getIzatDevId() const { return 0; } }; diff --git a/gps/core/LocAdapterBase.cpp b/gps/core/LocAdapterBase.cpp index 8fdb8cb..6a3f969 100644 --- a/gps/core/LocAdapterBase.cpp +++ b/gps/core/LocAdapterBase.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include namespace loc_core { @@ -85,6 +85,13 @@ void LocAdapterBase:: void* svExt) DEFAULT_IMPL() +void LocAdapterBase:: + reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet) +DEFAULT_IMPL() + +void LocAdapterBase:: + reportSvPolynomial(GnssSvPolynomial &svPolynomial) +DEFAULT_IMPL() void LocAdapterBase:: reportStatus(GpsStatusValue status) @@ -137,6 +144,6 @@ bool LocAdapterBase:: DEFAULT_IMPL(false) void LocAdapterBase:: - reportGpsMeasurementData(GpsData &gpsMeasurementData) + reportGnssMeasurementData(GnssData &gnssMeasurementData) DEFAULT_IMPL() } // namespace loc_core diff --git a/gps/core/LocAdapterBase.h b/gps/core/LocAdapterBase.h index 5f4660b..af25138 100644 --- a/gps/core/LocAdapterBase.h +++ b/gps/core/LocAdapterBase.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014,2016 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -78,12 +78,22 @@ public: mLocApi->updateEvtMask(); } + inline bool isFeatureSupported(uint8_t featureVal) { + return mLocApi->isFeatureSupported(featureVal); + } + // This will be overridden by the individual adapters // if necessary. - inline virtual void setUlpProxy(UlpProxyBase* ulp) {} + inline virtual void setUlpProxy(UlpProxyBase* ulp) { + + (void)ulp; + } virtual void handleEngineUpEvent(); virtual void handleEngineDownEvent(); - inline virtual void setPositionModeInt(LocPosMode& posMode) {} + inline virtual void setPositionModeInt(LocPosMode& posMode) { + + (void)posMode; + } virtual void startFixInt() {} virtual void stopFixInt() {} virtual void getZppInt() {} @@ -95,6 +105,8 @@ public: virtual void reportSv(GnssSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt); + virtual void reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet); + virtual void reportSvPolynomial(GnssSvPolynomial &svPolynomial); virtual void reportStatus(GpsStatusValue status); virtual void reportNmea(const char* nmea, int length); virtual bool reportXtraServer(const char* url1, const char* url2, @@ -111,7 +123,7 @@ public: const void* data); inline virtual bool isInSession() { return false; } ContextBase* getContext() const { return mContext; } - virtual void reportGpsMeasurementData(GpsData &gpsMeasurementData); + virtual void reportGnssMeasurementData(GnssData &gnssMeasurementData); }; } // namespace loc_core diff --git a/gps/core/LocAdapterProxyBase.h b/gps/core/LocAdapterProxyBase.h index 1ddcca4..82cba6b 100644 --- a/gps/core/LocAdapterProxyBase.h +++ b/gps/core/LocAdapterProxyBase.h @@ -46,21 +46,26 @@ protected: inline virtual ~LocAdapterProxyBase() { delete mLocAdapterBase; } - ContextBase* getContext() const { - return mLocAdapterBase->getContext(); - } inline void updateEvtMask(LOC_API_ADAPTER_EVENT_MASK_T event, loc_registration_mask_status isEnabled) { mLocAdapterBase->updateEvtMask(event,isEnabled); } 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) { + + (void)location; + (void)locationExtended; + (void)status; + (void)loc_technology_mask; return false; } }; diff --git a/gps/core/LocApiBase.cpp b/gps/core/LocApiBase.cpp index dcd35fe..fdfc537 100644 --- a/gps/core/LocApiBase.cpp +++ b/gps/core/LocApiBase.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014,2016 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include namespace loc_core { @@ -132,6 +132,7 @@ LocApiBase::LocApiBase(const MsgTask* msgTask, mMask(0), mSupportedMsg(0), mContext(context) { memset(mLocAdapters, 0, sizeof(mLocAdapters)); + memset(mFeaturesSupported, 0, sizeof(mFeaturesSupported)); } LOC_API_ADAPTER_EVENT_MASK_T LocApiBase::getEvtMask() @@ -257,25 +258,50 @@ void LocApiBase::reportSv(GnssSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt) { + const char* constellationString[] = { "Unknown", "GPS", "SBAS", "GLONASS", + "QZSS", "BEIDOU", "GALILEO" }; + // print the SV info before delivering - LOC_LOGV("num sv: %d\n ephemeris mask: %dxn almanac mask: %x\n gps/glo/bds in use" - " mask: %x/%x/%x\n sv: prn snr elevation azimuth", - svStatus.num_svs, svStatus.ephemeris_mask, - svStatus.almanac_mask, svStatus.gps_used_in_fix_mask, - svStatus.glo_used_in_fix_mask, svStatus.bds_used_in_fix_mask); - for (int i = 0; i < svStatus.num_svs && i < GPS_MAX_SVS; i++) { - LOC_LOGV(" %d: %d %f %f %f", - i, - svStatus.sv_list[i].prn, - svStatus.sv_list[i].snr, - svStatus.sv_list[i].elevation, - svStatus.sv_list[i].azimuth); + 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 < GNSS_MAX_SVS; i++) { + if (svStatus.gnss_sv_list[i].constellation > + sizeof(constellationString) / sizeof(constellationString[0]) - 1) { + svStatus.gnss_sv_list[i].constellation = 0; + } + 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); } // loop through adapters, and deliver to all adapters. TO_ALL_LOCADAPTERS( mLocAdapters[i]->reportSv(svStatus, - locationExtended, - svExt) + locationExtended, + svExt) + ); +} + +void LocApiBase::reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet) +{ + // loop through adapters, and deliver to all adapters. + TO_ALL_LOCADAPTERS( + mLocAdapters[i]->reportSvMeasurement(svMeasurementSet) + ); +} + +void LocApiBase::reportSvPolynomial(GnssSvPolynomial &svPolynomial) +{ + // loop through adapters, and deliver to all adapters. + TO_ALL_LOCADAPTERS( + mLocAdapters[i]->reportSvPolynomial(svPolynomial) ); } @@ -358,16 +384,21 @@ void LocApiBase::saveSupportedMsgList(uint64_t supportedMsgList) mSupportedMsg = supportedMsgList; } +void LocApiBase::saveSupportedFeatureList(uint8_t *featureList) +{ + memcpy((void *)mFeaturesSupported, (void *)featureList, sizeof(mFeaturesSupported)); +} + void* LocApiBase :: getSibling() DEFAULT_IMPL(NULL) LocApiProxyBase* LocApiBase :: getLocApiProxy() DEFAULT_IMPL(NULL) -void LocApiBase::reportGpsMeasurementData(GpsData &gpsMeasurementData) +void LocApiBase::reportGnssMeasurementData(GnssData &gnssMeasurementData) { // loop through adapters, and deliver to all adapters. - TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGpsMeasurementData(gpsMeasurementData)); + TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssMeasurementData(gnssMeasurementData)); } enum loc_api_adapter_err LocApiBase:: @@ -445,6 +476,10 @@ enum loc_api_adapter_err LocApiBase:: setSUPLVersion(uint32_t version) DEFAULT_IMPL(LOC_API_ADAPTER_ERR_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) @@ -481,12 +516,12 @@ enum loc_api_adapter_err LocApiBase:: DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) enum loc_api_adapter_err LocApiBase:: - setExtPowerConfig(int isBatteryCharging) + setAGLONASSProtocol(unsigned long aGlonassProtocol) DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) enum loc_api_adapter_err LocApiBase:: - setAGLONASSProtocol(unsigned long aGlonassProtocol) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + setLPPeProtocol(unsigned long lppeCP, unsigned long lppeUP) + DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) enum loc_api_adapter_err LocApiBase:: getWwanZppFix(GpsLocation& zppLoc) @@ -541,13 +576,18 @@ enum loc_api_adapter_err LocApiBase:: setXtraVersionCheck(enum xtra_version_check check) DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) -int LocApiBase:: - updateRegistrationMask(LOC_API_ADAPTER_EVENT_MASK_T event, - loc_registration_mask_status isEnabled) -DEFAULT_IMPL(-1) - bool LocApiBase:: gnssConstellationConfig() DEFAULT_IMPL(false) +bool LocApiBase:: + isFeatureSupported(uint8_t featureVal) +{ + uint8_t arrayIndex = featureVal >> 3; + uint8_t bitPos = featureVal & 7; + + if (arrayIndex >= MAX_FEATURE_LENGTH) return false; + return ((mFeaturesSupported[arrayIndex] >> bitPos ) & 0x1); +} + } // namespace loc_core diff --git a/gps/core/LocApiBase.h b/gps/core/LocApiBase.h index b1c3d30..066695c 100644 --- a/gps/core/LocApiBase.h +++ b/gps/core/LocApiBase.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014, 2016 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -33,7 +33,7 @@ #include #include #include -#include +#include namespace loc_core { class ContextBase; @@ -44,6 +44,7 @@ int decodeAddress(char *addr_string, int string_size, const char *data, int data_size); #define MAX_ADAPTERS 10 +#define MAX_FEATURE_LENGTH 100 #define TO_ALL_ADAPTERS(adapters, call) \ for (int i = 0; i < MAX_ADAPTERS && NULL != (adapters)[i]; i++) { \ @@ -81,6 +82,7 @@ class LocApiBase { ContextBase *mContext; LocAdapterBase* mLocAdapters[MAX_ADAPTERS]; uint64_t mSupportedMsg; + uint8_t mFeaturesSupported[MAX_FEATURE_LENGTH]; protected: virtual enum loc_api_adapter_err @@ -116,6 +118,8 @@ public: void reportSv(GnssSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt); + void reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet); + void reportSvPolynomial(GnssSvPolynomial &svPolynomial); void reportStatus(GpsStatusValue status); void reportNmea(const char* nmea, int length); void reportXtraServer(const char* url1, const char* url2, @@ -130,7 +134,8 @@ public: void reportDataCallClosed(); void requestNiNotify(GpsNiNotification ¬ify, const void* data); void saveSupportedMsgList(uint64_t supportedMsgList); - void reportGpsMeasurementData(GpsData &gpsMeasurementData); + void reportGnssMeasurementData(GnssData &gnssMeasurementData); + void saveSupportedFeatureList(uint8_t *featureList); // downward calls // All below functions are to be defined by adapter specific modules: @@ -171,6 +176,8 @@ public: informNiResponse(GpsUserResponseType userResponse, const void* passThroughData); virtual enum loc_api_adapter_err setSUPLVersion(uint32_t version); + virtual enum loc_api_adapter_err + setNMEATypes (uint32_t typesMask); virtual enum loc_api_adapter_err setLPPConfig(uint32_t profile); virtual enum loc_api_adapter_err @@ -197,10 +204,10 @@ public: int gyroSamplesPerBatchHigh, int gyroBatchesPerSecHigh, int algorithmConfig); - virtual enum loc_api_adapter_err - setExtPowerConfig(int isBatteryCharging); virtual enum loc_api_adapter_err setAGLONASSProtocol(unsigned long aGlonassProtocol); + virtual enum loc_api_adapter_err + setLPPeProtocol(unsigned long lppeCP, unsigned long lppeUP); virtual enum loc_api_adapter_err getWwanZppFix(GpsLocation & zppLoc); virtual enum loc_api_adapter_err @@ -214,9 +221,15 @@ public: virtual void installAGpsCert(const DerEncodedCertificate* pData, size_t length, uint32_t slotBitMask); - inline virtual void setInSession(bool inSession) {} + inline virtual void setInSession(bool inSession) { + + (void)inSession; + } inline bool isMessageSupported (LocCheckingMessagesID msgID) const { - if (msgID > (sizeof(mSupportedMsg) << 3)) { + + // confirm if msgID is not larger than the number of bits in + // mSupportedMsg + if ((uint64_t)msgID > (sizeof(mSupportedMsg) << 3)) { return false; } else { uint32_t messageChecker = 1 << msgID; @@ -241,15 +254,15 @@ public: virtual enum loc_api_adapter_err setXtraVersionCheck(enum xtra_version_check check); - /* - Update gps reporting events - */ - virtual int updateRegistrationMask(LOC_API_ADAPTER_EVENT_MASK_T event, - loc_registration_mask_status isEnabled); /* Check if the modem support the service */ virtual bool gnssConstellationConfig(); + + /* + Check if a feature is supported + */ + bool isFeatureSupported(uint8_t featureVal); }; typedef LocApiBase* (getLocApi_t)(const MsgTask* msgTask, diff --git a/gps/core/LocDualContext.cpp b/gps/core/LocDualContext.cpp index 578421c..74b2903 100644 --- a/gps/core/LocDualContext.cpp +++ b/gps/core/LocDualContext.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include namespace loc_core { @@ -59,7 +59,11 @@ ContextBase* LocDualContext::mBgContext = NULL; ContextBase* LocDualContext::mInjectContext = NULL; // the name must be shorter than 15 chars const char* LocDualContext::mLocationHalName = "Loc_hal_worker"; +#ifndef USE_GLIB const char* LocDualContext::mLBSLibName = "liblbs_core.so"; +#else +const char* LocDualContext::mLBSLibName = "liblbs_core.so.1"; +#endif pthread_mutex_t LocDualContext::mGetLocContextMutex = PTHREAD_MUTEX_INITIALIZER; diff --git a/gps/core/Makefile.am b/gps/core/Makefile.am new file mode 100644 index 0000000..341153a --- /dev/null +++ b/gps/core/Makefile.am @@ -0,0 +1,46 @@ +AM_CFLAGS = -I./ \ + -I../utils \ + $(LOCPLA_CFLAGS) \ + -I$(WORKSPACE)/gps-noship/flp \ + -D__func__=__PRETTY_FUNCTION__ \ + -fno-short-enums + +libloc_core_la_h_sources = \ + LocApiBase.h \ + LocAdapterBase.h \ + ContextBase.h \ + LocDualContext.h \ + LBSProxyBase.h \ + UlpProxyBase.h \ + gps_extended_c.h \ + gps_extended.h \ + loc_core_log.h \ + LocAdapterProxyBase.h + +libloc_core_la_c_sources = \ + LocApiBase.cpp \ + LocAdapterBase.cpp \ + ContextBase.cpp \ + LocDualContext.cpp \ + loc_core_log.cpp + +library_includedir = $(pkgincludedir)/core + +library_include_HEADERS = $(libloc_core_la_h_sources) + +libloc_core_la_SOURCES = $(libloc_core_la_c_sources) + +if USE_GLIB +libloc_core_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@ +libloc_core_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 +libloc_core_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@ +else +libloc_core_la_CFLAGS = $(AM_CFLAGS) +libloc_core_la_LDFLAGS = -lpthread -shared -version-info 1:0:0 +libloc_core_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) +endif + +libloc_core_la_LIBADD = -lstdc++ -ldl $(LOCPLA_LIBS) ../utils/libgps_utils_so.la + +#Create and Install libraries +lib_LTLIBRARIES = libloc_core.la diff --git a/gps/core/UlpProxyBase.h b/gps/core/UlpProxyBase.h index efcf98a..2e92bed 100644 --- a/gps/core/UlpProxyBase.h +++ b/gps/core/UlpProxyBase.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. +/* Copyright (c) 2013-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 @@ -59,26 +59,62 @@ public: void* locationExt, 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(GnssSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt) { + (void)svStatus; + (void)locationExtended; + (void)svExt; return false; } + inline virtual bool reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet) { + (void)svMeasurementSet; + return false; + } + + inline virtual bool reportSvPolynomial(GnssSvPolynomial &svPolynomial) + { + (void)svPolynomial; + return false; + } inline virtual bool reportStatus(GpsStatusValue status) { + + (void)status; return false; } - inline virtual void setAdapter(LocAdapterBase* adapter) {} - inline virtual void setCapabilities(unsigned long capabilities) {} + inline virtual void setAdapter(LocAdapterBase* adapter) { + + (void)adapter; + } + inline virtual void setCapabilities(unsigned long capabilities) { + + (void)capabilities; + } inline virtual bool reportBatchingSession(FlpExtBatchOptions &options, bool active) { + + (void)options; + (void)active; return false; } inline virtual bool reportPositions(const struct FlpExtLocation_s* locations, int32_t number_of_locations) { + (void)locations; + (void)number_of_locations; return false; } + inline virtual bool reportDeleteAidingData(GpsAidingData aidingData) + { + (void)aidingData; + return false; + } }; } // namespace loc_core diff --git a/gps/core/gps_extended.h b/gps/core/gps_extended.h index 88b0415..9460d4e 100644 --- a/gps/core/gps_extended.h +++ b/gps/core/gps_extended.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2013, The Linux Foundation. All rights reserved. +/* Copyright (c) 2013-2015, 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,11 +29,19 @@ #ifndef GPS_EXTENDED_H #define GPS_EXTENDED_H +#include +/** + * @file + * @brief C++ declarations for GPS types + */ + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -#include +#if defined(USE_GLIB) || defined(OFF_TARGET) +#include +#endif struct LocPosMode { @@ -42,14 +50,17 @@ struct LocPosMode 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, uint32_t gap, uint32_t accu, uint32_t time, - const char* cred, const char* prov) : + bool sp, const char* cred, const char* prov) : mode(m), recurrence(recr), - min_interval(gap < MIN_POSSIBLE_FIX_INTERVAL ? MIN_POSSIBLE_FIX_INTERVAL : gap), - preferred_accuracy(accu), preferred_time(time) { + min_interval(gap < GPS_MIN_POSSIBLE_FIX_INTERVAL_MS ? + GPS_MIN_POSSIBLE_FIX_INTERVAL_MS : gap), + preferred_accuracy(accu), preferred_time(time), + share_position(sp) { memset(credentials, 0, sizeof(credentials)); memset(provider, 0, sizeof(provider)); if (NULL != cred) { @@ -63,8 +74,9 @@ struct LocPosMode inline LocPosMode() : mode(LOC_POSITION_MODE_MS_BASED), recurrence(GPS_POSITION_RECURRENCE_PERIODIC), - min_interval(MIN_POSSIBLE_FIX_INTERVAL), - preferred_accuracy(50), preferred_time(120000) { + min_interval(GPS_DEFAULT_FIX_INTERVAL_MS), + preferred_accuracy(50), preferred_time(120000), + share_position(true) { memset(credentials, 0, sizeof(credentials)); memset(provider, 0, sizeof(provider)); } diff --git a/gps/core/gps_extended_c.h b/gps/core/gps_extended_c.h index 75ee17e..e16d758 100644 --- a/gps/core/gps_extended_c.h +++ b/gps/core/gps_extended_c.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. +/* Copyright (c) 2013-2015, 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 @@ -29,15 +29,21 @@ #ifndef GPS_EXTENDED_C_H #define GPS_EXTENDED_C_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include #include #include #include #include +#include + +/** + * @file + * @brief C++ declarations for GPS types + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ /** Location has valid source information. */ #define LOCATION_HAS_SOURCE_INFO 0x0020 @@ -68,6 +74,8 @@ extern "C" { #define ULP_LOCATION_IS_FROM_NLP 0x0020 /** Position is from PIP */ #define ULP_LOCATION_IS_FROM_PIP 0x0040 +/** Position is from external DR solution*/ +#define ULP_LOCATION_IS_FROM_EXT_DR 0X0080 #define ULP_MIN_INTERVAL_INVALID 0xffffffff @@ -82,6 +90,11 @@ enum loc_registration_mask_status { LOC_REGISTRATION_MASK_DISABLED }; +typedef enum { + LOC_SUPPORTED_FEATURE_ODCPI_2_V02 = 0, /**< Support ODCPI version 2 feature */ + LOC_SUPPORTED_FEATURE_WIFI_AP_DATA_INJECT_2_V02 /**< Support Wifi AP data inject version 2 feature */ +} loc_supported_feature_enum; + typedef struct { /** set to sizeof(UlpLocation) */ size_t size; @@ -165,14 +178,14 @@ typedef struct { } AGpsExtCallbacks; +typedef void (*loc_ni_notify_callback)(GpsNiNotification *notification, bool esEnalbed); /** GPS NI callback structure. */ typedef struct { /** * Sends the notification request from HAL to GPSLocationProvider. */ - gps_ni_notify_callback notify_cb; - gps_create_thread create_thread_cb; + loc_ni_notify_callback notify_cb; } GpsNiExtCallbacks; typedef enum loc_server_type { @@ -195,7 +208,24 @@ typedef enum loc_position_mode_type { } LocPositionMode; -#define MIN_POSSIBLE_FIX_INTERVAL 1000 /* msec */ +/** + * @brief Minimum allowed value for fix interval. + * + * This value is a sanity limit in GPS framework. The hardware has own internal + * limits that may not match this value + * + * @sa GPS_DEFAULT_FIX_INTERVAL_MS + */ + +#define GPS_MIN_POSSIBLE_FIX_INTERVAL_MS 100 +/** + * @brief Default value for fix interval. + * + * This value is used by default whenever appropriate. + * + * @sa GPS_MIN_POSSIBLE_FIX_INTERVAL_MS + */ +#define GPS_DEFAULT_FIX_INTERVAL_MS 1000 /** Flags to indicate which values are valid in a GpsLocationExtended. */ typedef uint16_t GpsLocationExtendedFlags; @@ -217,6 +247,12 @@ typedef uint16_t GpsLocationExtendedFlags; #define GPS_LOCATION_EXTENDED_HAS_HOR_RELIABILITY 0x0080 /** GpsLocationExtended has valid vertical reliability */ #define GPS_LOCATION_EXTENDED_HAS_VERT_RELIABILITY 0x0100 +/** GpsLocationExtended has valid Horizontal Elliptical Uncertainty (Semi-Major Axis) */ +#define GPS_LOCATION_EXTENDED_HAS_HOR_ELIP_UNC_MAJOR 0x0200 +/** GpsLocationExtended has valid Horizontal Elliptical Uncertainty (Semi-Minor Axis) */ +#define GPS_LOCATION_EXTENDED_HAS_HOR_ELIP_UNC_MINOR 0x0400 +/** GpsLocationExtended has valid Elliptical Horizontal Uncertainty Azimuth */ +#define GPS_LOCATION_EXTENDED_HAS_HOR_ELIP_UNC_AZIMUTH 0x0800 typedef enum { LOC_RELIABILITY_NOT_SET = 0, @@ -226,6 +262,13 @@ typedef enum { LOC_RELIABILITY_HIGH = 4 }LocReliability; +typedef struct { + struct timespec apTimeStamp; + /*boottime received from pps-ktimer*/ + float apTimeStampUncertaintyMs; + /* timestamp uncertainty in milli seconds */ +}Gnss_ApTimeStampStructType; + /** Represents gps location extended. */ typedef struct { /** set to sizeof(GpsLocationExtended) */ @@ -252,48 +295,15 @@ typedef struct { LocReliability horizontal_reliability; /** vertical reliability. */ LocReliability vertical_reliability; -} GpsLocationExtended; - -/** Represents SV status. */ -typedef struct { - /** set to sizeof(GnssSvStatus) */ - size_t size; - - /** Number of SVs currently visible. */ - int num_svs; - - /** Contains an array of SV information. */ - GpsSvInfo sv_list[GPS_MAX_SVS]; - - /** Represents a bit mask indicating which SVs - * have ephemeris data. - */ - uint32_t ephemeris_mask; - - /** Represents a bit mask indicating which SVs - * have almanac data. - */ - uint32_t almanac_mask; - - /** - * Represents a bit mask indicating which GPS SVs - * were used for computing the most recent position fix. - */ - uint32_t gps_used_in_fix_mask; - - /** - * Represents a bit mask indicating which GLONASS SVs - * were used for computing the most recent position fix. - */ - uint32_t glo_used_in_fix_mask; + /* Horizontal Elliptical Uncertainty (Semi-Major Axis) */ + float horUncEllipseSemiMajor; + /* Horizontal Elliptical Uncertainty (Semi-Minor Axis) */ + float horUncEllipseSemiMinor; + /* Elliptical Horizontal Uncertainty Azimuth */ + float horUncEllipseOrientAzimuth; - /** - * Represents a bit mask indicating which BDS SVs - * were used for computing the most recent position fix. - */ - uint64_t bds_used_in_fix_mask; - -} GnssSvStatus; + Gnss_ApTimeStampStructType timeStamp; +} GpsLocationExtended; enum loc_sess_status { LOC_SESS_SUCCESS, @@ -312,6 +322,34 @@ typedef uint32_t LocPosTechMask; #define LOC_POS_TECH_MASK_AFLT ((LocPosTechMask)0x00000040) #define LOC_POS_TECH_MASK_HYBRID ((LocPosTechMask)0x00000080) +// Nmea sentence types mask +typedef uint32_t NmeaSentenceTypesMask; +#define LOC_NMEA_MASK_GGA_V02 ((NmeaSentenceTypesMask)0x00000001) /**< Enable GGA type */ +#define LOC_NMEA_MASK_RMC_V02 ((NmeaSentenceTypesMask)0x00000002) /**< Enable RMC type */ +#define LOC_NMEA_MASK_GSV_V02 ((NmeaSentenceTypesMask)0x00000004) /**< Enable GSV type */ +#define LOC_NMEA_MASK_GSA_V02 ((NmeaSentenceTypesMask)0x00000008) /**< Enable GSA type */ +#define LOC_NMEA_MASK_VTG_V02 ((NmeaSentenceTypesMask)0x00000010) /**< Enable VTG type */ +#define LOC_NMEA_MASK_PQXFI_V02 ((NmeaSentenceTypesMask)0x00000020) /**< Enable PQXFI type */ +#define LOC_NMEA_MASK_PSTIS_V02 ((NmeaSentenceTypesMask)0x00000040) /**< Enable PSTIS type */ +#define LOC_NMEA_MASK_GLGSV_V02 ((NmeaSentenceTypesMask)0x00000080) /**< Enable GLGSV type */ +#define LOC_NMEA_MASK_GNGSA_V02 ((NmeaSentenceTypesMask)0x00000100) /**< Enable GNGSA type */ +#define LOC_NMEA_MASK_GNGNS_V02 ((NmeaSentenceTypesMask)0x00000200) /**< Enable GNGNS type */ +#define LOC_NMEA_MASK_GARMC_V02 ((NmeaSentenceTypesMask)0x00000400) /**< Enable GARMC type */ +#define LOC_NMEA_MASK_GAGSV_V02 ((NmeaSentenceTypesMask)0x00000800) /**< Enable GAGSV type */ +#define LOC_NMEA_MASK_GAGSA_V02 ((NmeaSentenceTypesMask)0x00001000) /**< Enable GAGSA type */ +#define LOC_NMEA_MASK_GAVTG_V02 ((NmeaSentenceTypesMask)0x00002000) /**< Enable GAVTG type */ +#define LOC_NMEA_MASK_GAGGA_V02 ((NmeaSentenceTypesMask)0x00004000) /**< Enable GAGGA type */ +#define LOC_NMEA_MASK_PQGSA_V02 ((NmeaSentenceTypesMask)0x00008000) /**< Enable PQGSA type */ +#define LOC_NMEA_MASK_PQGSV_V02 ((NmeaSentenceTypesMask)0x00010000) /**< Enable PQGSV type */ +#define LOC_NMEA_ALL_SUPPORTED_MASK (LOC_NMEA_MASK_GGA_V02 | LOC_NMEA_MASK_RMC_V02 | \ + LOC_NMEA_MASK_GSV_V02 | LOC_NMEA_MASK_GSA_V02 | LOC_NMEA_MASK_VTG_V02 | \ + LOC_NMEA_MASK_PQXFI_V02 | LOC_NMEA_MASK_PSTIS_V02 | LOC_NMEA_MASK_GLGSV_V02 | \ + LOC_NMEA_MASK_GNGSA_V02 | LOC_NMEA_MASK_GNGNS_V02 | LOC_NMEA_MASK_GARMC_V02 | \ + LOC_NMEA_MASK_GAGSV_V02 | LOC_NMEA_MASK_GAGSA_V02 | LOC_NMEA_MASK_GAVTG_V02 | \ + LOC_NMEA_MASK_GAGGA_V02 | LOC_NMEA_MASK_PQGSA_V02 | LOC_NMEA_MASK_PQGSV_V02 ) + + + typedef enum { LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC = 0, LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM, @@ -374,6 +412,8 @@ enum loc_api_adapter_event_index { LOC_API_ADAPTER_BATCH_FULL, // Batching on full LOC_API_ADAPTER_BATCHED_POSITION_REPORT, // Batching on fix LOC_API_ADAPTER_BATCHED_GENFENCE_BREACH_REPORT, // + LOC_API_ADAPTER_GNSS_MEASUREMENT_REPORT, //GNSS Measurement Report + LOC_API_ADAPTER_GNSS_SV_POLYNOMIAL_REPORT, //GNSS SV Polynomial Report LOC_API_ADAPTER_GDT_UPLOAD_BEGIN_REQ, // GDT upload start request LOC_API_ADAPTER_GDT_UPLOAD_END_REQ, // GDT upload end request LOC_API_ADAPTER_GNSS_MEASUREMENT, // GNSS Measurement report @@ -404,6 +444,8 @@ enum loc_api_adapter_event_index { #define LOC_API_ADAPTER_BIT_REQUEST_WIFI_AP_DATA (1< -#include #include +#include void LocPosMode::logv() const { -- cgit v1.2.3