diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/binder/BackendUnifiedServiceManager.cpp | 13 | ||||
-rw-r--r-- | libs/binder/BackendUnifiedServiceManager.h | 3 | ||||
-rw-r--r-- | libs/binder/IServiceManager.cpp | 2 | ||||
-rw-r--r-- | libs/binder/aidl/android/os/IServiceManager.aidl | 16 | ||||
-rw-r--r-- | libs/binder/servicedispatcher.cpp | 7 |
5 files changed, 35 insertions, 6 deletions
diff --git a/libs/binder/BackendUnifiedServiceManager.cpp b/libs/binder/BackendUnifiedServiceManager.cpp index 0bf3cadd35..54f687b280 100644 --- a/libs/binder/BackendUnifiedServiceManager.cpp +++ b/libs/binder/BackendUnifiedServiceManager.cpp @@ -33,10 +33,19 @@ BackendUnifiedServiceManager::BackendUnifiedServiceManager(const sp<AidlServiceM sp<AidlServiceManager> BackendUnifiedServiceManager::getImpl() { return mTheRealServiceManager; } + binder::Status BackendUnifiedServiceManager::getService(const ::std::string& name, - os::Service* _out) { + sp<IBinder>* _aidl_return) { + os::Service service; + binder::Status status = getService2(name, &service); + *_aidl_return = service.get<os::Service::Tag::binder>(); + return status; +} + +binder::Status BackendUnifiedServiceManager::getService2(const ::std::string& name, + os::Service* _out) { os::Service service; - binder::Status status = mTheRealServiceManager->getService(name, &service); + binder::Status status = mTheRealServiceManager->getService2(name, &service); toBinderService(service, _out); return status; } diff --git a/libs/binder/BackendUnifiedServiceManager.h b/libs/binder/BackendUnifiedServiceManager.h index 4715be4580..f5d7e66568 100644 --- a/libs/binder/BackendUnifiedServiceManager.h +++ b/libs/binder/BackendUnifiedServiceManager.h @@ -26,7 +26,8 @@ public: explicit BackendUnifiedServiceManager(const sp<os::IServiceManager>& impl); sp<os::IServiceManager> getImpl(); - binder::Status getService(const ::std::string& name, os::Service* out) override; + binder::Status getService(const ::std::string& name, sp<IBinder>* _aidl_return) override; + binder::Status getService2(const ::std::string& name, os::Service* out) override; binder::Status checkService(const ::std::string& name, os::Service* out) override; binder::Status addService(const ::std::string& name, const sp<IBinder>& service, bool allowIsolated, int32_t dumpPriority) override; diff --git a/libs/binder/IServiceManager.cpp b/libs/binder/IServiceManager.cpp index 12a18f2a69..8b80aed630 100644 --- a/libs/binder/IServiceManager.cpp +++ b/libs/binder/IServiceManager.cpp @@ -143,7 +143,7 @@ protected: // mUnifiedServiceManager->getService so that it can be overridden in ServiceManagerHostShim. virtual Status realGetService(const std::string& name, sp<IBinder>* _aidl_return) { Service service; - Status status = mUnifiedServiceManager->getService(name, &service); + Status status = mUnifiedServiceManager->getService2(name, &service); *_aidl_return = service.get<Service::Tag::binder>(); return status; } diff --git a/libs/binder/aidl/android/os/IServiceManager.aidl b/libs/binder/aidl/android/os/IServiceManager.aidl index ac95188470..1d1f84fc01 100644 --- a/libs/binder/aidl/android/os/IServiceManager.aidl +++ b/libs/binder/aidl/android/os/IServiceManager.aidl @@ -60,9 +60,23 @@ interface IServiceManager { * exists for legacy purposes. * * Returns null if the service does not exist. + * + * @deprecated TODO(b/355394904): Use getService2 instead. */ @UnsupportedAppUsage - Service getService(@utf8InCpp String name); + @nullable IBinder getService(@utf8InCpp String name); + + /** + * Retrieve an existing service called @a name from the + * service manager. + * + * This is the same as checkService (returns immediately) but + * exists for legacy purposes. + * + * Returns an enum Service that can be of different types. The + * enum value is null if the service does not exist. + */ + Service getService2(@utf8InCpp String name); /** * Retrieve an existing service called @a name from the service diff --git a/libs/binder/servicedispatcher.cpp b/libs/binder/servicedispatcher.cpp index 201dfbc400..be990657d5 100644 --- a/libs/binder/servicedispatcher.cpp +++ b/libs/binder/servicedispatcher.cpp @@ -118,7 +118,12 @@ int Dispatch(const char* name, const ServiceRetriever& serviceRetriever, class ServiceManagerProxyToNative : public android::os::BnServiceManager { public: ServiceManagerProxyToNative(const sp<android::os::IServiceManager>& impl) : mImpl(impl) {} - android::binder::Status getService(const std::string&, android::os::Service*) override { + android::binder::Status getService(const std::string&, + android::sp<android::IBinder>*) override { + // We can't send BpBinder for regular binder over RPC. + return android::binder::Status::fromStatusT(android::INVALID_OPERATION); + } + android::binder::Status getService2(const std::string&, android::os::Service*) override { // We can't send BpBinder for regular binder over RPC. return android::binder::Status::fromStatusT(android::INVALID_OPERATION); } |