blob: a67d5bae2df6b30c28ae3529504a04710f2dff9c [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
18#include <android-base/properties.h>
19#include <android/os/BnServiceManager.h>
20#include <android/os/IServiceManager.h>
21#include <binder/IPCThreadState.h>
22
23namespace android {
24
25class BackendUnifiedServiceManager : public android::os::BnServiceManager {
26public:
27 explicit BackendUnifiedServiceManager(const sp<os::IServiceManager>& impl);
28
29 sp<os::IServiceManager> getImpl();
30 binder::Status getService(const ::std::string& name, sp<IBinder>* _aidl_return) override;
31 binder::Status checkService(const ::std::string& name, sp<IBinder>* _aidl_return) override;
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
62private:
63 sp<os::IServiceManager> mTheRealServiceManager;
64};
65
66sp<BackendUnifiedServiceManager> getBackendUnifiedServiceManager();
67
68} // namespace android