diff options
author | Saurabh Srivastava <quic_ssrivast@quicinc.com> | 2022-02-21 17:11:24 +0530 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2022-03-27 20:56:28 -0700 |
commit | b47ca8f9876d1ae5cb8954077691303b7a80bb58 (patch) | |
tree | fbf3faa33274622794aacd1a6898cd79161ea89a | |
parent | 39dfeb6a76b3f06b7324c1071e3341b1cd016a15 (diff) |
Removing measurement callback on close request
CRs-Fixed: 3130205
Change-Id: I8ddcfa9a6df91845aecee3b5f1e0a3f4a3f634ad
-rw-r--r-- | android/1.0/location_api/MeasurementAPIClient.cpp | 41 | ||||
-rw-r--r-- | android/1.1/location_api/MeasurementAPIClient.cpp | 41 | ||||
-rw-r--r-- | android/2.0/location_api/MeasurementAPIClient.cpp | 41 | ||||
-rw-r--r-- | android/2.1/location_api/MeasurementAPIClient.cpp | 41 | ||||
-rw-r--r-- | android/aidl-impl/GnssMeasurementInterface.cpp | 41 | ||||
-rw-r--r-- | gnss/XtraSystemStatusObserver.cpp | 36 | ||||
-rw-r--r-- | location/LocationAPI.cpp | 12 |
7 files changed, 253 insertions, 0 deletions
diff --git a/android/1.0/location_api/MeasurementAPIClient.cpp b/android/1.0/location_api/MeasurementAPIClient.cpp index 9b23308..4bf455d 100644 --- a/android/1.0/location_api/MeasurementAPIClient.cpp +++ b/android/1.0/location_api/MeasurementAPIClient.cpp @@ -27,6 +27,41 @@ * */ +/* +Changes from Qualcomm Innovation Center are provided under the following license: + +Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted (subject to the limitations in the +disclaimer below) 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 Qualcomm Innovation Center, Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE +GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT +HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. +*/ #define LOG_NDEBUG 0 #define LOG_TAG "LocSvc_MeasurementAPIClient" @@ -119,6 +154,12 @@ void MeasurementAPIClient::measurementClose() { LOC_LOGD("%s]: ()", __FUNCTION__); mTracking = false; locAPIStopTracking(); + + // Clear measurement callback + LocationCallbacks locationCallbacks; + memset(&locationCallbacks, 0, sizeof(LocationCallbacks)); + locationCallbacks.size = sizeof(LocationCallbacks); + locAPISetCallbacks(locationCallbacks); } // callbacks diff --git a/android/1.1/location_api/MeasurementAPIClient.cpp b/android/1.1/location_api/MeasurementAPIClient.cpp index a87ae6d..3f3bb2a 100644 --- a/android/1.1/location_api/MeasurementAPIClient.cpp +++ b/android/1.1/location_api/MeasurementAPIClient.cpp @@ -27,6 +27,41 @@ * */ +/* +Changes from Qualcomm Innovation Center are provided under the following license: + +Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted (subject to the limitations in the +disclaimer below) 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 Qualcomm Innovation Center, Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE +GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT +HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. +*/ #define LOG_NDEBUG 0 #define LOG_TAG "LocSvc_MeasurementAPIClient" @@ -142,6 +177,12 @@ void MeasurementAPIClient::measurementClose() { LOC_LOGD("%s]: ()", __FUNCTION__); mTracking = false; locAPIStopTracking(); + + // Clear measurement callback + LocationCallbacks locationCallbacks; + memset(&locationCallbacks, 0, sizeof(LocationCallbacks)); + locationCallbacks.size = sizeof(LocationCallbacks); + locAPISetCallbacks(locationCallbacks); } // callbacks diff --git a/android/2.0/location_api/MeasurementAPIClient.cpp b/android/2.0/location_api/MeasurementAPIClient.cpp index 425415f..bb19269 100644 --- a/android/2.0/location_api/MeasurementAPIClient.cpp +++ b/android/2.0/location_api/MeasurementAPIClient.cpp @@ -27,6 +27,41 @@ * */ +/* +Changes from Qualcomm Innovation Center are provided under the following license: + +Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted (subject to the limitations in the +disclaimer below) 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 Qualcomm Innovation Center, Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE +GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT +HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. +*/ #define LOG_NDEBUG 0 #define LOG_TAG "LocSvc_MeasurementAPIClient" @@ -178,6 +213,12 @@ void MeasurementAPIClient::measurementClose() { LOC_LOGD("%s]: ()", __FUNCTION__); mTracking = false; locAPIStopTracking(); + + // Clear measurement callback + LocationCallbacks locationCallbacks; + memset(&locationCallbacks, 0, sizeof(LocationCallbacks)); + locationCallbacks.size = sizeof(LocationCallbacks); + locAPISetCallbacks(locationCallbacks); } // callbacks diff --git a/android/2.1/location_api/MeasurementAPIClient.cpp b/android/2.1/location_api/MeasurementAPIClient.cpp index e16858d..53ab056 100644 --- a/android/2.1/location_api/MeasurementAPIClient.cpp +++ b/android/2.1/location_api/MeasurementAPIClient.cpp @@ -27,6 +27,41 @@ * */ +/* +Changes from Qualcomm Innovation Center are provided under the following license: + +Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted (subject to the limitations in the +disclaimer below) 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 Qualcomm Innovation Center, Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE +GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT +HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. +*/ #define LOG_NDEBUG 0 #define LOG_TAG "LocSvc_MeasurementAPIClient" @@ -205,6 +240,12 @@ void MeasurementAPIClient::measurementClose() { LOC_LOGD("%s]: ()", __FUNCTION__); mTracking = false; locAPIStopTracking(); + + // Clear measurement callback + LocationCallbacks locationCallbacks; + memset(&locationCallbacks, 0, sizeof(LocationCallbacks)); + locationCallbacks.size = sizeof(LocationCallbacks); + locAPISetCallbacks(locationCallbacks); } // callbacks diff --git a/android/aidl-impl/GnssMeasurementInterface.cpp b/android/aidl-impl/GnssMeasurementInterface.cpp index c3379b8..9fe86a1 100644 --- a/android/aidl-impl/GnssMeasurementInterface.cpp +++ b/android/aidl-impl/GnssMeasurementInterface.cpp @@ -18,6 +18,41 @@ * limitations under the License. */ +/* +Changes from Qualcomm Innovation Center are provided under the following license: + +Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted (subject to the limitations in the +disclaimer below) 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 Qualcomm Innovation Center, Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE +GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT +HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. +*/ #define LOG_TAG "GnssMeasurementInterfaceAidl" #include <log_util.h> @@ -80,6 +115,12 @@ GnssMeasurementInterface::GnssMeasurementInterface() : lock.unlock(); locAPIStopTracking(); + // Clear measurement callback + LocationCallbacks locationCallbacks; + memset(&locationCallbacks, 0, sizeof(LocationCallbacks)); + locationCallbacks.size = sizeof(LocationCallbacks); + locAPISetCallbacks(locationCallbacks); + return ndk::ScopedAStatus::ok(); } diff --git a/gnss/XtraSystemStatusObserver.cpp b/gnss/XtraSystemStatusObserver.cpp index 78fa231..19676cf 100644 --- a/gnss/XtraSystemStatusObserver.cpp +++ b/gnss/XtraSystemStatusObserver.cpp @@ -26,6 +26,42 @@ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ + +/* +Changes from Qualcomm Innovation Center are provided under the following license: + +Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted (subject to the limitations in the +disclaimer below) 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 Qualcomm Innovation Center, Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE +GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT +HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. +*/ #define LOG_TAG "LocSvc_XtraSystemStatusObs" #include <sys/stat.h> diff --git a/location/LocationAPI.cpp b/location/LocationAPI.cpp index ca51182..95c4c31 100644 --- a/location/LocationAPI.cpp +++ b/location/LocationAPI.cpp @@ -360,12 +360,20 @@ LocationAPI::updateCallbacks(LocationCallbacks& locationCallbacks) pthread_mutex_lock(&gDataMutex); + LocationCallbacks currentCallbacks = {}; + auto it = gData.clientData.find(this); + if (it != gData.clientData.end()) { + currentCallbacks = gData.clientData[this]; + } + if (isGnssClient(locationCallbacks)) { loadLibGnss(); if (NULL != gData.gnssInterface) { // either adds new Client or updates existing Client gData.gnssInterface->addClient(this, locationCallbacks); } + } else if (NULL != gData.gnssInterface && isGnssClient(currentCallbacks)) { + gData.gnssInterface->removeClient(this, nullptr); } if (isBatchingClient(locationCallbacks)) { @@ -374,6 +382,8 @@ LocationAPI::updateCallbacks(LocationCallbacks& locationCallbacks) // either adds new Client or updates existing Client gData.batchingInterface->addClient(this, locationCallbacks); } + } else if (NULL != gData.batchingInterface && isBatchingClient(currentCallbacks)) { + gData.batchingInterface->removeClient(this, nullptr); } if (isGeofenceClient(locationCallbacks)) { @@ -382,6 +392,8 @@ LocationAPI::updateCallbacks(LocationCallbacks& locationCallbacks) // either adds new Client or updates existing Client gData.geofenceInterface->addClient(this, locationCallbacks); } + } else if (NULL != gData.geofenceInterface && isGeofenceClient(currentCallbacks)) { + gData.geofenceInterface->removeClient(this, nullptr); } gData.clientData[this] = locationCallbacks; |