GnssBatching::init handle multiple invoking

Release mApi if mApi is not null and return true.

Change-Id: I996bd94fca83f93fa47a9dcf282ebf4610071288
CRs-fixed: 2043876
This commit is contained in:
Baili Feng 2017-05-08 15:37:22 +08:00
parent 10ab9ccaaf
commit 997b6b55ab

View file

@ -55,8 +55,9 @@ GnssBatching::~GnssBatching() {
// 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);