From 9f7448e7644b2d420814743d979c406458a5842a Mon Sep 17 00:00:00 2001 From: Rajeswari N Date: Wed, 19 Aug 2020 15:09:05 +0530 Subject: [PATCH] power: add check for shared pointer Add check for shared pointer Change-Id: I984988e49b3e59f3a674fb6dbfc8c19d3adb6d74 --- main.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index 8389368..5909b71 100644 --- a/main.cpp +++ b/main.cpp @@ -40,10 +40,12 @@ int main() { std::shared_ptr vib = ndk::SharedRefBase::make(); const std::string instance = std::string() + Power::descriptor + "/default"; LOG(INFO) << "Instance " << instance; - binder_status_t status = AServiceManager_addService(vib->asBinder().get(), instance.c_str()); - LOG(INFO) << "Status " << status; - if(status != STATUS_OK){ - LOG(ERROR) << "Could not register" << instance; + if(vib){ + binder_status_t status = AServiceManager_addService(vib->asBinder().get(), instance.c_str()); + LOG(INFO) << "Status " << status; + if(status != STATUS_OK){ + LOG(ERROR) << "Could not register" << instance; + } } ABinderProcess_joinThreadPool();