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:
@@ -1084,13 +1084,13 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
if (callingUid != android.os.Process.SYSTEM_UID && callingUid != uid) {
|
if (callingUid != android.os.Process.SYSTEM_UID && callingUid != uid) {
|
||||||
return UNSUPPORTED;
|
return UNSUPPORTED;
|
||||||
}
|
}
|
||||||
return nativeGetUidStat(uid, type, checkBpfStatsEnable());
|
return nativeGetUidStat(uid, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getIfaceStats(@NonNull String iface, int type) {
|
public long getIfaceStats(@NonNull String iface, int type) {
|
||||||
Objects.requireNonNull(iface);
|
Objects.requireNonNull(iface);
|
||||||
long nativeIfaceStats = nativeGetIfaceStat(iface, type, checkBpfStatsEnable());
|
long nativeIfaceStats = nativeGetIfaceStat(iface, type);
|
||||||
if (nativeIfaceStats == -1) {
|
if (nativeIfaceStats == -1) {
|
||||||
return nativeIfaceStats;
|
return nativeIfaceStats;
|
||||||
} else {
|
} else {
|
||||||
@@ -1104,7 +1104,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getTotalStats(int type) {
|
public long getTotalStats(int type) {
|
||||||
long nativeTotalStats = nativeGetTotalStat(type, checkBpfStatsEnable());
|
long nativeTotalStats = nativeGetTotalStat(type);
|
||||||
if (nativeTotalStats == -1) {
|
if (nativeTotalStats == -1) {
|
||||||
return nativeTotalStats;
|
return nativeTotalStats;
|
||||||
} else {
|
} else {
|
||||||
@@ -1137,10 +1137,6 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkBpfStatsEnable() {
|
|
||||||
return mUseBpfTrafficStats;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update {@link NetworkStatsRecorder} and {@link #mGlobalAlertBytes} to
|
* Update {@link NetworkStatsRecorder} and {@link #mGlobalAlertBytes} to
|
||||||
* reflect current {@link #mPersistThreshold} value. Always defers 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 nativeGetTotalStat(int type);
|
||||||
private static native long nativeGetIfaceStat(String iface, int type, boolean useBpfStats);
|
private static native long nativeGetIfaceStat(String iface, int type);
|
||||||
private static native long nativeGetUidStat(int uid, int type, boolean useBpfStats);
|
private static native long nativeGetUidStat(int uid, int type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 = {};
|
Stats stats = {};
|
||||||
|
|
||||||
if (bpfGetIfaceStats(NULL, &stats) == 0) {
|
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,
|
static jlong getIfaceStat(JNIEnv* env, jclass clazz, jstring iface, jint type) {
|
||||||
jboolean useBpfStats) {
|
|
||||||
ScopedUtfChars iface8(env, iface);
|
ScopedUtfChars iface8(env, iface);
|
||||||
if (iface8.c_str() == NULL) {
|
if (iface8.c_str() == NULL) {
|
||||||
return UNKNOWN;
|
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 = {};
|
Stats stats = {};
|
||||||
|
|
||||||
if (bpfGetUidStats(uid, &stats) == 0) {
|
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[] = {
|
static const JNINativeMethod gMethods[] = {
|
||||||
{"nativeGetTotalStat", "(IZ)J", (void*) getTotalStat},
|
{"nativeGetTotalStat", "(I)J", (void*)getTotalStat},
|
||||||
{"nativeGetIfaceStat", "(Ljava/lang/String;IZ)J", (void*) getIfaceStat},
|
{"nativeGetIfaceStat", "(Ljava/lang/String;I)J", (void*)getIfaceStat},
|
||||||
{"nativeGetUidStat", "(IIZ)J", (void*) getUidStat},
|
{"nativeGetUidStat", "(II)J", (void*)getUidStat},
|
||||||
};
|
};
|
||||||
|
|
||||||
int register_android_server_net_NetworkStatsService(JNIEnv* env) {
|
int register_android_server_net_NetworkStatsService(JNIEnv* env) {
|
||||||
|
|||||||
Reference in New Issue
Block a user