diff --git a/Tethering/Android.bp b/Tethering/Android.bp index 06a1f11a8a..3c49383e80 100644 --- a/Tethering/Android.bp +++ b/Tethering/Android.bp @@ -43,6 +43,7 @@ java_defaults { "android.hardware.tetheroffload.control-V1.1-java", "net-utils-framework-common", "net-utils-device-common", + "net-utils-device-common-bpf", "net-utils-device-common-netlink", "netd-client", ], @@ -84,7 +85,7 @@ android_library { // Due to b/143733063, APK can't access a jni lib that is in APEX (but not in the APK). cc_library { - name: "libtetherutilsjni", + name: "libcom_android_networkstack_tethering_util_jni", sdk_version: "30", apex_available: [ "//apex_available:platform", // Used by InProcessTethering @@ -103,7 +104,7 @@ cc_library { "libnativehelper_compat_libc++", ], static_libs: [ - "libbpfmapjni", + "libnet_utils_device_common_bpfjni", "libnetjniutils", ], @@ -133,7 +134,7 @@ java_defaults { name: "TetheringAppDefaults", privileged: true, jni_libs: [ - "libtetherutilsjni", + "libcom_android_networkstack_tethering_util_jni", ], resource_dirs: [ "res", diff --git a/Tethering/src/com/android/networkstack/tethering/BpfCoordinator.java b/Tethering/src/com/android/networkstack/tethering/BpfCoordinator.java index 2c510fe527..8c8a2fd101 100644 --- a/Tethering/src/com/android/networkstack/tethering/BpfCoordinator.java +++ b/Tethering/src/com/android/networkstack/tethering/BpfCoordinator.java @@ -32,6 +32,7 @@ import static com.android.networkstack.tethering.BpfUtils.DOWNSTREAM; import static com.android.networkstack.tethering.BpfUtils.UPSTREAM; import static com.android.networkstack.tethering.TetheringConfiguration.DEFAULT_TETHER_OFFLOAD_POLL_INTERVAL_MS; import static com.android.networkstack.tethering.UpstreamNetworkState.isVcnInterface; +import static com.android.networkstack.tethering.util.TetheringUtils.getTetheringJniLibraryName; import android.app.usage.NetworkStatsManager; import android.net.INetd; @@ -99,7 +100,7 @@ public class BpfCoordinator { // TetherService, but for tests it needs to be either loaded here or loaded by every test. // TODO: is there a better way? static { - System.loadLibrary("tetherutilsjni"); + System.loadLibrary(getTetheringJniLibraryName()); } private static final String TAG = BpfCoordinator.class.getSimpleName(); diff --git a/Tethering/src/com/android/networkstack/tethering/BpfUtils.java b/Tethering/src/com/android/networkstack/tethering/BpfUtils.java index 0b44249458..4f095cf501 100644 --- a/Tethering/src/com/android/networkstack/tethering/BpfUtils.java +++ b/Tethering/src/com/android/networkstack/tethering/BpfUtils.java @@ -18,6 +18,8 @@ package com.android.networkstack.tethering; import static android.system.OsConstants.ETH_P_IP; import static android.system.OsConstants.ETH_P_IPV6; +import static com.android.networkstack.tethering.util.TetheringUtils.getTetheringJniLibraryName; + import android.net.util.InterfaceParams; import androidx.annotation.NonNull; @@ -31,7 +33,7 @@ import java.io.IOException; */ public class BpfUtils { static { - System.loadLibrary("tetherutilsjni"); + System.loadLibrary(getTetheringJniLibraryName()); } // For better code clarity when used for 'bool ingress' parameter. diff --git a/Tethering/src/com/android/networkstack/tethering/util/TetheringUtils.java b/Tethering/src/com/android/networkstack/tethering/util/TetheringUtils.java index a8945b1b93..66d67a1ce6 100644 --- a/Tethering/src/com/android/networkstack/tethering/util/TetheringUtils.java +++ b/Tethering/src/com/android/networkstack/tethering/util/TetheringUtils.java @@ -21,6 +21,7 @@ import android.util.Log; import androidx.annotation.NonNull; +import com.android.net.module.util.JniUtil; import com.android.networkstack.tethering.TetherStatsValue; import java.io.FileDescriptor; @@ -37,13 +38,18 @@ import java.util.Objects; */ public class TetheringUtils { static { - System.loadLibrary("tetherutilsjni"); + System.loadLibrary(getTetheringJniLibraryName()); } public static final byte[] ALL_NODES = new byte[] { (byte) 0xff, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + /** The name should be com_android_networkstack_tethering_util_jni. */ + public static String getTetheringJniLibraryName() { + return JniUtil.getJniLibraryName(TetheringUtils.class.getPackage()); + } + /** * Configures a socket for receiving and sending ICMPv6 neighbor advertisments. * @param fd the socket's {@link FileDescriptor}. diff --git a/Tethering/tests/integration/Android.bp b/Tethering/tests/integration/Android.bp index 7e8c65b713..a2bd1a5e2d 100644 --- a/Tethering/tests/integration/Android.bp +++ b/Tethering/tests/integration/Android.bp @@ -142,7 +142,7 @@ android_test { "libstaticjvmtiagent", // For NetworkStackUtils included in NetworkStackBase "libnetworkstackutilsjni", - "libtetherutilsjni", + "libcom_android_networkstack_tethering_util_jni", ], compile_multilib: "both", manifest: "AndroidManifest_coverage.xml", diff --git a/Tethering/tests/privileged/Android.bp b/Tethering/tests/privileged/Android.bp index 8e29ed3730..214b014c14 100644 --- a/Tethering/tests/privileged/Android.bp +++ b/Tethering/tests/privileged/Android.bp @@ -23,7 +23,7 @@ java_defaults { jni_libs: [ "libdexmakerjvmtiagent", "libstaticjvmtiagent", - "libtetherutilsjni", + "libcom_android_networkstack_tethering_util_jni", ], jni_uses_sdk_apis: true, jarjar_rules: ":TetheringTestsJarJarRules", diff --git a/Tethering/tests/privileged/src/android/net/ip/DadProxyTest.java b/Tethering/tests/privileged/src/android/net/ip/DadProxyTest.java index 59974bfca5..eb9cf711f7 100644 --- a/Tethering/tests/privileged/src/android/net/ip/DadProxyTest.java +++ b/Tethering/tests/privileged/src/android/net/ip/DadProxyTest.java @@ -20,6 +20,7 @@ import static android.system.OsConstants.IPPROTO_ICMPV6; import static com.android.net.module.util.IpUtils.icmpv6Checksum; import static com.android.net.module.util.NetworkStackConstants.ETHER_SRC_ADDR_OFFSET; +import static com.android.networkstack.tethering.util.TetheringUtils.getTetheringJniLibraryName; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -80,7 +81,7 @@ public class DadProxyTest { @BeforeClass public static void setupOnce() { - System.loadLibrary("tetherutilsjni"); + System.loadLibrary(getTetheringJniLibraryName()); final Instrumentation inst = InstrumentationRegistry.getInstrumentation(); final IBinder netdIBinder = diff --git a/Tethering/tests/privileged/src/com/android/networkstack/tethering/BpfMapTest.java b/Tethering/tests/privileged/src/com/android/networkstack/tethering/BpfMapTest.java index 184d045904..646c75f445 100644 --- a/Tethering/tests/privileged/src/com/android/networkstack/tethering/BpfMapTest.java +++ b/Tethering/tests/privileged/src/com/android/networkstack/tethering/BpfMapTest.java @@ -18,6 +18,8 @@ package com.android.networkstack.tethering; import static android.system.OsConstants.ETH_P_IPV6; +import static com.android.networkstack.tethering.util.TetheringUtils.getTetheringJniLibraryName; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -59,7 +61,7 @@ public final class BpfMapTest { @BeforeClass public static void setupOnce() { - System.loadLibrary("tetherutilsjni"); + System.loadLibrary(getTetheringJniLibraryName()); } @Before diff --git a/Tethering/tests/unit/Android.bp b/Tethering/tests/unit/Android.bp index 85169f9e4d..228f3fde40 100644 --- a/Tethering/tests/unit/Android.bp +++ b/Tethering/tests/unit/Android.bp @@ -75,7 +75,7 @@ java_defaults { // For mockito extended "libdexmakerjvmtiagent", "libstaticjvmtiagent", - "libtetherutilsjni", + "libcom_android_networkstack_tethering_util_jni", ], } diff --git a/tests/common/Android.bp b/tests/common/Android.bp index c4c72c83cf..f47f6b0400 100644 --- a/tests/common/Android.bp +++ b/tests/common/Android.bp @@ -89,7 +89,7 @@ android_test { "libstaticjvmtiagent", // For NetworkStackUtils included in NetworkStackBase "libnetworkstackutilsjni", - "libtetherutilsjni", + "libcom_android_networkstack_tethering_util_jni", // For framework tests "libservice-connectivity", ],