1 /*
2 * Copyright (C) 2024 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 #include <nativehelper/JNIHelp.h>
18
19 #include "jni.h"
20
21 namespace android {
22
23 // Forward declared per-class registration methods.
24 int register_android_server_ConsumerIrService(JNIEnv* env);
25 int register_android_server_app_GameManagerService(JNIEnv* env);
26 int register_android_server_vr_VrManagerService(JNIEnv* env);
27
28 namespace {
29
30 // TODO(b/)375264322: Remove these trampoline methods after finalizing the
31 // registrar implementation. Instead, just update the called methods to take a
32 // class arg, and hand those methods to jniRegisterNativeMethods directly.
registerConsumerIrService(JNIEnv * env,jclass)33 void registerConsumerIrService(JNIEnv* env, jclass) {
34 register_android_server_ConsumerIrService(env);
35 }
36
registerGameManagerService(JNIEnv * env,jclass)37 void registerGameManagerService(JNIEnv* env, jclass) {
38 register_android_server_app_GameManagerService(env);
39 }
40
registerVrManagerService(JNIEnv * env,jclass)41 void registerVrManagerService(JNIEnv* env, jclass) {
42 register_android_server_vr_VrManagerService(env);
43 }
44
45 static const JNINativeMethod sJniRegistrarMethods[] = {
registerConsumerIrService()46 {"registerConsumerIrService", "()V", (void*)registerConsumerIrService},
registerGameManagerService()47 {"registerGameManagerService", "()V", (void*)registerGameManagerService},
registerVrManagerService()48 {"registerVrManagerService", "()V", (void*)registerVrManagerService},
49 };
50
51 } // namespace
52
register_android_server_utils_LazyJniRegistrar(JNIEnv * env)53 int register_android_server_utils_LazyJniRegistrar(JNIEnv* env) {
54 return jniRegisterNativeMethods(env, "com/android/server/utils/LazyJniRegistrar",
55 sJniRegistrarMethods, NELEM(sJniRegistrarMethods));
56 }
57
58 } // namespace android
59