Steven Moreland | 5d5ef7f | 2016-10-20 19:19:55 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | #ifndef ANDROID_HARDWARE_ISERVICE_MANAGER_H |
| 18 | #define ANDROID_HARDWARE_ISERVICE_MANAGER_H |
| 19 | |
Steven Moreland | cbefd35 | 2017-01-23 20:29:05 -0800 | [diff] [blame] | 20 | #include <string> |
Martijn Coenen | 86c3abb | 2017-10-24 09:33:28 +0200 | [diff] [blame^] | 21 | |
| 22 | #include <android/hidl/base/1.0/IBase.h> |
Steven Moreland | 5d5ef7f | 2016-10-20 19:19:55 -0700 | [diff] [blame] | 23 | #include <utils/StrongPointer.h> |
| 24 | |
| 25 | namespace android { |
| 26 | |
| 27 | namespace hidl { |
| 28 | namespace manager { |
| 29 | namespace V1_0 { |
| 30 | struct IServiceManager; |
| 31 | }; // namespace V1_0 |
Steven Moreland | 2a2678e | 2017-07-21 18:07:38 -0700 | [diff] [blame] | 32 | namespace V1_1 { |
| 33 | struct IServiceManager; |
| 34 | }; // namespace V1_0 |
Steven Moreland | 5d5ef7f | 2016-10-20 19:19:55 -0700 | [diff] [blame] | 35 | }; // namespace manager |
| 36 | }; // namespace hidl |
| 37 | |
| 38 | namespace hardware { |
| 39 | |
Steven Moreland | cbefd35 | 2017-01-23 20:29:05 -0800 | [diff] [blame] | 40 | namespace details { |
Steven Moreland | cd4dbdf | 2017-04-07 20:31:22 -0700 | [diff] [blame] | 41 | // e.x.: android.hardware.foo@1.0, IFoo, default |
| 42 | void onRegistration(const std::string &packageName, |
| 43 | const std::string &interfaceName, |
| 44 | const std::string &instanceName); |
| 45 | |
| 46 | // e.x.: android.hardware.foo@1.0::IFoo, default |
Steven Moreland | cbefd35 | 2017-01-23 20:29:05 -0800 | [diff] [blame] | 47 | void waitForHwService(const std::string &interface, const std::string &instanceName); |
Steven Moreland | 519306f | 2017-06-06 17:14:12 -0700 | [diff] [blame] | 48 | |
| 49 | void preloadPassthroughService(const std::string &descriptor); |
Martijn Coenen | 86c3abb | 2017-10-24 09:33:28 +0200 | [diff] [blame^] | 50 | |
| 51 | // Returns a service with the following constraints: |
| 52 | // - retry => service is waited for and returned if available in this process |
| 53 | // - getStub => internal only. Forces to get the unwrapped (no BsFoo) if available. |
| 54 | // TODO(b/65843592) |
| 55 | // If the service is a remote service, this function returns BpBase. If the service is |
| 56 | // a passthrough service, this function returns the appropriately wrapped Bs child object. |
| 57 | sp<::android::hidl::base::V1_0::IBase> getRawServiceInternal(const std::string& descriptor, |
| 58 | const std::string& instance, |
| 59 | bool retry, bool getStub); |
Steven Moreland | cbefd35 | 2017-01-23 20:29:05 -0800 | [diff] [blame] | 60 | }; |
| 61 | |
Steven Moreland | 519306f | 2017-06-06 17:14:12 -0700 | [diff] [blame] | 62 | // These functions are for internal use by hidl. If you want to get ahold |
| 63 | // of an interface, the best way to do this is by calling IFoo::getService() |
| 64 | sp<::android::hidl::manager::V1_0::IServiceManager> defaultServiceManager(); |
Steven Moreland | 2a2678e | 2017-07-21 18:07:38 -0700 | [diff] [blame] | 65 | sp<::android::hidl::manager::V1_1::IServiceManager> defaultServiceManager1_1(); |
Steven Moreland | 519306f | 2017-06-06 17:14:12 -0700 | [diff] [blame] | 66 | sp<::android::hidl::manager::V1_0::IServiceManager> getPassthroughServiceManager(); |
Steven Moreland | 2a2678e | 2017-07-21 18:07:38 -0700 | [diff] [blame] | 67 | sp<::android::hidl::manager::V1_1::IServiceManager> getPassthroughServiceManager1_1(); |
Steven Moreland | 519306f | 2017-06-06 17:14:12 -0700 | [diff] [blame] | 68 | |
| 69 | /** |
| 70 | * Given a service that is in passthrough mode, this function will go ahead and load the |
| 71 | * required passthrough module library (but not call HIDL_FETCH_I* functions to instantiate it). |
| 72 | * |
| 73 | * E.x.: preloadPassthroughService<IFoo>(); |
| 74 | */ |
| 75 | template<typename I> |
| 76 | static inline void preloadPassthroughService() { |
| 77 | details::preloadPassthroughService(I::descriptor); |
| 78 | } |
| 79 | |
Steven Moreland | 5d5ef7f | 2016-10-20 19:19:55 -0700 | [diff] [blame] | 80 | }; // namespace hardware |
| 81 | }; // namespace android |
| 82 | |
| 83 | #endif // ANDROID_HARDWARE_ISERVICE_MANAGER_H |
| 84 | |