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