GnssBatching::init handle multiple invoking
Release mApi if mApi is not null and return true.
Change-Id: I996bd94fca83f93fa47a9dcf282ebf4610071288
CRs-fixed: 2043876
diff --git a/android/GnssBatching.cpp b/android/GnssBatching.cpp
index a78989c..6ffadc9 100644
--- a/android/GnssBatching.cpp
+++ b/android/GnssBatching.cpp
@@ -55,8 +55,9 @@
// Methods from ::android::hardware::gnss::V1_0::IGnssBatching follow.
Return<bool> GnssBatching::init(const sp<IGnssBatchingCallback>& callback) {
if (mApi != nullptr) {
- LOC_LOGE("%s]: mApi is NOT nullptr", __FUNCTION__);
- return false;
+ LOC_LOGD("%s]: mApi is NOT nullptr, delete it first", __FUNCTION__);
+ delete mApi;
+ mApi = nullptr;
}
mApi = new BatchingAPIClient(callback);