Move stats map A/B dump to NetworkStatsService
Map status dump will do access check if map is null.
This could show different message from the current dump output.
Information in map content dump does not change
$ dumpsys connectivity trafficcontroller
....
mStatsMapA:
ifaceIndex ifaceName tag_hex uid_int cnt_set rxBytes rxPackets txBytes txPackets
20 wlan0 0x0 1051 0 144 2 312 4
10 rmnet_data0 0x0 0 0 0 0 48 1
20 wlan0 0x0 0 0 0 0 136 2
20 wlan0 0xffffff82 1051 0 144 2 312 4
mStatsMapB:
ifaceIndex ifaceName tag_hex uid_int cnt_set rxBytes rxPackets txBytes txPackets
....
$ dumpsys netstats
....
mStatsMapA:
ifaceIndex ifaceName tag_hex uid_int cnt_set rxBytes rxPackets txBytes txPackets
20 wlan0 0x0 1051 0 144 2 312 4
10 rmnet_data0 0x0 0 0 0 0 48 1
20 wlan0 0x0 0 0 0 0 136 2
20 wlan0 0xffffff82 1051 0 144 2 312 4
mStatsMapB:
ifaceIndex ifaceName tag_hex uid_int cnt_set rxBytes rxPackets txBytes txPackets
....
Bug: 217624062
Test: dumpsys netstats, dumpstate, atest NetworkStatsServiceTest
Change-Id: Ifbd45f0ad6dd9c519a15a7680cf0ea99fb5f5dcf
This commit is contained in:
@@ -2528,4 +2528,28 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
||||
assertDumpContains(dump, "uid rxBytes rxPackets txBytes txPackets");
|
||||
assertDumpContains(dump, "1002 10000 10 6000 6");
|
||||
}
|
||||
|
||||
private void doTestDumpStatsMap(final String expectedIfaceName) throws ErrnoException {
|
||||
initBpfMapsWithTagData(UID_BLUE);
|
||||
|
||||
final String dump = getDump();
|
||||
assertDumpContains(dump, "mStatsMapA: OK");
|
||||
assertDumpContains(dump, "mStatsMapB: OK");
|
||||
assertDumpContains(dump,
|
||||
"ifaceIndex ifaceName tag_hex uid_int cnt_set rxBytes rxPackets txBytes txPackets");
|
||||
assertDumpContains(dump, "10 " + expectedIfaceName + " 0x2 1002 0 5000 5 3000 3");
|
||||
assertDumpContains(dump, "10 " + expectedIfaceName + " 0x1 1002 0 5000 5 3000 3");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDumpStatsMap() throws ErrnoException {
|
||||
doReturn("wlan0").when(mBpfInterfaceMapUpdater).getIfNameByIndex(10 /* index */);
|
||||
doTestDumpStatsMap("wlan0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDumpStatsMapUnknownInterface() throws ErrnoException {
|
||||
doReturn(null).when(mBpfInterfaceMapUpdater).getIfNameByIndex(10 /* index */);
|
||||
doTestDumpStatsMap("unknown");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user