From 997b6b55abd2461aeda54a8f274ed774be812181 Mon Sep 17 00:00:00 2001 From: Baili Feng Date: Mon, 8 May 2017 15:37:22 +0800 Subject: [PATCH] GnssBatching::init handle multiple invoking Release mApi if mApi is not null and return true. Change-Id: I996bd94fca83f93fa47a9dcf282ebf4610071288 CRs-fixed: 2043876 --- android/GnssBatching.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/android/GnssBatching.cpp b/android/GnssBatching.cpp index a78989cd..6ffadc95 100644 --- a/android/GnssBatching.cpp +++ b/android/GnssBatching.cpp @@ -55,8 +55,9 @@ GnssBatching::~GnssBatching() { // Methods from ::android::hardware::gnss::V1_0::IGnssBatching follow. Return GnssBatching::init(const sp& 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);