Move socket tagging implementation to mainline.
Currently, socket tagging is implemented in the framework. The
Java code is in NetworkManagmentSocketTagger.java and the JNI is
in libandroid and loaded by the general framework JNI loader.
- Move the Java implementation to TrafficStats, which is the only
caller of NetworkManagmentSocketTagger. This simplifies the
code a bit because a number of methods can be deleted.
- Move the JNI code to a new JNI library in the APEX. The library
depends only on the NDK and statically links the NDK-only
version of libnativehelper. Its size is only 5k on ARM and 10k
on ARM64.
- Temporarily make the framework depend on this library until the
rest of the T connectivity code moves to the APEX.
Test: atest NetworkUsageStatsTest CtsNetTestCases:TrafficStatsTest
Change-Id: I050c7c515237f68b78d08987bc443f50a7949c06
diff --git a/framework-t/Sources.bp b/framework-t/Sources.bp
index 223bdcd..327b1fb 100644
--- a/framework-t/Sources.bp
+++ b/framework-t/Sources.bp
@@ -39,7 +39,6 @@
"src/android/net/TrafficStats.java",
"src/android/net/UnderlyingNetworkInfo.*",
"src/android/net/netstats/**/*.*",
- "src/com/android/server/NetworkManagementSocketTagger.java",
],
path: "src",
visibility: [
@@ -176,3 +175,34 @@
"//packages/modules/Connectivity:__subpackages__",
],
}
+
+cc_library_shared {
+ name: "libframework-connectivity-tiramisu-jni",
+ min_sdk_version: "30",
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wno-unused-parameter",
+ // Don't warn about S API usage even with
+ // min_sdk 30: the library is only loaded
+ // on S+ devices
+ "-Wno-unguarded-availability",
+ "-Wthread-safety",
+ ],
+ srcs: [
+ "jni/android_net_TrafficStats.cpp",
+ "jni/onload.cpp",
+ ],
+ shared_libs: [
+ "liblog",
+ ],
+ static_libs: [
+ "libnativehelper_compat_libc++",
+ ],
+ stl: "none",
+ apex_available: [
+ "com.android.tethering",
+ // TODO: remove when ConnectivityT moves to APEX.
+ "//apex_available:platform",
+ ],
+}