@@ -79,10 +79,9 @@ IServiceManager::IServiceManager() {}
7979IServiceManager::~IServiceManager () {}
8080
8181// From the old libbinder IServiceManager interface to IServiceManager.
82- class ServiceManagerShim : public IServiceManager
83- {
82+ class CppBackendShim : public IServiceManager {
8483public:
85- explicit ServiceManagerShim (const sp<AidlServiceManager >& impl);
84+ explicit CppBackendShim (const sp<BackendUnifiedServiceManager >& impl);
8685
8786 sp<IBinder> getService (const String16& name) const override ;
8887 sp<IBinder> checkService (const String16& name) const override ;
@@ -136,11 +135,11 @@ class ServiceManagerShim : public IServiceManager
136135 sp<RegistrationWaiter>* waiter);
137136
138137 // Directly get the service in a way that, for lazy services, requests the service to be started
139- // if it is not currently started. This way, calls directly to ServiceManagerShim ::getService
138+ // if it is not currently started. This way, calls directly to CppBackendShim ::getService
140139 // will still have the 5s delay that is expected by a large amount of Android code.
141140 //
142- // When implementing ServiceManagerShim , use realGetService instead of
143- // mUnifiedServiceManager->getService so that it can be overridden in ServiceManagerHostShim .
141+ // When implementing CppBackendShim , use realGetService instead of
142+ // mUnifiedServiceManager->getService so that it can be overridden in CppServiceManagerHostShim .
144143 virtual Status realGetService (const std::string& name, sp<IBinder>* _aidl_return) {
145144 Service service;
146145 Status status = mUnifiedServiceManager ->getService2 (name, &service);
@@ -155,7 +154,7 @@ class ServiceManagerShim : public IServiceManager
155154sp<IServiceManager> defaultServiceManager ()
156155{
157156 std::call_once (gSmOnce , []() {
158- gDefaultServiceManager = sp<ServiceManagerShim >::make (getBackendUnifiedServiceManager ());
157+ gDefaultServiceManager = sp<CppBackendShim >::make (getBackendUnifiedServiceManager ());
159158 });
160159
161160 return gDefaultServiceManager ;
@@ -279,16 +278,14 @@ void* openDeclaredPassthroughHal(const String16& interface, const String16& inst
279278
280279// ----------------------------------------------------------------------
281280
282- ServiceManagerShim::ServiceManagerShim (const sp<AidlServiceManager>& impl) {
283- mUnifiedServiceManager = sp<BackendUnifiedServiceManager>::make (impl);
284- }
281+ CppBackendShim::CppBackendShim (const sp<BackendUnifiedServiceManager>& impl)
282+ : mUnifiedServiceManager (impl) {}
285283
286284// This implementation could be simplified and made more efficient by delegating
287285// to waitForService. However, this changes the threading structure in some
288286// cases and could potentially break prebuilts. Once we have higher logistical
289287// complexity, this could be attempted.
290- sp<IBinder> ServiceManagerShim::getService (const String16& name) const
291- {
288+ sp<IBinder> CppBackendShim::getService (const String16& name) const {
292289 static bool gSystemBootCompleted = false ;
293290
294291 sp<IBinder> svc = checkService (name);
@@ -332,25 +329,22 @@ sp<IBinder> ServiceManagerShim::getService(const String16& name) const
332329 return nullptr ;
333330}
334331
335- sp<IBinder> ServiceManagerShim::checkService (const String16& name) const
336- {
332+ sp<IBinder> CppBackendShim::checkService (const String16& name) const {
337333 Service ret;
338334 if (!mUnifiedServiceManager ->checkService (String8 (name).c_str (), &ret).isOk ()) {
339335 return nullptr ;
340336 }
341337 return ret.get <Service::Tag::binder>();
342338}
343339
344- status_t ServiceManagerShim::addService (const String16& name, const sp<IBinder>& service,
345- bool allowIsolated, int dumpsysPriority)
346- {
340+ status_t CppBackendShim::addService (const String16& name, const sp<IBinder>& service,
341+ bool allowIsolated, int dumpsysPriority) {
347342 Status status = mUnifiedServiceManager ->addService (String8 (name).c_str (), service,
348343 allowIsolated, dumpsysPriority);
349344 return status.exceptionCode ();
350345}
351346
352- Vector<String16> ServiceManagerShim::listServices (int dumpsysPriority)
353- {
347+ Vector<String16> CppBackendShim::listServices (int dumpsysPriority) {
354348 std::vector<std::string> ret;
355349 if (!mUnifiedServiceManager ->listServices (dumpsysPriority, &ret).isOk ()) {
356350 return {};
@@ -364,8 +358,7 @@ Vector<String16> ServiceManagerShim::listServices(int dumpsysPriority)
364358 return res;
365359}
366360
367- sp<IBinder> ServiceManagerShim::waitForService (const String16& name16)
368- {
361+ sp<IBinder> CppBackendShim::waitForService (const String16& name16) {
369362 class Waiter : public android ::os::BnServiceCallback {
370363 Status onRegistration (const std::string& /* name*/ ,
371364 const sp<IBinder>& binder) override {
@@ -454,7 +447,7 @@ sp<IBinder> ServiceManagerShim::waitForService(const String16& name16)
454447 }
455448}
456449
457- bool ServiceManagerShim ::isDeclared (const String16& name) {
450+ bool CppBackendShim ::isDeclared (const String16& name) {
458451 bool declared;
459452 if (Status status = mUnifiedServiceManager ->isDeclared (String8 (name).c_str (), &declared);
460453 !status.isOk ()) {
@@ -465,7 +458,7 @@ bool ServiceManagerShim::isDeclared(const String16& name) {
465458 return declared;
466459}
467460
468- Vector<String16> ServiceManagerShim ::getDeclaredInstances (const String16& interface) {
461+ Vector<String16> CppBackendShim ::getDeclaredInstances (const String16& interface) {
469462 std::vector<std::string> out;
470463 if (Status status =
471464 mUnifiedServiceManager ->getDeclaredInstances (String8 (interface).c_str (), &out);
@@ -483,7 +476,7 @@ Vector<String16> ServiceManagerShim::getDeclaredInstances(const String16& interf
483476 return res;
484477}
485478
486- std::optional<String16> ServiceManagerShim ::updatableViaApex (const String16& name) {
479+ std::optional<String16> CppBackendShim ::updatableViaApex (const String16& name) {
487480 std::optional<std::string> declared;
488481 if (Status status = mUnifiedServiceManager ->updatableViaApex (String8 (name).c_str (), &declared);
489482 !status.isOk ()) {
@@ -494,7 +487,7 @@ std::optional<String16> ServiceManagerShim::updatableViaApex(const String16& nam
494487 return declared ? std::optional<String16>(String16 (declared.value ().c_str ())) : std::nullopt ;
495488}
496489
497- Vector<String16> ServiceManagerShim ::getUpdatableNames (const String16& apexName) {
490+ Vector<String16> CppBackendShim ::getUpdatableNames (const String16& apexName) {
498491 std::vector<std::string> out;
499492 if (Status status = mUnifiedServiceManager ->getUpdatableNames (String8 (apexName).c_str (), &out);
500493 !status.isOk ()) {
@@ -511,7 +504,7 @@ Vector<String16> ServiceManagerShim::getUpdatableNames(const String16& apexName)
511504 return res;
512505}
513506
514- std::optional<IServiceManager::ConnectionInfo> ServiceManagerShim ::getConnectionInfo (
507+ std::optional<IServiceManager::ConnectionInfo> CppBackendShim ::getConnectionInfo (
515508 const String16& name) {
516509 std::optional<os::ConnectionInfo> connectionInfo;
517510 if (Status status =
@@ -526,8 +519,8 @@ std::optional<IServiceManager::ConnectionInfo> ServiceManagerShim::getConnection
526519 : std::nullopt ;
527520}
528521
529- status_t ServiceManagerShim ::registerForNotifications (const String16& name,
530- const sp<AidlRegistrationCallback>& cb) {
522+ status_t CppBackendShim ::registerForNotifications (const String16& name,
523+ const sp<AidlRegistrationCallback>& cb) {
531524 if (cb == nullptr ) {
532525 ALOGE (" %s: null cb passed" , __FUNCTION__);
533526 return BAD_VALUE;
@@ -546,9 +539,9 @@ status_t ServiceManagerShim::registerForNotifications(const String16& name,
546539 return OK;
547540}
548541
549- void ServiceManagerShim ::removeRegistrationCallbackLocked (const sp<AidlRegistrationCallback>& cb,
550- ServiceCallbackMap::iterator* it,
551- sp<RegistrationWaiter>* waiter) {
542+ void CppBackendShim ::removeRegistrationCallbackLocked (const sp<AidlRegistrationCallback>& cb,
543+ ServiceCallbackMap::iterator* it,
544+ sp<RegistrationWaiter>* waiter) {
552545 std::vector<LocalRegistrationAndWaiter>& localRegistrationAndWaiters = (*it)->second ;
553546 for (auto lit = localRegistrationAndWaiters.begin ();
554547 lit != localRegistrationAndWaiters.end ();) {
@@ -567,8 +560,8 @@ void ServiceManagerShim::removeRegistrationCallbackLocked(const sp<AidlRegistrat
567560 }
568561}
569562
570- status_t ServiceManagerShim ::unregisterForNotifications (const String16& name,
571- const sp<AidlRegistrationCallback>& cb) {
563+ status_t CppBackendShim ::unregisterForNotifications (const String16& name,
564+ const sp<AidlRegistrationCallback>& cb) {
572565 if (cb == nullptr ) {
573566 ALOGE (" %s: null cb passed" , __FUNCTION__);
574567 return BAD_VALUE;
@@ -597,7 +590,7 @@ status_t ServiceManagerShim::unregisterForNotifications(const String16& name,
597590 return OK;
598591}
599592
600- std::vector<IServiceManager::ServiceDebugInfo> ServiceManagerShim ::getServiceDebugInfo () {
593+ std::vector<IServiceManager::ServiceDebugInfo> CppBackendShim ::getServiceDebugInfo () {
601594 std::vector<os::ServiceDebugInfo> serviceDebugInfos;
602595 std::vector<IServiceManager::ServiceDebugInfo> ret;
603596 if (Status status = mUnifiedServiceManager ->getServiceDebugInfo (&serviceDebugInfos);
@@ -615,21 +608,21 @@ std::vector<IServiceManager::ServiceDebugInfo> ServiceManagerShim::getServiceDeb
615608}
616609
617610#ifndef __ANDROID__
618- // ServiceManagerShim for host. Implements the old libbinder android::IServiceManager API.
611+ // CppBackendShim for host. Implements the old libbinder android::IServiceManager API.
619612// The internal implementation of the AIDL interface android::os::IServiceManager calls into
620613// on-device service manager.
621- class ServiceManagerHostShim : public ServiceManagerShim {
614+ class CppServiceManagerHostShim : public CppBackendShim {
622615public:
623- ServiceManagerHostShim (const sp<AidlServiceManager>& impl,
624- const RpcDelegateServiceManagerOptions& options)
625- : ServiceManagerShim( impl), mOptions (options) {}
626- // ServiceManagerShim ::getService is based on checkService, so no need to override it.
616+ CppServiceManagerHostShim (const sp<AidlServiceManager>& impl,
617+ const RpcDelegateServiceManagerOptions& options)
618+ : CppBackendShim(sp<BackendUnifiedServiceManager>::make( impl) ), mOptions (options) {}
619+ // CppBackendShim ::getService is based on checkService, so no need to override it.
627620 sp<IBinder> checkService (const String16& name) const override {
628621 return getDeviceService ({String8 (name).c_str ()}, mOptions );
629622 }
630623
631624protected:
632- // Override realGetService for ServiceManagerShim ::waitForService.
625+ // Override realGetService for CppBackendShim ::waitForService.
633626 Status realGetService (const std::string& name, sp<IBinder>* _aidl_return) override {
634627 *_aidl_return = getDeviceService ({" -g" , name}, mOptions );
635628 return Status::ok ();
@@ -650,7 +643,7 @@ sp<IServiceManager> createRpcDelegateServiceManager(
650643 ALOGE (" getDeviceService(\" manager\" ) returns non service manager" );
651644 return nullptr ;
652645 }
653- return sp<ServiceManagerHostShim >::make (interface, options);
646+ return sp<CppServiceManagerHostShim >::make (interface, options);
654647}
655648#endif
656649
0 commit comments