From 678984fb42798c54be8b29c3f35852a56536b716 Mon Sep 17 00:00:00 2001 From: Devin Moore Date: Fri, 18 Oct 2024 22:43:22 +0000 Subject: 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 --- libs/binder/BackendUnifiedServiceManager.cpp | 83 ++++++++++++++-------------- 1 file changed, 40 insertions(+), 43 deletions(-) (limited to 'libs/binder/BackendUnifiedServiceManager.cpp') diff --git a/libs/binder/BackendUnifiedServiceManager.cpp b/libs/binder/BackendUnifiedServiceManager.cpp index 52b485a6f6..04de39abe1 100644 --- a/libs/binder/BackendUnifiedServiceManager.cpp +++ b/libs/binder/BackendUnifiedServiceManager.cpp @@ -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, - const os::Service& service) { +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 binder = service.get(); @@ -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 BackendUnifiedServiceManager::getImpl() { return mTheRealServiceManager; } -binder::Status BackendUnifiedServiceManager::getService(const ::std::string& name, - sp* _aidl_return) { +Status BackendUnifiedServiceManager::getService(const ::std::string& name, + sp* _aidl_return) { os::Service service; - binder::Status status = getService2(name, &service); + Status status = getService2(name, &service); *_aidl_return = service.get(); 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() == 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(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 accessorBinder = in.get(); @@ -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(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(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& service, - bool allowIsolated, int32_t dumpPriority) { +Status BackendUnifiedServiceManager::addService(const ::std::string& name, + const sp& 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& callback) { return mTheRealServiceManager->registerForNotifications(name, callback); } -binder::Status BackendUnifiedServiceManager::unregisterForNotifications( +Status BackendUnifiedServiceManager::unregisterForNotifications( const ::std::string& name, const sp& 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* _aidl_return) { return mTheRealServiceManager->getConnectionInfo(name, _aidl_return); } -binder::Status BackendUnifiedServiceManager::registerClientCallback( +Status BackendUnifiedServiceManager::registerClientCallback( const ::std::string& name, const sp& service, const sp& callback) { return mTheRealServiceManager->registerClientCallback(name, service, callback); } -binder::Status BackendUnifiedServiceManager::tryUnregisterService(const ::std::string& name, - const sp& service) { +Status BackendUnifiedServiceManager::tryUnregisterService(const ::std::string& name, + const sp& service) { return mTheRealServiceManager->tryUnregisterService(name, service); } -binder::Status BackendUnifiedServiceManager::getServiceDebugInfo( +Status BackendUnifiedServiceManager::getServiceDebugInfo( ::std::vector* _aidl_return) { return mTheRealServiceManager->getServiceDebugInfo(_aidl_return); } -- cgit v1.2.3-59-g8ed1b