From a3867c739a80d0c8a58dcb00bcae8f98afdc78ef Mon Sep 17 00:00:00 2001 From: Devin Moore Date: Wed, 23 Oct 2024 19:29:49 +0000 Subject: Add listServices/isDeclared/getDeclaredInstances for Accessors We associate specific accessors with instance names, so we can get more information about what is available through the existing service manager APIs. Test: atest binderRpcTest Bug: 358427181 Change-Id: I337430a222b537643351bfc70178ccd1dc06d73b --- libs/binder/IServiceManager.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'libs/binder/IServiceManager.cpp') diff --git a/libs/binder/IServiceManager.cpp b/libs/binder/IServiceManager.cpp index 53435c357b..5c72ed3197 100644 --- a/libs/binder/IServiceManager.cpp +++ b/libs/binder/IServiceManager.cpp @@ -304,6 +304,25 @@ android::binder::Status getInjectedAccessor(const std::string& name, return android::binder::Status::ok(); } +void appendInjectedAccessorServices(std::vector* list) { + LOG_ALWAYS_FATAL_IF(list == nullptr, + "Attempted to get list of services from Accessors with nullptr"); + std::lock_guard lock(gAccessorProvidersMutex); + for (const auto& entry : gAccessorProviders) { + list->insert(list->end(), entry.mProvider->instances().begin(), + entry.mProvider->instances().end()); + } +} + +void forEachInjectedAccessorService(const std::function& f) { + std::lock_guard lock(gAccessorProvidersMutex); + for (const auto& entry : gAccessorProviders) { + for (const auto& instance : entry.mProvider->instances()) { + f(instance); + } + } +} + sp defaultServiceManager() { std::call_once(gSmOnce, []() { -- cgit v1.2.3-59-g8ed1b