Parth Sane | 56a0471 | 2024-04-22 14:21:07 +0000 | [diff] [blame] | 1 | /* |
| 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 | #pragma once |
| 17 | |
Parth Sane | 56a0471 | 2024-04-22 14:21:07 +0000 | [diff] [blame] | 18 | #include <android/os/BnServiceManager.h> |
| 19 | #include <android/os/IServiceManager.h> |
| 20 | #include <binder/IPCThreadState.h> |
| 21 | |
| 22 | namespace android { |
| 23 | |
| 24 | class BackendUnifiedServiceManager : public android::os::BnServiceManager { |
| 25 | public: |
| 26 | explicit BackendUnifiedServiceManager(const sp<os::IServiceManager>& impl); |
| 27 | |
| 28 | sp<os::IServiceManager> getImpl(); |
Alice Wang | 11da150 | 2024-07-25 12:03:22 +0000 | [diff] [blame^] | 29 | binder::Status getService(const ::std::string& name, sp<IBinder>* _aidl_return) override; |
| 30 | binder::Status getService2(const ::std::string& name, os::Service* out) override; |
Alice Wang | 8578f13 | 2024-05-03 09:01:56 +0000 | [diff] [blame] | 31 | binder::Status checkService(const ::std::string& name, os::Service* out) override; |
Parth Sane | 56a0471 | 2024-04-22 14:21:07 +0000 | [diff] [blame] | 32 | binder::Status addService(const ::std::string& name, const sp<IBinder>& service, |
| 33 | bool allowIsolated, int32_t dumpPriority) override; |
| 34 | binder::Status listServices(int32_t dumpPriority, |
| 35 | ::std::vector<::std::string>* _aidl_return) override; |
| 36 | binder::Status registerForNotifications(const ::std::string& name, |
| 37 | const sp<os::IServiceCallback>& callback) override; |
| 38 | binder::Status unregisterForNotifications(const ::std::string& name, |
| 39 | const sp<os::IServiceCallback>& callback) override; |
| 40 | binder::Status isDeclared(const ::std::string& name, bool* _aidl_return) override; |
| 41 | binder::Status getDeclaredInstances(const ::std::string& iface, |
| 42 | ::std::vector<::std::string>* _aidl_return) override; |
| 43 | binder::Status updatableViaApex(const ::std::string& name, |
| 44 | ::std::optional<::std::string>* _aidl_return) override; |
| 45 | binder::Status getUpdatableNames(const ::std::string& apexName, |
| 46 | ::std::vector<::std::string>* _aidl_return) override; |
| 47 | binder::Status getConnectionInfo(const ::std::string& name, |
| 48 | ::std::optional<os::ConnectionInfo>* _aidl_return) override; |
| 49 | binder::Status registerClientCallback(const ::std::string& name, const sp<IBinder>& service, |
| 50 | const sp<os::IClientCallback>& callback) override; |
| 51 | binder::Status tryUnregisterService(const ::std::string& name, |
| 52 | const sp<IBinder>& service) override; |
| 53 | binder::Status getServiceDebugInfo(::std::vector<os::ServiceDebugInfo>* _aidl_return) override; |
| 54 | |
| 55 | // for legacy ABI |
| 56 | const String16& getInterfaceDescriptor() const override { |
| 57 | return mTheRealServiceManager->getInterfaceDescriptor(); |
| 58 | } |
| 59 | |
| 60 | IBinder* onAsBinder() override { return IInterface::asBinder(mTheRealServiceManager).get(); } |
| 61 | |
| 62 | private: |
| 63 | sp<os::IServiceManager> mTheRealServiceManager; |
Alice Wang | 8578f13 | 2024-05-03 09:01:56 +0000 | [diff] [blame] | 64 | void toBinderService(const os::Service& in, os::Service* _out); |
Parth Sane | 56a0471 | 2024-04-22 14:21:07 +0000 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | sp<BackendUnifiedServiceManager> getBackendUnifiedServiceManager(); |
| 68 | |
| 69 | } // namespace android |