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

Commit 678984fb authored by Devin Moore's avatar Devin Moore
Browse files

Add `using binder::Status` to BackendUnifiedServiceManager.cpp

It's used so often in the file and `Status` is easier to read.

Test: m
Bug: none
Change-Id: I0b996c5d53332d47deb2bb6c6142d828f9971d3b
parent 23e0a8e4
Loading
Loading
Loading
Loading
+40 −43
Original line number Diff line number Diff line
@@ -31,7 +31,8 @@ constexpr bool kUseCache = false;
#endif

using AidlServiceManager = android::os::IServiceManager;
using IAccessor = android::os::IAccessor;
using android::os::IAccessor;
using binder::Status;

static const char* kStaticCachableList[] = {
        // go/keep-sorted start
@@ -109,10 +110,10 @@ bool BinderCacheWithInvalidation::isClientSideCachingEnabled(const std::string&
    return false;
}

binder::Status BackendUnifiedServiceManager::updateCache(const std::string& serviceName,
Status BackendUnifiedServiceManager::updateCache(const std::string& serviceName,
                                                 const os::Service& service) {
    if (!kUseCache) {
        return binder::Status::ok();
        return Status::ok();
    }
    if (service.getTag() == os::Service::Tag::binder) {
        sp<IBinder> binder = service.get<os::Service::Tag::binder>();
@@ -121,7 +122,7 @@ binder::Status BackendUnifiedServiceManager::updateCache(const std::string& serv
            return mCacheForGetService->setItem(serviceName, binder);
        }
    }
    return binder::Status::ok();
    return Status::ok();
}

bool BackendUnifiedServiceManager::returnIfCached(const std::string& serviceName,
@@ -147,21 +148,20 @@ sp<AidlServiceManager> BackendUnifiedServiceManager::getImpl() {
    return mTheRealServiceManager;
}

binder::Status BackendUnifiedServiceManager::getService(const ::std::string& name,
Status BackendUnifiedServiceManager::getService(const ::std::string& name,
                                                sp<IBinder>* _aidl_return) {
    os::Service service;
    binder::Status status = getService2(name, &service);
    Status status = getService2(name, &service);
    *_aidl_return = service.get<os::Service::Tag::binder>();
    return status;
}

binder::Status BackendUnifiedServiceManager::getService2(const ::std::string& name,
                                                         os::Service* _out) {
Status BackendUnifiedServiceManager::getService2(const ::std::string& name, os::Service* _out) {
    if (returnIfCached(name, _out)) {
        return binder::Status::ok();
        return Status::ok();
    }
    os::Service service;
    binder::Status status = mTheRealServiceManager->getService2(name, &service);
    Status status = mTheRealServiceManager->getService2(name, &service);

    if (status.isOk()) {
        status = toBinderService(name, service, _out);
@@ -172,14 +172,13 @@ binder::Status BackendUnifiedServiceManager::getService2(const ::std::string& na
    return status;
}

binder::Status BackendUnifiedServiceManager::checkService(const ::std::string& name,
                                                          os::Service* _out) {
Status BackendUnifiedServiceManager::checkService(const ::std::string& name, os::Service* _out) {
    os::Service service;
    if (returnIfCached(name, _out)) {
        return binder::Status::ok();
        return Status::ok();
    }

    binder::Status status = mTheRealServiceManager->checkService(name, &service);
    Status status = mTheRealServiceManager->checkService(name, &service);
    if (status.isOk()) {
        status = toBinderService(name, service, _out);
        if (status.isOk()) {
@@ -189,16 +188,15 @@ binder::Status BackendUnifiedServiceManager::checkService(const ::std::string& n
    return status;
}

binder::Status BackendUnifiedServiceManager::toBinderService(const ::std::string& name,
                                                             const os::Service& in,
                                                             os::Service* _out) {
Status BackendUnifiedServiceManager::toBinderService(const ::std::string& name,
                                                     const os::Service& in, os::Service* _out) {
    switch (in.getTag()) {
        case os::Service::Tag::binder: {
            if (in.get<os::Service::Tag::binder>() == nullptr) {
                // failed to find a service. Check to see if we have any local
                // injected Accessors for this service.
                os::Service accessor;
                binder::Status status = getInjectedAccessor(name, &accessor);
                Status status = getInjectedAccessor(name, &accessor);
                if (!status.isOk()) {
                    *_out = os::Service::make<os::Service::Tag::binder>(nullptr);
                    return status;
@@ -214,7 +212,7 @@ binder::Status BackendUnifiedServiceManager::toBinderService(const ::std::string
            }

            *_out = in;
            return binder::Status::ok();
            return Status::ok();
        }
        case os::Service::Tag::accessor: {
            sp<IBinder> accessorBinder = in.get<os::Service::Tag::accessor>();
@@ -222,11 +220,11 @@ binder::Status BackendUnifiedServiceManager::toBinderService(const ::std::string
            if (accessor == nullptr) {
                ALOGE("Service#accessor doesn't have accessor. VM is maybe starting...");
                *_out = os::Service::make<os::Service::Tag::binder>(nullptr);
                return binder::Status::ok();
                return Status::ok();
            }
            auto request = [=] {
                os::ParcelFileDescriptor fd;
                binder::Status ret = accessor->addConnection(&fd);
                Status ret = accessor->addConnection(&fd);
                if (ret.isOk()) {
                    return base::unique_fd(fd.release());
                } else {
@@ -239,11 +237,11 @@ binder::Status BackendUnifiedServiceManager::toBinderService(const ::std::string
            if (status != OK) {
                ALOGE("Failed to set up preconnected binder RPC client: %s",
                      statusToString(status).c_str());
                return binder::Status::fromStatusT(status);
                return Status::fromStatusT(status);
            }
            session->setSessionSpecificRoot(accessorBinder);
            *_out = os::Service::make<os::Service::Tag::binder>(session->getRootObject());
            return binder::Status::ok();
            return Status::ok();
        }
        default: {
            LOG_ALWAYS_FATAL("Unknown service type: %d", in.getTag());
@@ -251,53 +249,52 @@ binder::Status BackendUnifiedServiceManager::toBinderService(const ::std::string
    }
}

binder::Status BackendUnifiedServiceManager::addService(const ::std::string& name,
                                                        const sp<IBinder>& service,
                                                        bool allowIsolated, int32_t dumpPriority) {
Status BackendUnifiedServiceManager::addService(const ::std::string& name,
                                                const sp<IBinder>& service, bool allowIsolated,
                                                int32_t dumpPriority) {
    return mTheRealServiceManager->addService(name, service, allowIsolated, dumpPriority);
}
binder::Status BackendUnifiedServiceManager::listServices(
        int32_t dumpPriority, ::std::vector<::std::string>* _aidl_return) {
Status BackendUnifiedServiceManager::listServices(int32_t dumpPriority,
                                                  ::std::vector<::std::string>* _aidl_return) {
    return mTheRealServiceManager->listServices(dumpPriority, _aidl_return);
}
binder::Status BackendUnifiedServiceManager::registerForNotifications(
Status BackendUnifiedServiceManager::registerForNotifications(
        const ::std::string& name, const sp<os::IServiceCallback>& callback) {
    return mTheRealServiceManager->registerForNotifications(name, callback);
}
binder::Status BackendUnifiedServiceManager::unregisterForNotifications(
Status BackendUnifiedServiceManager::unregisterForNotifications(
        const ::std::string& name, const sp<os::IServiceCallback>& callback) {
    return mTheRealServiceManager->unregisterForNotifications(name, callback);
}
binder::Status BackendUnifiedServiceManager::isDeclared(const ::std::string& name,
                                                        bool* _aidl_return) {
Status BackendUnifiedServiceManager::isDeclared(const ::std::string& name, bool* _aidl_return) {
    return mTheRealServiceManager->isDeclared(name, _aidl_return);
}
binder::Status BackendUnifiedServiceManager::getDeclaredInstances(
Status BackendUnifiedServiceManager::getDeclaredInstances(
        const ::std::string& iface, ::std::vector<::std::string>* _aidl_return) {
    return mTheRealServiceManager->getDeclaredInstances(iface, _aidl_return);
}
binder::Status BackendUnifiedServiceManager::updatableViaApex(
Status BackendUnifiedServiceManager::updatableViaApex(
        const ::std::string& name, ::std::optional<::std::string>* _aidl_return) {
    return mTheRealServiceManager->updatableViaApex(name, _aidl_return);
}
binder::Status BackendUnifiedServiceManager::getUpdatableNames(
        const ::std::string& apexName, ::std::vector<::std::string>* _aidl_return) {
Status BackendUnifiedServiceManager::getUpdatableNames(const ::std::string& apexName,
                                                       ::std::vector<::std::string>* _aidl_return) {
    return mTheRealServiceManager->getUpdatableNames(apexName, _aidl_return);
}
binder::Status BackendUnifiedServiceManager::getConnectionInfo(
Status BackendUnifiedServiceManager::getConnectionInfo(
        const ::std::string& name, ::std::optional<os::ConnectionInfo>* _aidl_return) {
    return mTheRealServiceManager->getConnectionInfo(name, _aidl_return);
}
binder::Status BackendUnifiedServiceManager::registerClientCallback(
Status BackendUnifiedServiceManager::registerClientCallback(
        const ::std::string& name, const sp<IBinder>& service,
        const sp<os::IClientCallback>& callback) {
    return mTheRealServiceManager->registerClientCallback(name, service, callback);
}
binder::Status BackendUnifiedServiceManager::tryUnregisterService(const ::std::string& name,
Status BackendUnifiedServiceManager::tryUnregisterService(const ::std::string& name,
                                                          const sp<IBinder>& service) {
    return mTheRealServiceManager->tryUnregisterService(name, service);
}
binder::Status BackendUnifiedServiceManager::getServiceDebugInfo(
Status BackendUnifiedServiceManager::getServiceDebugInfo(
        ::std::vector<os::ServiceDebugInfo>* _aidl_return) {
    return mTheRealServiceManager->getServiceDebugInfo(_aidl_return);
}