diff options
author | Kevin Tang <zhikait@codeaurora.org> | 2019-03-14 17:37:59 -0700 |
---|---|---|
committer | Kevin Tang <zhikait@codeaurora.org> | 2019-03-14 17:43:05 -0700 |
commit | 5a9cc5ae728f73804dde2d3f855ebb387ee9ec0e (patch) | |
tree | 11b3c328e201d8d1362323e062c9a49a80f1ddda /location | |
parent | 1b6ad38fb95b904d30ec870efcbc8f46e81b76ba (diff) | |
parent | 6b687ef48e134b153a256cb0c8f05860722de72e (diff) | |
download | gps-5a9cc5ae728f73804dde2d3f855ebb387ee9ec0e.tar.gz |
Merge remote-tracking branch 'quic/location.lnx.4.0' into HEAD
CRs-fixed: 2414738
Change-Id: Ic8d1cd5bb37d1ad26c2749e46be279942e28ac05
Diffstat (limited to 'location')
-rw-r--r-- | location/LocationAPI.cpp | 22 | ||||
-rw-r--r-- | location/LocationAPI.h | 2 | ||||
-rw-r--r-- | location/LocationDataTypes.h | 113 |
3 files changed, 83 insertions, 54 deletions
diff --git a/location/LocationAPI.cpp b/location/LocationAPI.cpp index 4d859b3..e9f2ee4 100644 --- a/location/LocationAPI.cpp +++ b/location/LocationAPI.cpp @@ -37,13 +37,6 @@ typedef void* (getLocationInterface)(); -typedef uint16_t LocationAdapterTypeMask; -typedef enum { - LOCATION_ADAPTER_GNSS_TYPE_BIT = (1<<0), // adapter type is GNSS - LOCATION_ADAPTER_FLP_TYPE_BIT = (1<<1), // adapter type is FLP - LOCATION_ADAPTER_GEOFENCE_TYPE_BIT = (1<<2) // adapter type is geo fence -} LocationAdapterTypeBits; - typedef struct { // bit mask of the adpaters that we need to wait for the removeClientCompleteCallback // before we invoke the registered locationApiDestroyCompleteCallback @@ -129,14 +122,13 @@ static void* loadLocationInterface(const char* library, const char* name) } } -void onRemoveClientCompleteCb ( - LocationAPI* client, LocationAdapterTypeMask adapterType) +void LocationAPI::onRemoveClientCompleteCb (LocationAdapterTypeMask adapterType) { bool invokeCallback = false; locationApiDestroyCompleteCallback destroyCompleteCb; LOC_LOGd("adatper type %x", adapterType); pthread_mutex_lock(&gDataMutex); - auto it = gData.destroyClientData.find(client); + auto it = gData.destroyClientData.find(this); if (it != gData.destroyClientData.end()) { it->second.waitAdapterMask &= ~adapterType; if (it->second.waitAdapterMask == 0) { @@ -151,22 +143,24 @@ void onRemoveClientCompleteCb ( LOC_LOGd("invoke client destroy cb"); (destroyCompleteCb) (); LOC_LOGd("finish invoke client destroy cb"); + + delete this; } } void onGnssRemoveClientCompleteCb (LocationAPI* client) { - onRemoveClientCompleteCb (client, LOCATION_ADAPTER_GNSS_TYPE_BIT); + client->onRemoveClientCompleteCb (LOCATION_ADAPTER_GNSS_TYPE_BIT); } void onFlpRemoveClientCompleteCb (LocationAPI* client) { - onRemoveClientCompleteCb (client, LOCATION_ADAPTER_FLP_TYPE_BIT); + client->onRemoveClientCompleteCb (LOCATION_ADAPTER_FLP_TYPE_BIT); } void onGeofenceRemoveClientCompleteCb (LocationAPI* client) { - onRemoveClientCompleteCb (client, LOCATION_ADAPTER_GEOFENCE_TYPE_BIT); + client->onRemoveClientCompleteCb (LOCATION_ADAPTER_GEOFENCE_TYPE_BIT); } LocationAPI* @@ -310,6 +304,7 @@ LocationAPI::destroy(locationApiDestroyCompleteCallback destroyCompleteCb) pthread_mutex_unlock(&gDataMutex); if (invokeDestroyCb == true) { (destroyCompleteCb) (); + delete this; } } @@ -321,6 +316,7 @@ LocationAPI::LocationAPI() // private destructor LocationAPI::~LocationAPI() { + LOC_LOGD("LOCATION API DESTRUCTOR"); } void diff --git a/location/LocationAPI.h b/location/LocationAPI.h index c270ef4..6f5987c 100644 --- a/location/LocationAPI.h +++ b/location/LocationAPI.h @@ -52,6 +52,8 @@ public: */ void destroy(locationApiDestroyCompleteCallback destroyCompleteCb=nullptr); + void onRemoveClientCompleteCb (LocationAdapterTypeMask adapterType); + /* updates/changes the callbacks that will be called. mandatory callbacks must be present for callbacks to be successfully updated no return value */ diff --git a/location/LocationDataTypes.h b/location/LocationDataTypes.h index 8108ffc..5f21e0b 100644 --- a/location/LocationDataTypes.h +++ b/location/LocationDataTypes.h @@ -514,6 +514,22 @@ typedef enum { GNSS_AIDING_DATA_SV_TYPE_GALILEO_BIT = (1<<4), } GnssAidingDataSvTypeBits; +/* Gnss constellation type mask */ +typedef uint16_t GnssConstellationTypeMask; +typedef enum { + GNSS_CONSTELLATION_TYPE_GPS_BIT = (1<<0), + GNSS_CONSTELLATION_TYPE_GLONASS_BIT = (1<<1), + GNSS_CONSTELLATION_TYPE_QZSS_BIT = (1<<2), + GNSS_CONSTELLATION_TYPE_BEIDOU_BIT = (1<<3), + GNSS_CONSTELLATION_TYPE_GALILEO_BIT = (1<<4), + GNSS_CONSTELLATION_TYPE_SBAS_BIT = (1<<5) +} GnssConstellationTypeBits; + +#define GNSS_CONSTELLATION_TYPE_MASK_ALL\ + (GNSS_CONSTELLATION_TYPE_GPS_BIT | GNSS_CONSTELLATION_TYPE_GLONASS_BIT |\ + GNSS_CONSTELLATION_TYPE_QZSS_BIT | GNSS_CONSTELLATION_TYPE_BEIDOU_BIT |\ + GNSS_CONSTELLATION_TYPE_GALILEO_BIT | GNSS_CONSTELLATION_TYPE_SBAS_BIT) + /** GNSS Signal Type and RF Band */ typedef uint32_t GnssSignalTypeMask; typedef enum { @@ -555,21 +571,29 @@ typedef enum { GNSS_SIGNAL_SBAS_L1 = (1<<17) } GnssSignalTypeBits; +#define GNSS_SIGNAL_TYPE_MASK_ALL\ + (GNSS_SIGNAL_GPS_L1CA | GNSS_SIGNAL_GPS_L1C | GNSS_SIGNAL_GPS_L2 |\ + GNSS_SIGNAL_GPS_L5| GNSS_SIGNAL_GLONASS_G1 | GNSS_SIGNAL_GLONASS_G2 |\ + GNSS_SIGNAL_GALILEO_E1 | GNSS_SIGNAL_GALILEO_E5A | GNSS_SIGNAL_GALILEO_E5B |\ + GNSS_SIGNAL_BEIDOU_B1I | GNSS_SIGNAL_BEIDOU_B1C | GNSS_SIGNAL_BEIDOU_B2I|\ + GNSS_SIGNAL_BEIDOU_B2AI | GNSS_SIGNAL_QZSS_L1CA | GNSS_SIGNAL_QZSS_L1S |\ + GNSS_SIGNAL_QZSS_L2| GNSS_SIGNAL_QZSS_L5 | GNSS_SIGNAL_SBAS_L1) + typedef enum { + GNSS_LOC_SV_SYSTEM_UNKNOWN = 0, + /** unknown sv system. */ GNSS_LOC_SV_SYSTEM_GPS = 1, /**< GPS satellite. */ GNSS_LOC_SV_SYSTEM_GALILEO = 2, /**< GALILEO satellite. */ GNSS_LOC_SV_SYSTEM_SBAS = 3, /**< SBAS satellite. */ - GNSS_LOC_SV_SYSTEM_COMPASS = 4, - /**< COMPASS satellite. */ - GNSS_LOC_SV_SYSTEM_GLONASS = 5, + GNSS_LOC_SV_SYSTEM_GLONASS = 4, /**< GLONASS satellite. */ - GNSS_LOC_SV_SYSTEM_BDS = 6, + GNSS_LOC_SV_SYSTEM_BDS = 5, /**< BDS satellite. */ - GNSS_LOC_SV_SYSTEM_QZSS = 7 + GNSS_LOC_SV_SYSTEM_QZSS = 6 /**< QZSS satellite. */ } Gnss_LocSvSystemEnumType; @@ -616,7 +640,7 @@ typedef enum { typedef uint32_t GnssGloTimeStructTypeFlags; typedef enum { GNSS_CLO_DAYS_VALID = (1 << 0), - GNSS_GLOS_MSEC_VALID = (1 << 1), + GNSS_GLO_MSEC_VALID = (1 << 1), GNSS_GLO_CLK_TIME_BIAS_VALID = (1 << 2), GNSS_GLO_CLK_TIME_BIAS_UNC_VALID = (1 << 3), GNSS_GLO_REF_FCOUNT_VALID = (1 << 4), @@ -650,7 +674,7 @@ typedef struct { } GnssAidingData; typedef struct { - size_t size; // set to sizeof(Location) + uint32_t size; // set to sizeof(Location) LocationFlagsMask flags; // bitwise OR of LocationFlagsBits to mark which params are valid uint64_t timestamp; // UTC timestamp for location fix, milliseconds since January 1, 1970 double latitude; // in degrees @@ -667,7 +691,7 @@ typedef struct { } Location; struct LocationOptions { - size_t size; // set to sizeof(LocationOptions) + uint32_t size; // set to sizeof(LocationOptions) uint32_t minInterval; // in milliseconds uint32_t minDistance; // in meters. if minDistance > 0, gnssSvCallback/gnssNmeaCallback/ // gnssMeasurementsCallback may not be called @@ -694,7 +718,7 @@ struct TrackingOptions : LocationOptions { inline TrackingOptions() : LocationOptions(), powerMode(GNSS_POWER_MODE_INVALID), tbm(0) {} - inline TrackingOptions(size_t s, GnssPowerMode m, uint32_t t) : + inline TrackingOptions(uint32_t s, GnssPowerMode m, uint32_t t) : LocationOptions(), powerMode(m), tbm(t) { LocationOptions::size = s; } inline TrackingOptions(const LocationOptions& options) : LocationOptions(options), powerMode(GNSS_POWER_MODE_INVALID), tbm(0) {} @@ -718,7 +742,7 @@ struct BatchingOptions : LocationOptions { inline BatchingOptions() : LocationOptions(), batchingMode(BATCHING_MODE_ROUTINE) {} - inline BatchingOptions(size_t s, BatchingMode m) : + inline BatchingOptions(uint32_t s, BatchingMode m) : LocationOptions(), batchingMode(m) { LocationOptions::size = s; } inline BatchingOptions(const LocationOptions& options) : LocationOptions(options), batchingMode(BATCHING_MODE_ROUTINE) {} @@ -730,27 +754,27 @@ struct BatchingOptions : LocationOptions { }; typedef struct { - size_t size; + uint32_t size; BatchingStatus batchingStatus; } BatchingStatusInfo; typedef struct { - size_t size; // set to sizeof(GeofenceOption) + uint32_t size; // set to sizeof(GeofenceOption) GeofenceBreachTypeMask breachTypeMask; // bitwise OR of GeofenceBreachTypeBits uint32_t responsiveness; // in milliseconds uint32_t dwellTime; // in seconds } GeofenceOption; typedef struct { - size_t size; // set to sizeof(GeofenceInfo) + uint32_t size; // set to sizeof(GeofenceInfo) double latitude; // in degrees double longitude; // in degrees double radius; // in meters } GeofenceInfo; typedef struct { - size_t size; // set to sizeof(GeofenceBreachNotification) - size_t count; // number of ids in array + uint32_t size; // set to sizeof(GeofenceBreachNotification) + uint32_t count; // number of ids in array uint32_t* ids; // array of ids that have breached Location location; // location associated with breach GeofenceBreachType type; // type of breach @@ -758,7 +782,7 @@ typedef struct { } GeofenceBreachNotification; typedef struct { - size_t size; // set to sizeof(GeofenceBreachNotification) + uint32_t size; // set to sizeof(GeofenceBreachNotification) GeofenceStatusAvailable available; // GEOFENCE_STATUS_AVAILABILE_NO/_YES LocationTechnologyType techType; // GNSS } GeofenceStatusNotification; @@ -892,7 +916,7 @@ typedef struct { } GnssSystemTime; typedef struct { - size_t size; // set to sizeof(GnssLocationInfo) + uint32_t size; // set to sizeof(GnssLocationInfo) GnssLocationInfoFlagMask flags; // bitwise OR of GnssLocationInfoBits for param validity float altitudeMeanSeaLevel; // altitude wrt mean sea level float pdop; // position dilusion of precision @@ -928,7 +952,7 @@ typedef struct { } GnssLocationInfoNotification; typedef struct { - size_t size; // set to sizeof(GnssNiNotification) + uint32_t size; // set to sizeof(GnssNiNotification) GnssNiType type; // type of NI (Voice, SUPL, Control Plane) GnssNiOptionsMask options; // bitwise OR of GnssNiOptionsBits uint32_t timeout; // time (seconds) to wait for user input @@ -941,7 +965,7 @@ typedef struct { } GnssNiNotification; typedef struct { - size_t size; // set to sizeof(GnssSv) + uint32_t size; // set to sizeof(GnssSv) uint16_t svId; // Unique Identifier GnssSvType type; // type of SV (GPS, SBAS, GLONASS, QZSS, BEIDOU, GALILEO) float cN0Dbhz; // signal strength @@ -953,7 +977,7 @@ typedef struct { } GnssSv; struct GnssConfigSetAssistanceServer { - size_t size; // set to sizeof(GnssConfigSetAssistanceServer) + uint32_t size; // set to sizeof(GnssConfigSetAssistanceServer) GnssAssistanceType type; // SUPL or C2K const char* hostName; // null terminated string uint32_t port; // port of server @@ -970,7 +994,7 @@ struct GnssConfigSetAssistanceServer { }; typedef struct { - size_t size; // set to sizeof(GnssMeasurementsData) + uint32_t size; // set to sizeof(GnssMeasurementsData) GnssMeasurementsDataFlagsMask flags; // bitwise OR of GnssMeasurementsDataFlagsBits int16_t svId; GnssSvType svType; @@ -996,7 +1020,7 @@ typedef struct { } GnssMeasurementsData; typedef struct { - size_t size; // set to sizeof(GnssMeasurementsClock) + uint32_t size; // set to sizeof(GnssMeasurementsClock) GnssMeasurementsClockFlagsMask flags; // bitwise OR of GnssMeasurementsClockFlagsBits int16_t leapSecond; int64_t timeNs; @@ -1010,29 +1034,29 @@ typedef struct { } GnssMeasurementsClock; typedef struct { - size_t size; // set to sizeof(GnssSvNotification) - size_t count; // number of SVs in the GnssSv array + uint32_t size; // set to sizeof(GnssSvNotification) + uint32_t count; // number of SVs in the GnssSv array bool gnssSignalTypeMaskValid; GnssSv gnssSvs[GNSS_SV_MAX]; // information on a number of SVs } GnssSvNotification; typedef struct { - size_t size; // set to sizeof(GnssNmeaNotification) + uint32_t size; // set to sizeof(GnssNmeaNotification) uint64_t timestamp; // timestamp const char* nmea; // nmea text - size_t length; // length of the nmea text + uint32_t length; // length of the nmea text } GnssNmeaNotification; typedef struct { - size_t size; // set to sizeof(GnssDataNotification) + uint32_t size; // set to sizeof(GnssDataNotification) GnssDataMask gnssDataMask[GNSS_LOC_MAX_NUMBER_OF_SIGNAL_TYPES]; // bitwise OR of GnssDataBits double jammerInd[GNSS_LOC_MAX_NUMBER_OF_SIGNAL_TYPES]; // Jammer Indication double agc[GNSS_LOC_MAX_NUMBER_OF_SIGNAL_TYPES]; // Automatic gain control } GnssDataNotification; typedef struct { - size_t size; // set to sizeof(GnssMeasurementsNotification) - size_t count; // number of items in GnssMeasurements array + uint32_t size; // set to sizeof(GnssMeasurementsNotification) + uint32_t count; // number of items in GnssMeasurements array GnssMeasurementsData measurements[GNSS_MEASUREMENTS_MAX]; GnssMeasurementsClock clock; // clock } GnssMeasurementsNotification; @@ -1040,9 +1064,9 @@ typedef struct { typedef uint32_t GnssSvId; struct GnssSvIdSource{ - size_t size; // set to sizeof(GnssSvIdSource) - GnssSvType constellation; // constellation for the sv to blacklist - GnssSvId svId; // sv id to blacklist + uint32_t size; // set to sizeof(GnssSvIdSource) + GnssSvType constellation; // constellation for the sv to blacklist + GnssSvId svId; // sv id to blacklist }; inline bool operator ==(GnssSvIdSource const& left, GnssSvIdSource const& right) { return left.size == right.size && @@ -1051,7 +1075,7 @@ inline bool operator ==(GnssSvIdSource const& left, GnssSvIdSource const& right) #define GNSS_SV_CONFIG_ALL_BITS_ENABLED_MASK ((uint64_t)0xFFFFFFFFFFFFFFFF) typedef struct { - size_t size; // set to sizeof(GnssSvIdConfig) + uint32_t size; // set to sizeof(GnssSvIdConfig) // GLONASS - SV 65 maps to bit 0 #define GNSS_SV_CONFIG_GLO_INITIAL_SV_ID 65 @@ -1071,7 +1095,7 @@ typedef struct { } GnssSvIdConfig; struct GnssConfig{ - size_t size; // set to sizeof(GnssConfig) + uint32_t size; // set to sizeof(GnssConfig) GnssConfigFlagsMask flags; // bitwise OR of GnssConfigFlagsBits to mark which params are valid GnssConfigGpsLock gpsLock; GnssConfigSuplVersion suplVersion; @@ -1105,7 +1129,7 @@ struct GnssConfig{ }; typedef struct { - size_t size; // set to sizeof + uint32_t size; // set to sizeof bool mValid; Location mLocation; double verticalAccuracyMeters; @@ -1115,7 +1139,7 @@ typedef struct { } GnssDebugLocation; typedef struct { - size_t size; // set to sizeof + uint32_t size; // set to sizeof bool mValid; int64_t timeEstimate; float timeUncertaintyNs; @@ -1123,7 +1147,7 @@ typedef struct { } GnssDebugTime; typedef struct { - size_t size; // set to sizeof + uint32_t size; // set to sizeof uint32_t svid; GnssSvType constellation; GnssEphemerisType mEphemerisType; @@ -1135,7 +1159,7 @@ typedef struct { } GnssDebugSatelliteInfo; typedef struct { - size_t size; // set to sizeof + uint32_t size; // set to sizeof GnssDebugLocation mLocation; GnssDebugTime mTime; std::vector<GnssDebugSatelliteInfo> mSatelliteInfo; @@ -1210,7 +1234,7 @@ typedef std::function<void( collectiveResponseCallback is called for every geofence API call. ids array and LocationError array are only valid until collectiveResponseCallback returns. */ typedef std::function<void( - size_t count, // number of locations in arrays + uint32_t count, // number of locations in arrays LocationError* errs, // array of LocationError associated to the request uint32_t* ids // array of ids to be associated to the request )> collectiveResponseCallback; @@ -1226,7 +1250,7 @@ typedef std::function<void( batchingCallback is called when delivering locations in a batching session. broadcasted to all clients, no matter if a session has started by client */ typedef std::function<void( - size_t count, // number of locations in array + uint32_t count, // number of locations in array Location* location, // array of locations BatchingOptions batchingOptions // Batching options )> batchingCallback; @@ -1305,8 +1329,15 @@ typedef std::function<void( typedef std::function<void( )> locationApiDestroyCompleteCallback; +typedef uint16_t LocationAdapterTypeMask; +typedef enum { + LOCATION_ADAPTER_GNSS_TYPE_BIT = (1<<0), // adapter type is GNSS + LOCATION_ADAPTER_FLP_TYPE_BIT = (1<<1), // adapter type is FLP + LOCATION_ADAPTER_GEOFENCE_TYPE_BIT = (1<<2) // adapter type is geo fence +} LocationAdapterTypeBits; + typedef struct { - size_t size; // set to sizeof(LocationCallbacks) + uint32_t size; // set to sizeof(LocationCallbacks) capabilitiesCallback capabilitiesCb; // mandatory responseCallback responseCb; // mandatory collectiveResponseCallback collectiveResponseCb; // mandatory |