blob: 3d15d43db4670779b9a4f8e56fb08610abe52d52 [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 VANc8aa43c2022-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);
25int register_com_android_server_connectivity_ClatCoordinator(JNIEnv* env);
26int register_com_android_server_BpfNetMaps(JNIEnv* env);
Remi NGUYEN VANc8aa43c2022-02-02 13:03:29 +090027int register_android_server_net_NetworkStatsFactory(JNIEnv* env);
28int register_android_server_net_NetworkStatsService(JNIEnv* env);
Remi NGUYEN VANa985e582020-12-21 18:40:08 +090029
30extern "C" jint JNI_OnLoad(JavaVM* vm, void*) {
31 JNIEnv *env;
32 if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
33 ALOGE("GetEnv failed");
34 return JNI_ERR;
35 }
36
Patrick Rohr361b8592022-01-28 15:39:17 +010037 if (register_com_android_server_TestNetworkService(env) < 0) {
Remi NGUYEN VANa985e582020-12-21 18:40:08 +090038 return JNI_ERR;
39 }
40
Patrick Rohr361b8592022-01-28 15:39:17 +010041 if (register_com_android_server_connectivity_ClatCoordinator(env) < 0) {
42 return JNI_ERR;
43 }
44
45 if (register_com_android_server_BpfNetMaps(env) < 0) {
Hungming Chene2cf0552021-12-25 17:05:41 +080046 return JNI_ERR;
47 }
48
Remi NGUYEN VANc8aa43c2022-02-02 13:03:29 +090049 if (android::modules::sdklevel::IsAtLeastT()) {
50 if (register_android_server_net_NetworkStatsFactory(env) < 0) {
51 return JNI_ERR;
52 }
53
54 if (register_android_server_net_NetworkStatsService(env) < 0) {
55 return JNI_ERR;
56 }
57 }
58
Remi NGUYEN VANa985e582020-12-21 18:40:08 +090059 return JNI_VERSION_1_6;
60}
61
Lorenzo Colitti75a34a62021-02-15 17:07:57 +090062};