blob: 34d5a099480d77c6e06c55c7d9bce445f7b31657 [file] [log] [blame]
Parth Sane56a04712024-04-22 14:21:07 +00001/*
2 * Copyright (C) 2024 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#include "BackendUnifiedServiceManager.h"
17
Alice Wang8578f132024-05-03 09:01:56 +000018#include <android/os/IAccessor.h>
Parth Sane5e1b7e12024-11-29 10:40:41 +000019#include <android/os/IServiceManager.h>
Alice Wang8578f132024-05-03 09:01:56 +000020#include <binder/RpcSession.h>
21
Tomasz Wasilczykfe25f122024-06-26 12:45:57 -070022#if defined(__BIONIC__) && !defined(__ANDROID_VNDK__)
23#include <android-base/properties.h>
24#endif
25
Parth Sane56a04712024-04-22 14:21:07 +000026namespace android {
27
Parth Saneb6ed0eb2024-06-25 14:38:42 +000028#ifdef LIBBINDER_CLIENT_CACHE
29constexpr bool kUseCache = true;
30#else
31constexpr bool kUseCache = false;
32#endif
33
Parth Sanedc207542024-11-14 11:49:08 +000034#ifdef LIBBINDER_ADDSERVICE_CACHE
35constexpr bool kUseCacheInAddService = true;
36#else
37constexpr bool kUseCacheInAddService = false;
38#endif
39
Parth Sane5e1b7e12024-11-29 10:40:41 +000040#ifdef LIBBINDER_REMOVE_CACHE_STATIC_LIST
41constexpr bool kRemoveStaticList = true;
42#else
43constexpr bool kRemoveStaticList = false;
44#endif
45
Parth Sane56a04712024-04-22 14:21:07 +000046using AidlServiceManager = android::os::IServiceManager;
Devin Moore678984f2024-10-18 22:43:22 +000047using android::os::IAccessor;
48using binder::Status;
Parth Sane56a04712024-04-22 14:21:07 +000049
Parth Saneb6ed0eb2024-06-25 14:38:42 +000050static const char* kStaticCachableList[] = {
Parth Saneac492702024-09-18 15:54:16 +000051 // go/keep-sorted start
52 "accessibility",
53 "account",
Parth Saneb6ed0eb2024-06-25 14:38:42 +000054 "activity",
Parth Saneac492702024-09-18 15:54:16 +000055 "alarm",
Parth Sane0105ea52024-10-11 11:41:16 +000056 "android.frameworks.stats.IStats/default",
Parth Saneac492702024-09-18 15:54:16 +000057 "android.system.keystore2.IKeystoreService/default",
Parth Saneb6ed0eb2024-06-25 14:38:42 +000058 "appops",
59 "audio",
Parth Sane0105ea52024-10-11 11:41:16 +000060 "autofill",
61 "batteryproperties",
Parth Saneb6ed0eb2024-06-25 14:38:42 +000062 "batterystats",
Parth Sane0105ea52024-10-11 11:41:16 +000063 "biometic",
Parth Saneb6ed0eb2024-06-25 14:38:42 +000064 "carrier_config",
65 "connectivity",
Parth Saneac492702024-09-18 15:54:16 +000066 "content",
Parth Saneb6ed0eb2024-06-25 14:38:42 +000067 "content_capture",
68 "device_policy",
69 "display",
70 "dropbox",
71 "econtroller",
Parth Saneac492702024-09-18 15:54:16 +000072 "graphicsstats",
73 "input",
74 "input_method",
Parth Saneb6ed0eb2024-06-25 14:38:42 +000075 "isub",
Parth Saneac492702024-09-18 15:54:16 +000076 "jobscheduler",
Parth Saneb6ed0eb2024-06-25 14:38:42 +000077 "legacy_permission",
78 "location",
Parth Sane0105ea52024-10-11 11:41:16 +000079 "lock_settings",
Parth Saneb6ed0eb2024-06-25 14:38:42 +000080 "media.extractor",
81 "media.metrics",
82 "media.player",
83 "media.resource_manager",
Parth Saneac492702024-09-18 15:54:16 +000084 "media_resource_monitor",
85 "mount",
Parth Saneb6ed0eb2024-06-25 14:38:42 +000086 "netd_listener",
87 "netstats",
88 "network_management",
89 "nfc",
Parth Saneac492702024-09-18 15:54:16 +000090 "notification",
91 "package",
Parth Saneb6ed0eb2024-06-25 14:38:42 +000092 "package_native",
93 "performance_hint",
94 "permission",
Parth Saneb6ed0eb2024-06-25 14:38:42 +000095 "permission_checker",
Parth Saneac492702024-09-18 15:54:16 +000096 "permissionmgr",
Parth Saneb6ed0eb2024-06-25 14:38:42 +000097 "phone",
98 "platform_compat",
99 "power",
Parth Sane0105ea52024-10-11 11:41:16 +0000100 "processinfo",
Parth Saneb6ed0eb2024-06-25 14:38:42 +0000101 "role",
Parth Sane0105ea52024-10-11 11:41:16 +0000102 "sensitive_content_protection_service",
Parth Saneb6ed0eb2024-06-25 14:38:42 +0000103 "sensorservice",
104 "statscompanion",
105 "telephony.registry",
106 "thermalservice",
107 "time_detector",
Parth Sane0105ea52024-10-11 11:41:16 +0000108 "tracing.proxy",
Parth Saneb6ed0eb2024-06-25 14:38:42 +0000109 "trust",
110 "uimode",
Parth Saneac492702024-09-18 15:54:16 +0000111 "user",
Parth Sane0105ea52024-10-11 11:41:16 +0000112 "vibrator",
Parth Saneb6ed0eb2024-06-25 14:38:42 +0000113 "virtualdevice",
114 "virtualdevice_native",
115 "webviewupdate",
Parth Saneac492702024-09-18 15:54:16 +0000116 "window",
117 // go/keep-sorted end
Parth Saneb6ed0eb2024-06-25 14:38:42 +0000118};
119
Parth Sane5e1b7e12024-11-29 10:40:41 +0000120os::ServiceWithMetadata createServiceWithMetadata(const sp<IBinder>& service, bool isLazyService) {
121 os::ServiceWithMetadata out = os::ServiceWithMetadata();
122 out.service = service;
123 out.isLazyService = isLazyService;
124 return out;
125}
126
Parth Saneb6ed0eb2024-06-25 14:38:42 +0000127bool BinderCacheWithInvalidation::isClientSideCachingEnabled(const std::string& serviceName) {
Devin Moore74bc5892024-10-23 17:12:19 +0000128 sp<ProcessState> self = ProcessState::selfOrNull();
129 if (!self || self->getThreadPoolMaxTotalThreadCount() <= 0) {
Parth Saneb6ed0eb2024-06-25 14:38:42 +0000130 ALOGW("Thread Pool max thread count is 0. Cannot cache binder as linkToDeath cannot be "
131 "implemented. serviceName: %s",
132 serviceName.c_str());
133 return false;
134 }
Parth Saneb109db32024-12-05 19:43:40 +0000135 if (kRemoveStaticList) return true;
Parth Saneb6ed0eb2024-06-25 14:38:42 +0000136 for (const char* name : kStaticCachableList) {
137 if (name == serviceName) {
138 return true;
139 }
140 }
141 return false;
142}
143
Devin Moore678984f2024-10-18 22:43:22 +0000144Status BackendUnifiedServiceManager::updateCache(const std::string& serviceName,
145 const os::Service& service) {
Parth Saneb6ed0eb2024-06-25 14:38:42 +0000146 if (!kUseCache) {
Devin Moore678984f2024-10-18 22:43:22 +0000147 return Status::ok();
Parth Saneb6ed0eb2024-06-25 14:38:42 +0000148 }
Parth Sanedc207542024-11-14 11:49:08 +0000149
Parth Sane5e1b7e12024-11-29 10:40:41 +0000150 if (service.getTag() == os::Service::Tag::serviceWithMetadata) {
151 auto serviceWithMetadata = service.get<os::Service::Tag::serviceWithMetadata>();
152 return updateCache(serviceName, serviceWithMetadata.service,
153 serviceWithMetadata.isLazyService);
Parth Sanedc207542024-11-14 11:49:08 +0000154 }
155 return Status::ok();
156}
157
158Status BackendUnifiedServiceManager::updateCache(const std::string& serviceName,
Parth Sane5e1b7e12024-11-29 10:40:41 +0000159 const sp<IBinder>& binder, bool isServiceLazy) {
Parth Sanea6676ba2024-10-04 14:14:07 +0000160 std::string traceStr;
Parth Sane5e1b7e12024-11-29 10:40:41 +0000161 // Don't cache if service is lazy
162 if (kRemoveStaticList && isServiceLazy) {
163 return Status::ok();
164 }
Parth Sanea6676ba2024-10-04 14:14:07 +0000165 if (atrace_is_tag_enabled(ATRACE_TAG_AIDL)) {
166 traceStr = "BinderCacheWithInvalidation::updateCache : " + serviceName;
167 }
168 binder::ScopedTrace aidlTrace(ATRACE_TAG_AIDL, traceStr.c_str());
Parth Sanedc207542024-11-14 11:49:08 +0000169 if (!binder) {
170 binder::ScopedTrace
171 aidlTrace(ATRACE_TAG_AIDL,
172 "BinderCacheWithInvalidation::updateCache failed: binder_null");
173 } else if (!binder->isBinderAlive()) {
174 binder::ScopedTrace aidlTrace(ATRACE_TAG_AIDL,
175 "BinderCacheWithInvalidation::updateCache failed: "
176 "isBinderAlive_false");
Parth Sane5e1b7e12024-11-29 10:40:41 +0000177 }
178 // If we reach here with kRemoveStaticList=true then we know service isn't lazy
Parth Saneb109db32024-12-05 19:43:40 +0000179 else if (mCacheForGetService->isClientSideCachingEnabled(serviceName)) {
Parth Sanedc207542024-11-14 11:49:08 +0000180 binder::ScopedTrace aidlTrace(ATRACE_TAG_AIDL,
181 "BinderCacheWithInvalidation::updateCache successful");
182 return mCacheForGetService->setItem(serviceName, binder);
183 } else {
184 binder::ScopedTrace aidlTrace(ATRACE_TAG_AIDL,
185 "BinderCacheWithInvalidation::updateCache failed: "
186 "caching_not_enabled");
Parth Saneb6ed0eb2024-06-25 14:38:42 +0000187 }
Devin Moore678984f2024-10-18 22:43:22 +0000188 return Status::ok();
Parth Saneb6ed0eb2024-06-25 14:38:42 +0000189}
190
191bool BackendUnifiedServiceManager::returnIfCached(const std::string& serviceName,
192 os::Service* _out) {
193 if (!kUseCache) {
194 return false;
195 }
196 sp<IBinder> item = mCacheForGetService->getItem(serviceName);
197 // TODO(b/363177618): Enable caching for binders which are always null.
198 if (item != nullptr && item->isBinderAlive()) {
Parth Sane5e1b7e12024-11-29 10:40:41 +0000199 *_out = createServiceWithMetadata(item, false);
Parth Saneb6ed0eb2024-06-25 14:38:42 +0000200 return true;
201 }
202 return false;
203}
204
Parth Sane56a04712024-04-22 14:21:07 +0000205BackendUnifiedServiceManager::BackendUnifiedServiceManager(const sp<AidlServiceManager>& impl)
Parth Saneb6ed0eb2024-06-25 14:38:42 +0000206 : mTheRealServiceManager(impl) {
207 mCacheForGetService = std::make_shared<BinderCacheWithInvalidation>();
208}
Parth Sane56a04712024-04-22 14:21:07 +0000209
Devin Moore678984f2024-10-18 22:43:22 +0000210Status BackendUnifiedServiceManager::getService(const ::std::string& name,
211 sp<IBinder>* _aidl_return) {
Alice Wang8578f132024-05-03 09:01:56 +0000212 os::Service service;
Devin Moore678984f2024-10-18 22:43:22 +0000213 Status status = getService2(name, &service);
Parth Sane5e1b7e12024-11-29 10:40:41 +0000214 *_aidl_return = service.get<os::Service::Tag::serviceWithMetadata>().service;
Alice Wang11da1502024-07-25 12:03:22 +0000215 return status;
216}
217
Devin Moore678984f2024-10-18 22:43:22 +0000218Status BackendUnifiedServiceManager::getService2(const ::std::string& name, os::Service* _out) {
Parth Saneb6ed0eb2024-06-25 14:38:42 +0000219 if (returnIfCached(name, _out)) {
Devin Moore678984f2024-10-18 22:43:22 +0000220 return Status::ok();
Parth Saneb6ed0eb2024-06-25 14:38:42 +0000221 }
Alice Wang11da1502024-07-25 12:03:22 +0000222 os::Service service;
Devin Moore678984f2024-10-18 22:43:22 +0000223 Status status = mTheRealServiceManager->getService2(name, &service);
Parth Saneb6ed0eb2024-06-25 14:38:42 +0000224
Devin Moore18f63752024-08-08 21:01:24 +0000225 if (status.isOk()) {
Parth Saneb6ed0eb2024-06-25 14:38:42 +0000226 status = toBinderService(name, service, _out);
227 if (status.isOk()) {
228 return updateCache(name, service);
229 }
Devin Moore18f63752024-08-08 21:01:24 +0000230 }
Alice Wang8578f132024-05-03 09:01:56 +0000231 return status;
Parth Sane56a04712024-04-22 14:21:07 +0000232}
Alice Wang8578f132024-05-03 09:01:56 +0000233
Devin Moore678984f2024-10-18 22:43:22 +0000234Status BackendUnifiedServiceManager::checkService(const ::std::string& name, os::Service* _out) {
Alice Wang8578f132024-05-03 09:01:56 +0000235 os::Service service;
Parth Saneb6ed0eb2024-06-25 14:38:42 +0000236 if (returnIfCached(name, _out)) {
Devin Moore678984f2024-10-18 22:43:22 +0000237 return Status::ok();
Parth Saneb6ed0eb2024-06-25 14:38:42 +0000238 }
239
Devin Moore678984f2024-10-18 22:43:22 +0000240 Status status = mTheRealServiceManager->checkService(name, &service);
Devin Moore18f63752024-08-08 21:01:24 +0000241 if (status.isOk()) {
Parth Saneb6ed0eb2024-06-25 14:38:42 +0000242 status = toBinderService(name, service, _out);
243 if (status.isOk()) {
244 return updateCache(name, service);
245 }
Devin Moore18f63752024-08-08 21:01:24 +0000246 }
Alice Wang8578f132024-05-03 09:01:56 +0000247 return status;
Parth Sane56a04712024-04-22 14:21:07 +0000248}
Alice Wang8578f132024-05-03 09:01:56 +0000249
Devin Moore678984f2024-10-18 22:43:22 +0000250Status BackendUnifiedServiceManager::toBinderService(const ::std::string& name,
251 const os::Service& in, os::Service* _out) {
Alice Wang8578f132024-05-03 09:01:56 +0000252 switch (in.getTag()) {
Parth Sane5e1b7e12024-11-29 10:40:41 +0000253 case os::Service::Tag::serviceWithMetadata: {
254 auto serviceWithMetadata = in.get<os::Service::Tag::serviceWithMetadata>();
255 if (serviceWithMetadata.service == nullptr) {
Devin Moore18f63752024-08-08 21:01:24 +0000256 // failed to find a service. Check to see if we have any local
257 // injected Accessors for this service.
258 os::Service accessor;
Devin Moore678984f2024-10-18 22:43:22 +0000259 Status status = getInjectedAccessor(name, &accessor);
Devin Moore18f63752024-08-08 21:01:24 +0000260 if (!status.isOk()) {
Parth Sane5e1b7e12024-11-29 10:40:41 +0000261 *_out = os::Service::make<os::Service::Tag::serviceWithMetadata>(
262 createServiceWithMetadata(nullptr, false));
Devin Moore18f63752024-08-08 21:01:24 +0000263 return status;
264 }
265 if (accessor.getTag() == os::Service::Tag::accessor &&
266 accessor.get<os::Service::Tag::accessor>() != nullptr) {
267 ALOGI("Found local injected service for %s, will attempt to create connection",
268 name.c_str());
269 // Call this again using the accessor Service to get the real
270 // service's binder into _out
271 return toBinderService(name, accessor, _out);
272 }
273 }
274
Alice Wang8578f132024-05-03 09:01:56 +0000275 *_out = in;
Devin Moore678984f2024-10-18 22:43:22 +0000276 return Status::ok();
Alice Wang8578f132024-05-03 09:01:56 +0000277 }
278 case os::Service::Tag::accessor: {
279 sp<IBinder> accessorBinder = in.get<os::Service::Tag::accessor>();
280 sp<IAccessor> accessor = interface_cast<IAccessor>(accessorBinder);
281 if (accessor == nullptr) {
282 ALOGE("Service#accessor doesn't have accessor. VM is maybe starting...");
Parth Sane5e1b7e12024-11-29 10:40:41 +0000283 *_out = os::Service::make<os::Service::Tag::serviceWithMetadata>(
284 createServiceWithMetadata(nullptr, false));
Devin Moore678984f2024-10-18 22:43:22 +0000285 return Status::ok();
Alice Wang8578f132024-05-03 09:01:56 +0000286 }
287 auto request = [=] {
288 os::ParcelFileDescriptor fd;
Devin Moore678984f2024-10-18 22:43:22 +0000289 Status ret = accessor->addConnection(&fd);
Alice Wang8578f132024-05-03 09:01:56 +0000290 if (ret.isOk()) {
291 return base::unique_fd(fd.release());
292 } else {
293 ALOGE("Failed to connect to RpcSession: %s", ret.toString8().c_str());
294 return base::unique_fd(-1);
295 }
296 };
297 auto session = RpcSession::make();
Devin Moore18f63752024-08-08 21:01:24 +0000298 status_t status = session->setupPreconnectedClient(base::unique_fd{}, request);
299 if (status != OK) {
300 ALOGE("Failed to set up preconnected binder RPC client: %s",
301 statusToString(status).c_str());
Devin Moore678984f2024-10-18 22:43:22 +0000302 return Status::fromStatusT(status);
Devin Moore18f63752024-08-08 21:01:24 +0000303 }
Alice Wang8578f132024-05-03 09:01:56 +0000304 session->setSessionSpecificRoot(accessorBinder);
Parth Sane5e1b7e12024-11-29 10:40:41 +0000305 *_out = os::Service::make<os::Service::Tag::serviceWithMetadata>(
306 createServiceWithMetadata(session->getRootObject(), false));
Devin Moore678984f2024-10-18 22:43:22 +0000307 return Status::ok();
Alice Wang8578f132024-05-03 09:01:56 +0000308 }
309 default: {
310 LOG_ALWAYS_FATAL("Unknown service type: %d", in.getTag());
311 }
312 }
313}
314
Devin Moore678984f2024-10-18 22:43:22 +0000315Status BackendUnifiedServiceManager::addService(const ::std::string& name,
316 const sp<IBinder>& service, bool allowIsolated,
317 int32_t dumpPriority) {
Parth Sanedc207542024-11-14 11:49:08 +0000318 Status status = mTheRealServiceManager->addService(name, service, allowIsolated, dumpPriority);
319 // mEnableAddServiceCache is true by default.
320 if (kUseCacheInAddService && mEnableAddServiceCache && status.isOk()) {
Parth Sane5e1b7e12024-11-29 10:40:41 +0000321 return updateCache(name, service,
322 dumpPriority & android::os::IServiceManager::FLAG_IS_LAZY_SERVICE);
Parth Sanedc207542024-11-14 11:49:08 +0000323 }
324 return status;
Parth Sane56a04712024-04-22 14:21:07 +0000325}
Devin Moore678984f2024-10-18 22:43:22 +0000326Status BackendUnifiedServiceManager::listServices(int32_t dumpPriority,
327 ::std::vector<::std::string>* _aidl_return) {
Parth Sane56a04712024-04-22 14:21:07 +0000328 return mTheRealServiceManager->listServices(dumpPriority, _aidl_return);
329}
Devin Moore678984f2024-10-18 22:43:22 +0000330Status BackendUnifiedServiceManager::registerForNotifications(
Parth Sane56a04712024-04-22 14:21:07 +0000331 const ::std::string& name, const sp<os::IServiceCallback>& callback) {
332 return mTheRealServiceManager->registerForNotifications(name, callback);
333}
Devin Moore678984f2024-10-18 22:43:22 +0000334Status BackendUnifiedServiceManager::unregisterForNotifications(
Parth Sane56a04712024-04-22 14:21:07 +0000335 const ::std::string& name, const sp<os::IServiceCallback>& callback) {
336 return mTheRealServiceManager->unregisterForNotifications(name, callback);
337}
Devin Moore678984f2024-10-18 22:43:22 +0000338Status BackendUnifiedServiceManager::isDeclared(const ::std::string& name, bool* _aidl_return) {
Parth Sane56a04712024-04-22 14:21:07 +0000339 return mTheRealServiceManager->isDeclared(name, _aidl_return);
340}
Devin Moore678984f2024-10-18 22:43:22 +0000341Status BackendUnifiedServiceManager::getDeclaredInstances(
Parth Sane56a04712024-04-22 14:21:07 +0000342 const ::std::string& iface, ::std::vector<::std::string>* _aidl_return) {
343 return mTheRealServiceManager->getDeclaredInstances(iface, _aidl_return);
344}
Devin Moore678984f2024-10-18 22:43:22 +0000345Status BackendUnifiedServiceManager::updatableViaApex(
Parth Sane56a04712024-04-22 14:21:07 +0000346 const ::std::string& name, ::std::optional<::std::string>* _aidl_return) {
347 return mTheRealServiceManager->updatableViaApex(name, _aidl_return);
348}
Devin Moore678984f2024-10-18 22:43:22 +0000349Status BackendUnifiedServiceManager::getUpdatableNames(const ::std::string& apexName,
350 ::std::vector<::std::string>* _aidl_return) {
Parth Sane56a04712024-04-22 14:21:07 +0000351 return mTheRealServiceManager->getUpdatableNames(apexName, _aidl_return);
352}
Devin Moore678984f2024-10-18 22:43:22 +0000353Status BackendUnifiedServiceManager::getConnectionInfo(
Parth Sane56a04712024-04-22 14:21:07 +0000354 const ::std::string& name, ::std::optional<os::ConnectionInfo>* _aidl_return) {
355 return mTheRealServiceManager->getConnectionInfo(name, _aidl_return);
356}
Devin Moore678984f2024-10-18 22:43:22 +0000357Status BackendUnifiedServiceManager::registerClientCallback(
Parth Sane56a04712024-04-22 14:21:07 +0000358 const ::std::string& name, const sp<IBinder>& service,
359 const sp<os::IClientCallback>& callback) {
360 return mTheRealServiceManager->registerClientCallback(name, service, callback);
361}
Devin Moore678984f2024-10-18 22:43:22 +0000362Status BackendUnifiedServiceManager::tryUnregisterService(const ::std::string& name,
363 const sp<IBinder>& service) {
Parth Sane56a04712024-04-22 14:21:07 +0000364 return mTheRealServiceManager->tryUnregisterService(name, service);
365}
Devin Moore678984f2024-10-18 22:43:22 +0000366Status BackendUnifiedServiceManager::getServiceDebugInfo(
Parth Sane56a04712024-04-22 14:21:07 +0000367 ::std::vector<os::ServiceDebugInfo>* _aidl_return) {
368 return mTheRealServiceManager->getServiceDebugInfo(_aidl_return);
369}
370
371[[clang::no_destroy]] static std::once_flag gUSmOnce;
372[[clang::no_destroy]] static sp<BackendUnifiedServiceManager> gUnifiedServiceManager;
373
374sp<BackendUnifiedServiceManager> getBackendUnifiedServiceManager() {
375 std::call_once(gUSmOnce, []() {
376#if defined(__BIONIC__) && !defined(__ANDROID_VNDK__)
377 /* wait for service manager */ {
378 using std::literals::chrono_literals::operator""s;
379 using android::base::WaitForProperty;
380 while (!WaitForProperty("servicemanager.ready", "true", 1s)) {
381 ALOGE("Waited for servicemanager.ready for a second, waiting another...");
382 }
383 }
384#endif
385
386 sp<AidlServiceManager> sm = nullptr;
387 while (sm == nullptr) {
388 sm = interface_cast<AidlServiceManager>(
389 ProcessState::self()->getContextObject(nullptr));
390 if (sm == nullptr) {
391 ALOGE("Waiting 1s on context object on %s.",
392 ProcessState::self()->getDriverName().c_str());
393 sleep(1);
394 }
395 }
396
397 gUnifiedServiceManager = sp<BackendUnifiedServiceManager>::make(sm);
398 });
399
400 return gUnifiedServiceManager;
401}
402
Devin Moore18f63752024-08-08 21:01:24 +0000403} // namespace android