diff options
| author | 2018-05-01 13:51:13 -0700 | |
|---|---|---|
| committer | 2018-05-01 19:48:03 -0700 | |
| commit | bbabc51b5b13fdce80157deffdcf7f35d7905641 (patch) | |
| tree | 85c217690769e9fef0a7b2be4672a486766fc6e1 | |
| parent | 804be4a3bc6f9f631bce5241cafa32f2408cbcb6 (diff) | |
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
Merged-In: Icb7eaeef0eeb9fdffd32a90316c76ee05bafffbe
(cherry picked from aosp commit b815c978b81eee4b1494bd0b9d25bfad52f08b72)
| -rw-r--r-- | core/java/com/android/internal/net/NetworkStatsFactory.java | 41 | ||||
| -rw-r--r-- | tests/net/java/com/android/internal/net/NetworkStatsFactoryTest.java | 14 |
2 files changed, 0 insertions, 55 deletions
diff --git a/core/java/com/android/internal/net/NetworkStatsFactory.java b/core/java/com/android/internal/net/NetworkStatsFactory.java index e5cbdde544c0..c4d08c7dc5d6 100644 --- a/core/java/com/android/internal/net/NetworkStatsFactory.java +++ b/core/java/com/android/internal/net/NetworkStatsFactory.java @@ -56,8 +56,6 @@ public class NetworkStatsFactory { private static final boolean USE_NATIVE_PARSING = true; 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}. */ private final File mStatsXtIfaceAll; /** Path to {@code /proc/net/xt_qtaguid/iface_stat_fmt}. */ @@ -133,51 +131,12 @@ public class NetworkStatsFactory { @VisibleForTesting public NetworkStatsFactory(File procRoot, boolean useBpfStats) { - mStatsIfaceDev = new File(procRoot, "net/dev"); mStatsXtIfaceAll = new File(procRoot, "net/xt_qtaguid/iface_stat_all"); mStatsXtIfaceFmt = new File(procRoot, "net/xt_qtaguid/iface_stat_fmt"); mStatsXtUid = new File(procRoot, "net/xt_qtaguid/stats"); 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 { final NetworkStats stats = new NetworkStats(SystemClock.elapsedRealtime(), 6); if (nativeReadNetworkStatsDev(stats) != 0) { diff --git a/tests/net/java/com/android/internal/net/NetworkStatsFactoryTest.java b/tests/net/java/com/android/internal/net/NetworkStatsFactoryTest.java index fc46b9c85980..788924b1d3bf 100644 --- a/tests/net/java/com/android/internal/net/NetworkStatsFactoryTest.java +++ b/tests/net/java/com/android/internal/net/NetworkStatsFactoryTest.java @@ -116,20 +116,6 @@ public class NetworkStatsFactoryTest { } @Test - public void testNetworkStatsSummary() throws Exception { - stageFile(R.raw.net_dev_typical, file("net/dev")); - - final NetworkStats stats = mFactory.readNetworkStatsIfaceDev(); - assertEquals(6, stats.size()); - assertStatsEntry(stats, "lo", UID_ALL, SET_ALL, TAG_NONE, 8308L, 8308L); - assertStatsEntry(stats, "rmnet0", UID_ALL, SET_ALL, TAG_NONE, 1507570L, 489339L); - assertStatsEntry(stats, "ifb0", UID_ALL, SET_ALL, TAG_NONE, 52454L, 0L); - assertStatsEntry(stats, "ifb1", UID_ALL, SET_ALL, TAG_NONE, 52454L, 0L); - assertStatsEntry(stats, "sit0", UID_ALL, SET_ALL, TAG_NONE, 0L, 0L); - assertStatsEntry(stats, "ip6tnl0", UID_ALL, SET_ALL, TAG_NONE, 0L, 0L); - } - - @Test public void testNetworkStatsSingle() throws Exception { stageFile(R.raw.xt_qtaguid_iface_typical, file("net/xt_qtaguid/iface_stat_all")); |