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

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

libbinder: checkVintfService

As a convenience API.

Bug: 141828236
Test: using API to recover from vibrator HAL death
Change-Id: I555575dfb15990a9c4350c533fef5bef48da7daf
parent e4d836a4
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -113,6 +113,13 @@ sp<INTERFACE> waitForDeclaredService(const String16& name) {
    return interface_cast<INTERFACE>(sm->waitForService(name));
}

template <typename INTERFACE>
sp<INTERFACE> checkDeclaredService(const String16& name) {
    const sp<IServiceManager> sm = defaultServiceManager();
    if (!sm->isDeclared(name)) return nullptr;
    return interface_cast<INTERFACE>(sm->checkService(name));
}

template<typename INTERFACE>
sp<INTERFACE> waitForVintfService(
        const String16& instance = String16("default")) {
@@ -120,6 +127,13 @@ sp<INTERFACE> waitForVintfService(
        INTERFACE::descriptor + String16("/") + instance);
}

template<typename INTERFACE>
sp<INTERFACE> checkVintfService(
        const String16& instance = String16("default")) {
    return checkDeclaredService<INTERFACE>(
        INTERFACE::descriptor + String16("/") + instance);
}

template<typename INTERFACE>
status_t getService(const String16& name, sp<INTERFACE>* outService)
{