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