diff options
author | Isaac Chen <isaacchen@isaacchen.cn> | 2018-12-31 10:55:08 +0100 |
---|---|---|
committer | TingyiChen <tingyi364@gmail.com> | 2019-08-13 11:54:40 +0200 |
commit | e5c53750f06e9d9739b45ec108260ead7ff80941 (patch) | |
tree | fe1d84884caefc481e994ae9c59c84b11fddd408 /gps/utils | |
parent | 3ac2a0309619515c9ac27a5b6ec7c212b86dc355 (diff) |
wayne-common: Synchorize gps to P
* QC Tag: LA.UM.7.2.r1-04900-sdm660.0
Signed-off-by: Isaac Chen <isaacchen@isaacchen.cn>
Change-Id: I34383e8fbf394b774f83f8d662873e8786ff1bbf
Diffstat (limited to 'gps/utils')
59 files changed, 1585 insertions, 1763 deletions
diff --git a/gps/utils/Android.mk b/gps/utils/Android.mk index 197cd76..b8320de 100644 --- a/gps/utils/Android.mk +++ b/gps/utils/Android.mk @@ -11,8 +11,7 @@ include $(CLEAR_VARS) LOCAL_SHARED_LIBRARIES := \ libutils \ libcutils \ - liblog \ - libloc_pla + liblog LOCAL_SRC_FILES += \ loc_log.cpp \ @@ -20,13 +19,13 @@ LOCAL_SRC_FILES += \ msg_q.c \ linked_list.c \ loc_target.cpp \ - platform_lib_abstractions/elapsed_millis_since_boot.cpp \ LocHeap.cpp \ LocTimer.cpp \ LocThread.cpp \ MsgTask.cpp \ loc_misc_utils.cpp \ - loc_nmea.cpp + loc_nmea.cpp \ + LocIpc.cpp # Flag -std=c++11 is not accepted by compiler when LOCAL_CLANG is set to true LOCAL_CFLAGS += \ @@ -41,12 +40,12 @@ LOCAL_LDFLAGS += -Wl,--export-dynamic ## Includes LOCAL_HEADER_LIBRARIES := \ + libutils_headers \ libloc_pla_headers \ liblocation_api_headers LOCAL_MODULE := libgps.utils LOCAL_VENDOR_MODULE := true -LOCAL_MODULE_OWNER := qti LOCAL_MODULE_TAGS := optional LOCAL_PRELINK_MODULE := false @@ -60,6 +59,5 @@ LOCAL_MODULE := libgps.utils_headers LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) include $(BUILD_HEADER_LIBRARY) -include $(addsuffix /Android.mk, $(addprefix $(LOCAL_PATH)/, platform_lib_abstractions)) endif # not BUILD_TINY_ANDROID endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE diff --git a/gps/utils/LocIpc.cpp b/gps/utils/LocIpc.cpp new file mode 100644 index 0000000..675664a --- /dev/null +++ b/gps/utils/LocIpc.cpp @@ -0,0 +1,237 @@ +/* Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <sys/types.h> +#include <sys/stat.h> +#include <errno.h> +#include <log_util.h> +#include "LocIpc.h" + +namespace loc_util { + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "LocSvc_LocIpc" + +#define LOC_MSG_BUF_LEN 8192 +#define LOC_MSG_HEAD "$MSGLEN$" +#define LOC_MSG_ABORT "LocIpcMsg::ABORT" + +class LocIpcRunnable : public LocRunnable { +friend LocIpc; +public: + LocIpcRunnable(LocIpc& locIpc, const std::string& ipcName) + : mLocIpc(locIpc), mIpcName(ipcName) {} + bool run() override { + if (!mLocIpc.startListeningBlocking(mIpcName)) { + LOC_LOGe("listen to socket failed"); + } + + return false; + } +private: + LocIpc& mLocIpc; + const std::string mIpcName; +}; + +bool LocIpc::startListeningNonBlocking(const std::string& name) { + mRunnable = new LocIpcRunnable(*this, name); + std::string threadName("LocIpc-"); + threadName.append(name); + return mThread.start(threadName.c_str(), mRunnable); +} + +bool LocIpc::startListeningBlocking(const std::string& name) { + + int fd = socket(AF_UNIX, SOCK_DGRAM, 0); + if (fd < 0) { + LOC_LOGe("create socket error. reason:%s", strerror(errno)); + return false; + } + + if ((unlink(name.c_str()) < 0) && (errno != ENOENT)) { + LOC_LOGw("unlink socket error. reason:%s", strerror(errno)); + } + + struct sockaddr_un addr = { .sun_family = AF_UNIX }; + snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", name.c_str()); + + umask(0157); + + if (::bind(fd, (struct sockaddr*)&addr, sizeof(addr)) < 0) { + LOC_LOGe("bind socket error. reason:%s", strerror(errno)); + ::close(fd); + fd = -1; + return false; + } + + 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; + } + + if (strncmp(msg.data(), abort.c_str(), abort.length()) == 0) { + LOC_LOGi("recvd abort msg.data %s", msg.data()); + break; + } + + 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 (nBytes > 0) { + onReceive(msg); + } else { + break; + } + } + } + + if (mStopRequested) { + mStopRequested = false; + return true; + } else { + LOC_LOGe("cannot read socket. reason:%s", strerror(errno)); + (void)::close(mIpcFd); + mIpcFd = -1; + return false; + } +} + +void LocIpc::stopListening() { + + const char *socketName = nullptr; + mStopRequested = true; + + if (mRunnable) { + std::string abort = LOC_MSG_ABORT; + socketName = (reinterpret_cast<LocIpcRunnable *>(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); + } +} + +bool LocIpc::send(const char name[], const std::string& data) { + return send(name, (const uint8_t*)data.c_str(), data.length()); +} + +bool LocIpc::send(const char name[], const uint8_t data[], uint32_t length) { + + bool result = true; + int fd = ::socket(AF_UNIX, SOCK_DGRAM, 0); + if (fd < 0) { + LOC_LOGe("create socket error. reason:%s", strerror(errno)); + return false; + } + + struct sockaddr_un addr = { .sun_family = AF_UNIX }; + snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", name); + + result = sendData(fd, addr, data, length); + + (void)::close(fd); + return result; +} + + +bool LocIpc::sendData(int fd, const sockaddr_un &addr, const uint8_t data[], uint32_t length) { + + bool result = true; + + if (length <= LOC_MSG_BUF_LEN) { + if (::sendto(fd, data, length, 0, + (struct sockaddr*)&addr, sizeof(addr)) < 0) { + LOC_LOGe("cannot send to socket. reason:%s", strerror(errno)); + result = false; + } + } else { + std::string head = LOC_MSG_HEAD; + head.append(std::to_string(length)); + if (::sendto(fd, head.c_str(), head.length(), 0, + (struct sockaddr*)&addr, sizeof(addr)) < 0) { + LOC_LOGe("cannot send to socket. reason:%s", strerror(errno)); + result = false; + } else { + size_t sentBytes = 0; + while(sentBytes < length) { + size_t partLen = length - sentBytes; + if (partLen > LOC_MSG_BUF_LEN) { + partLen = LOC_MSG_BUF_LEN; + } + ssize_t rv = ::sendto(fd, data + sentBytes, partLen, 0, + (struct sockaddr*)&addr, sizeof(addr)); + if (rv < 0) { + LOC_LOGe("cannot send to socket. reason:%s", strerror(errno)); + result = false; + break; + } + sentBytes += rv; + } + } + } + return result; +} + +} diff --git a/gps/utils/LocIpc.h b/gps/utils/LocIpc.h new file mode 100644 index 0000000..364093b --- /dev/null +++ b/gps/utils/LocIpc.h @@ -0,0 +1,153 @@ +/* Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __LOC_SOCKET__ +#define __LOC_SOCKET__ + +#include <string> +#include <memory> +#include <unistd.h> +#include <sys/socket.h> +#include <sys/un.h> +#include <LocThread.h> + +namespace loc_util { + +class LocIpcSender; + +class LocIpc { +friend LocIpcSender; +public: + inline LocIpc() : mIpcFd(-1), mStopRequested(false), mRunnable(nullptr) {} + inline virtual ~LocIpc() { stopListening(); } + + // Listen for new messages in current thread. Calling this funciton will + // block current thread. The listening can be stopped by calling stopListening(). + // + // Argument name is the path of the unix local socket to be listened. + // The function will return true on success, and false on failure. + bool startListeningBlocking(const std::string& name); + + // Create a new LocThread and listen for new messages in it. + // Calling this function will return immediately and won't block current thread. + // The listening can be stopped by calling stopListening(). + // + // Argument name is the path of the unix local socket to be be listened. + // The function will return true on success, and false on failure. + bool startListeningNonBlocking(const std::string& name); + + // Stop listening to new messages. + void stopListening(); + + // Send out a message. + // Call this function to send a message in argument data to socket in argument name. + // + // Argument name contains the name of the target unix socket. data contains the + // message to be sent out. Convert your message to a string before calling this function. + // The function will return true on success, and false on failure. + static bool send(const char name[], const std::string& data); + static bool send(const char name[], const uint8_t data[], uint32_t length); + +protected: + // Callback function for receiving incoming messages. + // Override this function in your derived class to process incoming messages. + // For each received message, this callback function will be called once. + // This callback function will be called in the calling thread of startListeningBlocking + // or in the new LocThread created by startListeningNonBlocking. + // + // Argument data contains the received message. You need to parse it. + inline virtual void onReceive(const std::string& /*data*/) {} + + // LocIpc client can overwrite this function to get notification + // when the socket for LocIpc is ready to receive messages. + inline virtual void onListenerReady() {} + +private: + static bool sendData(int fd, const sockaddr_un& addr, + const uint8_t data[], uint32_t length); + + int mIpcFd; + bool mStopRequested; + LocThread mThread; + LocRunnable *mRunnable; +}; + +class LocIpcSender { +public: + // Constructor of LocIpcSender class + // + // Argument destSocket contains the full path name of destination socket. + // This class hides generated fd and destination address object from user. + inline LocIpcSender(const char* destSocket): + LocIpcSender(std::make_shared<int>(::socket(AF_UNIX, SOCK_DGRAM, 0)), destSocket) { + if (-1 == *mSocket) { + mSocket = nullptr; + } + } + + // Replicate a new LocIpcSender object with new destination socket. + inline LocIpcSender* replicate(const char* destSocket) { + return (nullptr == mSocket) ? nullptr : new LocIpcSender(mSocket, destSocket); + } + + inline ~LocIpcSender() { + if (nullptr != mSocket && mSocket.unique()) { + ::close(*mSocket); + } + } + + // Send out a message. + // Call this function to send a message + // + // Argument data and length contains the message to be sent out. + // Return true when succeeded + inline bool send(const uint8_t data[], uint32_t length) { + bool rtv = false; + if (nullptr != mSocket && nullptr != data) { + rtv = LocIpc::sendData(*mSocket, mDestAddr, data, length); + } + return rtv; + } + +private: + std::shared_ptr<int> mSocket; + struct sockaddr_un mDestAddr; + + inline LocIpcSender( + const std::shared_ptr<int>& mySocket, const char* destSocket) : mSocket(mySocket) { + if ((nullptr != mSocket) && (-1 != *mSocket) && (nullptr != destSocket)) { + mDestAddr.sun_family = AF_UNIX; + snprintf(mDestAddr.sun_path, sizeof(mDestAddr.sun_path), "%s", destSocket); + } + } +}; + +} + +#endif //__LOC_SOCKET__ diff --git a/gps/utils/LocThread.cpp b/gps/utils/LocThread.cpp index d112f61..c1052cb 100644 --- a/gps/utils/LocThread.cpp +++ b/gps/utils/LocThread.cpp @@ -29,7 +29,7 @@ #include <LocThread.h> #include <string.h> #include <pthread.h> -#include <platform_lib_macros.h> +#include <loc_pla.h> class LocThreadDelegate { LocRunnable* mRunnable; diff --git a/gps/utils/LocTimer.cpp b/gps/utils/LocTimer.cpp index 5bcdd7b..93775d0 100644 --- a/gps/utils/LocTimer.cpp +++ b/gps/utils/LocTimer.cpp @@ -27,14 +27,15 @@ * */ +#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <errno.h> -#include <loc_timer.h> #include <sys/timerfd.h> #include <sys/epoll.h> -#include <unistd.h> +#include <log_util.h> +#include <loc_timer.h> #include <LocTimer.h> #include <LocHeap.h> #include <LocThread.h> diff --git a/gps/utils/LocTimer.h b/gps/utils/LocTimer.h index c6a6362..abc7f64 100644 --- a/gps/utils/LocTimer.h +++ b/gps/utils/LocTimer.h @@ -31,7 +31,7 @@ #define __LOC_TIMER_CPP_H__ #include <stddef.h> -#include <platform_lib_includes.h> +#include <loc_pla.h> // opaque class to provide service implementation. class LocTimerDelegate; diff --git a/gps/utils/LocUnorderedSetMap.h b/gps/utils/LocUnorderedSetMap.h new file mode 100644 index 0000000..8748134 --- /dev/null +++ b/gps/utils/LocUnorderedSetMap.h @@ -0,0 +1,192 @@ +/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __LOC_UNORDERDED_SETMAP_H__ +#define __LOC_UNORDERDED_SETMAP_H__ + +#include <algorithm> +#include <unordered_set> +#include <unordered_map> + +using std::unordered_set; +using std::unordered_map; + +namespace loc_util { + +// Trim from *fromSet* any elements that also exist in *rVals*. +// The optional *goneVals*, if not null, will be populated with removed elements. +template <typename T> +inline static void trimSet(unordered_set<T>& fromSet, const unordered_set<T>& rVals, + unordered_set<T>* goneVals) { + for (auto val : rVals) { + if (fromSet.erase(val) > 0 && nullptr != goneVals) { + goneVals->insert(val); + } + } +} + +// this method is destructive to the input unordered_sets. +// the return set is the interset extracted out from the two input sets, *s1* and *s2*. +// *s1* and *s2* will be left with the intersect removed from them. +template <typename T> +static unordered_set<T> removeAndReturnInterset(unordered_set<T>& s1, unordered_set<T>& s2) { + unordered_set<T> common(0); + for (auto b = s2.begin(); b != s2.end(); b++) { + auto a = find(s1.begin(), s1.end(), *b); + if (a != s1.end()) { + // this is a common item of both l1 and l2, remove from both + // but after we add to common + common.insert(*a); + s1.erase(a); + s2.erase(b); + } + } + return common; +} + +template <typename KEY, typename VAL> +class LocUnorderedSetMap { + unordered_map<KEY, unordered_set<VAL>> mMap; + + + // Trim the VALs pointed to by *iter*, with everything that also exist in *rVals*. + // If the set becomes empty, remove the map entry. *goneVals*, if not null, records + // the trimmed VALs. + bool trimOrRemove(typename unordered_map<KEY, unordered_set<VAL>>::iterator iter, + const unordered_set<VAL>& rVals, unordered_set<VAL>* goneVals) { + trimSet<VAL>(iter->second, rVals, goneVals); + bool removeEntry = (iter->second.empty()); + if (removeEntry) { + mMap.erase(iter); + } + return removeEntry; + } + +public: + inline LocUnorderedSetMap() {} + inline LocUnorderedSetMap(size_t size) : mMap(size) {} + + inline bool empty() { return mMap.empty(); } + + // This gets the raw pointer to the VALs pointed to by *key* + // If the entry is not in the map, nullptr will be returned. + inline unordered_set<VAL>* getValSetPtr(const KEY& key) { + auto entry = mMap.find(key); + return (entry != mMap.end()) ? &(entry->second) : nullptr; + } + + // This gets a copy of VALs pointed to by *key* + // If the entry is not in the map, an empty set will be returned. + inline unordered_set<VAL> getValSet(const KEY& key) { + auto entry = mMap.find(key); + return (entry != mMap.end()) ? entry->second : unordered_set<VAL>(0); + } + + // This gets all the KEYs from the map + inline unordered_set<KEY> getKeys() { + unordered_set<KEY> keys(0); + for (auto entry : mMap) { + keys.insert(entry.first); + } + return keys; + } + + inline bool remove(const KEY& key) { + return mMap.erase(key) > 0; + } + + // This looks into all the entries keyed by *keys*. Remove any VALs from the entries + // that also exist in *rVals*. If the entry is left with an empty set, the entry will + // be removed. The optional parameters *goneKeys* and *goneVals* will record the KEYs + // (or entries) and the collapsed VALs removed from the map, respectively. + inline void trimOrRemove(unordered_set<KEY>&& keys, const unordered_set<VAL>& rVals, + unordered_set<KEY>* goneKeys, unordered_set<VAL>* goneVals) { + trimOrRemove(keys, rVals, goneKeys, goneVals); + } + inline void trimOrRemove(unordered_set<KEY>& keys, const unordered_set<VAL>& rVals, + unordered_set<KEY>* goneKeys, unordered_set<VAL>* goneVals) { + for (auto key : keys) { + auto iter = mMap.find(key); + if (iter != mMap.end() && trimOrRemove(iter, rVals, goneVals) && nullptr != goneKeys) { + goneKeys->insert(iter->first); + } + } + } + + // This adds all VALs from *newVals* to the map entry keyed by *key*. Or if it + // doesn't exist yet, add the set to the map. + bool add(const KEY& key, const unordered_set<VAL>& newVals) { + bool newEntryAdded = false; + if (!newVals.empty()) { + auto iter = mMap.find(key); + if (iter != mMap.end()) { + iter->second.insert(newVals.begin(), newVals.end()); + } else { + mMap[key] = newVals; + newEntryAdded = true; + } + } + return newEntryAdded; + } + + // This adds to each of entries in the map keyed by *keys* with the VALs in the + // *enwVals*. If there new entries added (new key in *keys*), *newKeys*, if not + // null, would be populated with those keys. + inline void add(const unordered_set<KEY>& keys, const unordered_set<VAL>&& newVals, + unordered_set<KEY>* newKeys) { + add(keys, newVals, newKeys); + } + inline void add(const unordered_set<KEY>& keys, const unordered_set<VAL>& newVals, + unordered_set<KEY>* newKeys) { + for (auto key : keys) { + if (add(key, newVals) && nullptr != newKeys) { + newKeys->insert(key); + } + } + } + + // This puts *newVals* into the map keyed by *key*, and returns the VALs that are + // in effect removed from the keyed VAL set in the map entry. + // This call would also remove those same VALs from *newVals*. + inline unordered_set<VAL> update(const KEY& key, unordered_set<VAL>& newVals) { + unordered_set<VAL> goneVals(0); + + if (newVals.empty()) { + mMap.erase(key); + } else { + auto curVals = mMap[key]; + mMap[key] = newVals; + goneVals = removeAndReturnInterset(curVals, newVals); + } + return goneVals; + } +}; + +} // namespace loc_util + +#endif // #ifndef __LOC_UNORDERDED_SETMAP_H__ diff --git a/gps/utils/Makefile.am b/gps/utils/Makefile.am index 33a87da..3801fdd 100644 --- a/gps/utils/Makefile.am +++ b/gps/utils/Makefile.am @@ -1,14 +1,17 @@ -AM_CFLAGS = -Wundef \ - -I./ \ - -std=c++11 \ - $(LOCPLA_CFLAGS) +ACLOCAL_AMFLAGS = -I m4 -AM_CPPFLAGS = -Wundef \ +AM_CFLAGS = -Wundef \ + -MD \ + -Wno-trigraphs \ + -g -O0 \ + -fno-inline \ + -fno-short-enums \ + -fpic \ -I./ \ -std=c++11 \ $(LOCPLA_CFLAGS) -libgps_utils_so_la_h_sources = \ +libgps_utils_la_h_sources = \ msg_q.h \ linked_list.h \ loc_cfg.h \ @@ -19,13 +22,15 @@ libgps_utils_so_la_h_sources = \ LocHeap.h \ LocThread.h \ LocTimer.h \ + LocIpc.h \ loc_misc_utils.h \ loc_nmea.h \ gps_extended_c.h \ gps_extended.h \ - loc_gps.h + loc_gps.h \ + log_util.h -libgps_utils_so_la_c_sources = \ +libgps_utils_la_c_sources = \ linked_list.c \ msg_q.c \ loc_cfg.cpp \ @@ -34,31 +39,32 @@ libgps_utils_so_la_c_sources = \ LocHeap.cpp \ LocTimer.cpp \ LocThread.cpp \ + LocIpc.cpp \ MsgTask.cpp \ loc_misc_utils.cpp \ loc_nmea.cpp +library_includedir = $(pkgincludedir) -library_include_HEADERS = $(libgps_utils_so_la_h_sources) +library_include_HEADERS = $(libgps_utils_la_h_sources) -libgps_utils_so_la_SOURCES = $(libgps_utils_so_la_c_sources) +libgps_utils_la_SOURCES = $(libgps_utils_la_c_sources) if USE_GLIB -libgps_utils_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@ -libgps_utils_so_la_LDFLAGS = -lstdc++ -Wl,-z,defs -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 -libgps_utils_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@ +libgps_utils_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@ +libgps_utils_la_LDFLAGS = -lstdc++ -Wl,-z,defs -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 +libgps_utils_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@ else -libgps_utils_so_la_CFLAGS = $(AM_CFLAGS) -libgps_utils_so_la_LDFLAGS = -Wl,-z,defs -lpthread -shared -version-info 1:0:0 -libgps_utils_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) +libgps_utils_la_CFLAGS = $(AM_CFLAGS) +libgps_utils_la_LDFLAGS = -Wl,-z,defs -lpthread -shared -version-info 1:0:0 +libgps_utils_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) endif -libgps_utils_so_la_LIBADD = -lcutils -lstdc++ -llog $(LOCPLA_LIBS) +libgps_utils_la_LIBADD = $(CUTILS_LIBS) #Create and Install libraries -lib_LTLIBRARIES = libgps_utils_so.la -library_includedir = $(pkgincludedir) -pkgconfigdir = $(libdir)/pkgconfig +lib_LTLIBRARIES = libgps_utils.la +pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = gps-utils.pc EXTRA_DIST = $(pkgconfig_DATA) diff --git a/gps/utils/MsgTask.cpp b/gps/utils/MsgTask.cpp index 80abeec..eaead5c 100644 --- a/gps/utils/MsgTask.cpp +++ b/gps/utils/MsgTask.cpp @@ -32,8 +32,9 @@ #include <unistd.h> #include <MsgTask.h> #include <msg_q.h> +#include <log_util.h> #include <loc_log.h> -#include <platform_lib_includes.h> +#include <loc_pla.h> static void LocMsgDestroy(void* msg) { delete (LocMsg*)msg; @@ -82,7 +83,7 @@ void MsgTask::sendMsg(const LocMsg* msg) const { void MsgTask::prerun() { // make sure we do not run in background scheduling group - platform_lib_abstraction_set_sched_policy(platform_lib_abstraction_gettid(), PLA_SP_FOREGROUND); + set_sched_policy(gettid(), SP_FOREGROUND); } bool MsgTask::run() { diff --git a/gps/utils/configure.ac b/gps/utils/configure.ac index a7ab9b4..639f8c4 100644 --- a/gps/utils/configure.ac +++ b/gps/utils/configure.ac @@ -28,9 +28,32 @@ AC_PROG_LN_S AC_PROG_MAKE_SET PKG_PROG_PKG_CONFIG -PKG_CHECK_MODULES([LOCPLA], [loc-pla]) -AC_SUBST([LOCPLA_CFLAGS]) -AC_SUBST([LOCPLA_LIBS]) +# Checks for libraries. +PKG_CHECK_MODULES([CUTILS], [libcutils]) +AC_SUBST([CUTILS_CFLAGS]) +AC_SUBST([CUTILS_LIBS]) + +AC_ARG_WITH([core_includes], + AC_HELP_STRING([--with-core-includes=@<:@dir@:>@], + [Specify the location of the core headers]), + [core_incdir=$withval], + with_core_includes=no) + +if test "x$with_core_includes" != "xno"; then + CPPFLAGS="${CPPFLAGS} -I${core_incdir}" +fi + +AC_ARG_WITH([locpla_includes], + AC_HELP_STRING([--with-locpla-includes=@<:@dir@:>@], + [specify the path to locpla-includes in loc-pla_git.bb]), + [locpla_incdir=$withval], + with_locpla_includes=no) + +if test "x$with_locpla_includes" != "xno"; then + AC_SUBST(LOCPLA_CFLAGS, "-I${locpla_incdir}") +fi + +AC_SUBST([CPPFLAGS]) AC_ARG_WITH([glib], AC_HELP_STRING([--with-glib], diff --git a/gps/utils/gps-utils.pc.in b/gps/utils/gps-utils.pc.in index 3ed3d90..a988731 100644 --- a/gps/utils/gps-utils.pc.in +++ b/gps/utils/gps-utils.pc.in @@ -6,5 +6,5 @@ includedir=@includedir@ Name: gps-utils Description: QTI GPS Location utils Version: @VERSION -Libs: -L${libdir} -lgps_utils_so +Libs: -L${libdir} -lgps_utils Cflags: -I${includedir}/gps-utils diff --git a/gps/utils/gps_extended_c.h b/gps/utils/gps_extended_c.h index f87a942..5479bec 100644 --- a/gps/utils/gps_extended_c.h +++ b/gps/utils/gps_extended_c.h @@ -115,7 +115,9 @@ enum loc_registration_mask_status { 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_DEBUG_NMEA_V02 /**< Support debug NMEA feature */ + LOC_SUPPORTED_FEATURE_DEBUG_NMEA_V02, /**< Support debug NMEA feature */ + LOC_SUPPORTED_FEATURE_GNSS_ONLY_POSITION_REPORT, /**< Support GNSS Only position reports */ + LOC_SUPPORTED_FEATURE_FDCL /**< Support FDCL */ } loc_supported_feature_enum; typedef struct { @@ -308,6 +310,10 @@ typedef uint32_t GpsLocationExtendedFlags; #define GPS_LOCATION_EXTENDED_HAS_POS_DYNAMICS_DATA 0x10000 /** GpsLocationExtended has GPS Time */ #define GPS_LOCATION_EXTENDED_HAS_GPS_TIME 0x20000 +/** GpsLocationExtended has Extended Dilution of Precision */ +#define GPS_LOCATION_EXTENDED_HAS_EXT_DOP 0x40000 +/** GpsLocationExtended has Elapsed Time */ +#define GPS_LOCATION_EXTENDED_HAS_ELAPSED_TIME 0x80000 typedef uint32_t LocNavSolutionMask; /* Bitmask to specify whether SBAS ionospheric correction is used */ @@ -393,6 +399,29 @@ typedef struct { float pitch; }LocPositionDynamics; +typedef struct { + + /** Position dilution of precision. + Range: 1 (highest accuracy) to 50 (lowest accuracy) */ + float PDOP; + + /** Horizontal dilution of precision. + Range: 1 (highest accuracy) to 50 (lowest accuracy) */ + float HDOP; + + /** Vertical dilution of precision. + Range: 1 (highest accuracy) to 50 (lowest accuracy) */ + float VDOP; + + /** geometric dilution of precision. + Range: 1 (highest accuracy) to 50 (lowest accuracy) */ + float GDOP; + + /** time dilution of precision. + Range: 1 (highest accuracy) to 50 (lowest accuracy) */ + float TDOP; +}LocExtDOP; + /* GPS Time structure */ typedef struct { @@ -451,6 +480,10 @@ typedef struct { LocPositionDynamics bodyFrameData; /** GPS Time */ GPSTimeStruct gpsTime; + /** Elapsed Time */ + int64_t elapsedTime; + /** Dilution of precision associated with this position*/ + LocExtDOP extDOP; } GpsLocationExtended; enum loc_sess_status { @@ -559,7 +592,8 @@ enum loc_api_adapter_event_index { LOC_API_ADAPTER_REPORT_GENFENCE_DWELL_REPORT, // Geofence dwell report LOC_API_ADAPTER_REQUEST_SRN_DATA, // request srn data from AP LOC_API_ADAPTER_REQUEST_POSITION_INJECTION, // Position injection request - LOC_API_ADAPTER_BATCH_STATUS, // batch status + LOC_API_ADAPTER_BATCH_STATUS, // batch status + LOC_API_ADAPTER_FDCL_SERVICE_REQ, // FDCL service request LOC_API_ADAPTER_EVENT_MAX }; @@ -595,9 +629,10 @@ enum loc_api_adapter_event_index { #define LOC_API_ADAPTER_BIT_REQUEST_SRN_DATA (1<<LOC_API_ADAPTER_REQUEST_SRN_DATA) #define LOC_API_ADAPTER_BIT_POSITION_INJECTION_REQUEST (1<<LOC_API_ADAPTER_REQUEST_POSITION_INJECTION) #define LOC_API_ADAPTER_BIT_BATCH_STATUS (1<<LOC_API_ADAPTER_BATCH_STATUS) +#define LOC_API_ADAPTER_BIT_FDCL_SERVICE_REQ (1ULL<<LOC_API_ADAPTER_FDCL_SERVICE_REQ) -typedef unsigned int LOC_API_ADAPTER_EVENT_MASK_T; +typedef uint64_t LOC_API_ADAPTER_EVENT_MASK_T; typedef enum loc_api_adapter_msg_to_check_supported { LOC_API_ADAPTER_MESSAGE_LOCATION_BATCHING, // Batching 1.0 @@ -1262,6 +1297,20 @@ struct AGnssExtStatusIpV6 { uint8_t ipV6Addr[16]; }; +/* ODCPI Request Info */ +enum OdcpiRequestType { + ODCPI_REQUEST_TYPE_START, + ODCPI_REQUEST_TYPE_STOP +}; +struct OdcpiRequestInfo { + size_t size; + OdcpiRequestType type; + uint32_t tbfMillis; + bool isEmergencyMode; +}; +/* Callback to send ODCPI request to framework */ +typedef std::function<void(const OdcpiRequestInfo& request)> OdcpiRequestCallback; + /* * Callback with AGNSS(IpV4) status information. * @@ -1282,6 +1331,9 @@ typedef void (*LocAgpsOpenResultCb)(bool isSuccess, AGpsExtType agpsType, const typedef void (*LocAgpsCloseResultCb)(bool isSuccess, AGpsExtType agpsType, void* userDataPtr); +/* Shared resources of LocIpc */ +#define LOC_IPC_HAL "/dev/socket/location/socket_hal" +#define LOC_IPC_XTRA "/dev/socket/location/xtra/socket_xtra" #ifdef __cplusplus } diff --git a/gps/utils/linked_list.c b/gps/utils/linked_list.c index 33185d0..02e1463 100644 --- a/gps/utils/linked_list.c +++ b/gps/utils/linked_list.c @@ -26,14 +26,15 @@ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#define LOG_TAG "LocSvc_utils_ll" + #include "linked_list.h" #include <stdio.h> #include <string.h> - -#define LOG_TAG "LocSvc_utils_ll" -#include <platform_lib_includes.h> #include <stdlib.h> #include <stdint.h> +#include <loc_pla.h> +#include <log_util.h> typedef struct list_element { struct list_element* next; diff --git a/gps/utils/loc_cfg.cpp b/gps/utils/loc_cfg.cpp index d2364f6..d7adad1 100644 --- a/gps/utils/loc_cfg.cpp +++ b/gps/utils/loc_cfg.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2015, 2018 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 @@ -37,13 +37,16 @@ #include <ctype.h> #include <unistd.h> #include <time.h> +#include <pwd.h> +#include <errno.h> #include <loc_cfg.h> -#include <platform_lib_includes.h> +#include <loc_pla.h> +#include <loc_target.h> #include <loc_misc_utils.h> #ifdef USE_GLIB #include <glib.h> #endif -#include "platform_lib_includes.h" +#include "log_util.h" /*============================================================================= * @@ -54,12 +57,14 @@ /* Parameter data */ static uint32_t DEBUG_LEVEL = 0xff; static uint32_t TIMESTAMP = 0; +static uint32_t LOC_MODEM_EMULATOR = 0; /* Parameter spec table */ static const loc_param_s_type loc_param_table[] = { - {"DEBUG_LEVEL", &DEBUG_LEVEL, NULL, 'n'}, - {"TIMESTAMP", &TIMESTAMP, NULL, 'n'}, + {"DEBUG_LEVEL", &DEBUG_LEVEL, NULL, 'n'}, + {"TIMESTAMP", &TIMESTAMP, NULL, 'n'}, + {"LOC_MODEM_EMULATOR", &LOC_MODEM_EMULATOR, NULL, 'n'}, }; static const int loc_param_num = sizeof(loc_param_table) / sizeof(loc_param_s_type); @@ -71,6 +76,28 @@ typedef struct loc_param_v_type double param_double_value; }loc_param_v_type; +// Reference below arrays wherever needed to avoid duplicating +// same conf path string over and again in location code. +const char LOC_PATH_GPS_CONF[] = LOC_PATH_GPS_CONF_STR; +const char LOC_PATH_IZAT_CONF[] = LOC_PATH_IZAT_CONF_STR; +const char LOC_PATH_FLP_CONF[] = LOC_PATH_FLP_CONF_STR; +const char LOC_PATH_LOWI_CONF[] = LOC_PATH_LOWI_CONF_STR; +const char LOC_PATH_SAP_CONF[] = LOC_PATH_SAP_CONF_STR; +const char LOC_PATH_APDR_CONF[] = LOC_PATH_APDR_CONF_STR; +const char LOC_PATH_XTWIFI_CONF[] = LOC_PATH_XTWIFI_CONF_STR; +const char LOC_PATH_QUIPC_CONF[] = LOC_PATH_QUIPC_CONF_STR; + +/*=========================================================================== +FUNCTION loc_modem_emulator_enabled + +DESCRIPTION + Provides access to Modem Emulator config item. +===========================================================================*/ +uint32_t loc_modem_emulator_enabled() +{ + return LOC_MODEM_EMULATOR; +} + /*=========================================================================== FUNCTION loc_set_config_entry @@ -381,9 +408,6 @@ void loc_read_conf(const char* conf_file_name, const loc_param_s_type* config_ta uint32_t table_length) { FILE *conf_fp = NULL; - char *lasts; - loc_param_v_type config_value; - uint32_t i; if((conf_fp = fopen(conf_file_name, "r")) != NULL) { @@ -398,3 +422,718 @@ void loc_read_conf(const char* conf_file_name, const loc_param_s_type* config_ta /* Initialize logging mechanism with parsed data */ loc_logger_init(DEBUG_LEVEL, TIMESTAMP); } + +/*============================================================================= + * + * Define and Structures for Parsing Location Process Configuration File + * + *============================================================================*/ +#define MAX_NUM_STRINGS 20 + +//We can have 8 masks for now +#define CONFIG_MASK_TARGET_ALL 0X01 +#define CONFIG_MASK_TARGET_FOUND 0X02 +#define CONFIG_MASK_TARGET_CHECK 0X03 +#define CONFIG_MASK_BASEBAND_ALL 0X04 +#define CONFIG_MASK_BASEBAND_FOUND 0X08 +#define CONFIG_MASK_BASEBAND_CHECK 0x0c +#define CONFIG_MASK_AUTOPLATFORM_ALL 0x10 +#define CONFIG_MASK_AUTOPLATFORM_FOUND 0x20 +#define CONFIG_MASK_AUTOPLATFORM_CHECK 0x30 + +#define LOC_FEATURE_MASK_GTP_WIFI_BASIC 0x01 +#define LOC_FEATURE_MASK_GTP_WIFI_PREMIUM 0X02 +#define LOC_FEATURE_MASK_GTP_CELL_BASIC 0X04 +#define LOC_FEATURE_MASK_GTP_CELL_PREMIUM 0X08 +#define LOC_FEATURE_MASK_GTP_AP_CELL_BASIC LOC_FEATURE_MASK_GTP_CELL_BASIC +#define LOC_FEATURE_MASK_GTP_AP_CELL_PREMIUM LOC_FEATURE_MASK_GTP_CELL_PREMIUM +#define LOC_FEATURE_MASK_SAP_BASIC 0x40 +#define LOC_FEATURE_MASK_SAP_PREMIUM 0X80 +#define LOC_FEATURE_MASK_GTP_WAA_BASIC 0X100 +#define LOC_FEATURE_MASK_GTP_WAA_PREMIUM 0x200 +#define LOC_FEATURE_MASK_GTP_MODEM_CELL_BASIC 0X400 +#define LOC_FEATURE_MASK_GTP_MODEM_CELL_PREMIUM 0X800 +#define LOC_FEATURE_MASK_ODCPI 0x1000 +#define LOC_FEATURE_MASK_FREE_WIFI_SCAN_INJECT 0x2000 +#define LOC_FEATURE_MASK_SUPL_WIFI 0x4000 +#define LOC_FEATURE_MASK_WIFI_SUPPLICANT_INFO 0x8000 + +typedef struct { + char proc_name[LOC_MAX_PARAM_STRING]; + char proc_argument[LOC_MAX_PARAM_STRING]; + char proc_status[LOC_MAX_PARAM_STRING]; + char group_list[LOC_MAX_PARAM_STRING]; + unsigned int premium_feature; + unsigned int loc_feature_mask; + char platform_list[LOC_MAX_PARAM_STRING]; + char baseband[LOC_MAX_PARAM_STRING]; + unsigned int sglte_target; + char feature_gtp_cell_proc[LOC_MAX_PARAM_STRING]; + char feature_gtp_waa[LOC_MAX_PARAM_STRING]; + char feature_gtp_cell[LOC_MAX_PARAM_STRING]; + char feature_gtp_wifi[LOC_MAX_PARAM_STRING]; + char feature_sap[LOC_MAX_PARAM_STRING]; + char feature_odcpi[LOC_MAX_PARAM_STRING]; + char feature_free_wifi_scan_inject[LOC_MAX_PARAM_STRING]; + char feature_supl_wifi[LOC_MAX_PARAM_STRING]; + char feature_wifi_supplicant_info[LOC_MAX_PARAM_STRING]; + char auto_platform[LOC_MAX_PARAM_STRING]; +} loc_launcher_conf; + +/* process configuration parameters */ +static loc_launcher_conf conf; + +/* gps.conf Parameter spec table */ +static const loc_param_s_type gps_conf_parameter_table[] = { + {"SGLTE_TARGET", &conf.sglte_target, NULL, 'n'}, +}; + +/* location feature conf, e.g.: izat.conf feature mode table*/ +static const loc_param_s_type loc_feature_conf_table[] = { + {"GTP_CELL_PROC", &conf.feature_gtp_cell_proc, NULL, 's'}, + {"GTP_CELL", &conf.feature_gtp_cell, NULL, 's'}, + {"GTP_WIFI", &conf.feature_gtp_wifi, NULL, 's'}, + {"GTP_WAA", &conf.feature_gtp_waa, NULL, 's'}, + {"SAP", &conf.feature_sap, NULL, 's'}, + {"ODCPI", &conf.feature_odcpi, NULL, 's'}, + {"FREE_WIFI_SCAN_INJECT", &conf.feature_free_wifi_scan_inject, NULL, 's'}, + {"SUPL_WIFI", &conf.feature_supl_wifi, NULL, 's'}, + {"WIFI_SUPPLICANT_INFO", &conf.feature_wifi_supplicant_info, NULL, 's'}, +}; + +/* location process conf, e.g.: izat.conf Parameter spec table */ +static const loc_param_s_type loc_process_conf_parameter_table[] = { + {"PROCESS_NAME", &conf.proc_name, NULL, 's'}, + {"PROCESS_ARGUMENT", &conf.proc_argument, NULL, 's'}, + {"PROCESS_STATE", &conf.proc_status, NULL, 's'}, + {"PROCESS_GROUPS", &conf.group_list, NULL, 's'}, + {"PREMIUM_FEATURE", &conf.premium_feature, NULL, 'n'}, + {"IZAT_FEATURE_MASK", &conf.loc_feature_mask, NULL, 'n'}, + {"PLATFORMS", &conf.platform_list, NULL, 's'}, + {"BASEBAND", &conf.baseband, NULL, 's'}, + {"HARDWARE_TYPE", &conf.auto_platform, NULL, 's'}, +}; + +/*=========================================================================== +FUNCTION loc_read_process_conf + +DESCRIPTION + Parse the specified conf file and return info for the processes defined. + The format of the file should conform with izat.conf. + +PARAMETERS: + conf_file_name: configuration file to read + process_count_ptr: pointer to store number of processes defined in the conf file. + process_info_table_ptr: pointer to store the process info table. + +DEPENDENCIES + The file must be in izat.conf format. + +RETURN VALUE + 0: success + none-zero: failure + +SIDE EFFECTS + N/A + +NOTES: + On success, memory pointed by (*process_info_table_ptr) must be freed. +===========================================================================*/ +int loc_read_process_conf(const char* conf_file_name, uint32_t * process_count_ptr, + loc_process_info_s_type** process_info_table_ptr) { + loc_process_info_s_type *child_proc = nullptr; + volatile int i=0; + unsigned int j=0; + gid_t gid_list[LOC_PROCESS_MAX_NUM_GROUPS]; + char *split_strings[MAX_NUM_STRINGS]; + int name_length=0, group_list_length=0, platform_length=0, baseband_length=0, ngroups=0, ret=0; + int auto_platform_length = 0; + int group_index=0, nstrings=0, status_length=0; + FILE* conf_fp = nullptr; + char platform_name[PROPERTY_VALUE_MAX], baseband_name[PROPERTY_VALUE_MAX]; + char autoplatform_name[PROPERTY_VALUE_MAX]; + unsigned int loc_service_mask=0; + char config_mask = 0; + unsigned char proc_list_length=0; + int gtp_cell_ap_enabled = 0; + char arg_gtp_waa[LOC_PROCESS_MAX_ARG_STR_LENGTH] = "--"; + char arg_gtp_ap_cell[LOC_PROCESS_MAX_ARG_STR_LENGTH] = "--"; + char arg_gtp_modem_cell[LOC_PROCESS_MAX_ARG_STR_LENGTH] = "--"; + char arg_gtp_wifi[LOC_PROCESS_MAX_ARG_STR_LENGTH] = "--"; + char arg_sap[LOC_PROCESS_MAX_ARG_STR_LENGTH] = "--"; + char arg_disabled[LOC_PROCESS_MAX_ARG_STR_LENGTH] = LOC_FEATURE_MODE_DISABLED; + char arg_basic[LOC_PROCESS_MAX_ARG_STR_LENGTH] = LOC_FEATURE_MODE_BASIC; + char arg_premium[LOC_PROCESS_MAX_ARG_STR_LENGTH] = LOC_FEATURE_MODE_PREMIUM; + + if (process_count_ptr == NULL || process_info_table_ptr == NULL) { + return -1; + } + + //Read gps.conf and fill parameter table + UTIL_READ_CONF(LOC_PATH_GPS_CONF, gps_conf_parameter_table); + + //Form argument strings + strlcat(arg_gtp_waa, LOC_FEATURE_GTP_WAA, LOC_PROCESS_MAX_ARG_STR_LENGTH-3); + strlcat(arg_gtp_ap_cell, LOC_FEATURE_GTP_AP_CELL, LOC_PROCESS_MAX_ARG_STR_LENGTH-3); + strlcat(arg_gtp_modem_cell, LOC_FEATURE_GTP_MODEM_CELL, LOC_PROCESS_MAX_ARG_STR_LENGTH-3); + strlcat(arg_gtp_wifi, LOC_FEATURE_GTP_WIFI, LOC_PROCESS_MAX_ARG_STR_LENGTH-3); + strlcat(arg_sap, LOC_FEATURE_SAP, LOC_PROCESS_MAX_ARG_STR_LENGTH-3); + + //Get platform name from ro.board.platform property + loc_get_platform_name(platform_name, sizeof(platform_name)); + //Get baseband name from ro.baseband property + loc_get_target_baseband(baseband_name, sizeof(baseband_name)); + //Identify if this is an automotive platform + loc_get_auto_platform_name(autoplatform_name,sizeof(autoplatform_name)); + + UTIL_READ_CONF(conf_file_name, loc_feature_conf_table); + + //Set service mask for GTP_WIFI + if(strcmp(conf.feature_gtp_wifi, "DISABLED") == 0) { + LOC_LOGD("%s:%d]: GTP WIFI DISABLED", __func__, __LINE__); + } + else if(strcmp(conf.feature_gtp_wifi, "BASIC") == 0) { + LOC_LOGD("%s:%d]: Setting GTP WIFI to mode: BASIC", __func__, __LINE__); + loc_service_mask |= LOC_FEATURE_MASK_GTP_WIFI_BASIC; + } + //conf file has a garbage value + else { + LOC_LOGE("%s:%d]: Unrecognized value for GTP WIFI Mode."\ + " Setting GTP WIFI to default mode: BASIC", __func__, __LINE__); + loc_service_mask |= LOC_FEATURE_MASK_GTP_WIFI_BASIC; + } + + //Set service mask for GTP_CELL + //Using a temp variable here to indicate wheter GTP cell is + //enabled on the AP or modem. This variable will be used in + //further checks below. An alternative was to compare the + //string again in each place which would've been more expensive + if(strcmp(conf.feature_gtp_cell_proc, "AP") == 0) { + gtp_cell_ap_enabled = 1; + } + + if(strcmp(conf.feature_gtp_cell, "PREMIUM") == 0) { + LOC_LOGE("%s:%d]: Error: location feature GTP CELL does not support PREMIUM mode" \ + " available modes are BASIC and DISABLED. Starting feature in BASIC mode", + __func__, __LINE__); + if(gtp_cell_ap_enabled) { + loc_service_mask |= LOC_FEATURE_MASK_GTP_AP_CELL_BASIC; + } + else { + loc_service_mask |= LOC_FEATURE_MASK_GTP_MODEM_CELL_BASIC; + } + } + else if(strcmp(conf.feature_gtp_cell, "BASIC") == 0) { + LOC_LOGD("%s:%d]: Setting GTP CELL to mode: BASIC", __func__, __LINE__); + if(gtp_cell_ap_enabled) { + loc_service_mask |= LOC_FEATURE_MASK_GTP_AP_CELL_BASIC; + } + else { + loc_service_mask |= LOC_FEATURE_MASK_GTP_MODEM_CELL_BASIC; + } + } + else if(strcmp(conf.feature_gtp_cell, "DISABLED") == 0) { + LOC_LOGD("%s:%d]: GTP CELL DISABLED", __func__, __LINE__); + } + //conf file has a garbage value + else { + LOC_LOGE("%s:%d]: Unrecognized value for GTP CELL Mode." \ + " Setting GTP CELL to default mode: BASIC", __func__, __LINE__); + if(gtp_cell_ap_enabled) { + loc_service_mask |= LOC_FEATURE_MASK_GTP_AP_CELL_BASIC; + } + else { + loc_service_mask |= LOC_FEATURE_MASK_GTP_MODEM_CELL_BASIC; + } + } + + //Set service mask for GTP_WAA + if(strcmp(conf.feature_gtp_waa, "PREMIUM") == 0) { + LOC_LOGE("%s:%d]: Error: location feature GTP WAA does not support PREMIUM mode" \ + " available modes are BASIC and DISABLED. Starting feature in BASIC mode", + __func__, __LINE__); + loc_service_mask |= LOC_FEATURE_MASK_GTP_WAA_BASIC; + } + else if(strcmp(conf.feature_gtp_waa, "BASIC") == 0) { + LOC_LOGD("%s:%d]: Setting GTP WAA to mode: BASIC", __func__, __LINE__); + loc_service_mask |= LOC_FEATURE_MASK_GTP_WAA_BASIC; + } + else if(strcmp(conf.feature_gtp_waa, "DISABLED") == 0) { + LOC_LOGD("%s:%d]: GTP WAA DISABLED", __func__, __LINE__); + } + //conf file has a garbage value + else { + LOC_LOGE("%s:%d]: Unrecognized value for GTP WAA Mode."\ + " Setting GTP WAA to default mode: DISABLED", __func__, __LINE__); + } + + //Set service mask for SAP + if(strcmp(conf.feature_sap, "PREMIUM") == 0) { + LOC_LOGD("%s:%d]: Setting SAP to mode: PREMIUM", __func__, __LINE__); + loc_service_mask |= LOC_FEATURE_MASK_SAP_PREMIUM; + } + else if(strcmp(conf.feature_sap, "BASIC") == 0) { + LOC_LOGD("%s:%d]: Setting SAP to mode: BASIC", __func__, __LINE__); + loc_service_mask |= LOC_FEATURE_MASK_SAP_BASIC; + } + else if(strcmp(conf.feature_sap, "DISABLED") == 0) { + LOC_LOGD("%s:%d]: Setting SAP to mode: DISABLED", __func__, __LINE__); + } + else { + LOC_LOGE("%s:%d]: Unrecognized value for SAP Mode."\ + " Setting SAP to default mode: BASIC", __func__, __LINE__); + loc_service_mask |= LOC_FEATURE_MASK_SAP_BASIC; + } + + // Set service mask for ODCPI + if(strcmp(conf.feature_odcpi, "BASIC") == 0) { + LOC_LOGD("%s:%d]: Setting ODCPI to mode: BASIC", __func__, __LINE__); + loc_service_mask |= LOC_FEATURE_MASK_ODCPI; + } + else if(strcmp(conf.feature_odcpi, "DISABLED") == 0) { + LOC_LOGD("%s:%d]: Setting ODCPI to mode: DISABLED", __func__, __LINE__); + } + else if(strcmp(conf.feature_odcpi, "PREMIUM") == 0) { + LOC_LOGD("%s:%d]: Unrecognized value for ODCPI mode."\ + "Setting ODCPI to default mode: BASIC", __func__, __LINE__); + loc_service_mask |= LOC_FEATURE_MASK_ODCPI; + } + + // Set service mask for FREE_WIFI_SCAN_INJECT + if(strcmp(conf.feature_free_wifi_scan_inject, "BASIC") == 0) { + LOC_LOGD("%s:%d]: Setting FREE_WIFI_SCAN_INJECT to mode: BASIC", __func__, __LINE__); + loc_service_mask |= LOC_FEATURE_MASK_FREE_WIFI_SCAN_INJECT; + } + else if(strcmp(conf.feature_free_wifi_scan_inject, "DISABLED") == 0) { + LOC_LOGD("%s:%d]: Setting FREE_WIFI_SCAN_INJECT to mode: DISABLED", __func__, __LINE__); + } + else if(strcmp(conf.feature_free_wifi_scan_inject, "PREMIUM") == 0) { + LOC_LOGD("%s:%d]: Unrecognized value for FREE_WIFI_SCAN_INJECT mode."\ + "Setting FREE_WIFI_SCAN_INJECT to default mode: BASIC", __func__, __LINE__); + loc_service_mask |= LOC_FEATURE_MASK_FREE_WIFI_SCAN_INJECT; + } + + // Set service mask for SUPL_WIFI + if(strcmp(conf.feature_supl_wifi, "BASIC") == 0) { + LOC_LOGD("%s:%d]: Setting SUPL_WIFI to mode: BASIC", __func__, __LINE__); + loc_service_mask |= LOC_FEATURE_MASK_SUPL_WIFI; + } + else if(strcmp(conf.feature_supl_wifi, "DISABLED") == 0) { + LOC_LOGD("%s:%d]: Setting SUPL_WIFI to mode: DISABLED", __func__, __LINE__); + } + else if(strcmp(conf.feature_supl_wifi, "PREMIUM") == 0) { + LOC_LOGD("%s:%d]: Unrecognized value for SUPL_WIFI mode."\ + "Setting SUPL_WIFI to default mode: BASIC", __func__, __LINE__); + loc_service_mask |= LOC_FEATURE_MASK_SUPL_WIFI; + } + + // Set service mask for WIFI_SUPPLICANT_INFO + if(strcmp(conf.feature_wifi_supplicant_info, "BASIC") == 0) { + LOC_LOGD("%s:%d]: Setting WIFI_SUPPLICANT_INFO to mode: BASIC", __func__, __LINE__); + loc_service_mask |= LOC_FEATURE_MASK_WIFI_SUPPLICANT_INFO; + } + else if(strcmp(conf.feature_wifi_supplicant_info, "DISABLED") == 0) { + LOC_LOGD("%s:%d]: Setting WIFI_SUPPLICANT_INFO to mode: DISABLED", __func__, __LINE__); + } + else if(strcmp(conf.feature_wifi_supplicant_info, "PREMIUM") == 0) { + LOC_LOGD("%s:%d]: Unrecognized value for WIFI_SUPPLICANT_INFO mode."\ + "Setting LOC_FEATURE_MASK_WIFI_SUPPLICANT_INFO to default mode: BASIC", __func__, __LINE__); + loc_service_mask |= LOC_FEATURE_MASK_WIFI_SUPPLICANT_INFO; + } + + LOC_LOGD("%s:%d]: loc_service_mask: %x\n", __func__, __LINE__, loc_service_mask); + + if((conf_fp = fopen(conf_file_name, "r")) == NULL) { + LOC_LOGE("%s:%d]: Error opening %s %s\n", __func__, + __LINE__, conf_file_name, strerror(errno)); + ret = -1; + goto err; + } + + //Parse through the file to find out how many processes are to be launched + proc_list_length = 0; + do { + conf.proc_name[0] = 0; + //Here note that the 3rd parameter is passed as 1. + //This is so that only the first parameter in the table which is "PROCESS_NAME" + //is read. We do not want to read the entire block of parameters at this time + //since we are only counting the number of processes to launch. + //Therefore, only counting the occurrences of PROCESS_NAME parameter + //should suffice + if(loc_read_conf_r(conf_fp, loc_process_conf_parameter_table, 1)) { + LOC_LOGE("%s:%d]: Unable to read conf file. Failing\n", __func__, __LINE__); + ret = -1; + goto err; + } + name_length=(int)strlen(conf.proc_name); + if(name_length) { + proc_list_length++; + LOC_LOGD("Process name:%s", conf.proc_name); + } + } while(name_length); + LOC_LOGD("Process cnt = %d", proc_list_length); + + child_proc = (loc_process_info_s_type *)calloc(proc_list_length, sizeof(loc_process_info_s_type)); + if(child_proc == NULL) { + LOC_LOGE("%s:%d]: ERROR: Malloc returned NULL\n", __func__, __LINE__); + ret = -1; + goto err; + } + + //Move file descriptor to the beginning of the file + //so that the parameters can be read + rewind(conf_fp); + + for(j=0; j<proc_list_length; j++) { + //Set defaults for all the child process structs + child_proc[j].proc_status = DISABLED; + memset(child_proc[j].group_list, 0, sizeof(child_proc[j].group_list)); + config_mask=0; + if(loc_read_conf_r(conf_fp, loc_process_conf_parameter_table, + sizeof(loc_process_conf_parameter_table)/sizeof(loc_process_conf_parameter_table[0]))) { + LOC_LOGE("%s:%d]: Unable to read conf file. Failing\n", __func__, __LINE__); + ret = -1; + goto err; + } + + name_length=(int)strlen(conf.proc_name); + group_list_length=(int)strlen(conf.group_list); + platform_length = (int)strlen(conf.platform_list); + baseband_length = (int)strlen(conf.baseband); + status_length = (int)strlen(conf.proc_status); + auto_platform_length = (int)strlen(conf.auto_platform); + + if(!name_length || !group_list_length || !platform_length || + !baseband_length || !status_length || !auto_platform_length) { + LOC_LOGE("%s:%d]: Error: i: %d; One of the parameters not specified in conf file", + __func__, __LINE__, i); + continue; + } + + if(strcmp(conf.proc_status, "DISABLED") == 0) { + LOC_LOGD("%s:%d]: Process %s is disabled in conf file", + __func__, __LINE__, conf.proc_name); + child_proc[j].proc_status = DISABLED_FROM_CONF; + continue; + } + else if(strcmp(conf.proc_status, "ENABLED") == 0) { + LOC_LOGD("%s:%d]: Process %s is enabled in conf file", + __func__, __LINE__, conf.proc_name); + } + + //Since strlcpy copies length-1 characters, we add 1 to name_length + if((name_length+1) > LOC_MAX_PARAM_STRING) { + LOC_LOGE("%s:%d]: i: %d; Length of name parameter too long. Max length: %d", + __func__, __LINE__, i, LOC_MAX_PARAM_STRING); + continue; + } + strlcpy(child_proc[j].name[0], conf.proc_name, sizeof (child_proc[j].name[0])); + + child_proc[j].num_groups = 0; + ngroups = loc_util_split_string(conf.group_list, split_strings, MAX_NUM_STRINGS, ' '); +#ifdef __ANDROID__ + for(i=0; i<ngroups; i++) { + struct passwd* pwd = getpwnam(split_strings[i]); + if (pwd) { + child_proc[j].group_list[i] = pwd->pw_gid; + child_proc[j].num_groups++; + LOC_LOGD("%s:%d]:Group %s = %d matches child_group: %d\n", + __func__, __LINE__, split_strings[i], + pwd->pw_gid,child_proc[j].group_list[i]); + } + } +#endif + nstrings = loc_util_split_string(conf.platform_list, split_strings, MAX_NUM_STRINGS, ' '); + if(strcmp("all", split_strings[0]) == 0) { + if (nstrings == 1 || (nstrings == 2 && (strcmp("exclude", split_strings[1]) == 0))) { + LOC_LOGD("%s:%d]: Enabled for all targets\n", __func__, __LINE__); + config_mask |= CONFIG_MASK_TARGET_ALL; + } + else if (nstrings > 2 && (strcmp("exclude", split_strings[1]) == 0)) { + config_mask |= CONFIG_MASK_TARGET_FOUND; + for (i=2; i<nstrings; i++) { + if(strcmp(platform_name, split_strings[i]) == 0) { + LOC_LOGD("%s:%d]: Disabled platform %s\n", __func__, __LINE__, platform_name); + config_mask &= ~CONFIG_MASK_TARGET_FOUND; + break; + } + } + } + } + else { + for(i=0; i<nstrings; i++) { + if(strcmp(platform_name, split_strings[i]) == 0) { + LOC_LOGD("%s:%d]: Matched platform: %s\n", + __func__, __LINE__, split_strings[i]); + config_mask |= CONFIG_MASK_TARGET_FOUND; + break; + } + } + } + + nstrings = loc_util_split_string(conf.baseband, split_strings, MAX_NUM_STRINGS, ' '); + if(strcmp("all", split_strings[0]) == 0) { + if (nstrings == 1 || (nstrings == 2 && (strcmp("exclude", split_strings[1]) == 0))) { + LOC_LOGD("%s:%d]: Enabled for all basebands\n", __func__, __LINE__); + config_mask |= CONFIG_MASK_BASEBAND_ALL; + } + else if (nstrings > 2 && (strcmp("exclude", split_strings[1]) == 0)) { + config_mask |= CONFIG_MASK_BASEBAND_FOUND; + for (i=2; i<nstrings; i++) { + if(strcmp(baseband_name, split_strings[i]) == 0) { + LOC_LOGD("%s:%d]: Disabled band %s\n", __func__, __LINE__, baseband_name); + config_mask &= ~CONFIG_MASK_BASEBAND_FOUND; + break; + } + } + } + } + else { + for(i=0; i<nstrings; i++) { + if(strcmp(baseband_name, split_strings[i]) == 0) { + LOC_LOGD("%s:%d]: Matched baseband: %s\n", + __func__, __LINE__, split_strings[i]); + config_mask |= CONFIG_MASK_BASEBAND_FOUND; + break; + } + //Since ro.baseband is not a reliable source for detecting sglte + //the alternative is to read the SGLTE_TARGET parameter from gps.conf + //this parameter is read into conf_sglte_target + else if((strcmp("sglte", split_strings[i]) == 0 ) && conf.sglte_target) { + LOC_LOGD("%s:%d]: Matched baseband SGLTE\n", __func__, __LINE__); + config_mask |= CONFIG_MASK_BASEBAND_FOUND; + break; + } + } + } + + nstrings = loc_util_split_string(conf.auto_platform, split_strings, MAX_NUM_STRINGS, ' '); + if(strcmp("all", split_strings[0]) == 0) { + LOC_LOGD("%s:%d]: Enabled for all auto platforms\n", __func__, __LINE__); + config_mask |= CONFIG_MASK_AUTOPLATFORM_ALL; + } + else { + for(i=0; i<nstrings; i++) { + if(strcmp(autoplatform_name, split_strings[i]) == 0) { + LOC_LOGD("%s:%d]: Matched auto platform: %s\n", + __func__, __LINE__, split_strings[i]); + config_mask |= CONFIG_MASK_AUTOPLATFORM_FOUND; + break; + } + } + } + + if((config_mask & CONFIG_MASK_TARGET_CHECK) && + (config_mask & CONFIG_MASK_BASEBAND_CHECK) && + (config_mask & CONFIG_MASK_AUTOPLATFORM_CHECK) && + (child_proc[j].proc_status != DISABLED_FROM_CONF)) { + + //Set args + //The first argument passed through argv is usually the name of the + //binary when started from commandline. + //getopt() seems to ignore this first argument and hence we assign it + //to the process name for consistency with command line args + i = 0; + char* temp_arg = ('/' == child_proc[j].name[0][0]) ? + (strrchr(child_proc[j].name[0], '/') + 1) : child_proc[j].name[0]; + strlcpy (child_proc[j].args[i++], temp_arg, sizeof (child_proc[j].args[i++])); + + if(conf.premium_feature) { + if(conf.loc_feature_mask & loc_service_mask) { + LOC_LOGD("%s:%d]: Enabled. %s has service mask: %x\n", + __func__, __LINE__, child_proc[j].name[0], conf.loc_feature_mask); + child_proc[j].proc_status = ENABLED; + + if(conf.loc_feature_mask & + (LOC_FEATURE_MASK_GTP_WIFI_BASIC | LOC_FEATURE_MASK_GTP_WIFI_PREMIUM)) { + if(loc_service_mask & LOC_FEATURE_MASK_GTP_WIFI_BASIC) { + strlcpy(child_proc[j].args[i++], arg_gtp_wifi, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_basic, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + } + else if(loc_service_mask & LOC_FEATURE_MASK_GTP_WIFI_PREMIUM) { + strlcpy(child_proc[j].args[i++], arg_gtp_wifi, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_premium, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + } + else + { + strlcpy(child_proc[j].args[i++], arg_gtp_wifi, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_disabled, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + } + } + if(conf.loc_feature_mask & + (LOC_FEATURE_MASK_GTP_CELL_BASIC | LOC_FEATURE_MASK_GTP_CELL_PREMIUM )) { + if(loc_service_mask & LOC_FEATURE_MASK_GTP_AP_CELL_BASIC){ + strlcpy(child_proc[j].args[i++], arg_gtp_ap_cell, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_basic, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_gtp_modem_cell, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_disabled, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + } + else if(loc_service_mask & LOC_FEATURE_MASK_GTP_AP_CELL_PREMIUM){ + strlcpy(child_proc[j].args[i++], arg_gtp_ap_cell, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_premium, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_gtp_modem_cell, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_disabled, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + } + else if(loc_service_mask & LOC_FEATURE_MASK_GTP_MODEM_CELL_BASIC) { + strlcpy(child_proc[j].args[i++], arg_gtp_modem_cell, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_basic, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_gtp_ap_cell, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_disabled, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + } + else if(loc_service_mask & LOC_FEATURE_MASK_GTP_MODEM_CELL_PREMIUM) { + strlcpy(child_proc[j].args[i++], arg_gtp_modem_cell, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_premium, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_gtp_ap_cell, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_disabled, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + } + else { + strlcpy(child_proc[j].args[i++], arg_gtp_ap_cell, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_disabled, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_gtp_modem_cell, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_disabled, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + } + } + if(conf.loc_feature_mask & + (LOC_FEATURE_MASK_GTP_WAA_BASIC | LOC_FEATURE_MASK_GTP_WAA_PREMIUM)) { + if(loc_service_mask & LOC_FEATURE_MASK_GTP_WAA_BASIC) { + strlcpy(child_proc[j].args[i++], arg_gtp_waa, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_basic, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + } + else if(loc_service_mask & LOC_FEATURE_MASK_GTP_WAA_PREMIUM) { + strlcpy(child_proc[j].args[i++], arg_gtp_waa, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_premium, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + } + else + { + strlcpy(child_proc[j].args[i++], arg_gtp_waa, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_disabled, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + } + } + if(conf.loc_feature_mask & + (LOC_FEATURE_MASK_SAP_BASIC | LOC_FEATURE_MASK_SAP_PREMIUM)) { + if(loc_service_mask & LOC_FEATURE_MASK_SAP_BASIC) { + strlcpy(child_proc[j].args[i++], arg_sap, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_basic, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + } + else if(loc_service_mask & LOC_FEATURE_MASK_SAP_PREMIUM) { + strlcpy(child_proc[j].args[i++], arg_sap, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_premium, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + } + else + { + strlcpy(child_proc[j].args[i++], arg_sap, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + strlcpy(child_proc[j].args[i++], arg_disabled, + LOC_PROCESS_MAX_ARG_STR_LENGTH); + } + } + IF_LOC_LOGD { + LOC_LOGD("%s:%d]: %s args\n", __func__, __LINE__, child_proc[j].name[0]); + for(unsigned int k=0; k<LOC_PROCESS_MAX_NUM_ARGS; k++) { + if(child_proc[j].args[k][0] != '\0') { + LOC_LOGD("%s:%d]: k: %d, %s\n", __func__, __LINE__, k, + child_proc[j].args[k]); + } + } + LOC_LOGD("%s:%d]: \n", __func__, __LINE__); + } + } + else { + LOC_LOGD("%s:%d]: Disabled. %s has service mask: %x \n", + __func__, __LINE__, child_proc[j].name[0], conf.loc_feature_mask); + } + } + else { + LOC_LOGD("%s:%d]: %s not a premium feature. Enabled\n", + __func__, __LINE__, child_proc[j].name[0]); + child_proc[j].proc_status = ENABLED; + } + + /*Fill up the remaining arguments from configuration file*/ + LOC_LOGD("%s] Parsing Process_Arguments from Configuration: %s \n", + __func__, conf.proc_argument); + if(0 != conf.proc_argument[0]) + { + /************************************** + ** conf_proc_argument is shared by all the programs getting launched, + ** hence copy to process specific argument string and parse the same. + ***************************************/ + strlcpy(child_proc[j].argumentString, conf.proc_argument, + sizeof(child_proc[j].argumentString)); + char *temp_args[LOC_PROCESS_MAX_NUM_ARGS]; + memset (temp_args, 0, sizeof (temp_args)); + loc_util_split_string(child_proc[j].argumentString, &temp_args[i], + (LOC_PROCESS_MAX_NUM_ARGS - i), ' '); + // copy argument from the pointer to the memory + for (unsigned int index = i; index < LOC_PROCESS_MAX_NUM_ARGS; index++) { + if (temp_args[index] == NULL) { + break; + } + strlcpy (child_proc[j].args[index], temp_args[index], + sizeof (child_proc[j].args[index])); + } + } + } + else { + LOC_LOGD("%s:%d]: Process %s is disabled\n", + __func__, __LINE__, child_proc[j].name[0]); + } + } + +err: + if (conf_fp) { + fclose(conf_fp); + } + if (ret != 0) { + LOC_LOGE("%s:%d]: ret: %d", __func__, __LINE__, ret); + if (child_proc) { + free (child_proc); + child_proc = nullptr; + } + *process_count_ptr = 0; + *process_info_table_ptr = nullptr; + + } + else { + *process_count_ptr = proc_list_length; + *process_info_table_ptr = child_proc; + } + + return ret; +} diff --git a/gps/utils/loc_cfg.h b/gps/utils/loc_cfg.h index 0a0f100..652d86e 100644 --- a/gps/utils/loc_cfg.h +++ b/gps/utils/loc_cfg.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2015, 2018 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,11 +32,29 @@ #include <stdio.h> #include <stdint.h> +#include <sys/types.h> +#include <unistd.h> +#include <grp.h> #define LOC_MAX_PARAM_NAME 80 #define LOC_MAX_PARAM_STRING 80 #define LOC_MAX_PARAM_LINE (LOC_MAX_PARAM_NAME + LOC_MAX_PARAM_STRING) +#define LOC_FEATURE_MODE_DISABLED "DISABLED" +#define LOC_FEATURE_MODE_BASIC "BASIC" +#define LOC_FEATURE_MODE_PREMIUM "PREMIUM" + +#define LOC_FEATURE_GTP_AP_CELL "gtp-ap-cell" +#define LOC_FEATURE_GTP_MODEM_CELL "gtp-modem-cell" +#define LOC_FEATURE_GTP_CELL_ENH "gtp-cell-enh" +#define LOC_FEATURE_GTP_WIFI "gtp-wifi" +#define LOC_FEATURE_GTP_WAA "gtp-waa" +#define LOC_FEATURE_SAP "sap" + +#define LOC_PROCESS_MAX_NUM_GROUPS 20 +#define LOC_PROCESS_MAX_NUM_ARGS 25 +#define LOC_PROCESS_MAX_ARG_STR_LENGTH 32 + #define UTIL_UPDATE_CONF(conf_data, len, config_table) \ loc_update_conf((conf_data), (len), (config_table), \ sizeof(config_table) / sizeof(config_table[0])) @@ -62,6 +80,23 @@ typedef struct 'f' for double */ } loc_param_s_type; +typedef enum { + ENABLED, + RUNNING, + DISABLED, + DISABLED_FROM_CONF +} loc_process_e_status; + +typedef struct { + loc_process_e_status proc_status; + pid_t proc_id; + char name[2][LOC_MAX_PARAM_STRING]; + gid_t group_list[LOC_PROCESS_MAX_NUM_GROUPS]; + unsigned char num_groups; + char args[LOC_PROCESS_MAX_NUM_ARGS][LOC_PROCESS_MAX_ARG_STR_LENGTH]; + char argumentString[LOC_MAX_PARAM_STRING]; +} loc_process_info_s_type; + /*============================================================================= * * MODULE EXTERNAL DATA @@ -84,6 +119,22 @@ int loc_read_conf_r(FILE *conf_fp, const loc_param_s_type* config_table, uint32_t table_length); int loc_update_conf(const char* conf_data, int32_t length, const loc_param_s_type* config_table, uint32_t table_length); + +// Below are the location conf file paths +extern const char LOC_PATH_GPS_CONF[]; +extern const char LOC_PATH_IZAT_CONF[]; +extern const char LOC_PATH_FLP_CONF[]; +extern const char LOC_PATH_LOWI_CONF[]; +extern const char LOC_PATH_SAP_CONF[]; +extern const char LOC_PATH_APDR_CONF[]; +extern const char LOC_PATH_XTWIFI_CONF[]; +extern const char LOC_PATH_QUIPC_CONF[]; + +int loc_read_process_conf(const char* conf_file_name, uint32_t * process_count_ptr, + loc_process_info_s_type** process_info_table_ptr); + +uint32_t loc_modem_emulator_enabled(); + #ifdef __cplusplus } #endif diff --git a/gps/utils/loc_log.cpp b/gps/utils/loc_log.cpp index fd9a236..50d9e4d 100644 --- a/gps/utils/loc_log.cpp +++ b/gps/utils/loc_log.cpp @@ -33,9 +33,10 @@ #include <stdlib.h> #include <sys/time.h> #include <time.h> +#include "log_util.h" #include "loc_log.h" #include "msg_q.h" -#include <platform_lib_includes.h> +#include <loc_pla.h> #define BUFFER_SIZE 120 diff --git a/gps/utils/loc_misc_utils.cpp b/gps/utils/loc_misc_utils.cpp index fd3ee6b..b7c8406 100644 --- a/gps/utils/loc_misc_utils.cpp +++ b/gps/utils/loc_misc_utils.cpp @@ -30,7 +30,7 @@ #define LOG_TAG "LocSvc_misc_utils" #include <stdio.h> #include <string.h> -#include <platform_lib_log_util.h> +#include <log_util.h> #include <loc_misc_utils.h> #include <ctype.h> diff --git a/gps/utils/loc_nmea.cpp b/gps/utils/loc_nmea.cpp index eb193cc..558dc65 100644 --- a/gps/utils/loc_nmea.cpp +++ b/gps/utils/loc_nmea.cpp @@ -31,7 +31,8 @@ #define LOG_TAG "LocSvc_nmea" #include <loc_nmea.h> #include <math.h> -#include <platform_lib_includes.h> +#include <log_util.h> +#include <loc_pla.h> #define GLONASS_SV_ID_OFFSET 64 #define MAX_SATELLITES_IN_USE 12 @@ -51,6 +52,7 @@ typedef struct loc_nmea_sv_meta_s uint32_t mask; uint32_t svCount; uint32_t svIdOffset; + uint32_t signalId; uint32_t systemId; } loc_nmea_sv_meta; @@ -71,8 +73,6 @@ typedef struct loc_sv_cache_info_s float vdop; } loc_sv_cache_info; -static loc_sv_cache_info sv_cache_info; - /*=========================================================================== FUNCTION loc_nmea_sv_meta_init @@ -90,6 +90,7 @@ SIDE EFFECTS ===========================================================================*/ static loc_nmea_sv_meta* loc_nmea_sv_meta_init(loc_nmea_sv_meta& sv_meta, + loc_sv_cache_info& sv_cache_info, GnssSvType svType, bool needCombine) { @@ -103,6 +104,7 @@ static loc_nmea_sv_meta* loc_nmea_sv_meta_init(loc_nmea_sv_meta& sv_meta, sv_meta.talker[1] = 'P'; sv_meta.mask = sv_cache_info.gps_used_mask; sv_meta.svCount = sv_cache_info.gps_count; + sv_meta.signalId = 1; sv_meta.systemId = SYSTEM_ID_GPS; break; case GNSS_SV_TYPE_GLONASS: @@ -112,6 +114,7 @@ static loc_nmea_sv_meta* loc_nmea_sv_meta_init(loc_nmea_sv_meta& sv_meta, sv_meta.svCount = sv_cache_info.glo_count; // GLONASS SV ids are from 65-96 sv_meta.svIdOffset = GLONASS_SV_ID_OFFSET; + sv_meta.signalId = 1; sv_meta.systemId = SYSTEM_ID_GLONASS; break; case GNSS_SV_TYPE_GALILEO: @@ -119,6 +122,7 @@ static loc_nmea_sv_meta* loc_nmea_sv_meta_init(loc_nmea_sv_meta& sv_meta, sv_meta.talker[1] = 'A'; sv_meta.mask = sv_cache_info.gal_used_mask; sv_meta.svCount = sv_cache_info.gal_count; + sv_meta.signalId = 7; sv_meta.systemId = SYSTEM_ID_GALILEO; break; case GNSS_SV_TYPE_QZSS: @@ -127,6 +131,7 @@ static loc_nmea_sv_meta* loc_nmea_sv_meta_init(loc_nmea_sv_meta& sv_meta, sv_meta.mask = sv_cache_info.qzss_used_mask; sv_meta.svCount = sv_cache_info.qzss_count; // QZSS SV ids are from 193-197. So keep svIdOffset 0 + sv_meta.signalId = 0; sv_meta.systemId = SYSTEM_ID_QZSS; break; case GNSS_SV_TYPE_BEIDOU: @@ -135,6 +140,7 @@ static loc_nmea_sv_meta* loc_nmea_sv_meta_init(loc_nmea_sv_meta& sv_meta, sv_meta.mask = sv_cache_info.bds_used_mask; sv_meta.svCount = sv_cache_info.bds_count; // BDS SV ids are from 201-235. So keep svIdOffset 0 + sv_meta.signalId = 0; sv_meta.systemId = SYSTEM_ID_BEIDOU; break; default: @@ -260,13 +266,14 @@ static uint32_t loc_nmea_generate_GSA(const GpsLocationExtended &locationExtende fixType = '3'; // 3D fix // Start printing the sentence - // Format: $--GSA,a,x,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,p.p,h.h,v.v*cc + // Format: $--GSA,a,x,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,p.p,h.h,v.v,s*cc // a : Mode : A : Automatic, allowed to automatically switch 2D/3D // x : Fixtype : 1 (no fix), 2 (2D fix), 3 (3D fix) // xx : 12 SV ID // p.p : Position DOP (Dilution of Precision) // h.h : Horizontal DOP // v.v : Vertical DOP + // s : GNSS System Id // cc : Checksum value length = snprintf(pMarker, lengthRemaining, "$%sGSA,A,%c,", talker, fixType); @@ -329,7 +336,7 @@ DESCRIPTION Generate NMEA GSV sentences generated based on sv report Currently below sentences are generated: - $GPGSV: GPS Satellites in View - - $GNGSV: GLONASS Satellites in View + - $GLGSV: GLONASS Satellites in View - $GAGSV: GALILEO Satellites in View DEPENDENCIES @@ -368,7 +375,7 @@ static void loc_nmea_generate_GSV(const GnssSvNotification &svNotify, if (svCount <= 0) { // no svs in view, so just send a blank $--GSV sentence - snprintf(sentence, lengthRemaining, "$%sGSV,1,1,0,", talker); + snprintf(sentence, lengthRemaining, "$%sGSV,1,1,0,%d", talker, sv_meta_p->signalId); length = loc_nmea_put_checksum(sentence, bufSize); nmeaArraystr.push_back(sentence); return; @@ -430,15 +437,10 @@ static void loc_nmea_generate_GSV(const GnssSvNotification &svNotify, } - // The following entries are specific to QZSS and BDS - if ((sv_meta_p->svType == GNSS_SV_TYPE_QZSS) || - (sv_meta_p->svType == GNSS_SV_TYPE_BEIDOU)) - { - // last one is System id and second last is Signal Id which is always zero - length = snprintf(pMarker, lengthRemaining,",%d,%d",0,sv_meta_p->systemId); - pMarker += length; - lengthRemaining -= length; - } + // append signalId + length = snprintf(pMarker, lengthRemaining,",%d",sv_meta_p->signalId); + pMarker += length; + lengthRemaining -= length; length = loc_nmea_put_checksum(sentence, bufSize); nmeaArraystr.push_back(sentence); @@ -495,7 +497,20 @@ void loc_nmea_generate_pos(const UlpLocation &location, int utcMinutes = pTm->tm_min; int utcSeconds = pTm->tm_sec; int utcMSeconds = (location.gpsLocation.timestamp)%1000; - + loc_sv_cache_info sv_cache_info = {}; + + if (GPS_LOCATION_EXTENDED_HAS_GNSS_SV_USED_DATA & locationExtended.flags) { + sv_cache_info.gps_used_mask = + (uint32_t)locationExtended.gnss_sv_used_ids.gps_sv_used_ids_mask; + sv_cache_info.glo_used_mask = + (uint32_t)locationExtended.gnss_sv_used_ids.glo_sv_used_ids_mask; + sv_cache_info.gal_used_mask = + (uint32_t)locationExtended.gnss_sv_used_ids.gal_sv_used_ids_mask; + sv_cache_info.qzss_used_mask = + (uint32_t)locationExtended.gnss_sv_used_ids.bds_sv_used_ids_mask; + sv_cache_info.bds_used_mask = + (uint32_t)locationExtended.gnss_sv_used_ids.qzss_sv_used_ids_mask; + } if (generate_nmea) { char talker[3] = {'G', 'P', '\0'}; uint32_t svUsedCount = 0; @@ -506,7 +521,8 @@ void loc_nmea_generate_pos(const UlpLocation &location, // ------------------- count = loc_nmea_generate_GSA(locationExtended, sentence, sizeof(sentence), - loc_nmea_sv_meta_init(sv_meta, GNSS_SV_TYPE_GPS, true), nmeaArraystr); + loc_nmea_sv_meta_init(sv_meta, sv_cache_info, GNSS_SV_TYPE_GPS, true), + nmeaArraystr); if (count > 0) { svUsedCount += count; @@ -519,7 +535,8 @@ void loc_nmea_generate_pos(const UlpLocation &location, // ------------------- count = loc_nmea_generate_GSA(locationExtended, sentence, sizeof(sentence), - loc_nmea_sv_meta_init(sv_meta, GNSS_SV_TYPE_GLONASS, true), nmeaArraystr); + loc_nmea_sv_meta_init(sv_meta, sv_cache_info, GNSS_SV_TYPE_GLONASS, true), + nmeaArraystr); if (count > 0) { svUsedCount += count; @@ -532,7 +549,8 @@ void loc_nmea_generate_pos(const UlpLocation &location, // ------------------- count = loc_nmea_generate_GSA(locationExtended, sentence, sizeof(sentence), - loc_nmea_sv_meta_init(sv_meta, GNSS_SV_TYPE_GALILEO, true), nmeaArraystr); + loc_nmea_sv_meta_init(sv_meta, sv_cache_info, GNSS_SV_TYPE_GALILEO, true), + nmeaArraystr); if (count > 0) { svUsedCount += count; @@ -545,7 +563,8 @@ void loc_nmea_generate_pos(const UlpLocation &location, // -------------------------- count = loc_nmea_generate_GSA(locationExtended, sentence, sizeof(sentence), - loc_nmea_sv_meta_init(sv_meta, GNSS_SV_TYPE_QZSS, false), nmeaArraystr); + loc_nmea_sv_meta_init(sv_meta, sv_cache_info, GNSS_SV_TYPE_QZSS, false), + nmeaArraystr); if (count > 0) { svUsedCount += count; @@ -556,7 +575,8 @@ void loc_nmea_generate_pos(const UlpLocation &location, // ---$PQGSA/$GNGSA (BEIDOU)--- // ---------------------------- count = loc_nmea_generate_GSA(locationExtended, sentence, sizeof(sentence), - loc_nmea_sv_meta_init(sv_meta, GNSS_SV_TYPE_BEIDOU, false), nmeaArraystr); + loc_nmea_sv_meta_init(sv_meta, sv_cache_info, GNSS_SV_TYPE_BEIDOU, false), + nmeaArraystr); if (count > 0) { svUsedCount += count; @@ -787,6 +807,14 @@ void loc_nmea_generate_pos(const UlpLocation &location, else // A means autonomous length = snprintf(pMarker, lengthRemaining, "%c", 'A'); + pMarker += length; + lengthRemaining -= length; + + // hardcode Navigation Status field to 'V' + length = snprintf(pMarker, lengthRemaining, ",%c", 'V'); + pMarker += length; + lengthRemaining -= length; + length = loc_nmea_put_checksum(sentence, sizeof(sentence)); nmeaArraystr.push_back(sentence); @@ -920,13 +948,6 @@ void loc_nmea_generate_pos(const UlpLocation &location, length = loc_nmea_put_checksum(sentence, sizeof(sentence)); nmeaArraystr.push_back(sentence); - - // clear the cache so they can't be used again - sv_cache_info.gps_used_mask = 0; - sv_cache_info.glo_used_mask = 0; - sv_cache_info.gal_used_mask = 0; - sv_cache_info.qzss_used_mask = 0; - sv_cache_info.bds_used_mask = 0; } //Send blank NMEA reports for non-final fixes else { @@ -946,7 +967,7 @@ void loc_nmea_generate_pos(const UlpLocation &location, length = loc_nmea_put_checksum(sentence, sizeof(sentence)); nmeaArraystr.push_back(sentence); - strlcpy(sentence, "$GPRMC,,V,,,,,,,,,,N", sizeof(sentence)); + strlcpy(sentence, "$GPRMC,,V,,,,,,,,,,N,V", sizeof(sentence)); length = loc_nmea_put_checksum(sentence, sizeof(sentence)); nmeaArraystr.push_back(sentence); @@ -982,27 +1003,11 @@ void loc_nmea_generate_sv(const GnssSvNotification &svNotify, ENTRY_LOG(); char sentence[NMEA_SENTENCE_MAX_LENGTH] = {0}; - char* pMarker = sentence; - int lengthRemaining = sizeof(sentence); - int length = 0; int svCount = svNotify.count; - int sentenceCount = 0; - int sentenceNumber = 1; int svNumber = 1; + loc_sv_cache_info sv_cache_info = {}; //Count GPS SVs for saparating GPS from GLONASS and throw others - - sv_cache_info.gps_used_mask = 0; - sv_cache_info.glo_used_mask = 0; - sv_cache_info.gal_used_mask = 0; - sv_cache_info.qzss_used_mask = 0; - sv_cache_info.bds_used_mask = 0; - - sv_cache_info.gps_count = 0; - sv_cache_info.glo_count = 0; - sv_cache_info.gal_count = 0; - sv_cache_info.qzss_count = 0; - sv_cache_info.bds_count = 0; for(svNumber=1; svNumber <= svCount; svNumber++) { if (GNSS_SV_TYPE_GPS == svNotify.gnssSvs[svNumber - 1].type) { @@ -1072,35 +1077,38 @@ void loc_nmea_generate_sv(const GnssSvNotification &svNotify, // ------------------ loc_nmea_generate_GSV(svNotify, sentence, sizeof(sentence), - loc_nmea_sv_meta_init(sv_meta, GNSS_SV_TYPE_GPS, false), nmeaArraystr); + loc_nmea_sv_meta_init(sv_meta, sv_cache_info, GNSS_SV_TYPE_GPS, false), nmeaArraystr); // ------------------ // ------$GLGSV------ // ------------------ loc_nmea_generate_GSV(svNotify, sentence, sizeof(sentence), - loc_nmea_sv_meta_init(sv_meta, GNSS_SV_TYPE_GLONASS, false), nmeaArraystr); + loc_nmea_sv_meta_init(sv_meta, sv_cache_info, GNSS_SV_TYPE_GLONASS, false), + nmeaArraystr); // ------------------ // ------$GAGSV------ // ------------------ loc_nmea_generate_GSV(svNotify, sentence, sizeof(sentence), - loc_nmea_sv_meta_init(sv_meta, GNSS_SV_TYPE_GALILEO, false), nmeaArraystr); + loc_nmea_sv_meta_init(sv_meta, sv_cache_info, GNSS_SV_TYPE_GALILEO, false), + nmeaArraystr); // ------------------------- // ------$PQGSV (QZSS)------ // ------------------------- loc_nmea_generate_GSV(svNotify, sentence, sizeof(sentence), - loc_nmea_sv_meta_init(sv_meta, GNSS_SV_TYPE_QZSS, false), nmeaArraystr); + loc_nmea_sv_meta_init(sv_meta, sv_cache_info, GNSS_SV_TYPE_QZSS, false), nmeaArraystr); // --------------------------- // ------$PQGSV (BEIDOU)------ // --------------------------- loc_nmea_generate_GSV(svNotify, sentence, sizeof(sentence), - loc_nmea_sv_meta_init(sv_meta, GNSS_SV_TYPE_BEIDOU, false), nmeaArraystr); + loc_nmea_sv_meta_init(sv_meta, sv_cache_info, GNSS_SV_TYPE_BEIDOU, false), + nmeaArraystr); EXIT_LOG(%d, 0); } diff --git a/gps/utils/loc_target.cpp b/gps/utils/loc_target.cpp index b7ba07b..569f3a7 100644 --- a/gps/utils/loc_target.cpp +++ b/gps/utils/loc_target.cpp @@ -27,18 +27,18 @@ * */ +#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> -#include <unistd.h> #include <fcntl.h> #include <errno.h> -#include <cutils/properties.h> +#include <log_util.h> #include "loc_target.h" #include "loc_log.h" -#include <platform_lib_includes.h> +#include <loc_pla.h> #define APQ8064_ID_1 "109" #define APQ8064_ID_2 "153" @@ -206,17 +206,3 @@ detected: LOC_LOGW("HAL: %s returned %d", __FUNCTION__, gTarget); return gTarget; } - -/*Reads the property ro.lean to identify if this is a lean target - Returns: - 0 if not a lean and mean target - 1 if this is a lean and mean target -*/ -int loc_identify_lean_target() -{ - int ret = 0; - char lean_target[PROPERTY_VALUE_MAX]; - property_get("ro.lean", lean_target, ""); - LOC_LOGD("%s:%d]: lean target: %s\n", __func__, __LINE__, lean_target); - return !(strncmp(lean_target, "true", PROPERTY_VALUE_MAX)); -} diff --git a/gps/utils/loc_target.h b/gps/utils/loc_target.h index 47a67d9..172b475 100644 --- a/gps/utils/loc_target.h +++ b/gps/utils/loc_target.h @@ -55,12 +55,6 @@ void loc_get_platform_name(char *platform_name, int array_length); of atleast PROPERTY_VALUE_MAX*/ void loc_get_auto_platform_name(char *platform_name, int array_length); -/*Reads the property ro.lean to identify if this is a lean target - Returns: - 0 if not a lean and mean target - 1 if this is a lean and mean target*/ -int loc_identify_lean_target(); - /* Please remember to update 'target_name' in loc_log.cpp, if do any changes to this enum. */ typedef enum { diff --git a/gps/utils/loc_timer.h b/gps/utils/loc_timer.h index 25fd179..fff0c46 100644 --- a/gps/utils/loc_timer.h +++ b/gps/utils/loc_timer.h @@ -34,7 +34,8 @@ extern "C" { #endif /* __cplusplus */ #include <stddef.h> -#include <platform_lib_includes.h> +#include <stdint.h> +#include <loc_pla.h> /* user_data: client context pointer, passthrough. Originally received from calling client when loc_timer_start() is called. diff --git a/gps/utils/log_util.h b/gps/utils/log_util.h index 7eb338a..feb4d3c 100644 --- a/gps/utils/log_util.h +++ b/gps/utils/log_util.h @@ -30,22 +30,23 @@ #ifndef __LOG_UTIL_H__ #define __LOG_UTIL_H__ -#ifndef USE_GLIB +#if defined (USE_ANDROID_LOGGING) || defined (ANDROID) +// Android and LE targets with logcat support #include <utils/Log.h> -#endif /* USE_GLIB */ - -#ifdef USE_GLIB +#elif defined (USE_GLIB) +// LE targets with no logcat support #include <stdio.h> +#include <string.h> #include <sys/types.h> #include <unistd.h> +#include <cutils/log.h> #ifndef LOG_TAG #define LOG_TAG "GPS_UTILS" +#endif /* LOG_TAG */ -#endif // LOG_TAG - -#endif /* USE_GLIB */ +#endif /* #if defined (USE_ANDROID_LOGGING) || defined (ANDROID) */ #ifdef __cplusplus extern "C" @@ -140,6 +141,7 @@ extern char* get_timestamp(char* str, unsigned long buf_size); #define LOC_LOG_HEAD(fmt) "%s:%d] " fmt #define LOC_LOGv(fmt,...) LOC_LOGV(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__) #define LOC_LOGw(fmt,...) LOC_LOGW(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__) +#define LOC_LOGi(fmt,...) LOC_LOGI(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__) #define LOC_LOGd(fmt,...) LOC_LOGD(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__) #define LOC_LOGe(fmt,...) LOC_LOGE(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__) diff --git a/gps/utils/msg_q.c b/gps/utils/msg_q.c index e8b4ffe..76c1478 100644 --- a/gps/utils/msg_q.c +++ b/gps/utils/msg_q.c @@ -26,14 +26,14 @@ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "msg_q.h" - #define LOG_TAG "LocSvc_utils_q" -#include <platform_lib_includes.h> -#include "linked_list.h" #include <stdio.h> #include <stdlib.h> #include <pthread.h> +#include <loc_pla.h> +#include <log_util.h> +#include "linked_list.h" +#include "msg_q.h" typedef struct msg_q { void* msg_list; /* Linked list to store information */ diff --git a/gps/utils/platform_lib_abstractions/Android.mk b/gps/utils/platform_lib_abstractions/Android.mk deleted file mode 100644 index b923a4c..0000000 --- a/gps/utils/platform_lib_abstractions/Android.mk +++ /dev/null @@ -1,5 +0,0 @@ -ifneq ($(BUILD_TINY_ANDROID),true) - -include $(call all-subdir-makefiles) - -endif diff --git a/gps/utils/platform_lib_abstractions/elapsed_millis_since_boot.cpp b/gps/utils/platform_lib_abstractions/elapsed_millis_since_boot.cpp deleted file mode 100644 index 6c183a8..0000000 --- a/gps/utils/platform_lib_abstractions/elapsed_millis_since_boot.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (c) 2013, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <stdlib.h> -#include <sys/time.h> -#include "platform_lib_time.h" - -int64_t systemTime(int /*clock*/) -{ - struct timeval t; - t.tv_sec = t.tv_usec = 0; - gettimeofday(&t, NULL); - return t.tv_sec*1000000LL + t.tv_usec; -} - - -int64_t elapsedMillisSinceBoot() -{ - int64_t t_us = systemTime(0); - return (int64_t) t_us / 1000LL; -} diff --git a/gps/utils/platform_lib_abstractions/loc_pla/Android.mk b/gps/utils/platform_lib_abstractions/loc_pla/Android.mk deleted file mode 100644 index b923a4c..0000000 --- a/gps/utils/platform_lib_abstractions/loc_pla/Android.mk +++ /dev/null @@ -1,5 +0,0 @@ -ifneq ($(BUILD_TINY_ANDROID),true) - -include $(call all-subdir-makefiles) - -endif diff --git a/gps/utils/platform_lib_abstractions/loc_pla/Makefile.am b/gps/utils/platform_lib_abstractions/loc_pla/Makefile.am deleted file mode 100644 index 8996763..0000000 --- a/gps/utils/platform_lib_abstractions/loc_pla/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -# Makefile.am for gps loc-pla -# - -ACLOCAL_AMFLAGS = -I m4 - -SUBDIRS = src - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = loc-pla.pc -EXTRA_DIST = $(pkgconfig_DATA) diff --git a/gps/utils/platform_lib_abstractions/loc_pla/configure.ac b/gps/utils/platform_lib_abstractions/loc_pla/configure.ac deleted file mode 100644 index a8b892b..0000000 --- a/gps/utils/platform_lib_abstractions/loc_pla/configure.ac +++ /dev/null @@ -1,61 +0,0 @@ -# configure.ac -- Autoconf script for gps loc-pla -# -# Process this file with autoconf to produce a configure script - -# Requires autoconf tool later than 2.61 -AC_PREREQ(2.61) -# Initialize the gps loc-pla package version 1.0.0 -AC_INIT([loc-pla],1.0.0) -# Does not strictly follow GNU Coding standards -AM_INIT_AUTOMAKE([foreign]) -# Disables auto rebuilding of configure, Makefile.ins -AM_MAINTAINER_MODE -# Verifies the --srcdir is correct by checking for the path -AC_CONFIG_SRCDIR([include/platform_lib_includes.h]) -# defines some macros variable to be included by source -AC_CONFIG_HEADERS([config.h]) -AC_CONFIG_MACRO_DIR([m4]) - -# Checks for programs. -AC_PROG_LIBTOOL -AC_PROG_CXX -AC_PROG_CC -AM_PROG_CC_C_O -AC_PROG_AWK -AC_PROG_CPP -AC_PROG_INSTALL -AC_PROG_LN_S -AC_PROG_MAKE_SET -PKG_PROG_PKG_CONFIG - -# Checks for libraries. -PKG_CHECK_MODULES([LOCSTUB], [loc-stub]) -AC_SUBST([LOCSTUB_CFLAGS]) -AC_SUBST([LOCSTUB_LIBS]) - -AC_ARG_WITH([glib], - AC_HELP_STRING([--with-glib], - [enable glib, building HLOS systems which use glib])) - -if (test "x${with_glib}" = "xyes"); then - AC_DEFINE(ENABLE_USEGLIB, 1, [Define if HLOS systems uses glib]) - PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes, - AC_MSG_ERROR(GThread >= 2.16 is required)) - PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes, - AC_MSG_ERROR(GLib >= 2.16 is required)) - GLIB_CFLAGS="$GLIB_CFLAGS $GTHREAD_CFLAGS" - GLIB_LIBS="$GLIB_LIBS $GTHREAD_LIBS" - - AC_SUBST(GLIB_CFLAGS) - AC_SUBST(GLIB_LIBS) -fi - -AM_CONDITIONAL(USE_GLIB, test "x${with_glib}" = "xyes") - -AC_CONFIG_FILES([ \ - Makefile \ - src/Makefile \ - loc-pla.pc \ - ]) - -AC_OUTPUT diff --git a/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_gettid.h b/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_gettid.h deleted file mode 100644 index 340c3c5..0000000 --- a/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_gettid.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (c) 2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __PLATFORM_LIB_GETTID_H__ -#define __PLATFORM_LIB_GETTID_H__ - -#include <sys/types.h> - -#ifdef __cplusplus -extern "C" { -#endif -#ifdef USE_GLIB -const char* getprogname(); -#endif /* USE_GLIB */ - -pid_t platform_lib_abstraction_gettid(); -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* __PLATFORM_LIB_GETTID_H__ */ diff --git a/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_includes.h b/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_includes.h deleted file mode 100644 index ebb7119..0000000 --- a/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_includes.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (c) 2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __PLATFORM_LIB_INCLUDES_H__ -#define __PLATFORM_LIB_INCLUDES_H__ - -#include "platform_lib_gettid.h" -#include "platform_lib_log_util.h" -#include "platform_lib_macros.h" -#include "platform_lib_property_service.h" -#include "platform_lib_sched_policy.h" -#include "platform_lib_time.h" - -#endif /* __PLATFORM_LIB_INCLUDES_H__ */ diff --git a/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_log_util.h b/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_log_util.h deleted file mode 100644 index 26d3c29..0000000 --- a/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_log_util.h +++ /dev/null @@ -1,174 +0,0 @@ -/* Copyright (c) 2011-2014 The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __PLATFORM_LIB_LOG_UTIL_H__ -#define __PLATFORM_LIB_LOG_UTIL_H__ - -#include "platform_lib_macros.h" - -#ifndef USE_GLIB -#include <log_util.h> -#else - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <time.h> -#include <unistd.h> - -#ifndef LOG_TAG -#define LOG_TAG "GPS_UTILS" -#endif /* LOG_TAG */ - -#ifdef __cplusplus -extern "C" -{ -#endif -/*============================================================================= - * - * LOC LOGGER TYPE DECLARATION - * - *============================================================================*/ -/* LOC LOGGER */ -typedef struct loc_logger_s -{ - unsigned long DEBUG_LEVEL; - unsigned long TIMESTAMP; -} loc_logger_s_type; - -/*============================================================================= - * - * EXTERNAL DATA - * - *============================================================================*/ -extern loc_logger_s_type loc_logger; - -// Logging Improvements -extern const char *loc_logger_boolStr[]; - -extern const char *boolStr[]; -extern const char VOID_RET[]; -extern const char FROM_AFW[]; -extern const char TO_MODEM[]; -extern const char FROM_MODEM[]; -extern const char TO_AFW[]; -extern const char EXIT_TAG[]; -extern const char ENTRY_TAG[]; -extern const char EXIT_ERROR_TAG[]; - -/*============================================================================= - * - * MODULE EXPORTED FUNCTIONS - * - *============================================================================*/ -void loc_logger_init(unsigned long debug, unsigned long timestamp); -char* get_timestamp(char* str, unsigned long buf_size); - -#ifndef DEBUG_DMN_LOC_API - -/* LOGGING MACROS */ -/*loc_logger.DEBUG_LEVEL is initialized to 0xff in loc_cfg.cpp - if that value remains unchanged, it means gps.conf did not - provide a value and we default to the initial value to use - Android's logging levels*/ -#define IF_LOC_LOGE if((loc_logger.DEBUG_LEVEL >= 1) && (loc_logger.DEBUG_LEVEL <= 5)) -#define IF_LOC_LOGW if((loc_logger.DEBUG_LEVEL >= 2) && (loc_logger.DEBUG_LEVEL <= 5)) -#define IF_LOC_LOGI if((loc_logger.DEBUG_LEVEL >= 3) && (loc_logger.DEBUG_LEVEL <= 5)) -#define IF_LOC_LOGD if((loc_logger.DEBUG_LEVEL >= 4) && (loc_logger.DEBUG_LEVEL <= 5)) -#define IF_LOC_LOGV if((loc_logger.DEBUG_LEVEL >= 5) && (loc_logger.DEBUG_LEVEL <= 5)) - -#define LOC_LOGE(...) IF_LOC_LOGE { ALOGE(__VA_ARGS__); } -#define LOC_LOGW(...) IF_LOC_LOGW { ALOGW(__VA_ARGS__); } -#define LOC_LOGI(...) IF_LOC_LOGI { ALOGI(__VA_ARGS__); } -#define LOC_LOGD(...) IF_LOC_LOGD { ALOGD(__VA_ARGS__); } -#define LOC_LOGV(...) IF_LOC_LOGV { ALOGV(__VA_ARGS__); } - -#else /* DEBUG_DMN_LOC_API */ - -#define LOC_LOGE(...) ALOGE(__VA_ARGS__) -#define LOC_LOGW(...) ALOGW(__VA_ARGS__) -#define LOC_LOGI(...) ALOGI(__VA_ARGS__) -#define LOC_LOGD(...) ALOGD(__VA_ARGS__) -#define LOC_LOGV(...) ALOGV(__VA_ARGS__) - -#endif /* DEBUG_DMN_LOC_API */ - -/*============================================================================= - * - * LOGGING IMPROVEMENT MACROS - * - *============================================================================*/ -#define LOG_(LOC_LOG, ID, WHAT, SPEC, VAL) \ - do { \ - if (loc_logger.TIMESTAMP) { \ - char ts[32]; \ - LOC_LOG("[%s] %s %s line %d " #SPEC, \ - get_timestamp(ts, sizeof(ts)), ID, WHAT, __LINE__, VAL); \ - } else { \ - LOC_LOG("%s %s line %d " #SPEC, \ - ID, WHAT, __LINE__, VAL); \ - } \ - } while(0) - -#define LOC_LOG_HEAD(fmt) "%s:%d] " fmt -#define LOC_LOGv(fmt,...) LOC_LOGV(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__) -#define LOC_LOGw(fmt,...) LOC_LOGW(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__) -#define LOC_LOGd(fmt,...) LOC_LOGD(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__) -#define LOC_LOGe(fmt,...) LOC_LOGE(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__) - -#define LOG_I(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGI, ID, WHAT, SPEC, VAL) -#define LOG_V(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGV, ID, WHAT, SPEC, VAL) -#define LOG_E(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGE, ID, WHAT, SPEC, VAL) - -#define ENTRY_LOG() LOG_V(ENTRY_TAG, __FUNCTION__, %s, "") -#define EXIT_LOG(SPEC, VAL) LOG_V(EXIT_TAG, __FUNCTION__, SPEC, VAL) -#define EXIT_LOG_WITH_ERROR(SPEC, VAL) \ - if (VAL != 0) { \ - LOG_E(EXIT_ERROR_TAG, __FUNCTION__, SPEC, VAL); \ - } else { \ - LOG_V(EXIT_TAG, __FUNCTION__, SPEC, VAL); \ - } - - -// Used for logging callflow from Android Framework -#define ENTRY_LOG_CALLFLOW() LOG_I(FROM_AFW, __FUNCTION__, %s, "") -// Used for logging callflow to Modem -#define EXIT_LOG_CALLFLOW(SPEC, VAL) LOG_I(TO_MODEM, __FUNCTION__, SPEC, VAL) -// Used for logging callflow from Modem(TO_MODEM, __FUNCTION__, %s, "") -#define MODEM_LOG_CALLFLOW(SPEC, VAL) LOG_I(FROM_MODEM, __FUNCTION__, SPEC, VAL) -// Used for logging callflow to Android Framework -#define CALLBACK_LOG_CALLFLOW(CB, SPEC, VAL) LOG_I(TO_AFW, CB, SPEC, VAL) - -#ifdef __cplusplus -} -#endif - -#endif /* USE_GLIB */ - -#endif /* __PLATFORM_LIB_LOG_UTIL_H__ */ diff --git a/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_macros.h b/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_macros.h deleted file mode 100644 index d0795eb..0000000 --- a/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_macros.h +++ /dev/null @@ -1,85 +0,0 @@ -/* Copyright (c) 2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __PLATFORM_LIB_MACROS_H__ -#define __PLATFORM_LIB_MACROS_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef USE_GLIB -#include <sys/time.h> -#include <string.h> -#include <stdlib.h> -#ifndef OFF_TARGET -#include <glib.h> -#define strlcat g_strlcat -#define strlcpy g_strlcpy -#else -#define strlcat strncat -#define strlcpy strncpy -#endif - -#define TS_PRINTF(format, x...) \ -{ \ - struct timeval tv; \ - struct timezone tz; \ - int hh, mm, ss; \ - gettimeofday(&tv, &tz); \ - hh = tv.tv_sec/3600%24; \ - mm = (tv.tv_sec%3600)/60; \ - ss = tv.tv_sec%60; \ - fprintf(stdout,"%02d:%02d:%02d.%06ld]" format "\n", hh, mm, ss, tv.tv_usec,##x); \ -} - -#define ALOGE(format, x...) TS_PRINTF("E/%s (%d): " format , LOG_TAG, getpid(), ##x) -#define ALOGW(format, x...) TS_PRINTF("W/%s (%d): " format , LOG_TAG, getpid(), ##x) -#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 /* USE_GLIB */ - - -// Below are the location conf file paths -extern const char LOC_PATH_GPS_CONF[]; -extern const char LOC_PATH_IZAT_CONF[]; -extern const char LOC_PATH_FLP_CONF[]; -extern const char LOC_PATH_LOWI_CONF[]; -extern const char LOC_PATH_SAP_CONF[]; -extern const char LOC_PATH_APDR_CONF[]; -extern const char LOC_PATH_XTWIFI_CONF[]; -extern const char LOC_PATH_QUIPC_CONF[]; - - -#ifdef __cplusplus -} -#endif /*__cplusplus */ - -#endif /* __PLATFORM_LIB_MACROS_H__ */ diff --git a/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_property_service.h b/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_property_service.h deleted file mode 100644 index ed2041f..0000000 --- a/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_property_service.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (c) 2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __PLATFORM_LIB_PROPERTY_SERVICE_H__ -#define __PLATFORM_LIB_PROPERTY_SERVICE_H__ - -#ifdef __cplusplus -extern "C" { -#endif -#ifndef PROPERTY_VALUE_MAX -#define PROPERTY_VALUE_MAX 92 -#endif -int platform_lib_abstraction_property_get(const char *key, char *value, const char *default_value); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __PLATFORM_LIB_PROPERTY_SERVICE_H__ */ diff --git a/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_sched_policy.h b/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_sched_policy.h deleted file mode 100644 index d10f151..0000000 --- a/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_sched_policy.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (c) 2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __PLATFORM_LIB_SCHED_POLICY_H__ -#define __PLATFORM_LIB_SCHED_POLICY_H__ - -#ifdef __cplusplus -extern "C" { -#endif -typedef enum { - PLA_SP_BACKGROUND = 0, - PLA_SP_FOREGROUND = 1, -} PLASchedPolicy; - -int platform_lib_abstraction_set_sched_policy(int tid, PLASchedPolicy policy); -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __PLATFORM_LIB_SCHED_POLICY_H__ */ - diff --git a/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_time.h b/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_time.h deleted file mode 100644 index ae25ae6..0000000 --- a/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_time.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright (c) 2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __PLATFORM_LIB_TIME_H__ -#define __PLATFORM_LIB_TIME_H__ - -#include <stdint.h> -int64_t platform_lib_abstraction_elapsed_millis_since_boot(); -int64_t platform_lib_abstraction_elapsed_micros_since_boot(); - -#endif /* __PLATFORM_LIB_TIME_H__ */ diff --git a/gps/utils/platform_lib_abstractions/loc_pla/loc-pla.pc.in b/gps/utils/platform_lib_abstractions/loc_pla/loc-pla.pc.in deleted file mode 100644 index 1aad2f4..0000000 --- a/gps/utils/platform_lib_abstractions/loc_pla/loc-pla.pc.in +++ /dev/null @@ -1,10 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: loc-pla -Description: QTI GPS Location Platform Library Abstractions -Version: @VERSION@ -Libs: -L${libdir} -lloc_pla -Cflags: -I${includedir}/loc-pla diff --git a/gps/utils/platform_lib_abstractions/loc_pla/src/Android.mk b/gps/utils/platform_lib_abstractions/loc_pla/src/Android.mk deleted file mode 100644 index 25d9439..0000000 --- a/gps/utils/platform_lib_abstractions/loc_pla/src/Android.mk +++ /dev/null @@ -1,67 +0,0 @@ -GNSS_CFLAGS := \ - -Werror \ - -Wno-error=unused-parameter \ - -Wno-error=format \ - -Wno-error=macro-redefined \ - -Wno-error=reorder \ - -Wno-error=missing-braces \ - -Wno-error=self-assign \ - -Wno-error=enum-conversion \ - -Wno-error=logical-op-parentheses \ - -Wno-error=null-arithmetic \ - -Wno-error=null-conversion \ - -Wno-error=parentheses-equality \ - -Wno-error=undefined-bool-conversion \ - -Wno-error=tautological-compare \ - -Wno-error=switch \ - -Wno-error=date-time - -ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),) -ifneq ($(BUILD_TINY_ANDROID),true) -#Compile this library only for builds with the latest modem image - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -## Libs -LOCAL_SHARED_LIBRARIES := \ - libutils \ - libcutils \ - liblog \ - libloc_stub - -LOCAL_SRC_FILES += \ - platform_lib_gettid.cpp \ - platform_lib_log_util.cpp \ - platform_lib_property_service.cpp \ - platform_lib_sched_policy.cpp \ - platform_lib_time.cpp - -LOCAL_CFLAGS += \ - -fno-short-enums \ - -D_ANDROID_ \ - -std=c++11 - -## Includes -LOCAL_C_INCLUDES:= \ - $(LOCAL_PATH)/../include -LOCAL_HEADER_LIBRARIES := \ - libgps.utils_headers \ - libloc_stub_headers - -LOCAL_MODULE := libloc_pla -LOCAL_VENDOR_MODULE := true -LOCAL_MODULE_TAGS := optional - -LOCAL_PRELINK_MODULE := false -LOCAL_CFLAGS += $(GNSS_CFLAGS) -include $(BUILD_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libloc_pla_headers -LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../include -include $(BUILD_HEADER_LIBRARY) - -endif # not BUILD_TINY_ANDROID -endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE diff --git a/gps/utils/platform_lib_abstractions/loc_pla/src/Makefile.am b/gps/utils/platform_lib_abstractions/loc_pla/src/Makefile.am deleted file mode 100644 index 30c4b4c..0000000 --- a/gps/utils/platform_lib_abstractions/loc_pla/src/Makefile.am +++ /dev/null @@ -1,39 +0,0 @@ -AM_CFLAGS = \ - $(LOCSTUB_CFLAGS) \ - -I../include \ - -D__func__=__PRETTY_FUNCTION__ \ - -fno-short-enums - -h_sources = \ - ../include/platform_lib_gettid.h \ - ../include/platform_lib_includes.h \ - ../include/platform_lib_log_util.h \ - ../include/platform_lib_macros.h \ - ../include/platform_lib_property_service.h \ - ../include/platform_lib_sched_policy.h \ - ../include/platform_lib_time.h - -library_includedir = $(pkgincludedir) -library_include_HEADERS = $(h_sources) - -libloc_pla_la_SOURCES = \ - platform_lib_gettid.cpp \ - platform_lib_log_util.cpp \ - platform_lib_property_service.cpp \ - platform_lib_sched_policy.cpp \ - platform_lib_time.cpp - -if USE_GLIB -libloc_pla_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@ -libloc_pla_la_LDFLAGS = -lstdc++ -Wl,-z,defs -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 -libloc_pla_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@ -else -libloc_pla_la_CFLAGS = $(AM_CFLAGS) -libloc_pla_la_LDFLAGS = -Wl,-z,defs -lpthread -shared -version-info 1:0:0 -libloc_pla_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) -endif - -libloc_pla_la_LIBADD = -lstdc++ -ldl -llog $(LOCSTUB_LIBS) - -#Create and Install libraries -lib_LTLIBRARIES = libloc_pla.la diff --git a/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_gettid.cpp b/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_gettid.cpp deleted file mode 100644 index 1b7aa32..0000000 --- a/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_gettid.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (c) 2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "platform_lib_gettid.h" - -#ifdef USE_GLIB -#include <loc_stub_gettid.h> - -#include <errno.h> -const char* getprogname() { - return program_invocation_short_name; -} - -#else -#include <unistd.h> -#endif /* USE_GLIB */ - -pid_t platform_lib_abstraction_gettid() -{ - return gettid(); -} diff --git a/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_log_util.cpp b/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_log_util.cpp deleted file mode 100644 index 90bf26d..0000000 --- a/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_log_util.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* Copyright (c) 2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include <cstdio> -#include <sys/time.h> - -#include "platform_lib_log_util.h" -#include "platform_lib_macros.h" - -char * get_timestamp(char *str, unsigned long buf_size) -{ - struct timeval tv; - struct timezone tz; - int hh, mm, ss; - gettimeofday(&tv, &tz); - hh = tv.tv_sec/3600%24; - mm = (tv.tv_sec%3600)/60; - ss = tv.tv_sec%60; - snprintf(str, buf_size, "%02d:%02d:%02d.%06ld", hh, mm, ss, tv.tv_usec); - return str; -} - -// Below are the location conf file paths -#ifdef __ANDROID__ - -#define LOC_PATH_GPS_CONF_STR "/vendor/etc/gps.conf" -#define LOC_PATH_IZAT_CONF_STR "/vendor/etc/izat.conf" -#define LOC_PATH_FLP_CONF_STR "/vendor/etc/flp.conf" -#define LOC_PATH_LOWI_CONF_STR "/vendor/etc/lowi.conf" -#define LOC_PATH_SAP_CONF_STR "/vendor/etc/sap.conf" -#define LOC_PATH_APDR_CONF_STR "/vendor/etc/apdr.conf" -#define LOC_PATH_XTWIFI_CONF_STR "/vendor/etc/xtwifi.conf" -#define LOC_PATH_QUIPC_CONF_STR "/vendor/etc/quipc.conf" - -#else - -#define LOC_PATH_GPS_CONF_STR "/etc/gps.conf" -#define LOC_PATH_IZAT_CONF_STR "/etc/izat.conf" -#define LOC_PATH_FLP_CONF_STR "/etc/flp.conf" -#define LOC_PATH_LOWI_CONF_STR "/etc/lowi.conf" -#define LOC_PATH_SAP_CONF_STR "/etc/sap.conf" -#define LOC_PATH_APDR_CONF_STR "/etc/apdr.conf" -#define LOC_PATH_XTWIFI_CONF_STR "/etc/xtwifi.conf" -#define LOC_PATH_QUIPC_CONF_STR "/etc/quipc.conf" - -#endif // __ANDROID__ - -// Reference below arrays wherever needed to avoid duplicating -// same conf path string over and again in location code. -const char LOC_PATH_GPS_CONF[] = LOC_PATH_GPS_CONF_STR; -const char LOC_PATH_IZAT_CONF[] = LOC_PATH_IZAT_CONF_STR; -const char LOC_PATH_FLP_CONF[] = LOC_PATH_FLP_CONF_STR; -const char LOC_PATH_LOWI_CONF[] = LOC_PATH_LOWI_CONF_STR; -const char LOC_PATH_SAP_CONF[] = LOC_PATH_SAP_CONF_STR; -const char LOC_PATH_APDR_CONF[] = LOC_PATH_APDR_CONF_STR; -const char LOC_PATH_XTWIFI_CONF[] = LOC_PATH_XTWIFI_CONF_STR; -const char LOC_PATH_QUIPC_CONF[] = LOC_PATH_QUIPC_CONF_STR; diff --git a/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_property_service.cpp b/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_property_service.cpp deleted file mode 100644 index dccdebc..0000000 --- a/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_property_service.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (c) 2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifdef USE_GLIB -#include <loc_stub_property_service.h> -#else -#include <cutils/properties.h> -#endif /* USE_GLIB */ - -#include "platform_lib_property_service.h" - -int platform_lib_abstraction_property_get(const char *key, char *value, const char *default_value) -{ - return property_get(key, value, default_value); -} diff --git a/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_sched_policy.cpp b/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_sched_policy.cpp deleted file mode 100644 index ba6b350..0000000 --- a/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_sched_policy.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (c) 2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "platform_lib_sched_policy.h" - -#ifdef USE_GLIB -#include <loc_stub_sched_policy.h> -#else -#include <cutils/sched_policy.h> -#endif /* USE_GLIB */ - -int platform_lib_abstraction_set_sched_policy(int tid, PLASchedPolicy policy) -{ - return set_sched_policy(tid, (SchedPolicy)policy); -} - diff --git a/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_time.cpp b/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_time.cpp deleted file mode 100644 index 3dcd4d3..0000000 --- a/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_time.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (c) 2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "platform_lib_time.h" - -#ifdef USE_GLIB -#include <loc_stub_time.h> -#else -#include <utils/SystemClock.h> -#include <utils/Timers.h> - -#endif /* USE_GLIB */ - -int64_t platform_lib_abstraction_elapsed_millis_since_boot() -{ -#ifdef USE_GLIB - - return elapsedMillisSinceBoot(); - -#else - - //return android::nanoseconds_to_microseconds(systemTime(SYSTEM_TIME_BOOTTIME))/1000; - return nanoseconds_to_microseconds(systemTime(SYSTEM_TIME_BOOTTIME))/1000; -#endif -} -int64_t platform_lib_abstraction_elapsed_micros_since_boot() -{ -#ifdef USE_GLIB - return elapsedMicrosSinceBoot(); - -#else - //return android::nanoseconds_to_microseconds(systemTime(SYSTEM_TIME_BOOTTIME)); - return nanoseconds_to_microseconds(systemTime(SYSTEM_TIME_BOOTTIME)); -#endif -} diff --git a/gps/utils/platform_lib_abstractions/loc_stub/Android.mk b/gps/utils/platform_lib_abstractions/loc_stub/Android.mk deleted file mode 100644 index b923a4c..0000000 --- a/gps/utils/platform_lib_abstractions/loc_stub/Android.mk +++ /dev/null @@ -1,5 +0,0 @@ -ifneq ($(BUILD_TINY_ANDROID),true) - -include $(call all-subdir-makefiles) - -endif diff --git a/gps/utils/platform_lib_abstractions/loc_stub/Makefile.am b/gps/utils/platform_lib_abstractions/loc_stub/Makefile.am deleted file mode 100644 index d81e363..0000000 --- a/gps/utils/platform_lib_abstractions/loc_stub/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -# Makefile.am for gps loc-stub - -ACLOCAL_AMFLAGS = -I m4 - -SUBDIRS = src - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = loc-stub.pc -EXTRA_DIST = $(pkgconfig_DATA) diff --git a/gps/utils/platform_lib_abstractions/loc_stub/configure.ac b/gps/utils/platform_lib_abstractions/loc_stub/configure.ac deleted file mode 100644 index 8900f04..0000000 --- a/gps/utils/platform_lib_abstractions/loc_stub/configure.ac +++ /dev/null @@ -1,67 +0,0 @@ -# configure.ac -- Autoconf script for gps loc-stub -# -# Process this file with autoconf to produce a configure script - -# Requires autoconf tool later than 2.61 -AC_PREREQ(2.61) -# Initialize the gps loc-stub package version 1.0.0 -AC_INIT([loc-stub],1.0.0) -# Does not strictly follow GNU Coding standards -AM_INIT_AUTOMAKE([foreign]) -# Disables auto rebuilding of configure, Makefile.ins -AM_MAINTAINER_MODE -# Verifies the --srcdir is correct by checking for the path -AC_CONFIG_SRCDIR([Makefile.am]) -# defines some macros variable to be included by source -AC_CONFIG_HEADERS([config.h]) -AC_CONFIG_MACRO_DIR([m4]) - -# Checks for programs. -AC_PROG_LIBTOOL -AC_PROG_CXX -AC_PROG_CC -AM_PROG_CC_C_O -AC_PROG_AWK -AC_PROG_CPP -AC_PROG_INSTALL -AC_PROG_LN_S -AC_PROG_MAKE_SET -PKG_PROG_PKG_CONFIG - -# Checks for libraries. -AC_ARG_WITH([hardware_include], - AC_HELP_STRING([--with-hardware-include=@<:@dir@:>@], - [Specify the location of the hardware headers]), - [hardware_incdir=$withval], - with_hardware_include=no) - -if test "x$with_hardware_include" != "xno"; then - CPPFLAGS="${CPPFLAGS} -I${hardware_incdir}" -fi - -AC_ARG_WITH([glib], - AC_HELP_STRING([--with-glib], - [enable glib, building HLOS systems which use glib])) - -if (test "x${with_glib}" = "xyes"); then - AC_DEFINE(ENABLE_USEGLIB, 1, [Define if HLOS systems uses glib]) - PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes, - AC_MSG_ERROR(GThread >= 2.16 is required)) - PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes, - AC_MSG_ERROR(GLib >= 2.16 is required)) - GLIB_CFLAGS="$GLIB_CFLAGS $GTHREAD_CFLAGS" - GLIB_LIBS="$GLIB_LIBS $GTHREAD_LIBS" - - AC_SUBST(GLIB_CFLAGS) - AC_SUBST(GLIB_LIBS) -fi - -AM_CONDITIONAL(USE_GLIB, test "x${with_glib}" = "xyes") - -AC_CONFIG_FILES([ \ - Makefile \ - src/Makefile \ - loc-stub.pc - ]) - -AC_OUTPUT diff --git a/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_android_runtime.h b/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_android_runtime.h deleted file mode 100644 index c8764ee..0000000 --- a/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_android_runtime.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (c) 2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __LOC_STUB_ANDROID_RUNTIME_H__ -#define __LOC_STUB_ANDROID_RUNTIME_H__ - -#include <pthread.h> - -namespace android { - -class AndroidRuntime -{ -public: - /** create a new thread that is visible from Java */ - static pthread_t createJavaThread(const char* name, void (*start)(void *), - void* arg); -}; - -} -#endif /* __LOC_STUB_ANDROID_RUNTIME_H__ */ diff --git a/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_gettid.h b/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_gettid.h deleted file mode 100644 index 677bc81..0000000 --- a/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_gettid.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (c) 2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __LOC_STUB_GETTID_H__ -#define __LOC_STUB_GETTID_H__ - -#include <pthread.h> - -#ifdef __cplusplus -extern "C" { -#endif - -pid_t gettid(void); - -#ifdef __cplusplus -} -#endif - -#endif /* __LOC_STUB_GETTID_H__ */ diff --git a/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_property_service.h b/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_property_service.h deleted file mode 100644 index 3677cdf..0000000 --- a/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_property_service.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (c) 2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __LOC_STUB_PROPERTY_SERVICE_H__ -#define __LOC_STUB_PROPERTY_SERVICE_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -int property_get(const char *key, char *value, const char *default_value); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __LOC_STUB_PROPERTY_SERVICE_H__ */ diff --git a/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_sched_policy.h b/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_sched_policy.h deleted file mode 100644 index a42b117..0000000 --- a/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_sched_policy.h +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright (c) 2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __LOC_STUB_SCHED_POLICY_H__ -#define __LOC_STUB_SCHED_POLICY_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - SP_BACKGROUND = 0, - SP_FOREGROUND = 1, -} SchedPolicy; - -/*=========================================================================== -FUNCTION set_sched_policy - -DESCRIPTION - Local copy of this function which bypasses android set_sched_policy - -DEPENDENCIES - None - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -int set_sched_policy(int tid, SchedPolicy policy); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __LOC_STUB_SCHED_POLICY_H__ */ - diff --git a/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_time.h b/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_time.h deleted file mode 100644 index f00a49b..0000000 --- a/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_time.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (c) 2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __LOC_STUB_TIME_H__ -#define __LOC_STUB_TIME_H__ - -#include <stdint.h> - -#ifdef __cplusplus -extern "C" { -#endif - -int64_t systemTime(int clock); -int64_t elapsedMillisSinceBoot(); -int64_t elapsedMicrosSinceBoot(); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __LOC_STUB_TIME_H__ */ diff --git a/gps/utils/platform_lib_abstractions/loc_stub/loc-stub.pc.in b/gps/utils/platform_lib_abstractions/loc_stub/loc-stub.pc.in deleted file mode 100644 index c2ae764..0000000 --- a/gps/utils/platform_lib_abstractions/loc_stub/loc-stub.pc.in +++ /dev/null @@ -1,10 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: loc-stub -Description: QTI GPS Location Stub -Version: @VERSION -Libs: -L${libdir} -lloc_stub -Cflags: -I${includedir}/loc-stub diff --git a/gps/utils/platform_lib_abstractions/loc_stub/src/Android.mk b/gps/utils/platform_lib_abstractions/loc_stub/src/Android.mk deleted file mode 100644 index f4cec2b..0000000 --- a/gps/utils/platform_lib_abstractions/loc_stub/src/Android.mk +++ /dev/null @@ -1,49 +0,0 @@ -ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),) -ifneq ($(BUILD_TINY_ANDROID),true) -#Compile this library only for builds with the latest modem image - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -## Libs -LOCAL_SHARED_LIBRARIES := \ - libutils \ - libcutils \ - liblog - -LOCAL_SRC_FILES += \ - loc_stub_android_runtime.cpp \ - loc_stub_gettid.cpp \ - loc_stub_property_service.cpp \ - loc_stub_sched_policy.cpp \ - loc_stub_time.cpp - -LOCAL_CFLAGS += \ - -fno-short-enums \ - -D_ANDROID_ \ - -std=c++11 - - -LOCAL_LDFLAGS += -Wl,--export-dynamic - -## Includes -LOCAL_C_INCLUDES:= \ - $(LOCAL_PATH)/../include \ - -LOCAL_MODULE := libloc_stub -LOCAL_VENDOR_MODULE := true -LOCAL_MODULE_OWNER := qti -LOCAL_MODULE_TAGS := optional - -LOCAL_PRELINK_MODULE := false -LOCAL_CFLAGS += $(GNSS_CFLAGS) -include $(BUILD_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libloc_stub_headers -LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../include -include $(BUILD_HEADER_LIBRARY) - -endif # not BUILD_TINY_ANDROID -endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE diff --git a/gps/utils/platform_lib_abstractions/loc_stub/src/Makefile.am b/gps/utils/platform_lib_abstractions/loc_stub/src/Makefile.am deleted file mode 100644 index ba823a2..0000000 --- a/gps/utils/platform_lib_abstractions/loc_stub/src/Makefile.am +++ /dev/null @@ -1,40 +0,0 @@ -AM_CFLAGS = \ - -I../include \ - -D__func__=__PRETTY_FUNCTION__ \ - -fno-short-enums - -libloc_stub_la_extra_h = \ - ../include/utils/Log.h - -libloc_stub_la_c_sources = \ - loc_stub_android_runtime.cpp \ - loc_stub_gettid.cpp \ - loc_stub_property_service.cpp \ - loc_stub_sched_policy.cpp \ - loc_stub_time.cpp - -libloc_stub_la_SOURCES = $(libloc_stub_la_c_sources) $(libloc_stub_la_extra_h) - -library_include_HEADERS = \ - ../include/loc_stub_android_runtime.h \ - ../include/loc_stub_gettid.h \ - ../include/loc_stub_property_service.h \ - ../include/loc_stub_sched_policy.h \ - ../include/loc_stub_time.h - -library_includedir = $(pkgincludedir) - -if USE_GLIB -libloc_stub_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@ -libloc_stub_la_LDFLAGS = -lstdc++ -Wl,-z,defs -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 -libloc_stub_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@ -else -libloc_stub_la_CFLAGS = $(AM_CFLAGS) -libloc_stub_la_LDFLAGS = -Wl,-z,defs -lpthread -shared -version-info 1:0:0 -libloc_stub_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) -endif - -libloc_stub_la_LIBADD = -lstdc++ -ldl -llog - -#Create and Install libraries -lib_LTLIBRARIES = libloc_stub.la diff --git a/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_android_runtime.cpp b/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_android_runtime.cpp deleted file mode 100644 index 068df4e..0000000 --- a/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_android_runtime.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (c) 2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "loc_stub_android_runtime.h" - -namespace android { - -pthread_t AndroidRuntime::createJavaThread(const char* /*name*/, - void (*start)(void *), void* arg) -{ - pthread_t threadId = 0; - pthread_create(&threadId, NULL, (void *(*)(void*))start, arg); - return threadId; -} - -} diff --git a/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_gettid.cpp b/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_gettid.cpp deleted file mode 100644 index 55ef48a..0000000 --- a/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_gettid.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (c) 2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "loc_stub_gettid.h" -#include <sys/syscall.h> -#include <unistd.h> - -// Required for off-target environment to compile properly -pid_t gettid(void) -{ - return syscall(SYS_gettid); -} diff --git a/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_property_service.cpp b/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_property_service.cpp deleted file mode 100644 index 907ab02..0000000 --- a/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_property_service.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (c) 2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "loc_stub_property_service.h" -#include <stdio.h> -#include <string.h> - -int property_get(const char *key, char * value, const char */*default_value*/) -{ - /* This will disable gps interface - value[0] = '1'; - */ - if (strcmp(key, "ro.baseband") == 0) { - memcpy(value, "msm", 4); - } - return 0; -} diff --git a/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_sched_policy.cpp b/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_sched_policy.cpp deleted file mode 100644 index 5e26245..0000000 --- a/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_sched_policy.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (c) 2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "loc_stub_sched_policy.h" - -/*=========================================================================== -FUNCTION set_sched_policy - -DESCRIPTION - Local copy of this function which bypasses android set_sched_policy - -DEPENDENCIES - None - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -int set_sched_policy(int /*tid*/, SchedPolicy /*policy*/) -{ - return 0; -} diff --git a/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_time.cpp b/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_time.cpp deleted file mode 100644 index 48149a6..0000000 --- a/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_time.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (c) 2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "loc_stub_time.h" -#include <stdlib.h> -#include <sys/time.h> -#include <time.h> - -int64_t systemTime(int /*clock*/) -{ - struct timeval t; - t.tv_sec = t.tv_usec = 0; - gettimeofday(&t, NULL); - return t.tv_sec*1000000LL + t.tv_usec; -} - -int64_t elapsedMicrosSinceBoot() -{ - struct timespec ts; - int64_t time_ms = 0; - clock_gettime(CLOCK_BOOTTIME, &ts); - time_ms += (ts.tv_sec * 1000000000LL); /* Seconds to nanoseconds */ - time_ms += ts.tv_nsec; /* Add Nanoseconds */ - return time_ms; -} - -int64_t elapsedMillisSinceBoot() -{ - return (int64_t) (elapsedMicrosSinceBoot() /1000000LL); -} |