Remove the unused file parsing function
With the new xt_bpf support for iface stats. We no longer need to parse the per interface stats from /proc/net/dev. And since the old xt_qtaguid code path also not depend on it, we can completly remove that helper function since no caller is depending on it now. Bug: 72111305 Test: runtest frameworks-net -c com.android.internal.net.NetworkStatsFactoryTest Change-Id: Icb7eaeef0eeb9fdffd32a90316c76ee05bafffbe
This commit is contained in:
@@ -54,8 +54,6 @@ public class NetworkStatsFactory {
|
|||||||
private static final boolean USE_NATIVE_PARSING = true;
|
private static final boolean USE_NATIVE_PARSING = true;
|
||||||
private static final boolean SANITY_CHECK_NATIVE = false;
|
private static final boolean SANITY_CHECK_NATIVE = false;
|
||||||
|
|
||||||
/** Path to {@code /proc/net/dev}. */
|
|
||||||
private final File mStatsIfaceDev;
|
|
||||||
/** Path to {@code /proc/net/xt_qtaguid/iface_stat_all}. */
|
/** Path to {@code /proc/net/xt_qtaguid/iface_stat_all}. */
|
||||||
private final File mStatsXtIfaceAll;
|
private final File mStatsXtIfaceAll;
|
||||||
/** Path to {@code /proc/net/xt_qtaguid/iface_stat_fmt}. */
|
/** Path to {@code /proc/net/xt_qtaguid/iface_stat_fmt}. */
|
||||||
@@ -131,51 +129,12 @@ public class NetworkStatsFactory {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public NetworkStatsFactory(File procRoot, boolean useBpfStats) {
|
public NetworkStatsFactory(File procRoot, boolean useBpfStats) {
|
||||||
mStatsIfaceDev = new File(procRoot, "net/dev");
|
|
||||||
mStatsXtIfaceAll = new File(procRoot, "net/xt_qtaguid/iface_stat_all");
|
mStatsXtIfaceAll = new File(procRoot, "net/xt_qtaguid/iface_stat_all");
|
||||||
mStatsXtIfaceFmt = new File(procRoot, "net/xt_qtaguid/iface_stat_fmt");
|
mStatsXtIfaceFmt = new File(procRoot, "net/xt_qtaguid/iface_stat_fmt");
|
||||||
mStatsXtUid = new File(procRoot, "net/xt_qtaguid/stats");
|
mStatsXtUid = new File(procRoot, "net/xt_qtaguid/stats");
|
||||||
mUseBpfStats = useBpfStats;
|
mUseBpfStats = useBpfStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
public NetworkStats readNetworkStatsIfaceDev() throws IOException {
|
|
||||||
final StrictMode.ThreadPolicy savedPolicy = StrictMode.allowThreadDiskReads();
|
|
||||||
|
|
||||||
final NetworkStats stats = new NetworkStats(SystemClock.elapsedRealtime(), 6);
|
|
||||||
final NetworkStats.Entry entry = new NetworkStats.Entry();
|
|
||||||
|
|
||||||
BufferedReader reader = null;
|
|
||||||
try {
|
|
||||||
reader = new BufferedReader(new FileReader(mStatsIfaceDev));
|
|
||||||
|
|
||||||
// skip first two header lines
|
|
||||||
reader.readLine();
|
|
||||||
reader.readLine();
|
|
||||||
|
|
||||||
// parse remaining lines
|
|
||||||
String line;
|
|
||||||
while ((line = reader.readLine()) != null) {
|
|
||||||
String[] values = line.trim().split("\\:?\\s+");
|
|
||||||
entry.iface = values[0];
|
|
||||||
entry.uid = UID_ALL;
|
|
||||||
entry.set = SET_ALL;
|
|
||||||
entry.tag = TAG_NONE;
|
|
||||||
entry.rxBytes = Long.parseLong(values[1]);
|
|
||||||
entry.rxPackets = Long.parseLong(values[2]);
|
|
||||||
entry.txBytes = Long.parseLong(values[9]);
|
|
||||||
entry.txPackets = Long.parseLong(values[10]);
|
|
||||||
stats.addValues(entry);
|
|
||||||
}
|
|
||||||
} catch (NullPointerException|NumberFormatException e) {
|
|
||||||
throw new ProtocolException("problem parsing stats", e);
|
|
||||||
} finally {
|
|
||||||
IoUtils.closeQuietly(reader);
|
|
||||||
StrictMode.setThreadPolicy(savedPolicy);
|
|
||||||
}
|
|
||||||
return stats;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NetworkStats readBpfNetworkStatsDev() throws IOException {
|
public NetworkStats readBpfNetworkStatsDev() throws IOException {
|
||||||
final NetworkStats stats = new NetworkStats(SystemClock.elapsedRealtime(), 6);
|
final NetworkStats stats = new NetworkStats(SystemClock.elapsedRealtime(), 6);
|
||||||
if (nativeReadNetworkStatsDev(stats) != 0) {
|
if (nativeReadNetworkStatsDev(stats) != 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user