bpf is required - remove checkBpfStatsEnable()

Test: git grep 'nativeGetTotalStat|nativeGetIfaceStat|nativeGetUidStat'
    - shows all locations have been updated
  git grep 'checkBpfStatsEnable'
    - find nothings relevant (just services/art-profile)
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ib584ea57c39d5ab0605787b05133097fd2c82a39
This commit is contained in:
Maciej Żenczykowski
2021-04-14 07:34:00 -07:00
parent b6d8c8c7a8
commit 667b94d131
2 changed files with 12 additions and 17 deletions

View File

@@ -1084,13 +1084,13 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
if (callingUid != android.os.Process.SYSTEM_UID && callingUid != uid) {
return UNSUPPORTED;
}
return nativeGetUidStat(uid, type, checkBpfStatsEnable());
return nativeGetUidStat(uid, type);
}
@Override
public long getIfaceStats(@NonNull String iface, int type) {
Objects.requireNonNull(iface);
long nativeIfaceStats = nativeGetIfaceStat(iface, type, checkBpfStatsEnable());
long nativeIfaceStats = nativeGetIfaceStat(iface, type);
if (nativeIfaceStats == -1) {
return nativeIfaceStats;
} else {
@@ -1104,7 +1104,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
@Override
public long getTotalStats(int type) {
long nativeTotalStats = nativeGetTotalStat(type, checkBpfStatsEnable());
long nativeTotalStats = nativeGetTotalStat(type);
if (nativeTotalStats == -1) {
return nativeTotalStats;
} else {
@@ -1137,10 +1137,6 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
}
}
private boolean checkBpfStatsEnable() {
return mUseBpfTrafficStats;
}
/**
* Update {@link NetworkStatsRecorder} and {@link #mGlobalAlertBytes} to
* reflect current {@link #mPersistThreshold} value. Always defers to
@@ -2249,7 +2245,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
}
}
private static native long nativeGetTotalStat(int type, boolean useBpfStats);
private static native long nativeGetIfaceStat(String iface, int type, boolean useBpfStats);
private static native long nativeGetUidStat(int uid, int type, boolean useBpfStats);
private static native long nativeGetTotalStat(int type);
private static native long nativeGetIfaceStat(String iface, int type);
private static native long nativeGetUidStat(int uid, int type);
}

View File

@@ -69,7 +69,7 @@ static uint64_t getStatsType(Stats* stats, StatsType type) {
}
}
static jlong getTotalStat(JNIEnv* env, jclass clazz, jint type, jboolean useBpfStats) {
static jlong getTotalStat(JNIEnv* env, jclass clazz, jint type) {
Stats stats = {};
if (bpfGetIfaceStats(NULL, &stats) == 0) {
@@ -79,8 +79,7 @@ static jlong getTotalStat(JNIEnv* env, jclass clazz, jint type, jboolean useBpfS
}
}
static jlong getIfaceStat(JNIEnv* env, jclass clazz, jstring iface, jint type,
jboolean useBpfStats) {
static jlong getIfaceStat(JNIEnv* env, jclass clazz, jstring iface, jint type) {
ScopedUtfChars iface8(env, iface);
if (iface8.c_str() == NULL) {
return UNKNOWN;
@@ -95,7 +94,7 @@ static jlong getIfaceStat(JNIEnv* env, jclass clazz, jstring iface, jint type,
}
}
static jlong getUidStat(JNIEnv* env, jclass clazz, jint uid, jint type, jboolean useBpfStats) {
static jlong getUidStat(JNIEnv* env, jclass clazz, jint uid, jint type) {
Stats stats = {};
if (bpfGetUidStats(uid, &stats) == 0) {
@@ -106,9 +105,9 @@ static jlong getUidStat(JNIEnv* env, jclass clazz, jint uid, jint type, jboolean
}
static const JNINativeMethod gMethods[] = {
{"nativeGetTotalStat", "(IZ)J", (void*) getTotalStat},
{"nativeGetIfaceStat", "(Ljava/lang/String;IZ)J", (void*) getIfaceStat},
{"nativeGetUidStat", "(IIZ)J", (void*) getUidStat},
{"nativeGetTotalStat", "(I)J", (void*)getTotalStat},
{"nativeGetIfaceStat", "(Ljava/lang/String;I)J", (void*)getIfaceStat},
{"nativeGetUidStat", "(II)J", (void*)getUidStat},
};
int register_android_server_net_NetworkStatsService(JNIEnv* env) {