1 /*
2  * Copyright (C) 2018 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 <android/binder_ibinder.h>
20 #include <android/binder_status.h>
21 
22 __BEGIN_DECLS
23 
24 /**
25  * This registers the service with the default service manager under this instance name. This does
26  * not take ownership of binder.
27  *
28  * \param binder object to register globally with the service manager.
29  * \param instance identifier of the service. This will be used to lookup the service.
30  *
31  * \return STATUS_OK on success.
32  */
33 binder_status_t AServiceManager_addService(AIBinder* binder, const char* instance);
34 
35 /**
36  * Gets a binder object with this specific instance name. Will return nullptr immediately if the
37  * service is not available This also implicitly calls AIBinder_incStrong (so the caller of this
38  * function is responsible for calling AIBinder_decStrong).
39  *
40  * \param instance identifier of the service used to lookup the service.
41  */
42 __attribute__((warn_unused_result)) AIBinder* AServiceManager_checkService(const char* instance);
43 
44 /**
45  * Gets a binder object with this specific instance name. Blocks for a couple of seconds waiting on
46  * it. This also implicitly calls AIBinder_incStrong (so the caller of this function is responsible
47  * for calling AIBinder_decStrong).
48  *
49  * \param instance identifier of the service used to lookup the service.
50  */
51 __attribute__((warn_unused_result)) AIBinder* AServiceManager_getService(const char* instance);
52 
53 __END_DECLS
54