blob: 5e89ad0c80a12778ba08d10fd251e8e70a304990 [file] [log] [blame]
Remi NGUYEN VANa985e582020-12-21 18:40:08 +09001/*
2 * Copyright (C) 2020 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#include <log/log.h>
19
Remi NGUYEN VANd9504892022-02-02 13:03:29 +090020#include <android-modules-utils/sdk_level.h>
21
Remi NGUYEN VANa985e582020-12-21 18:40:08 +090022namespace android {
23
Patrick Rohr361b8592022-01-28 15:39:17 +010024int register_com_android_server_TestNetworkService(JNIEnv* env);
Patrick Rohr361b8592022-01-28 15:39:17 +010025int register_com_android_server_BpfNetMaps(JNIEnv* env);
Maciej Żenczykowskia2b6ea12023-04-25 07:43:38 +000026int register_com_android_server_connectivity_ClatCoordinator(JNIEnv* env);
Remi NGUYEN VANd9504892022-02-02 13:03:29 +090027int register_android_server_net_NetworkStatsFactory(JNIEnv* env);
28int register_android_server_net_NetworkStatsService(JNIEnv* env);
Kangping Dong192e4b02023-10-25 20:34:21 +080029int register_com_android_server_ServiceManagerWrapper(JNIEnv* env);
Remi NGUYEN VANa985e582020-12-21 18:40:08 +090030
31extern "C" jint JNI_OnLoad(JavaVM* vm, void*) {
32 JNIEnv *env;
33 if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
34 ALOGE("GetEnv failed");
35 return JNI_ERR;
36 }
37
Patrick Rohr361b8592022-01-28 15:39:17 +010038 if (register_com_android_server_TestNetworkService(env) < 0) {
Remi NGUYEN VANa985e582020-12-21 18:40:08 +090039 return JNI_ERR;
40 }
41
Kangping Dong192e4b02023-10-25 20:34:21 +080042 if (register_com_android_server_ServiceManagerWrapper(env) < 0) {
43 return JNI_ERR;
44 }
45
Remi NGUYEN VANd9504892022-02-02 13:03:29 +090046 if (android::modules::sdklevel::IsAtLeastT()) {
Patrick Rohr31edd952023-05-02 16:17:53 +000047 if (register_com_android_server_BpfNetMaps(env) < 0) {
48 return JNI_ERR;
49 }
50
Maciej Żenczykowskia2b6ea12023-04-25 07:43:38 +000051 if (register_com_android_server_connectivity_ClatCoordinator(env) < 0) {
52 return JNI_ERR;
53 }
54
Remi NGUYEN VANd9504892022-02-02 13:03:29 +090055 if (register_android_server_net_NetworkStatsFactory(env) < 0) {
56 return JNI_ERR;
57 }
58
59 if (register_android_server_net_NetworkStatsService(env) < 0) {
60 return JNI_ERR;
61 }
62 }
63
Remi NGUYEN VANa985e582020-12-21 18:40:08 +090064 return JNI_VERSION_1_6;
65}
66
Lorenzo Colitti75a34a62021-02-15 17:07:57 +090067};