| Brett Chabot | c9ee330 | 2020-01-31 09:20:28 -0800 | [diff] [blame] | 1 | /* | 
|  | 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> | 
| Steven Moreland | edd4e07 | 2021-04-21 00:27:29 +0000 | [diff] [blame] | 22 | #include <optional> | 
| Jayant Chowdhary | ddd3da0 | 2022-05-20 03:30:09 +0000 | [diff] [blame] | 23 | #include <vector> | 
| Brett Chabot | c9ee330 | 2020-01-31 09:20:28 -0800 | [diff] [blame] | 24 |  | 
|  | 25 | namespace android { | 
|  | 26 |  | 
|  | 27 | /** | 
|  | 28 | * A local host simple implementation of IServiceManager, that does not | 
|  | 29 | * communicate over binder. | 
|  | 30 | */ | 
|  | 31 | class ServiceManager : public IServiceManager { | 
|  | 32 | public: | 
|  | 33 | ServiceManager(); | 
|  | 34 |  | 
| Brett Chabot | c9ee330 | 2020-01-31 09:20:28 -0800 | [diff] [blame] | 35 | sp<IBinder> getService( const String16& name) const override; | 
|  | 36 |  | 
| Brett Chabot | c9ee330 | 2020-01-31 09:20:28 -0800 | [diff] [blame] | 37 | sp<IBinder> checkService( const String16& name) const override; | 
|  | 38 |  | 
| Brett Chabot | c9ee330 | 2020-01-31 09:20:28 -0800 | [diff] [blame] | 39 | status_t addService(const String16& name, const sp<IBinder>& service, | 
|  | 40 | bool allowIsolated = false, | 
|  | 41 | int dumpsysFlags = DUMP_FLAG_PRIORITY_DEFAULT) override; | 
|  | 42 |  | 
| Brett Chabot | c9ee330 | 2020-01-31 09:20:28 -0800 | [diff] [blame] | 43 | Vector<String16> listServices(int dumpsysFlags = 0) override; | 
|  | 44 |  | 
|  | 45 | IBinder* onAsBinder() override; | 
|  | 46 |  | 
| Brett Chabot | c9ee330 | 2020-01-31 09:20:28 -0800 | [diff] [blame] | 47 | sp<IBinder> waitForService(const String16& name) override; | 
|  | 48 |  | 
| Steven Moreland | c68e32d | 2020-09-24 16:34:21 +0000 | [diff] [blame] | 49 | bool isDeclared(const String16& name) override; | 
| Brett Chabot | c9ee330 | 2020-01-31 09:20:28 -0800 | [diff] [blame] | 50 |  | 
| Steven Moreland | 2e293aa | 2020-09-23 00:25:16 +0000 | [diff] [blame] | 51 | Vector<String16> getDeclaredInstances(const String16& iface) override; | 
|  | 52 |  | 
| Steven Moreland | edd4e07 | 2021-04-21 00:27:29 +0000 | [diff] [blame] | 53 | std::optional<String16> updatableViaApex(const String16& name) override; | 
|  | 54 |  | 
| Devin Moore | 5e4c2f1 | 2021-09-09 22:36:33 +0000 | [diff] [blame] | 55 | std::optional<IServiceManager::ConnectionInfo> getConnectionInfo(const String16& name) override; | 
|  | 56 |  | 
| Jayant Chowdhary | 3070094 | 2022-01-31 14:12:40 -0800 | [diff] [blame] | 57 | status_t registerForNotifications(const String16& name, | 
|  | 58 | const sp<LocalRegistrationCallback>& callback) override; | 
|  | 59 |  | 
|  | 60 | status_t unregisterForNotifications(const String16& name, | 
|  | 61 | const sp<LocalRegistrationCallback>& callback) override; | 
| Jayant Chowdhary | ddd3da0 | 2022-05-20 03:30:09 +0000 | [diff] [blame] | 62 |  | 
|  | 63 | std::vector<IServiceManager::ServiceDebugInfo> getServiceDebugInfo() override; | 
|  | 64 |  | 
| Brett Chabot | c9ee330 | 2020-01-31 09:20:28 -0800 | [diff] [blame] | 65 | private: | 
|  | 66 | std::map<String16, sp<IBinder>> mNameToService; | 
|  | 67 | }; | 
|  | 68 |  | 
|  | 69 | }  // namespace android |