Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 82f3bd31 authored by Kelvin Zhang's avatar Kelvin Zhang Committed by Automerger Merge Worker
Browse files

Check if AIDL service is declared before calling wait am: 781b4ff1 am: c65e1ef8 am: 0e17ea32

parents d742ae14 0e17ea32
Loading
Loading
Loading
Loading
+7 −2
Original line number Original line Diff line number Diff line
@@ -327,9 +327,14 @@ std::unique_ptr<BootControlClient> BootControlClient::WaitForService() {
    const auto instance_name =
    const auto instance_name =
            std::string(::aidl::android::hardware::boot::IBootControl::descriptor) + "/default";
            std::string(::aidl::android::hardware::boot::IBootControl::descriptor) + "/default";


    if (auto module = ::aidl::android::hardware::boot::IBootControl::fromBinder(
    if (AServiceManager_isDeclared(instance_name.c_str())) {
        auto module = ::aidl::android::hardware::boot::IBootControl::fromBinder(
                ndk::SpAIBinder(AServiceManager_waitForService(instance_name.c_str())));
                ndk::SpAIBinder(AServiceManager_waitForService(instance_name.c_str())));
        module != nullptr) {
        if (module == nullptr) {
            LOG(ERROR) << "AIDL " << instance_name
                       << " is declared but waitForService returned nullptr.";
            return nullptr;
        }
        LOG(INFO) << "Using AIDL version of IBootControl";
        LOG(INFO) << "Using AIDL version of IBootControl";
        return std::make_unique<BootControlClientAidl>(module);
        return std::make_unique<BootControlClientAidl>(module);
    }
    }