Debian Codegraph @

libartservice/service/java/com/android/server/art/ArtModuleServiceInitializer.java

raw
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
17 package com.android.server.art;
18
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.annotation.SystemApi;
22 import android.os.ArtModuleServiceManager;
23 import android.os.Build;
24
25 import androidx.annotation.RequiresApi;
26
27 import com.android.internal.annotations.GuardedBy;
28
29 import java.util.Objects;
30
31 /**
32 * Class for performing registration for the ART mainline module.
33 *
34 * @hide
35 */
36 @SystemApi(client = SystemApi.Client.SYSTEM_SERVER)
37 @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
38 public class ArtModuleServiceInitializer {
39 private ArtModuleServiceInitializer() {}
40
41 @NonNull private static Object sLock = new Object();
42 @GuardedBy("sLock") @Nullable private static ArtModuleServiceManager sArtModuleServiceManager;
43
44 /**
45 * Sets an instance of {@link ArtModuleServiceManager} that allows the ART mainline module to
46 * obtain ART binder services. This is called by the platform during the system server
47 * initialization.
48 */
49 public static void setArtModuleServiceManager(
50 @NonNull ArtModuleServiceManager artModuleServiceManager) {
51 synchronized (sLock) {
52 if (sArtModuleServiceManager != null) {
53 throw new IllegalStateException("ArtModuleServiceManager is already set");
54 }
55 sArtModuleServiceManager = artModuleServiceManager;
56 }
57 }
58
59 /** @hide */
60 @NonNull
61 public static ArtModuleServiceManager getArtModuleServiceManager() {
62 synchronized (sLock) {
63 return Objects.requireNonNull(sArtModuleServiceManager);
64 }
65 }
66 }