NetworkStatsService - add void nativeRegisterIface(iface) am: bfb3a3c5b4
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2924886
Change-Id: Ic8551cc6b1085e161234e4f72fc19bcc2ecc4f1c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/service-t/jni/com_android_server_net_NetworkStatsService.cpp b/service-t/jni/com_android_server_net_NetworkStatsService.cpp
index 17b4875..028642f 100644
--- a/service-t/jni/com_android_server_net_NetworkStatsService.cpp
+++ b/service-t/jni/com_android_server_net_NetworkStatsService.cpp
@@ -38,6 +38,9 @@
namespace android {
+static void nativeRegisterIface(JNIEnv* env, jclass clazz, jstring iface) {
+}
+
static jobject statsValueToEntry(JNIEnv* env, StatsValue* stats) {
// Find the Java class that represents the structure
jclass gEntryClass = env->FindClass("android/net/NetworkStats$Entry");
@@ -101,6 +104,11 @@
static const JNINativeMethod gMethods[] = {
{
+ "nativeRegisterIface",
+ "(Ljava/lang/String;)V",
+ (void*)nativeRegisterIface
+ },
+ {
"nativeGetTotalStat",
"()Landroid/net/NetworkStats$Entry;",
(void*)nativeGetTotalStat
diff --git a/service-t/src/com/android/server/net/NetworkStatsService.java b/service-t/src/com/android/server/net/NetworkStatsService.java
index 6742246..7b24315 100644
--- a/service-t/src/com/android/server/net/NetworkStatsService.java
+++ b/service-t/src/com/android/server/net/NetworkStatsService.java
@@ -2211,6 +2211,7 @@
// both total usage and UID details.
final String baseIface = snapshot.getLinkProperties().getInterfaceName();
if (baseIface != null) {
+ nativeRegisterIface(baseIface);
findOrCreateNetworkIdentitySet(mActiveIfaces, baseIface).add(ident);
findOrCreateNetworkIdentitySet(mActiveUidIfaces, baseIface).add(ident);
@@ -2282,6 +2283,7 @@
// baseIface has been handled, so ignore it.
if (TextUtils.equals(baseIface, iface)) continue;
if (iface != null) {
+ nativeRegisterIface(iface);
findOrCreateNetworkIdentitySet(mActiveIfaces, iface).add(ident);
findOrCreateNetworkIdentitySet(mActiveUidIfaces, iface).add(ident);
if (isMobile) {
@@ -3415,6 +3417,7 @@
}
// TODO: Read stats by using BpfNetMapsReader.
+ private static native void nativeRegisterIface(String iface);
@Nullable
private static native NetworkStats.Entry nativeGetTotalStat();
@Nullable