diff --git a/service-t/jni/com_android_server_net_NetworkStatsService.cpp b/service-t/jni/com_android_server_net_NetworkStatsService.cpp index 17b48757d03976085a30a1788e86b476c6acd890..028642fe2ce2503a74d4ac2142080b257c9b3ae3 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 @@ using android::bpf::NetworkTraceHandler; 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"); @@ -100,6 +103,11 @@ static void nativeInitNetworkTracing(JNIEnv* env, jclass clazz) { } static const JNINativeMethod gMethods[] = { + { + "nativeRegisterIface", + "(Ljava/lang/String;)V", + (void*)nativeRegisterIface + }, { "nativeGetTotalStat", "()Landroid/net/NetworkStats$Entry;", diff --git a/service-t/src/com/android/server/net/NetworkStatsService.java b/service-t/src/com/android/server/net/NetworkStatsService.java index 6742246a334352246329da2fbf5d35dd2b7431ec..7b24315241c051ecf2dd203229812edc9588a4f4 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 @@ public class NetworkStatsService extends INetworkStatsService.Stub { // 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 @@ public class NetworkStatsService extends INetworkStatsService.Stub { // 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 @@ public class NetworkStatsService extends INetworkStatsService.Stub { } // TODO: Read stats by using BpfNetMapsReader. + private static native void nativeRegisterIface(String iface); @Nullable private static native NetworkStats.Entry nativeGetTotalStat(); @Nullable