diff --git a/Tethering/apex/Android.bp b/Tethering/apex/Android.bp index 53a14ad9db..c0f68fde2c 100644 --- a/Tethering/apex/Android.bp +++ b/Tethering/apex/Android.bp @@ -53,7 +53,6 @@ apex { jni_libs: [ "libservice-connectivity", "libcom_android_connectivity_com_android_net_module_util_jni", - "libtraffic_controller_jni", ], }, both: { diff --git a/service/Android.bp b/service/Android.bp index 33d4b662a3..d940003318 100644 --- a/service/Android.bp +++ b/service/Android.bp @@ -57,23 +57,29 @@ cc_library_shared { "-Wthread-safety", ], srcs: [ - "jni/com_android_server_TestNetworkService.cpp", + "jni/com_android_server_BpfNetMaps.cpp", "jni/com_android_server_connectivity_ClatCoordinator.cpp", + "jni/com_android_server_TestNetworkService.cpp", "jni/onload.cpp", ], stl: "libc++_static", header_libs: [ + "bpf_connectivity_headers", "libbase_headers", ], static_libs: [ "libbase", "libclat", "libip_checksum", + "libnetdutils", "libnetjniutils", + "libtraffic_controller", + "netd_aidl_interface-lateststable-ndk", ], shared_libs: [ "liblog", "libnativehelper", + "libutils", ], apex_available: [ "com.android.tethering", diff --git a/service/native/jni/com_android_server_BpfNetMaps.cpp b/service/jni/com_android_server_BpfNetMaps.cpp similarity index 100% rename from service/native/jni/com_android_server_BpfNetMaps.cpp rename to service/jni/com_android_server_BpfNetMaps.cpp diff --git a/service/jni/com_android_server_TestNetworkService.cpp b/service/jni/com_android_server_TestNetworkService.cpp index 1a0de32ae9..4efd0e1a53 100644 --- a/service/jni/com_android_server_TestNetworkService.cpp +++ b/service/jni/com_android_server_TestNetworkService.cpp @@ -98,7 +98,7 @@ static const JNINativeMethod gMethods[] = { {"jniCreateTunTap", "(ZLjava/lang/String;)I", (void*)create}, }; -int register_android_server_TestNetworkService(JNIEnv* env) { +int register_com_android_server_TestNetworkService(JNIEnv* env) { return jniRegisterNativeMethods(env, "com/android/server/TestNetworkService", gMethods, NELEM(gMethods)); } diff --git a/service/jni/com_android_server_connectivity_ClatCoordinator.cpp b/service/jni/com_android_server_connectivity_ClatCoordinator.cpp index b445462a9a..ee512ec95f 100644 --- a/service/jni/com_android_server_connectivity_ClatCoordinator.cpp +++ b/service/jni/com_android_server_connectivity_ClatCoordinator.cpp @@ -519,7 +519,7 @@ static const JNINativeMethod gMethods[] = { (void*)com_android_server_connectivity_ClatCoordinator_stopClatd}, }; -int register_android_server_connectivity_ClatCoordinator(JNIEnv* env) { +int register_com_android_server_connectivity_ClatCoordinator(JNIEnv* env) { return jniRegisterNativeMethods(env, "com/android/server/connectivity/ClatCoordinator", gMethods, NELEM(gMethods)); } diff --git a/service/jni/onload.cpp b/service/jni/onload.cpp index 04d9671fad..facdad7041 100644 --- a/service/jni/onload.cpp +++ b/service/jni/onload.cpp @@ -19,8 +19,9 @@ namespace android { -int register_android_server_TestNetworkService(JNIEnv* env); -int register_android_server_connectivity_ClatCoordinator(JNIEnv* env); +int register_com_android_server_TestNetworkService(JNIEnv* env); +int register_com_android_server_connectivity_ClatCoordinator(JNIEnv* env); +int register_com_android_server_BpfNetMaps(JNIEnv* env); extern "C" jint JNI_OnLoad(JavaVM* vm, void*) { JNIEnv *env; @@ -29,11 +30,15 @@ extern "C" jint JNI_OnLoad(JavaVM* vm, void*) { return JNI_ERR; } - if (register_android_server_TestNetworkService(env) < 0) { + if (register_com_android_server_TestNetworkService(env) < 0) { return JNI_ERR; } - if (register_android_server_connectivity_ClatCoordinator(env) < 0) { + if (register_com_android_server_connectivity_ClatCoordinator(env) < 0) { + return JNI_ERR; + } + + if (register_com_android_server_BpfNetMaps(env) < 0) { return JNI_ERR; } diff --git a/service/native/Android.bp b/service/native/Android.bp index b49457da5b..0e805e2903 100644 --- a/service/native/Android.bp +++ b/service/native/Android.bp @@ -52,37 +52,6 @@ cc_library { min_sdk_version: "30", } -cc_library_shared { - name: "libtraffic_controller_jni", - cflags: [ - "-Wall", - "-Werror", - "-Wno-unused-parameter", - "-Wthread-safety", - ], - srcs: [ - "jni/*.cpp", - ], - header_libs: [ - "bpf_connectivity_headers", - ], - static_libs: [ - "libnetdutils", - "libtraffic_controller", - "netd_aidl_interface-lateststable-ndk", - ], - shared_libs: [ - "libbase", - "liblog", - "libutils", - "libnativehelper", - ], - apex_available: [ - "com.android.tethering", - ], - min_sdk_version: "30", -} - cc_test { name: "traffic_controller_unit_test", test_suites: ["general-tests"], diff --git a/service/native/jni/onload.cpp b/service/native/jni/onload.cpp deleted file mode 100644 index df7c77bfb6..0000000000 --- a/service/native/jni/onload.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2022 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_TAG "TrafficControllerJni" - -#include -#include - -#include "utils/Log.h" - -namespace android { - -int register_com_android_server_BpfNetMaps(JNIEnv* env); - -extern "C" jint JNI_OnLoad(JavaVM* vm, void*) { - JNIEnv *env; - if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { - ALOGE("%s: ERROR: GetEnv failed", __func__); - return JNI_ERR; - } - - if (register_com_android_server_BpfNetMaps(env) < 0) - return JNI_ERR; - - return JNI_VERSION_1_6; -} - -}; // namespace android