diff options
author | Vamana Murthi <vthuniki@codeaurora.org> | 2017-07-05 00:39:06 +0530 |
---|---|---|
committer | Katz Yamada <kyamada@codeaurora.org> | 2017-08-15 14:36:57 -0700 |
commit | 1b6695633f82f1905cdbf159249862ac5f19c28a (patch) | |
tree | 2f13a0ae1d44f18506c2a5d3fca36d8803dd0167 /android | |
parent | 3d75c952a857459fe7dcdbbd49f6aa23d8e5b4eb (diff) | |
download | gps-1b6695633f82f1905cdbf159249862ac5f19c28a.tar.gz |
XC 2.5 : additional changes
Add the XTRAsystemstatus observer to
pass the HAL init info to XTRA-Client
CRs-Fixed: 2093274
Change-Id: I893da1470d4fedafbc7545806ea97667acdf60d3
Diffstat (limited to 'android')
-rw-r--r-- | android/AGnssRil.cpp | 70 |
1 files changed, 3 insertions, 67 deletions
diff --git a/android/AGnssRil.cpp b/android/AGnssRil.cpp index ec3dd76..bd4bb37 100644 --- a/android/AGnssRil.cpp +++ b/android/AGnssRil.cpp @@ -37,7 +37,6 @@ namespace gnss { namespace V1_0 { namespace implementation { -static bool sendConnectionEvent(const bool connected, const uint8_t type); AGnssRil::AGnssRil(Gnss* gnss) : mGnss(gnss) { ENTRY_LOG_CALLFLOW(); @@ -51,73 +50,10 @@ Return<bool> AGnssRil::updateNetworkState(bool connected, NetworkType type, bool ENTRY_LOG_CALLFLOW(); // for XTRA - sendConnectionEvent(connected, (uint8_t)type); - - return true; -} - -// for XTRA -static inline int createSocket() { - int socketFd = -1; - - if ((socketFd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { - LOC_LOGe("create socket error. reason:%s", strerror(errno)); - - } else { - const char* socketPath = "/data/vendor/location/xtra/socket_hal_xtra"; - struct sockaddr_un addr = { .sun_family = AF_UNIX }; - snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", socketPath); - - if (::connect(socketFd, (struct sockaddr*)&addr, sizeof(addr)) < 0) { - LOC_LOGe("cannot connect to XTRA. reason:%s", strerror(errno)); - if (::close(socketFd)) { - LOC_LOGe("close socket error. reason:%s", strerror(errno)); - } - socketFd = -1; - } - } - - return socketFd; -} - -static inline void closeSocket(const int socketFd) { - if (socketFd >= 0) { - if(::close(socketFd)) { - LOC_LOGe("close socket error. reason:%s", strerror(errno)); - } + if (nullptr != mGnss && ( nullptr != mGnss->getGnssInterface() )) { + mGnss->getGnssInterface()->updateConnectionStatus(connected, (uint8_t)type); } -} - -static inline bool sendConnectionEvent(const bool connected, const uint8_t type) { - int socketFd = createSocket(); - if (socketFd < 0) { - LOC_LOGe("XTRA unreachable. sending failed."); - return false; - } - - std::stringstream ss; - ss << "connection"; - ss << " " << (connected ? "1" : "0"); - ss << " " << (int)type; - ss << "\n"; // append seperator - - const std::string& data = ss.str(); - int remain = data.length(); - ssize_t sent = 0; - - while (remain > 0 && - (sent = ::send(socketFd, data.c_str() + (data.length() - remain), - remain, MSG_NOSIGNAL)) > 0) { - remain -= sent; - } - - if (sent < 0) { - LOC_LOGe("sending error. reason:%s", strerror(errno)); - } - - closeSocket(socketFd); - - return (remain == 0); + return true; } } // namespace implementation |