diff options
-rw-r--r-- | location/LocationAPI.cpp | 18 | ||||
-rw-r--r-- | utils/LocIpc.cpp | 16 | ||||
-rw-r--r-- | utils/gps_extended_c.h | 7 |
3 files changed, 26 insertions, 15 deletions
diff --git a/location/LocationAPI.cpp b/location/LocationAPI.cpp index 7c125b8..d38c023 100644 --- a/location/LocationAPI.cpp +++ b/location/LocationAPI.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2017-2019 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 @@ -121,7 +121,6 @@ void LocationAPI::onRemoveClientCompleteCb (LocationAdapterTypeMask adapterType) if ((true == invokeCallback) && (nullptr != destroyCompleteCb)) { LOC_LOGd("invoke client destroy cb"); (destroyCompleteCb) (); - LOC_LOGd("finish invoke client destroy cb"); delete this; } @@ -143,7 +142,7 @@ void onGeofenceRemoveClientCompleteCb (LocationAPI* client) } LocationAPI* -LocationAPI::createInstance(LocationCallbacks& locationCallbacks) +LocationAPI::createInstance (LocationCallbacks& locationCallbacks) { if (nullptr == locationCallbacks.capabilitiesCb || nullptr == locationCallbacks.responseCb || @@ -234,15 +233,12 @@ LocationAPI::destroy(locationApiDestroyCompleteCallback destroyCompleteCb) pthread_mutex_lock(&gDataMutex); auto it = gData.clientData.find(this); if (it != gData.clientData.end()) { - bool removeFromGnssInf = - (isGnssClient(it->second) && NULL != gData.gnssInterface); - bool removeFromBatchingInf = - (isBatchingClient(it->second) && NULL != gData.batchingInterface); - bool removeFromGeofenceInf = - (isGeofenceClient(it->second) && NULL != gData.geofenceInterface); + bool removeFromGnssInf = (NULL != gData.gnssInterface); + bool removeFromBatchingInf = (NULL != gData.batchingInterface); + bool removeFromGeofenceInf = (NULL != gData.geofenceInterface); bool needToWait = (removeFromGnssInf || removeFromBatchingInf || removeFromGeofenceInf); LOC_LOGe("removeFromGnssInf: %d, removeFromBatchingInf: %d, removeFromGeofenceInf: %d," - "need %d", removeFromGnssInf, removeFromBatchingInf, removeFromGeofenceInf, + "needToWait: %d", removeFromGnssInf, removeFromBatchingInf, removeFromGeofenceInf, needToWait); if ((NULL != destroyCompleteCb) && (true == needToWait)) { @@ -258,7 +254,7 @@ LocationAPI::destroy(locationApiDestroyCompleteCallback destroyCompleteCb) destroyCbData.waitAdapterMask |= (removeFromGeofenceInf ? LOCATION_ADAPTER_GEOFENCE_TYPE_BIT : 0); gData.destroyClientData[this] = destroyCbData; - LOC_LOGe("destroy data stored in the map: 0x%x", destroyCbData.waitAdapterMask); + LOC_LOGi("destroy data stored in the map: 0x%x", destroyCbData.waitAdapterMask); } if (removeFromGnssInf) { 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 |