From a24baedab8a9ad6dd3c3aa99d95672b5efa156b2 Mon Sep 17 00:00:00 2001 From: Remi NGUYEN VAN Date: Wed, 2 Feb 2022 13:22:57 +0900 Subject: [PATCH] Move networkstats JNI to connectivity module Reorganize networkstats JNI so it can be included in the connectivity module. Bug: 197717846 Test: m Change-Id: I815ea379f3d9915041c80ac5e743ce62e05f4cf8 Merged-In: I815ea379f3d9915041c80ac5e743ce62e05f4cf8 --- framework-t/Sources.bp | 5 ++-- service-t/Sources.bp | 24 +++++++++++++++++++ ...android_server_net_NetworkStatsFactory.cpp | 0 ...android_server_net_NetworkStatsService.cpp | 0 .../server/net/NetworkStatsFactory.java | 4 ++++ .../server/net/NetworkStatsService.java | 4 ++++ 6 files changed, 34 insertions(+), 3 deletions(-) rename {services/core => service-t}/jni/com_android_server_net_NetworkStatsFactory.cpp (100%) rename {services/core => service-t}/jni/com_android_server_net_NetworkStatsService.cpp (100%) diff --git a/framework-t/Sources.bp b/framework-t/Sources.bp index b30e54d20b..66527802a0 100644 --- a/framework-t/Sources.bp +++ b/framework-t/Sources.bp @@ -194,10 +194,9 @@ cc_library_shared { "jni/onload.cpp", ], shared_libs: [ + "libandroid", "liblog", - ], - static_libs: [ - "libnativehelper_compat_libc++", + "libnativehelper", ], stl: "none", apex_available: [ diff --git a/service-t/Sources.bp b/service-t/Sources.bp index 502c56a7fb..5100e7c5b9 100644 --- a/service-t/Sources.bp +++ b/service-t/Sources.bp @@ -40,6 +40,30 @@ filegroup { ], } +// For test code only. +filegroup { + name: "lib_networkStatsFactory_native", + srcs: [ + "jni/com_android_server_net_NetworkStatsFactory.cpp", + ], + path: "jni", + visibility: [ + "//packages/modules/Connectivity:__subpackages__", + ], +} + +filegroup { + name: "services.connectivity-netstats-jni-sources", + srcs: [ + "jni/com_android_server_net_NetworkStatsFactory.cpp", + "jni/com_android_server_net_NetworkStatsService.cpp", + ], + path: "jni", + visibility: [ + "//packages/modules/Connectivity:__subpackages__", + ], +} + // Nsd related libraries. filegroup { diff --git a/services/core/jni/com_android_server_net_NetworkStatsFactory.cpp b/service-t/jni/com_android_server_net_NetworkStatsFactory.cpp similarity index 100% rename from services/core/jni/com_android_server_net_NetworkStatsFactory.cpp rename to service-t/jni/com_android_server_net_NetworkStatsFactory.cpp diff --git a/services/core/jni/com_android_server_net_NetworkStatsService.cpp b/service-t/jni/com_android_server_net_NetworkStatsService.cpp similarity index 100% rename from services/core/jni/com_android_server_net_NetworkStatsService.cpp rename to service-t/jni/com_android_server_net_NetworkStatsService.cpp diff --git a/service-t/src/com/android/server/net/NetworkStatsFactory.java b/service-t/src/com/android/server/net/NetworkStatsFactory.java index 668d1cba92..151c90dd41 100644 --- a/service-t/src/com/android/server/net/NetworkStatsFactory.java +++ b/service-t/src/com/android/server/net/NetworkStatsFactory.java @@ -54,6 +54,10 @@ import java.util.concurrent.ConcurrentHashMap; * @hide */ public class NetworkStatsFactory { + static { + System.loadLibrary("service-connectivity"); + } + private static final String TAG = "NetworkStatsFactory"; private static final boolean USE_NATIVE_PARSING = true; diff --git a/service-t/src/com/android/server/net/NetworkStatsService.java b/service-t/src/com/android/server/net/NetworkStatsService.java index c441c81602..3e4687f9d2 100644 --- a/service-t/src/com/android/server/net/NetworkStatsService.java +++ b/service-t/src/com/android/server/net/NetworkStatsService.java @@ -173,6 +173,10 @@ import java.util.concurrent.TimeUnit; */ @TargetApi(Build.VERSION_CODES.TIRAMISU) public class NetworkStatsService extends INetworkStatsService.Stub { + static { + System.loadLibrary("service-connectivity"); + } + static final String TAG = "NetworkStats"; static final boolean LOGD = Log.isLoggable(TAG, Log.DEBUG); static final boolean LOGV = Log.isLoggable(TAG, Log.VERBOSE);