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

Commit 9c5d3f03 authored by Steven Moreland's avatar Steven Moreland Committed by Gerrit Code Review
Browse files

Merge "libbinder: servicemanagement errors"

parents 8d72a07c a1d7017f
Loading
Loading
Loading
Loading
+23 −7
Original line number Diff line number Diff line
@@ -320,14 +320,18 @@ sp<IBinder> ServiceManagerShim::waitForService(const String16& name16)
    const std::string name = String8(name16).c_str();

    sp<IBinder> out;
    if (!mTheRealServiceManager->getService(name, &out).isOk()) {
    if (Status status = mTheRealServiceManager->getService(name, &out); !status.isOk()) {
        ALOGW("Failed to getService in waitForService for %s: %s", name.c_str(),
              status.toString8().c_str());
        return nullptr;
    }
    if (out != nullptr) return out;

    sp<Waiter> waiter = sp<Waiter>::make();
    if (!mTheRealServiceManager->registerForNotifications(
            name, waiter).isOk()) {
    if (Status status = mTheRealServiceManager->registerForNotifications(name, waiter);
        !status.isOk()) {
        ALOGW("Failed to registerForNotifications in waitForService for %s: %s", name.c_str(),
              status.toString8().c_str());
        return nullptr;
    }
    Defer unregister ([&] {
@@ -360,7 +364,9 @@ sp<IBinder> ServiceManagerShim::waitForService(const String16& name16)
        // - init gets death signal, but doesn't know it needs to restart
        //   the service
        // - we need to request service again to get it to start
        if (!mTheRealServiceManager->getService(name, &out).isOk()) {
        if (Status status = mTheRealServiceManager->getService(name, &out); !status.isOk()) {
            ALOGW("Failed to getService in waitForService on later try for %s: %s", name.c_str(),
                  status.toString8().c_str());
            return nullptr;
        }
        if (out != nullptr) return out;
@@ -369,7 +375,10 @@ sp<IBinder> ServiceManagerShim::waitForService(const String16& name16)

bool ServiceManagerShim::isDeclared(const String16& name) {
    bool declared;
    if (!mTheRealServiceManager->isDeclared(String8(name).c_str(), &declared).isOk()) {
    if (Status status = mTheRealServiceManager->isDeclared(String8(name).c_str(), &declared);
        !status.isOk()) {
        ALOGW("Failed to get isDeclard for %s: %s", String8(name).c_str(),
              status.toString8().c_str());
        return false;
    }
    return declared;
@@ -377,7 +386,11 @@ bool ServiceManagerShim::isDeclared(const String16& name) {

Vector<String16> ServiceManagerShim::getDeclaredInstances(const String16& interface) {
    std::vector<std::string> out;
    if (!mTheRealServiceManager->getDeclaredInstances(String8(interface).c_str(), &out).isOk()) {
    if (Status status =
                mTheRealServiceManager->getDeclaredInstances(String8(interface).c_str(), &out);
        !status.isOk()) {
        ALOGW("Failed to getDeclaredInstances for %s: %s", String8(interface).c_str(),
              status.toString8().c_str());
        return {};
    }

@@ -391,7 +404,10 @@ Vector<String16> ServiceManagerShim::getDeclaredInstances(const String16& interf

std::optional<String16> ServiceManagerShim::updatableViaApex(const String16& name) {
    std::optional<std::string> declared;
    if (!mTheRealServiceManager->updatableViaApex(String8(name).c_str(), &declared).isOk()) {
    if (Status status = mTheRealServiceManager->updatableViaApex(String8(name).c_str(), &declared);
        !status.isOk()) {
        ALOGW("Failed to get updatableViaApex for %s: %s", String8(name).c_str(),
              status.toString8().c_str());
        return std::nullopt;
    }
    return declared ? std::optional<String16>(String16(declared.value().c_str())) : std::nullopt;