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

Commit ded421f5 authored by Steven Moreland's avatar Steven Moreland
Browse files

HwBinder: register with registerAsServiceInternal

This ties together the Java/C++ logic for service registration.

Bug: 36424585
Test: boot
Change-Id: I1fe8266e7d291e3253af492e9321bd5a24da4cc3
parent 4d9823f3
Loading
Loading
Loading
Loading
+3 −14
Original line number Diff line number Diff line
@@ -269,27 +269,16 @@ static void JHwBinder_native_registerService(
    }

    sp<hardware::IBinder> binder = JHwBinder::GetNativeBinder(env, thiz);

    /* TODO(b/33440494) this is not right */
    sp<hidl::base::V1_0::IBase> base = new hidl::base::V1_0::BpHwBase(binder);

    auto manager = hardware::defaultServiceManager();

    if (manager == nullptr) {
        LOG(ERROR) << "Could not get hwservicemanager.";
        signalExceptionForError(env, UNKNOWN_ERROR, true /* canThrowRemoteException */);
        return;
    }

    Return<bool> ret = manager->add(str.c_str(), base);

    bool ok = ret.isOk() && ret;
    bool ok = hardware::details::registerAsServiceInternal(base, str.c_str()) == OK;

    if (ok) {
        LOG(INFO) << "HwBinder: Starting thread pool for " << str.c_str();
        ::android::hardware::ProcessState::self()->startThreadPool();
    }

    // avoiding richer error exceptions to stick with legacy behavior
    signalExceptionForError(env, (ok ? OK : UNKNOWN_ERROR), true /*canThrowRemoteException*/);
}