From f7c6bf552ae3818f98c19dd327b55de531924d47 Mon Sep 17 00:00:00 2001 From: Hoss Zhou Date: Tue, 4 Dec 2018 16:58:02 +0800 Subject: fix multiple GPS_LOCK request donot send GPS_LOCK request when new gpsLock is the same as last one. Change-Id: Ifb87018d11aef0383762b9b132742faf3d4d7e79 CRs-fixed: 2360896 --- gnss/GnssAdapter.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index fc59c22..54a2145 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -846,13 +846,14 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config) if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) { uint32_t newGpsLock = mAdapter.convertGpsLock(gnssConfigRequested.gpsLock); - ContextBase::mGps_conf.GPS_LOCK = newGpsLock; - if (0 == ContextBase::mGps_conf.GPS_LOCK) { - ContextBase::mGps_conf.GPS_LOCK = 3; + if (0 == newGpsLock) { + newGpsLock = 3; } - if (0 != mAdapter.getPowerVoteId()) { + if (newGpsLock == ContextBase::mGps_conf.GPS_LOCK || + 0 != mAdapter.getPowerVoteId()) { gnssConfigNeedEngineUpdate.flags &= ~(GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT); } + ContextBase::mGps_conf.GPS_LOCK = newGpsLock; index++; } if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) { -- cgit v1.2.3 From abfeea182d6ea4905f80da6f17556da278cce4d4 Mon Sep 17 00:00:00 2001 From: Yingjie Wang Date: Fri, 4 Jan 2019 15:56:04 +0800 Subject: Fix KW P1 related issues Change-Id: Ifc3cb9dcabf2e07439fd596b5ad33b46ea562b3d CRs-fixed: 2375836 --- gnss/GnssAdapter.cpp | 14 ++++++++------ gnss/XtraSystemStatusObserver.cpp | 7 +++++-- utils/LocIpc.h | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 016356b..fb1c7ec 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -1999,8 +1999,10 @@ GnssAdapter::restartSessions() } // get the LocationOptions that has the smallest interval, which should be the active one - TrackingOptions smallestIntervalOptions = {}; // size is zero until set for the first time - TrackingOptions highestPowerTrackingOptions = {}; + TrackingOptions smallestIntervalOptions; // size is zero until set for the first time + TrackingOptions highestPowerTrackingOptions; + memset(&smallestIntervalOptions, 0, sizeof(smallestIntervalOptions)); + memset(&highestPowerTrackingOptions, 0, sizeof(highestPowerTrackingOptions)); for (auto it = mTrackingSessions.begin(); it != mTrackingSessions.end(); ++it) { // size of zero means we havent set it yet if (0 == smallestIntervalOptions.size || @@ -3022,8 +3024,8 @@ GnssAdapter::reportPosition(const UlpLocation& ulpLocation, loc_nmea_generate_pos(ulpLocation, locationExtended, mLocSystemInfo, generate_nmea, nmeaArraystr); stringstream ss; - for (auto sentence : nmeaArraystr) { - ss << sentence; + for (auto itor = nmeaArraystr.begin(); itor != nmeaArraystr.end(); ++itor) { + ss << *itor; } string s = ss.str(); reportNmea(s.c_str(), s.length()); @@ -3118,8 +3120,8 @@ GnssAdapter::reportSv(GnssSvNotification& svNotify) std::vector nmeaArraystr; loc_nmea_generate_sv(svNotify, nmeaArraystr); stringstream ss; - for (auto sentence : nmeaArraystr) { - ss << sentence; + for (auto itor = nmeaArraystr.begin(); itor != nmeaArraystr.end(); ++itor) { + ss << *itor; } string s = ss.str(); reportNmea(s.c_str(), s.length()); diff --git a/gnss/XtraSystemStatusObserver.cpp b/gnss/XtraSystemStatusObserver.cpp index 6df5480..d84ae42 100644 --- a/gnss/XtraSystemStatusObserver.cpp +++ b/gnss/XtraSystemStatusObserver.cpp @@ -219,8 +219,11 @@ void XtraSystemStatusObserver::notify(const list& dlist) } inline ~HandleOsObserverUpdateMsg() { - for (auto each : mDataItemList) { - delete each; + for (auto itor = mDataItemList.begin(); itor != mDataItemList.end(); ++itor) { + if (*itor != nullptr) { + delete *itor; + *itor = nullptr; + } } } diff --git a/utils/LocIpc.h b/utils/LocIpc.h index a1a994d..62309e7 100644 --- a/utils/LocIpc.h +++ b/utils/LocIpc.h @@ -106,7 +106,7 @@ public: // This class hides generated fd and destination address object from user. inline LocIpcSender(const char* destSocket): LocIpcSender(std::make_shared(::socket(AF_UNIX, SOCK_DGRAM, 0)), destSocket) { - if (-1 == *mSocket) { + if (mSocket != nullptr && -1 == *mSocket) { mSocket = nullptr; } } -- cgit v1.2.3 From 2332db20a984a1f49b31be3bf320aaa448b40b8d Mon Sep 17 00:00:00 2001 From: Bhavna Sharma Date: Fri, 4 Jan 2019 17:13:21 -0800 Subject: Fix issue with setting of thread name Only first 3 chars of thread name were getting set because of incorrect length check. This change fixes the issue. CRs-Fixed: 2376235 Change-Id: Iba4ad44af2e3bfde8da8ae4efdd4b132299ae9b7 --- utils/LocThread.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/LocThread.cpp b/utils/LocThread.cpp index c1052cb..568a6bb 100644 --- a/utils/LocThread.cpp +++ b/utils/LocThread.cpp @@ -85,8 +85,8 @@ LocThreadDelegate::LocThreadDelegate(LocThread::tCreate creator, if (mThandle) { // set thread name char lname[16]; - int len = (sizeof(lname)>sizeof(threadName)) ? - (sizeof(threadName) -1):(sizeof(lname) - 1); + int len = (sizeof(lname) > (strlen(threadName) + 1)) ? + (strlen(threadName)):(sizeof(lname) - 1); memcpy(lname, threadName, len); lname[len] = 0; // set the thread name here -- cgit v1.2.3 From cd387d1e8eb7dbf07741005f0cf33677a911dd43 Mon Sep 17 00:00:00 2001 From: Kevin Tang Date: Fri, 11 Jan 2019 17:41:30 -0800 Subject: LocIpc could be using data member from a deleted obj startListeningBlocking is meant to be called under a reader thread, which is the case if startListeningNonBlocking calls it. A LocIpc client may delete the LocIpc obj, which would trigger sending an ABORT msg to the reader thread before it is subsequently deleted, in which case, it is possible that when the reader thread comes around to process the ABORT msg, referencing the data members of the possibly stale obj would cause unpredictable behaviors. Change-Id: I441af85c04d92b6fff695c020e3e0b4bd5e90409 CRs-Fixed: 2380093 --- utils/LocIpc.cpp | 113 ++++++++++++++++++++++++------------------------------- utils/LocIpc.h | 3 +- 2 files changed, 51 insertions(+), 65 deletions(-) diff --git a/utils/LocIpc.cpp b/utils/LocIpc.cpp index f7e163d..7347b78 100644 --- a/utils/LocIpc.cpp +++ b/utils/LocIpc.cpp @@ -69,8 +69,9 @@ bool LocIpc::startListeningNonBlocking(const std::string& name) { } bool LocIpc::startListeningBlocking(const std::string& name) { - + bool stopRequested = false; int fd = socket(AF_UNIX, SOCK_DGRAM, 0); + if (fd < 0) { LOC_LOGe("create socket error. reason:%s", strerror(errno)); return false; @@ -87,89 +88,75 @@ bool LocIpc::startListeningBlocking(const std::string& name) { if (::bind(fd, (struct sockaddr*)&addr, sizeof(addr)) < 0) { LOC_LOGe("bind socket error. reason:%s", strerror(errno)); - ::close(fd); - fd = -1; - return false; - } + } else { + mIpcFd = fd; - mIpcFd = fd; - - // inform that the socket is ready to receive message - onListenerReady(); - - ssize_t nBytes = 0; - std::string msg = ""; - std::string abort = LOC_MSG_ABORT; - while (1) { - msg.resize(LOC_MSG_BUF_LEN); - nBytes = ::recvfrom(mIpcFd, (void*)(msg.data()), msg.size(), 0, NULL, NULL); - if (nBytes < 0) { - break; - } else if (nBytes == 0) { - continue; - } + // inform that the socket is ready to receive message + onListenerReady(); - if (strncmp(msg.data(), abort.c_str(), abort.length()) == 0) { - LOC_LOGi("recvd abort msg.data %s", msg.data()); - break; - } + ssize_t nBytes = 0; + std::string msg = ""; + std::string abort = LOC_MSG_ABORT; + while (1) { + msg.resize(LOC_MSG_BUF_LEN); + nBytes = ::recvfrom(fd, (void*)(msg.data()), msg.size(), 0, NULL, NULL); + if (nBytes < 0) { + LOC_LOGe("cannot read socket. reason:%s", strerror(errno)); + break; + } else if (0 == nBytes) { + continue; + } - if (strncmp(msg.data(), LOC_MSG_HEAD, sizeof(LOC_MSG_HEAD) - 1)) { - // short message - msg.resize(nBytes); - onReceive(msg); - } else { - // long message - size_t msgLen = 0; - sscanf(msg.data(), LOC_MSG_HEAD"%zu", &msgLen); - msg.resize(msgLen); - size_t msgLenReceived = 0; - while ((msgLenReceived < msgLen) && (nBytes > 0)) { - nBytes = recvfrom(mIpcFd, (void*)&(msg[msgLenReceived]), - msg.size() - msgLenReceived, 0, NULL, NULL); - msgLenReceived += nBytes; + if (strncmp(msg.data(), abort.c_str(), abort.length()) == 0) { + LOC_LOGi("recvd abort msg.data %s", msg.data()); + stopRequested = true; + break; } - if (nBytes > 0) { + + if (strncmp(msg.data(), LOC_MSG_HEAD, sizeof(LOC_MSG_HEAD) - 1)) { + // short message + msg.resize(nBytes); onReceive(msg); } else { - break; + // long message + size_t msgLen = 0; + sscanf(msg.data(), LOC_MSG_HEAD"%zu", &msgLen); + msg.resize(msgLen); + size_t msgLenReceived = 0; + while ((msgLenReceived < msgLen) && (nBytes > 0)) { + nBytes = recvfrom(fd, (void*)&(msg[msgLenReceived]), + msg.size() - msgLenReceived, 0, NULL, NULL); + msgLenReceived += nBytes; + } + if (nBytes > 0) { + onReceive(msg); + } else { + LOC_LOGe("cannot read socket. reason:%s", strerror(errno)); + break; + } } } } - if (mStopRequested) { - mStopRequested = false; - return true; - } else { - LOC_LOGe("cannot read socket. reason:%s", strerror(errno)); - (void)::close(mIpcFd); - mIpcFd = -1; - return false; + if (::close(fd)) { + LOC_LOGe("cannot close socket:%s", strerror(errno)); } + unlink(name.c_str()); + + return stopRequested; } void LocIpc::stopListening() { - const char *socketName = nullptr; - mStopRequested = true; - if (mRunnable) { + if (mIpcFd >= 0) { std::string abort = LOC_MSG_ABORT; socketName = (reinterpret_cast(mRunnable))->mIpcName.c_str(); send(socketName, abort); - mRunnable = nullptr; - } - - if (mIpcFd >= 0) { - if (::close(mIpcFd)) { - LOC_LOGe("cannot close socket:%s", strerror(errno)); - } mIpcFd = -1; } - - //delete from the file system at the end - if (socketName) { - unlink(socketName); + if (mRunnable) { + mRunnable = nullptr; } } diff --git a/utils/LocIpc.h b/utils/LocIpc.h index a1a994d..87f2ff8 100644 --- a/utils/LocIpc.h +++ b/utils/LocIpc.h @@ -44,7 +44,7 @@ class LocIpcSender; class LocIpc { friend LocIpcSender; public: - inline LocIpc() : mIpcFd(-1), mStopRequested(false), mRunnable(nullptr) {} + inline LocIpc() : mIpcFd(-1), mRunnable(nullptr) {} inline virtual ~LocIpc() { stopListening(); } // Listen for new messages in current thread. Calling this funciton will @@ -93,7 +93,6 @@ private: const uint8_t data[], uint32_t length); int mIpcFd; - bool mStopRequested; LocThread mThread; LocRunnable *mRunnable; }; -- cgit v1.2.3 From 5fba9e7dfb011b776264ffb57849970aa1b41fb0 Mon Sep 17 00:00:00 2001 From: "Srivastava, Saurabh" Date: Fri, 25 Jan 2019 10:33:26 +0530 Subject: Adding SBAS in GSV NMEA Adding missing constellation handling for SBAS in GSV NMEA Change-Id: I51ce3f60fc3bf340936901b753169df34d6db5c2 CRs-Fixed: 2387458 --- utils/loc_nmea.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils/loc_nmea.cpp b/utils/loc_nmea.cpp index e9a8f84..0f7c48f 100644 --- a/utils/loc_nmea.cpp +++ b/utils/loc_nmea.cpp @@ -674,6 +674,9 @@ static void loc_nmea_generate_GSV(const GnssSvNotification &svNotify, case GNSS_SV_TYPE_BEIDOU: signalType = GNSS_SIGNAL_BEIDOU_B1I; break; + case GNSS_SV_TYPE_SBAS: + signalType = GNSS_SIGNAL_SBAS_L1; + break; default: LOC_LOGE("NMEA Error unknow constellation type: %d", svNotify.gnssSvs[svNumber - 1].type); -- cgit v1.2.3 From 49c60ab27a04ab0f0f41b62181c5539b4e671842 Mon Sep 17 00:00:00 2001 From: Bhavna Sharma Date: Thu, 24 Jan 2019 16:18:38 -0800 Subject: LocationAPI must also be freed on destroy call LocationAPI object instance itself must also be freed when destroy is called. CRs-Fixed: 2388028 Change-Id: Ie6e1c34e126a10ea58076c0385aecd447233c7aa --- location/LocationAPI.cpp | 22 +++++++++------------- location/LocationAPI.h | 2 ++ location/LocationDataTypes.h | 7 +++++++ 3 files changed, 18 insertions(+), 13 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 61598be..1590b88 100644 --- a/location/LocationDataTypes.h +++ b/location/LocationDataTypes.h @@ -1277,6 +1277,13 @@ typedef std::function 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) capabilitiesCallback capabilitiesCb; // mandatory -- cgit v1.2.3 From 8e04d01cd2e35bfea1dc7d1f5f689e7780a90f1f Mon Sep 17 00:00:00 2001 From: Wei Chen Date: Tue, 4 Dec 2018 15:55:00 -0800 Subject: GPS SV meas: new structure to support 10Hz (1) revise struct of GnssSvMeasurementSet so it can be used to send only valid SV measurement via IPC (2) remove reference to COMPASS system, as COMPASS named is replaced by BEIDOU system (3) correct typo in GNSS_GLOS_MSEC_VALID to GNSS_GLO_MSEC_VALID CRs-fixed: 2337832 Change-Id: I325346fa414e3a94422cb8ab4cc5b77d6efaf485 --- gnss/GnssAdapter.cpp | 1 + location/LocationDataTypes.h | 28 +++++-- utils/gps_extended_c.h | 175 ++++++++++++++----------------------------- 3 files changed, 81 insertions(+), 123 deletions(-) diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 791f9d6..57d055c 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -1939,6 +1939,7 @@ GnssAdapter::updateClientsEventMask() if((1 == ContextBase::mGps_conf.EXTERNAL_DR_ENABLED) || (true == initEngHubProxy())) { mask |= LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT; + mask |= LOC_API_ADAPTER_BIT_GNSS_NHZ_MEASUREMENT; mask |= LOC_API_ADAPTER_BIT_GNSS_SV_POLYNOMIAL_REPORT; mask |= LOC_API_ADAPTER_BIT_PARSED_UNPROPAGATED_POSITION_REPORT; mask |= LOC_API_ADAPTER_BIT_GNSS_SV_EPHEMERIS_REPORT; diff --git a/location/LocationDataTypes.h b/location/LocationDataTypes.h index 1590b88..e478473 100644 --- a/location/LocationDataTypes.h +++ b/location/LocationDataTypes.h @@ -488,6 +488,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 { @@ -531,19 +547,19 @@ typedef enum { 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; @@ -590,7 +606,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), diff --git a/utils/gps_extended_c.h b/utils/gps_extended_c.h index 8ddf488..22b2dd0 100644 --- a/utils/gps_extended_c.h +++ b/utils/gps_extended_c.h @@ -410,6 +410,8 @@ typedef uint32_t LocPosDataMask; /** GPS PRN Range */ #define GPS_SV_PRN_MIN 1 #define GPS_SV_PRN_MAX 32 +#define SBAS_SV_PRN_MIN 33 +#define SBAS_SV_PRN_MAX 64 #define GLO_SV_PRN_MIN 65 #define GLO_SV_PRN_MAX 96 #define QZSS_SV_PRN_MIN 193 @@ -838,8 +840,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_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 @@ -853,6 +855,7 @@ enum loc_api_adapter_event_index { LOC_API_ADAPTER_BS_OBS_DATA_SERVICE_REQ, // BS observation data request LOC_API_ADAPTER_GNSS_SV_EPHEMERIS_REPORT, // GNSS SV Ephemeris Report LOC_API_ADAPTER_LOC_SYSTEM_INFO, // Location system info event + LOC_API_ADAPTER_GNSS_NHZ_MEASUREMENT_REPORT, // GNSS SV nHz measurement report LOC_API_ADAPTER_EVENT_MAX }; @@ -893,6 +896,7 @@ enum loc_api_adapter_event_index { #define LOC_API_ADAPTER_BIT_BS_OBS_DATA_SERVICE_REQ (1ULL< Date: Tue, 15 Jan 2019 16:29:48 -0800 Subject: New structures and handling of new data in the pipe 1. KlobucharIonoModel 2. Additional parameters for Glonass 3. Add gps system time to ephemeris reports. CRs-Fixed: 2388931 Change-Id: Ibd08496c8eda2ce7571cbdd71ff0c179f7376aa7 --- core/EngineHubProxyBase.h | 11 ++++++ core/LocAdapterBase.cpp | 8 ++++ core/LocAdapterBase.h | 3 ++ core/LocApiBase.cpp | 10 +++++ core/LocApiBase.h | 2 + gnss/GnssAdapter.cpp | 29 +++++++------- gnss/GnssAdapter.h | 3 ++ location/LocationDataTypes.h | 8 ++++ utils/gps_extended_c.h | 90 +++++++++++++++++++++++++++++++++++++++++++- 9 files changed, 149 insertions(+), 15 deletions(-) diff --git a/core/EngineHubProxyBase.h b/core/EngineHubProxyBase.h index 34af4d0..4239a50 100644 --- a/core/EngineHubProxyBase.h +++ b/core/EngineHubProxyBase.h @@ -90,6 +90,17 @@ public: (void) systemInfo; return false; } + + inline virtual bool gnssReportKlobucharIonoModel(const GnssKlobucharIonoModel& ionoModel) { + (void) ionoModel; + return false; + } + + inline virtual bool gnssReportAdditionalSystemInfo( + const GnssAdditionalSystemInfo& additionalSystemInfo) { + (void) additionalSystemInfo; + return false; + } }; typedef std::functionreportDeleteAidingDataEvent(aidingData)); } +void LocApiBase::reportKlobucharIonoModel(GnssKlobucharIonoModel & ionoModel) { + // loop through adapters, and deliver to the first handling adapter. + TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportKlobucharIonoModelEvent(ionoModel)); +} + +void LocApiBase::reportGnssAdditionalSystemInfo(GnssAdditionalSystemInfo& additionalSystemInfo) { + // loop through adapters, and deliver to the first handling adapter. + TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportGnssAdditionalSystemInfoEvent( + additionalSystemInfo)); +} void LocApiBase::reportSv(GnssSvNotification& svNotify) { diff --git a/core/LocApiBase.h b/core/LocApiBase.h index e5dfebf..70bebc3 100644 --- a/core/LocApiBase.h +++ b/core/LocApiBase.h @@ -187,6 +187,8 @@ public: void requestOdcpi(OdcpiRequestInfo& request); void reportGnssEngEnergyConsumedEvent(uint64_t energyConsumedSinceFirstBoot); void reportDeleteAidingDataEvent(GnssAidingData& aidingData); + void reportKlobucharIonoModel(GnssKlobucharIonoModel& ionoModel); + void reportGnssAdditionalSystemInfo(GnssAdditionalSystemInfo& additionalSystemInfo); // downward calls // All below functions are to be defined by adapter specific modules: diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 57d055c..e0290ad 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -1944,6 +1944,7 @@ GnssAdapter::updateClientsEventMask() mask |= LOC_API_ADAPTER_BIT_PARSED_UNPROPAGATED_POSITION_REPORT; mask |= LOC_API_ADAPTER_BIT_GNSS_SV_EPHEMERIS_REPORT; mask |= LOC_API_ADAPTER_BIT_LOC_SYSTEM_INFO; + mask |= LOC_API_ADAPTER_BIT_EVENT_REPORT_INFO; LOC_LOGd("Auto usecase, Enable MEAS/POLY/EPHEMERIS - mask 0x%" PRIx64 "", mask); @@ -3591,24 +3592,24 @@ void GnssAdapter::requestOdcpi(const OdcpiRequestInfo& request) bool GnssAdapter::reportDeleteAidingDataEvent(GnssAidingData& aidingData) { LOC_LOGD("%s]:", __func__); + mEngHubProxy->gnssDeleteAidingData(aidingData); + return true; +} - struct MsgHandleDeleteAidingDataEvent : public LocMsg { - GnssAdapter& mAdapter; - GnssAidingData mData; - inline MsgHandleDeleteAidingDataEvent(GnssAdapter& adapter, - GnssAidingData& data) : - LocMsg(), - mAdapter(adapter), - mData(data) {} - inline virtual void proc() const { - mAdapter.mEngHubProxy->gnssDeleteAidingData(mData); - } - }; - - sendMsg(new MsgHandleDeleteAidingDataEvent(*this, aidingData)); +bool GnssAdapter::reportKlobucharIonoModelEvent(GnssKlobucharIonoModel & ionoModel) +{ + LOC_LOGD("%s]:", __func__); + mEngHubProxy->gnssReportKlobucharIonoModel(ionoModel); return true; } +bool GnssAdapter::reportGnssAdditionalSystemInfoEvent( + GnssAdditionalSystemInfo & additionalSystemInfo) +{ + LOC_LOGD("%s]:", __func__); + mEngHubProxy->gnssReportAdditionalSystemInfo(additionalSystemInfo); + return true; +} void GnssAdapter::initOdcpiCommand(const OdcpiRequestCallback& callback) { diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h index 1682f02..55cadba 100644 --- a/gnss/GnssAdapter.h +++ b/gnss/GnssAdapter.h @@ -356,6 +356,9 @@ public: virtual bool releaseATL(int connHandle); virtual bool requestOdcpiEvent(OdcpiRequestInfo& request); virtual bool reportDeleteAidingDataEvent(GnssAidingData& aidingData); + virtual bool reportKlobucharIonoModelEvent(GnssKlobucharIonoModel& ionoModel); + virtual bool reportGnssAdditionalSystemInfoEvent( + GnssAdditionalSystemInfo& additionalSystemInfo); /* ======== UTILITIES ================================================================= */ bool needReport(const UlpLocation& ulpLocation, diff --git a/location/LocationDataTypes.h b/location/LocationDataTypes.h index e478473..99e6d45 100644 --- a/location/LocationDataTypes.h +++ b/location/LocationDataTypes.h @@ -545,6 +545,14 @@ 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, diff --git a/utils/gps_extended_c.h b/utils/gps_extended_c.h index 22b2dd0..cd661b3 100644 --- a/utils/gps_extended_c.h +++ b/utils/gps_extended_c.h @@ -407,6 +407,13 @@ typedef uint32_t LocPosDataMask; /* Bitmask to specify whether Navigation data has Body pitch Unc*/ #define LOC_NAV_DATA_HAS_PITCH_UNC ((LocPosDataMask)0x0200) +typedef uint32_t GnssAdditionalSystemInfoMask; +/* Bitmask to specify whether Tauc is valid */ +#define GNSS_ADDITIONAL_SYSTEMINFO_HAS_TAUC ((GnssAdditionalSystemInfoMask)0x0001) +/* Bitmask to specify whether leapSec is valid */ +#define GNSS_ADDITIONAL_SYSTEMINFO_HAS_LEAP_SEC ((GnssAdditionalSystemInfoMask)0x0002) + + /** GPS PRN Range */ #define GPS_SV_PRN_MIN 1 #define GPS_SV_PRN_MAX 32 @@ -856,6 +863,7 @@ enum loc_api_adapter_event_index { LOC_API_ADAPTER_GNSS_SV_EPHEMERIS_REPORT, // GNSS SV Ephemeris Report LOC_API_ADAPTER_LOC_SYSTEM_INFO, // Location system info event LOC_API_ADAPTER_GNSS_NHZ_MEASUREMENT_REPORT, // GNSS SV nHz measurement report + LOC_API_ADAPTER_EVENT_REPORT_INFO, // Event report info LOC_API_ADAPTER_EVENT_MAX }; @@ -897,6 +905,7 @@ enum loc_api_adapter_event_index { #define LOC_API_ADAPTER_BIT_GNSS_SV_EPHEMERIS_REPORT (1ULL< Date: Thu, 13 Dec 2018 10:08:18 -0800 Subject: Enable support for External AP build Enable support for build on External AP without libcutils or any Android library support. CRs-fixed: 2368435 Change-Id: I978127348fd6b8d90ed5ef0a714c02437dc59ee0 --- pla/oe/loc_pla.h | 17 +++++++++++++++++ utils/LocSharedLock.h | 20 +++++++++++++++++++- utils/MsgTask.cpp | 2 ++ utils/configure.ac | 18 ++++++++++++++---- 4 files changed, 52 insertions(+), 5 deletions(-) diff --git a/pla/oe/loc_pla.h b/pla/oe/loc_pla.h index 9446888..e795a23 100644 --- a/pla/oe/loc_pla.h +++ b/pla/oe/loc_pla.h @@ -30,7 +30,10 @@ #define __LOC_PLA__ #ifdef __cplusplus +#ifndef FEATURE_EXTERNAL_AP #include +#endif /* FEATURE_EXTERNAL_AP */ +#include #include #include @@ -47,10 +50,14 @@ inline int64_t uptimeMillis() extern "C" { #endif +#ifndef FEATURE_EXTERNAL_AP #include #include #include +#endif /* FEATURE_EXTERNAL_AP */ +#include #include +#include #include #include #ifndef OFF_TARGET @@ -76,6 +83,16 @@ extern "C" { #define LOC_PATH_XTWIFI_CONF_STR "/etc/xtwifi.conf" #define LOC_PATH_QUIPC_CONF_STR "/etc/quipc.conf" +#ifdef FEATURE_EXTERNAL_AP +#define PROPERTY_VALUE_MAX 92 + +inline int property_get(const char* key, char* value, const char* default_value) +{ + strlcpy(value, default_value, PROPERTY_VALUE_MAX - 1); + return strlen(value); +} +#endif /* FEATURE_EXTERNAL_AP */ + #ifdef __cplusplus } #endif /*__cplusplus */ diff --git a/utils/LocSharedLock.h b/utils/LocSharedLock.h index 7fe6237..a7af35e 100644 --- a/utils/LocSharedLock.h +++ b/utils/LocSharedLock.h @@ -30,10 +30,28 @@ #define __LOC_SHARED_LOCK__ #include +#ifndef FEATURE_EXTERNAL_AP #include +#endif /* FEATURE_EXTERNAL_AP */ #include -// This is a utility created for use cases such that there are more than +#ifdef FEATURE_EXTERNAL_AP +#include + +inline int32_t android_atomic_inc(volatile int32_t *addr) +{ + volatile std::atomic_int_least32_t* a = (volatile std::atomic_int_least32_t*)addr; + return std::atomic_fetch_add_explicit(a, 1, std::memory_order_release); +} + +inline int32_t android_atomic_dec(volatile int32_t *addr) +{ + volatile std::atomic_int_least32_t* a = (volatile std::atomic_int_least32_t*)addr; + return std::atomic_fetch_sub_explicit(a, 1, std::memory_order_release); +} + +#endif /* FEATURE_EXTERNAL_AP */ + // This is a utility created for use cases such that there are more than // one client who need to share the same lock, but it is not predictable // which of these clients is to last to go away. This shared lock deletes // itself when the last client calls its drop() method. To add a cient, diff --git a/utils/MsgTask.cpp b/utils/MsgTask.cpp index ad95a83..73a77fd 100644 --- a/utils/MsgTask.cpp +++ b/utils/MsgTask.cpp @@ -83,8 +83,10 @@ void MsgTask::sendMsg(const LocMsg* msg) const { } void MsgTask::prerun() { +#ifndef FEATURE_EXTERNAL_AP // make sure we do not run in background scheduling group set_sched_policy(gettid(), SP_FOREGROUND); +#endif /* FEATURE_EXTERNAL_AP */ } bool MsgTask::run() { diff --git a/utils/configure.ac b/utils/configure.ac index 639f8c4..fd16494 100644 --- a/utils/configure.ac +++ b/utils/configure.ac @@ -28,10 +28,20 @@ AC_PROG_LN_S AC_PROG_MAKE_SET PKG_PROG_PKG_CONFIG -# Checks for libraries. -PKG_CHECK_MODULES([CUTILS], [libcutils]) -AC_SUBST([CUTILS_CFLAGS]) -AC_SUBST([CUTILS_LIBS]) +AC_ARG_WITH([external_ap], + AC_HELP_STRING([--with-external_ap=@<:@dir@:>@], + [Using External Application Processor]), + [], + with_external_ap=no) + +if test "x$with_external_ap" != "xno"; then + CPPFLAGS="${CPPFLAGS} -DFEATURE_EXTERNAL_AP" +else + # Checks for libraries. + PKG_CHECK_MODULES([CUTILS], [libcutils]) + AC_SUBST([CUTILS_CFLAGS]) + AC_SUBST([CUTILS_LIBS]) +fi AC_ARG_WITH([core_includes], AC_HELP_STRING([--with-core-includes=@<:@dir@:>@], -- cgit v1.2.3 From 1d823b05ec27ec6ed5a0565213aae66321e9812d Mon Sep 17 00:00:00 2001 From: Wei Chen Date: Fri, 14 Dec 2018 16:22:17 -0800 Subject: FR47367: Location client API for External AP (1) In location data struct, change size_t to uint32_t as size_t is machine dependent and can not be sent as part of payload to the other processor. (2) Change LocIpc ifdef to match with the file name Change-Id: Ia3f029641106a547e18904be1e3fb56ec09de569 CRs-fixed: 2367517 --- location/LocationDataTypes.h | 70 ++++++++++++++++++++++---------------------- utils/LocIpc.h | 6 ++-- utils/gps_extended_c.h | 1 + utils/log_util.h | 9 ++++++ 4 files changed, 48 insertions(+), 38 deletions(-) diff --git a/location/LocationDataTypes.h b/location/LocationDataTypes.h index e478473..e4e4b07 100644 --- a/location/LocationDataTypes.h +++ b/location/LocationDataTypes.h @@ -640,7 +640,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 @@ -657,7 +657,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 @@ -684,7 +684,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) {} @@ -708,7 +708,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) {} @@ -720,27 +720,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 @@ -748,7 +748,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; @@ -882,7 +882,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 @@ -918,7 +918,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 @@ -931,7 +931,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 @@ -943,7 +943,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 @@ -960,7 +960,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; @@ -984,7 +984,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; @@ -998,29 +998,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; @@ -1028,9 +1028,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 && @@ -1039,7 +1039,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 @@ -1059,7 +1059,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; @@ -1093,7 +1093,7 @@ struct GnssConfig{ }; typedef struct { - size_t size; // set to sizeof + uint32_t size; // set to sizeof bool mValid; Location mLocation; double verticalAccuracyMeters; @@ -1103,7 +1103,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; @@ -1111,7 +1111,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; @@ -1123,7 +1123,7 @@ typedef struct { } GnssDebugSatelliteInfo; typedef struct { - size_t size; // set to sizeof + uint32_t size; // set to sizeof GnssDebugLocation mLocation; GnssDebugTime mTime; std::vector mSatelliteInfo; @@ -1198,7 +1198,7 @@ typedef std::function collectiveResponseCallback; @@ -1214,7 +1214,7 @@ typedef std::function batchingCallback; @@ -1301,7 +1301,7 @@ typedef enum { } 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 diff --git a/utils/LocIpc.h b/utils/LocIpc.h index 2288a0a..90f9e1b 100644 --- a/utils/LocIpc.h +++ b/utils/LocIpc.h @@ -27,8 +27,8 @@ * */ -#ifndef __LOC_SOCKET__ -#define __LOC_SOCKET__ +#ifndef __LOC_IPC__ +#define __LOC_IPC__ #include #include @@ -149,4 +149,4 @@ private: } -#endif //__LOC_SOCKET__ +#endif //__LOC_IPC__ diff --git a/utils/gps_extended_c.h b/utils/gps_extended_c.h index 22b2dd0..9b38c0e 100644 --- a/utils/gps_extended_c.h +++ b/utils/gps_extended_c.h @@ -1994,6 +1994,7 @@ typedef void (*LocAgpsCloseResultCb)(bool isSuccess, AGpsExtType agpsType, void* #define SOCKET_DIR_TO_CLIENT "/dev/socket/loc_client/" #define SOCKET_TO_LOCATION_CLIENT_BASE "/dev/socket/loc_client/toclient" +#define SOCKET_TO_EXTERANL_AP_LOCATION_CLIENT_BASE "/dev/socket/loc_client/extap.toclient" #ifdef __cplusplus } diff --git a/utils/log_util.h b/utils/log_util.h index 4fed90b..ed7e19e 100644 --- a/utils/log_util.h +++ b/utils/log_util.h @@ -47,6 +47,14 @@ #endif /* LOG_TAG */ // LE targets with no logcat support +#ifdef FEATURE_EXTERNAL_AP +#include +#define ALOGE(...) syslog(LOG_ERR, "LOC_LOGE: " __VA_ARGS__); +#define ALOGW(...) syslog(LOG_WARNING, "LOC_LOGW: " __VA_ARGS__); +#define ALOGI(...) syslog(LOG_NOTICE, "LOC_LOGI: " __VA_ARGS__); +#define ALOGD(...) syslog(LOG_DEBUG, "LOC_LOGD: " __VA_ARGS__); +#define ALOGV(...) syslog(LOG_NOTICE, "LOC_LOGV: " __VA_ARGS__); +#else /* FEATURE_EXTERNAL_AP */ #define TS_PRINTF(format, x...) \ { \ struct timeval tv; \ @@ -64,6 +72,7 @@ #define ALOGI(format, x...) TS_PRINTF("I/%s (%d): " format , LOG_TAG, getpid(), ##x) #define ALOGD(format, x...) TS_PRINTF("D/%s (%d): " format , LOG_TAG, getpid(), ##x) #define ALOGV(format, x...) TS_PRINTF("V/%s (%d): " format , LOG_TAG, getpid(), ##x) +#endif /* FEATURE_EXTERNAL_AP */ #endif /* #if defined (USE_ANDROID_LOGGING) || defined (ANDROID) */ -- cgit v1.2.3 From 9a055d5208d598a841404ba5276c00e060f62fca Mon Sep 17 00:00:00 2001 From: Kevin Tang Date: Tue, 12 Feb 2019 18:44:00 -0800 Subject: Fix race condition that adapter does not get handleEngineUp - Removed redundant injectFeatureConfig() call, as it this happens twice, once when the first context is created which would have been too early and once when LocApi open success. - Resolved a race condition that second adapter added may not have been in LocApi's adapter list yet when handleEngineUp() is broadcast. Change-Id: I8ecc18eab6b450c326c0be1abc011f70285439aa CRs-Fixed: 2397902 --- core/LocApiBase.cpp | 20 +++++++++++++------- core/LocDualContext.cpp | 21 +++------------------ core/LocDualContext.h | 1 - 3 files changed, 16 insertions(+), 26 deletions(-) diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp index c2ee411..13b1c71 100644 --- a/core/LocApiBase.cpp +++ b/core/LocApiBase.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -95,7 +96,10 @@ struct LocSsrMsg : public LocMsg { } inline virtual void proc() const { mLocApi->close(); - mLocApi->open(mLocApi->getEvtMask()); + if (LOC_API_ADAPTER_ERR_SUCCESS == mLocApi->open(mLocApi->getEvtMask())) { + // Notify adapters that engine up after SSR + mLocApi->handleEngineUpEvent(); + } } inline void locallog() const { LOC_LOGV("LocSsrMsg"); @@ -107,13 +111,17 @@ struct LocSsrMsg : public LocMsg { struct LocOpenMsg : public LocMsg { LocApiBase* mLocApi; - inline LocOpenMsg(LocApiBase* locApi) : - LocMsg(), mLocApi(locApi) + LocAdapterBase* mAdapter; + inline LocOpenMsg(LocApiBase* locApi, LocAdapterBase* adapter = nullptr) : + LocMsg(), mLocApi(locApi), mAdapter(adapter) { locallog(); } inline virtual void proc() const { - mLocApi->open(mLocApi->getEvtMask()); + if (LOC_API_ADAPTER_ERR_SUCCESS == mLocApi->open(mLocApi->getEvtMask()) && + nullptr != mAdapter) { + mAdapter->handleEngineUpEvent(); + } } inline void locallog() const { LOC_LOGv("LocOpen Mask: %" PRIx64 "\n", mLocApi->getEvtMask()); @@ -222,7 +230,7 @@ void LocApiBase::addAdapter(LocAdapterBase* adapter) for (int i = 0; i < MAX_ADAPTERS && mLocAdapters[i] != adapter; i++) { if (mLocAdapters[i] == NULL) { mLocAdapters[i] = adapter; - mMsgTask->sendMsg(new LocOpenMsg(this)); + mMsgTask->sendMsg(new LocOpenMsg(this, adapter)); break; } } @@ -295,8 +303,6 @@ void LocApiBase::updateNmeaMask(uint32_t mask) void LocApiBase::handleEngineUpEvent() { - LocDualContext::injectFeatureConfig(mContext); - // loop through adapters, and deliver to all adapters. TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineUpEvent()); } diff --git a/core/LocDualContext.cpp b/core/LocDualContext.cpp index 180d9dc..9851d61 100644 --- a/core/LocDualContext.cpp +++ b/core/LocDualContext.cpp @@ -55,7 +55,6 @@ LocDualContext::mBgExclMask = const MsgTask* LocDualContext::mMsgTask = NULL; ContextBase* LocDualContext::mFgContext = NULL; 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 @@ -91,11 +90,6 @@ ContextBase* LocDualContext::getLocFgContext(LocThread::tCreate tCreator, mFgContext = new LocDualContext(msgTask, mFgExclMask); } - if(NULL == mInjectContext) { - LOC_LOGD("%s:%d]: mInjectContext is FgContext", __func__, __LINE__); - mInjectContext = mFgContext; - injectFeatureConfig(mInjectContext); - } pthread_mutex_unlock(&LocDualContext::mGetLocContextMutex); if (firstMsg) { @@ -116,11 +110,6 @@ ContextBase* LocDualContext::getLocBgContext(LocThread::tCreate tCreator, mBgContext = new LocDualContext(msgTask, mBgExclMask); } - if(NULL == mInjectContext) { - LOC_LOGD("%s:%d]: mInjectContext is BgContext", __func__, __LINE__); - mInjectContext = mBgContext; - injectFeatureConfig(mInjectContext); - } pthread_mutex_unlock(&LocDualContext::mGetLocContextMutex); if (firstMsg) { @@ -132,13 +121,9 @@ ContextBase* LocDualContext::getLocBgContext(LocThread::tCreate tCreator, void LocDualContext :: injectFeatureConfig(ContextBase *curContext) { - LOC_LOGD("%s:%d]: Enter", __func__, __LINE__); - if(curContext == mInjectContext) { - LOC_LOGD("%s:%d]: Calling LBSProxy (%p) to inject feature config", - __func__, __LINE__, ((LocDualContext *)mInjectContext)->mLBSProxy); - ((LocDualContext *)mInjectContext)->mLBSProxy->injectFeatureConfig(curContext); - } - LOC_LOGD("%s:%d]: Exit", __func__, __LINE__); + LOC_LOGD("%s:%d]: Calling LBSProxy (%p) to inject feature config", + __func__, __LINE__, ((LocDualContext *)curContext)->mLBSProxy); + ((LocDualContext *)curContext)->mLBSProxy->injectFeatureConfig(curContext); } LocDualContext::LocDualContext(const MsgTask* msgTask, diff --git a/core/LocDualContext.h b/core/LocDualContext.h index 3b3ce2c..edfbfb7 100644 --- a/core/LocDualContext.h +++ b/core/LocDualContext.h @@ -40,7 +40,6 @@ class LocDualContext : public ContextBase { static const MsgTask* mMsgTask; static ContextBase* mFgContext; static ContextBase* mBgContext; - static ContextBase* mInjectContext; static const MsgTask* getMsgTask(LocThread::tCreate tCreator, const char* name, bool joinable = true); static const MsgTask* getMsgTask(const char* name, bool joinable = true); -- cgit v1.2.3 From ae8db6cf15b243e58efddae88d2790a4a59bca81 Mon Sep 17 00:00:00 2001 From: Naresh Munagala Date: Wed, 10 Oct 2018 16:53:28 +0530 Subject: add remove api for message queue Change-Id: I278eca90ebb50e291a1b9076caf46f41a074b1d7 CRs-Fixed: 2338245 --- utils/linked_list.h | 2 ++ utils/msg_q.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ utils/msg_q.h | 23 +++++++++++++++++++++++ 3 files changed, 70 insertions(+) diff --git a/utils/linked_list.h b/utils/linked_list.h index a85f09a..0b33ecb 100644 --- a/utils/linked_list.h +++ b/utils/linked_list.h @@ -50,6 +50,8 @@ typedef enum /**< Failed because an there were not enough resources. */ eLINKED_LIST_INSUFFICIENT_BUFFER = -5, /**< Failed because an the supplied buffer was too small. */ + eLINKED_LIST_EMPTY = -6 + /**< Failed because list is empty. */ }linked_list_err_type; /*=========================================================================== diff --git a/utils/msg_q.c b/utils/msg_q.c index 76c1478..2d49b4a 100644 --- a/utils/msg_q.c +++ b/utils/msg_q.c @@ -265,6 +265,51 @@ msq_q_err_type msg_q_rcv(void* msg_q_data, void** msg_obj) return rv; } +/*=========================================================================== + + FUNCTION: msg_q_rmv + + ===========================================================================*/ +msq_q_err_type msg_q_rmv(void* msg_q_data, void** msg_obj) +{ + msq_q_err_type rv; + if (msg_q_data == NULL) { + LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__); + return eMSG_Q_INVALID_HANDLE; + } + + if (msg_obj == NULL) { + LOC_LOGE("%s: Invalid msg_obj parameter!\n", __FUNCTION__); + return eMSG_Q_INVALID_PARAMETER; + } + + msg_q* p_msg_q = (msg_q*)msg_q_data; + + pthread_mutex_lock(&p_msg_q->list_mutex); + + if (p_msg_q->unblocked) { + LOC_LOGE("%s: Message queue has been unblocked.\n", __FUNCTION__); + pthread_mutex_unlock(&p_msg_q->list_mutex); + return eMSG_Q_UNAVAILABLE_RESOURCE; + } + + if (linked_list_empty(p_msg_q->msg_list)) { + LOC_LOGW("%s: list is empty !!\n", __FUNCTION__); + pthread_mutex_unlock(&p_msg_q->list_mutex); + return eLINKED_LIST_EMPTY; + } + + rv = convert_linked_list_err_type(linked_list_remove(p_msg_q->msg_list, msg_obj)); + + pthread_mutex_unlock(&p_msg_q->list_mutex); + + LOC_LOGV("%s: Removed message %p rv = %d\n", __FUNCTION__, *msg_obj, rv); + + return rv; +} + + + /*=========================================================================== FUNCTION: msg_q_flush diff --git a/utils/msg_q.h b/utils/msg_q.h index 453b8ce..16df494 100644 --- a/utils/msg_q.h +++ b/utils/msg_q.h @@ -157,6 +157,29 @@ SIDE EFFECTS ===========================================================================*/ msq_q_err_type msg_q_rcv(void* msg_q_data, void** msg_obj); +/*=========================================================================== +FUNCTION msg_q_rmv + +DESCRIPTION + Remove data from the message queue. msg_obj is the oldest message received + and pointer is simply removed from message queue. + + msg_q_data: Message Queue to copy data from into msgp. + msg_obj: Pointer to space to copy msg_q contents to. + +DEPENDENCIES + N/A + +RETURN VALUE + Look at error codes above. + +SIDE EFFECTS + N/A + +===========================================================================*/ +msq_q_err_type msg_q_rmv(void* msg_q_data, void** msg_obj); + + /*=========================================================================== FUNCTION msg_q_flush -- cgit v1.2.3 From 6b687ef48e134b153a256cb0c8f05860722de72e Mon Sep 17 00:00:00 2001 From: Yingjie Wang Date: Tue, 19 Feb 2019 18:37:58 +0800 Subject: Combine updateConfig in GnssAdapter Adjust setConfigCommand and gnssUpdateConfigCommand to use one gnssUpdateConfig method. CRs-fixed: 2402752 Change-Id: I6a9ec474bd9ffed52edd2422574af0f6d41493c4 --- gnss/GnssAdapter.cpp | 378 +++++++++++++++++++++++++++------------------------ gnss/GnssAdapter.h | 4 + 2 files changed, 207 insertions(+), 175 deletions(-) diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index e0290ad..fe02db1 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -681,45 +681,36 @@ GnssAdapter::setConfigCommand() mApi.sendMsg(new LocApiMsg( [&adapter, gpsConf, sapConf, oldServerUrl, oldMoServerUrl] () { - - std::string serverUrl = adapter.getServerUrl(); - std::string moServerUrl = adapter.getMoServerUrl(); - int serverUrlLen = serverUrl.length(); - int moServerUrlLen = moServerUrl.length(); - - if (gpsConf.AGPS_CONFIG_INJECT) { - adapter.mLocApi->setSUPLVersionSync( - adapter.mLocApi->convertSuplVersion(gpsConf.SUPL_VER)); - adapter.mLocApi->setLPPConfigSync( - adapter.mLocApi->convertLppProfile(gpsConf.LPP_PROFILE)); - adapter.mLocApi->setAGLONASSProtocolSync( - gpsConf.A_GLONASS_POS_PROTOCOL_SELECT); + //cache the injected configuration with GnssConfigRequested struct + GnssConfig gnssConfigRequested = {}; + gnssConfigRequested.flags |= GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT | + GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT | + GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT | + GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT; + gnssConfigRequested.gpsLock = GNSS_CONFIG_GPS_LOCK_NONE; + if (0 == adapter.getPowerVoteId()) { + gnssConfigRequested.gpsLock = adapter.convertGpsLock(gpsConf.GPS_LOCK); } - if ((serverUrlLen !=0) && (oldServerUrl.compare(serverUrl) != 0)) { - LocationError locErr = - adapter.mLocApi->setServerSync(serverUrl.c_str(), serverUrlLen, - LOC_AGPS_SUPL_SERVER); - if (locErr != LOCATION_ERROR_SUCCESS) { - LOC_LOGe("Error while setting SUPL_HOST server:%s", - serverUrl.c_str()); - } - } - if ((moServerUrlLen != 0) && (oldMoServerUrl.compare(moServerUrl) != 0)) { - LocationError locErr = - adapter.mLocApi->setServerSync(moServerUrl.c_str(), - moServerUrlLen, - LOC_AGPS_MO_SUPL_SERVER); - if (locErr != LOCATION_ERROR_SUCCESS) { - LOC_LOGe("Error while setting MO SUPL_HOST server:%s", - moServerUrl.c_str()); - } + if (gpsConf.AGPS_CONFIG_INJECT) { + gnssConfigRequested.flags |= GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT | + GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT | + GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT; + gnssConfigRequested.suplVersion = + adapter.mLocApi->convertSuplVersion(gpsConf.SUPL_VER); + gnssConfigRequested.lppProfile = + adapter.mLocApi->convertLppProfile(gpsConf.LPP_PROFILE); + gnssConfigRequested.aGlonassPositionProtocolMask = + gpsConf.A_GLONASS_POS_PROTOCOL_SELECT; } - - adapter.mLocApi->setLPPeProtocolCpSync( - adapter.mLocApi->convertLppeCp(gpsConf.LPPE_CP_TECHNOLOGY)); - adapter.mLocApi->setLPPeProtocolUpSync( - adapter.mLocApi->convertLppeUp(gpsConf.LPPE_UP_TECHNOLOGY)); + gnssConfigRequested.lppeControlPlaneMask = + adapter.mLocApi->convertLppeCp(gpsConf.LPPE_CP_TECHNOLOGY); + gnssConfigRequested.lppeUserPlaneMask = + adapter.mLocApi->convertLppeUp(gpsConf.LPPE_UP_TECHNOLOGY); + gnssConfigRequested.blacklistedSvIds.assign(adapter.mBlacklistedSvIds.begin(), + adapter.mBlacklistedSvIds.end()); + adapter.gnssUpdateConfig(oldServerUrl, oldMoServerUrl, gnssConfigRequested, + gnssConfigRequested); // set nmea mask type uint32_t mask = 0; @@ -778,6 +769,180 @@ GnssAdapter::setConfigCommand() sendMsg(new MsgSetConfig(*this, *mLocApi)); } +std::vector GnssAdapter::gnssUpdateConfig(const std::string& oldServerUrl, + const std::string& oldMoServerUrl, const GnssConfig& gnssConfigRequested, + const GnssConfig& gnssConfigNeedEngineUpdate, size_t count) { + loc_gps_cfg_s gpsConf = ContextBase::mGps_conf; + size_t index = 0; + LocationError err = LOCATION_ERROR_SUCCESS; + std::vector errsList = {err}; + if (count > 0) { + errsList.insert(errsList.begin(), count, LOCATION_ERROR_SUCCESS); + } + + + std::string serverUrl = getServerUrl(); + std::string moServerUrl = getMoServerUrl(); + + int serverUrlLen = serverUrl.length(); + int moServerUrlLen = moServerUrl.length(); + + if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) { + if (gnssConfigNeedEngineUpdate.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) { + err = mLocApi->setGpsLockSync(gnssConfigRequested.gpsLock); + if (index < count) { + errsList[index] = err; + } + } + index++; + } + + if (gnssConfigRequested.flags & + GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) { + if (gnssConfigNeedEngineUpdate.flags & + GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) { + if (gnssConfigNeedEngineUpdate.assistanceServer.type == + GNSS_ASSISTANCE_TYPE_SUPL) { + if ((serverUrlLen != 0) && (oldServerUrl.compare(serverUrl) !=0)) { + + err = mLocApi->setServerSync( + serverUrl.c_str(), serverUrlLen, LOC_AGPS_SUPL_SERVER); + if (index < count) { + errsList[index] = err; + } + } + if ((moServerUrlLen != 0) && (oldMoServerUrl.compare(moServerUrl) != 0)) { + LocationError locErr = + mLocApi->setServerSync(moServerUrl.c_str(), + moServerUrlLen, + LOC_AGPS_MO_SUPL_SERVER); + if (locErr != LOCATION_ERROR_SUCCESS) { + LOC_LOGe("Error while setting MO SUPL_HOST server:%s", + moServerUrl.c_str()); + } + } + } else if (gnssConfigNeedEngineUpdate.assistanceServer.type == + GNSS_ASSISTANCE_TYPE_C2K) { + struct in_addr addr; + struct hostent* hp; + bool resolveAddrSuccess = true; + + hp = gethostbyname( + gnssConfigNeedEngineUpdate.assistanceServer.hostName); + if (hp != NULL) { /* DNS OK */ + memcpy(&addr, hp->h_addr_list[0], hp->h_length); + } else { + /* Try IP representation */ + if (inet_aton( + gnssConfigNeedEngineUpdate.assistanceServer.hostName, + &addr) == 0) { + /* IP not valid */ + LOC_LOGE("%s]: hostname '%s' cannot be resolved ", + __func__, + gnssConfigNeedEngineUpdate.assistanceServer.hostName); + if (index < count) { + errsList[index] = LOCATION_ERROR_INVALID_PARAMETER; + } + } else { + resolveAddrSuccess = false; + } + } + + if (resolveAddrSuccess) { + unsigned int ip = htonl(addr.s_addr); + err = mLocApi->setServerSync(ip, + gnssConfigNeedEngineUpdate.assistanceServer.port, + LOC_AGPS_CDMA_PDE_SERVER); + if (index < count) { + errsList[index] = err; + } + } + } + } + index++; + } + + if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) { + if (gnssConfigNeedEngineUpdate.flags & + GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) { + err = mLocApi->setSUPLVersionSync(gnssConfigRequested.suplVersion); + if (index < count) { + errsList[index] = err; + } + } + index++; + } + + if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) { + if (gnssConfigNeedEngineUpdate.flags & + GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) { + err = mLocApi->setLPPConfigSync(gnssConfigRequested.lppProfile); + if (index < count) { + errsList[index] = err; + } + } + index++; + } + + if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) { + if (gnssConfigNeedEngineUpdate.flags & + GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) { + err = mLocApi->setLPPeProtocolCpSync( + gnssConfigRequested.lppeControlPlaneMask); + if (index < count) { + errsList[index] = err; + } + } + index++; + } + + if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) { + if (gnssConfigNeedEngineUpdate.flags & + GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) { + err = mLocApi->setLPPeProtocolUpSync( + gnssConfigRequested.lppeUserPlaneMask); + if (index < count) { + errsList[index] = err; + } + } + index++; + } + + if (gnssConfigRequested.flags & + GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) { + if (gnssConfigNeedEngineUpdate.flags & + GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) { + err = mLocApi->setAGLONASSProtocolSync( + gnssConfigRequested.aGlonassPositionProtocolMask); + if (index < count) { + errsList[index] = err; + } + } + index++; + } + if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT) { + // Check if feature is supported + if (!ContextBase::isFeatureSupported( + LOC_SUPPORTED_FEATURE_CONSTELLATION_ENABLEMENT_V02)) { + LOC_LOGe("Feature constellation enablement not supported."); + err = LOCATION_ERROR_NOT_SUPPORTED; + } else { + // Send the SV ID Config to Modem + mBlacklistedSvIds.assign(gnssConfigRequested.blacklistedSvIds.begin(), + gnssConfigRequested.blacklistedSvIds.end()); + err = gnssSvIdConfigUpdateSync(gnssConfigRequested.blacklistedSvIds); + if (LOCATION_ERROR_SUCCESS != err) { + LOC_LOGe("Failed to send config to modem, err %d", err); + } + } + if (index < count) { + errsList[index] = err; + } + index++; + } + return errsList; +} + uint32_t* GnssAdapter::gnssUpdateConfigCommand(GnssConfig config) { @@ -962,148 +1127,11 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config) mApi.sendMsg(new LocApiMsg( [&adapter, gnssConfigRequested, gnssConfigNeedEngineUpdate, countOfConfigs, configCollectiveResponse, errs, oldServerUrl] () { - - size_t index = 0; - LocationError err = LOCATION_ERROR_SUCCESS; - std::vector errsList(errs); - std::string serverUrl = adapter.getServerUrl(); int serverUrlLen = serverUrl.length(); + std::vector errsList = adapter.gnssUpdateConfig(oldServerUrl, + "", gnssConfigRequested, gnssConfigNeedEngineUpdate, countOfConfigs); - if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) { - if (gnssConfigNeedEngineUpdate.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) { - err = adapter.mLocApi->setGpsLockSync(gnssConfigRequested.gpsLock); - if (index < countOfConfigs) { - errsList[index] = err; - } - } - index++; - } - if (gnssConfigRequested.flags & - GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) { - if (gnssConfigNeedEngineUpdate.flags & - GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) { - if (gnssConfigNeedEngineUpdate.assistanceServer.type == - GNSS_ASSISTANCE_TYPE_SUPL) { - if ((serverUrlLen != 0) && (oldServerUrl.compare(serverUrl) !=0)) { - err = adapter.mLocApi->setServerSync( - serverUrl.c_str(), serverUrlLen, LOC_AGPS_SUPL_SERVER); - if (index < countOfConfigs) { - errsList[index] = err; - } - } - } else if (gnssConfigNeedEngineUpdate.assistanceServer.type == - GNSS_ASSISTANCE_TYPE_C2K) { - struct in_addr addr; - struct hostent* hp; - bool resolveAddrSuccess = true; - - hp = gethostbyname( - gnssConfigNeedEngineUpdate.assistanceServer.hostName); - if (hp != NULL) { /* DNS OK */ - memcpy(&addr, hp->h_addr_list[0], hp->h_length); - } else { - /* Try IP representation */ - if (inet_aton( - gnssConfigNeedEngineUpdate.assistanceServer.hostName, - &addr) == 0) { - /* IP not valid */ - LOC_LOGE("%s]: hostname '%s' cannot be resolved ", - __func__, - gnssConfigNeedEngineUpdate.assistanceServer.hostName); - if (index < countOfConfigs) { - errsList[index] = LOCATION_ERROR_INVALID_PARAMETER; - } - } else { - resolveAddrSuccess = false; - } - } - - if (resolveAddrSuccess) { - unsigned int ip = htonl(addr.s_addr); - err = adapter.mLocApi->setServerSync(ip, - gnssConfigNeedEngineUpdate.assistanceServer.port, - LOC_AGPS_CDMA_PDE_SERVER); - if (index < countOfConfigs) { - errsList[index] = err; - } - } - } - } - index++; - } - if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) { - if (gnssConfigNeedEngineUpdate.flags & - GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) { - err = adapter.mLocApi->setSUPLVersionSync(gnssConfigRequested.suplVersion); - if (index < countOfConfigs) { - errsList[index] = err; - } - } - index++; - } - if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) { - if (gnssConfigNeedEngineUpdate.flags & - GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) { - err = adapter.mLocApi->setLPPConfigSync(gnssConfigRequested.lppProfile); - if (index < countOfConfigs) { - errsList[index] = err; - } - } - index++; - } - if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) { - if (gnssConfigNeedEngineUpdate.flags & - GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) { - err = adapter.mLocApi->setLPPeProtocolCpSync( - gnssConfigRequested.lppeControlPlaneMask); - if (index < countOfConfigs) { - errsList[index] = err; - } - } - index++; - } - if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) { - if (gnssConfigNeedEngineUpdate.flags & - GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) { - err = adapter.mLocApi->setLPPeProtocolUpSync( - gnssConfigRequested.lppeUserPlaneMask); - if (index < countOfConfigs) { - errsList[index] = err; - } - } - index++; - } - if (gnssConfigRequested.flags & - GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) { - if (gnssConfigNeedEngineUpdate.flags & - GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) { - err = adapter.mLocApi->setAGLONASSProtocolSync( - gnssConfigRequested.aGlonassPositionProtocolMask); - if (index < countOfConfigs) { - errsList[index] = err; - } - } - index++; - } - if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT) { - // Check if feature is supported - if (!ContextBase::isFeatureSupported( - LOC_SUPPORTED_FEATURE_CONSTELLATION_ENABLEMENT_V02)) { - LOC_LOGe("Feature constellation enablement not supported."); - err = LOCATION_ERROR_NOT_SUPPORTED; - } else { - // Send the SV ID Config to Modem - err = adapter.gnssSvIdConfigUpdateSync(gnssConfigRequested.blacklistedSvIds); - if (LOCATION_ERROR_SUCCESS != err) { - LOC_LOGe("Failed to send config to modem, err %d", err); - } - } - if (index < countOfConfigs) { - errsList[index] = err; - } - index++; - } configCollectiveResponse->returnToSender(errsList); })); } diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h index 55cadba..381ccf4 100644 --- a/gnss/GnssAdapter.h +++ b/gnss/GnssAdapter.h @@ -175,6 +175,7 @@ class GnssAdapter : public LocAdapterBase { std::string mMoServerUrl; XtraSystemStatusObserver mXtraObserver; LocationSystemInfo mLocSystemInfo; + std::vector mBlacklistedSvIds; /* === Misc ===================================================================== */ BlockCPIInfo mBlockCPIInfo; @@ -278,6 +279,9 @@ public: uint32_t gnssDeleteAidingDataCommand(GnssAidingData& data); void deleteAidingData(const GnssAidingData &data, uint32_t sessionId); void gnssUpdateXtraThrottleCommand(const bool enabled); + std::vector gnssUpdateConfig(const std::string& oldServerUrl, + const std::string& oldMoServerUrl, const GnssConfig& gnssConfigRequested, + const GnssConfig& gnssConfigNeedEngineUpdate, size_t count = 0); /* ==== GNSS SV TYPE CONFIG ============================================================ */ /* ==== COMMANDS ====(Called from Client Thread)======================================== */ -- cgit v1.2.3