• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 package android.os;
17 
18 import android.annotation.NonNull;
19 import android.annotation.Nullable;
20 import android.annotation.SystemApi;
21 
22 /**
23  * Provides a way to register and obtain the system service binder objects managed by the ART
24  * mainline module.
25  *
26  * Only the ART mainline module will be able to access an instance of this class.
27  *
28  * @hide
29  */
30 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
31 public class ArtModuleServiceManager {
32     /** @hide */
ArtModuleServiceManager()33     public ArtModuleServiceManager() {}
34 
35     /** A class that exposes the method to obtain each system service. */
36     public static final class ServiceRegisterer {
37         @NonNull private final String mServiceName;
38 
39         /** @hide */
ServiceRegisterer(@onNull String serviceName)40         public ServiceRegisterer(@NonNull String serviceName) {
41             mServiceName = serviceName;
42         }
43 
44         /**
45          * Returns the service from the service manager.
46          *
47          * If the service is not running, servicemanager will attempt to start it, and this function
48          * will wait for it to be ready.
49          *
50          * @return {@code null} only if there are permission problems or fatal errors.
51          */
52         @Nullable
waitForService()53         public IBinder waitForService() {
54             return ServiceManager.waitForService(mServiceName);
55         }
56     }
57 
58     /** Returns {@link ServiceRegisterer} for the "artd" service. */
59     @NonNull
getArtdServiceRegisterer()60     public ServiceRegisterer getArtdServiceRegisterer() {
61         return new ServiceRegisterer("artd");
62     }
63 }
64