1 /*
2  * Copyright (C) 2021 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 package android.car.builtin.os;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.annotation.SystemApi;
22 import android.os.IBinder;
23 import android.os.ServiceManager;
24 
25 /**
26  * Helper class for {@code ServiceManager} API
27  *
28  * @hide
29  */
30 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
31 public final class ServiceManagerHelper {
32 
ServiceManagerHelper()33     private ServiceManagerHelper()  {
34         throw new UnsupportedOperationException();
35     }
36 
37     /** Check {@link ServiceManager#getService(String)} */
38     @Nullable
getService(@onNull String name)39     public static IBinder getService(@NonNull String name) {
40         return ServiceManager.getService(name);
41     }
42 
43     /** Check {@link ServiceManager#checkService(String)} */
44     @Nullable
checkService(@onNull String name)45     public static IBinder checkService(@NonNull String name) {
46         return ServiceManager.checkService(name);
47     }
48 
49     /** Check {@link ServiceManager#waitForDeclaredService(String)} */
50     @Nullable
waitForDeclaredService(@onNull String name)51     public static IBinder waitForDeclaredService(@NonNull String name) {
52         return ServiceManager.waitForDeclaredService(name);
53     }
54 
55     /** Check {@link ServiceManager#addService(String, IBinder)} */
addService(@onNull String name, @NonNull IBinder service)56     public static void addService(@NonNull String name, @NonNull IBinder service) {
57         ServiceManager.addService(name, service);
58     }
59 
60     /** Check {@link ServiceManager#getDeclaredInstances(String)} */
61     @Nullable
getDeclaredInstances(@onNull String iface)62     public static String[] getDeclaredInstances(@NonNull String iface) {
63         return ServiceManager.getDeclaredInstances(iface);
64     }
65 }
66