From 74bc589a226cf790a7d600dbe32a3a5861a5b265 Mon Sep 17 00:00:00 2001 From: Devin Moore Date: Wed, 23 Oct 2024 17:12:19 +0000 Subject: Use ProcessState::selfOrNull in ServiceManager APIs Allow the APIs to be used when ProcessState isn't initialized. This allows the use of these APIs in systems like microdroid where there is no kernel binder driver. Test: atest vm_accessor_test Bug: 358427181 Change-Id: Ie981b0ca4335ddc7a5676d30721c01be1ffdf35e --- libs/binder/BackendUnifiedServiceManager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libs/binder/BackendUnifiedServiceManager.cpp') diff --git a/libs/binder/BackendUnifiedServiceManager.cpp b/libs/binder/BackendUnifiedServiceManager.cpp index f7b9f059a5..dfc084a661 100644 --- a/libs/binder/BackendUnifiedServiceManager.cpp +++ b/libs/binder/BackendUnifiedServiceManager.cpp @@ -105,7 +105,8 @@ static const char* kStaticCachableList[] = { }; bool BinderCacheWithInvalidation::isClientSideCachingEnabled(const std::string& serviceName) { - if (ProcessState::self()->getThreadPoolMaxTotalThreadCount() <= 0) { + sp self = ProcessState::selfOrNull(); + if (!self || self->getThreadPoolMaxTotalThreadCount() <= 0) { ALOGW("Thread Pool max thread count is 0. Cannot cache binder as linkToDeath cannot be " "implemented. serviceName: %s", serviceName.c_str()); -- cgit v1.2.3-59-g8ed1b