blob: a26a2822cd24eb3eafba52d484514e5aecd7929a [file] [log] [blame]
Steven Moreland5d5ef7f2016-10-20 19:19:55 -07001/*
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 Morelandcbefd352017-01-23 20:29:05 -080020#include <string>
Martijn Coenen86c3abb2017-10-24 09:33:28 +020021
22#include <android/hidl/base/1.0/IBase.h>
Steven Moreland5d5ef7f2016-10-20 19:19:55 -070023#include <utils/StrongPointer.h>
24
25namespace android {
26
27namespace hidl {
28namespace manager {
29namespace V1_0 {
30 struct IServiceManager;
Steven Moreland89909692018-05-30 14:11:19 -070031}; // namespace V1_0
Steven Moreland2a2678e2017-07-21 18:07:38 -070032namespace V1_1 {
Steven Moreland89909692018-05-30 14:11:19 -070033struct IServiceManager;
34}; // namespace V1_1
35namespace V1_2 {
36struct IServiceManager;
37}; // namespace V1_2
38}; // namespace manager
39}; // namespace hidl
Steven Moreland5d5ef7f2016-10-20 19:19:55 -070040
41namespace hardware {
42
Steven Morelandcbefd352017-01-23 20:29:05 -080043namespace details {
Steven Morelandcd4dbdf2017-04-07 20:31:22 -070044// e.x.: android.hardware.foo@1.0, IFoo, default
45void onRegistration(const std::string &packageName,
46 const std::string &interfaceName,
47 const std::string &instanceName);
48
Steven Moreland0771d8a2018-05-09 13:29:14 -070049// Will not attempt to start a lazy HAL
Steven Morelandcd4dbdf2017-04-07 20:31:22 -070050// e.x.: android.hardware.foo@1.0::IFoo, default
Steven Morelandcbefd352017-01-23 20:29:05 -080051void waitForHwService(const std::string &interface, const std::string &instanceName);
Steven Moreland519306f2017-06-06 17:14:12 -070052
53void preloadPassthroughService(const std::string &descriptor);
Martijn Coenen86c3abb2017-10-24 09:33:28 +020054
55// Returns a service with the following constraints:
56// - retry => service is waited for and returned if available in this process
57// - getStub => internal only. Forces to get the unwrapped (no BsFoo) if available.
58// TODO(b/65843592)
59// If the service is a remote service, this function returns BpBase. If the service is
60// a passthrough service, this function returns the appropriately wrapped Bs child object.
61sp<::android::hidl::base::V1_0::IBase> getRawServiceInternal(const std::string& descriptor,
62 const std::string& instance,
63 bool retry, bool getStub);
Steven Morelandcbefd352017-01-23 20:29:05 -080064};
65
Steven Moreland519306f2017-06-06 17:14:12 -070066// These functions are for internal use by hidl. If you want to get ahold
67// of an interface, the best way to do this is by calling IFoo::getService()
68sp<::android::hidl::manager::V1_0::IServiceManager> defaultServiceManager();
Steven Moreland2a2678e2017-07-21 18:07:38 -070069sp<::android::hidl::manager::V1_1::IServiceManager> defaultServiceManager1_1();
Steven Moreland89909692018-05-30 14:11:19 -070070sp<::android::hidl::manager::V1_2::IServiceManager> defaultServiceManager1_2();
Steven Moreland519306f2017-06-06 17:14:12 -070071sp<::android::hidl::manager::V1_0::IServiceManager> getPassthroughServiceManager();
Steven Moreland2a2678e2017-07-21 18:07:38 -070072sp<::android::hidl::manager::V1_1::IServiceManager> getPassthroughServiceManager1_1();
Steven Moreland519306f2017-06-06 17:14:12 -070073
74/**
75 * Given a service that is in passthrough mode, this function will go ahead and load the
76 * required passthrough module library (but not call HIDL_FETCH_I* functions to instantiate it).
77 *
78 * E.x.: preloadPassthroughService<IFoo>();
79 */
80template<typename I>
81static inline void preloadPassthroughService() {
82 details::preloadPassthroughService(I::descriptor);
83}
84
Steven Moreland5d5ef7f2016-10-20 19:19:55 -070085}; // namespace hardware
86}; // namespace android
87
88#endif // ANDROID_HARDWARE_ISERVICE_MANAGER_H
89