summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorWei Chen <weic@codeaurora.org>2019-12-12 12:53:04 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2020-01-08 12:01:36 -0800
commit8400fc771740f62536e454ecf97289d689158043 (patch)
tree0b614c1aa886799906a4d89da2818654471ec3f2 /utils
parent7a736851d49f0eb3fffb0c3bf4ecbf4036086d46 (diff)
downloadgps-8400fc771740f62536e454ecf97289d689158043.tar.gz
Location integration API: misc fix
1: Socket name for location integration api client to share same prefix as location client API, so HAL daemon can notify both when restarted 2: Add 2 seconds timeout for datagram socket send operation 3: Make the location api destroy more robust when callback gets updated Change-Id: If4764afc29d9e3650dd847766d412c6b4e15b2d5 CRs-fixed: 2579959
Diffstat (limited to 'utils')
-rw-r--r--utils/LocIpc.cpp16
-rw-r--r--utils/gps_extended_c.h7
2 files changed, 19 insertions, 4 deletions
diff --git a/utils/LocIpc.cpp b/utils/LocIpc.cpp
index e9dbe9d..344e487 100644
--- a/utils/LocIpc.cpp
+++ b/utils/LocIpc.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-2020 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
@@ -139,8 +139,20 @@ protected:
}
public:
inline LocIpcLocalSender(const char* name) : LocIpcSender(),
- mSock(make_shared<Sock>((nullptr == name) ? -1 : (::socket(AF_UNIX, SOCK_DGRAM, 0)))),
+ mSock(nullptr),
mAddr({.sun_family = AF_UNIX, {}}) {
+
+ int fd = -1;
+ if (nullptr != name) {
+ fd = ::socket(AF_UNIX, SOCK_DGRAM, 0);
+ if (fd >= 0) {
+ timeval timeout;
+ timeout.tv_sec = 2;
+ timeout.tv_usec = 0;
+ setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout));
+ }
+ }
+ mSock.reset(new Sock(fd));
if (mSock != nullptr && mSock->isValid()) {
snprintf(mAddr.sun_path, sizeof(mAddr.sun_path), "%s", name);
}
diff --git a/utils/gps_extended_c.h b/utils/gps_extended_c.h
index ad39ce2..677b750 100644
--- a/utils/gps_extended_c.h
+++ b/utils/gps_extended_c.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2020 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
@@ -2297,7 +2297,10 @@ enum PowerStateType {
#define EAP_LOC_CLIENT_DIR "/data/vendor/location/extap_locclient/"
#define LOC_CLIENT_NAME_PREFIX "toclient"
-#define LOC_INTAPI_NAME_PREFIX "toIntapiClient"
+// Please note that the socket name for all location hal daemon client need
+// to start with LOC_CLIENT_NAME_PREFIX so that upon hal daemon restarts,
+// every client can get the notification that hal daemon has restarted.
+#define LOC_INTAPI_NAME_PREFIX LOC_CLIENT_NAME_PREFIX "_intapi"
typedef uint64_t NetworkHandle;
#define NETWORK_HANDLE_UNKNOWN ~0