blob: 4ef47fb043bd0f2f952516d73ddb6669da84580f [file] [log] [blame]
Brett Chabotc9ee3302020-01-31 09:20:28 -08001/*
2 * Copyright (C) 2020 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
17#pragma once
18
19#include <binder/IServiceManager.h>
20
21#include <map>
22
23namespace android {
24
25/**
26 * A local host simple implementation of IServiceManager, that does not
27 * communicate over binder.
28*/
29class ServiceManager : public IServiceManager {
30public:
31 ServiceManager();
32
Brett Chabotc9ee3302020-01-31 09:20:28 -080033 sp<IBinder> getService( const String16& name) const override;
34
Brett Chabotc9ee3302020-01-31 09:20:28 -080035 sp<IBinder> checkService( const String16& name) const override;
36
Brett Chabotc9ee3302020-01-31 09:20:28 -080037 status_t addService(const String16& name, const sp<IBinder>& service,
38 bool allowIsolated = false,
39 int dumpsysFlags = DUMP_FLAG_PRIORITY_DEFAULT) override;
40
Brett Chabotc9ee3302020-01-31 09:20:28 -080041 Vector<String16> listServices(int dumpsysFlags = 0) override;
42
43 IBinder* onAsBinder() override;
44
Brett Chabotc9ee3302020-01-31 09:20:28 -080045 sp<IBinder> waitForService(const String16& name) override;
46
Steven Morelandc68e32d2020-09-24 16:34:21 +000047 bool isDeclared(const String16& name) override;
Brett Chabotc9ee3302020-01-31 09:20:28 -080048
Steven Moreland2e293aa2020-09-23 00:25:16 +000049 Vector<String16> getDeclaredInstances(const String16& iface) override;
50
Brett Chabotc9ee3302020-01-31 09:20:28 -080051private:
52 std::map<String16, sp<IBinder>> mNameToService;
53};
54
55} // namespace android