NetworkStatsService: Fix getDetailedUidStats to take VPNs into account.
(cherry picked from commit 2af0b66aba)
This API is similar to one provided by NetworkStatsFactory with the
difference that NSS also migrates traffic from VPN UID to other apps.
Since traffic can only be migrated over NetworkStats delta, NSS
therefore maintains NetworkStats snapshot across all UIDs/ifaces/tags.
This snapshot gets updated whenever NSS records a new snapshot
(based on various hooks such as VPN updating its underlying networks,
network getting lost, etc.), or getDetailedUidStats API is invoked by
one of its callers.
Bug: 113122541
Bug: 120145746
Test: atest FrameworksNetTests
Test: manually verified that battery stats are migrating traffic off of
TUN (after patching above CL where we point BatteryStats to use this
API).
Change-Id: I4b8d7c5b6905a4a12c1806dfd35c2c4c63610404
This commit is contained in:
committed by
Lorenzo Colitti
parent
97482de1fd
commit
e7094673d5
@@ -812,6 +812,37 @@ public class NetworkStatsTest {
|
||||
assertEquals(entry2, stats.getValues(1, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilterDebugEntries() {
|
||||
NetworkStats.Entry entry1 = new NetworkStats.Entry(
|
||||
"test1", 10100, SET_DEFAULT, TAG_NONE, METERED_NO, ROAMING_NO,
|
||||
DEFAULT_NETWORK_NO, 50000L, 25L, 100000L, 50L, 0L);
|
||||
|
||||
NetworkStats.Entry entry2 = new NetworkStats.Entry(
|
||||
"test2", 10101, SET_DBG_VPN_IN, TAG_NONE, METERED_NO, ROAMING_NO,
|
||||
DEFAULT_NETWORK_NO, 50000L, 25L, 100000L, 50L, 0L);
|
||||
|
||||
NetworkStats.Entry entry3 = new NetworkStats.Entry(
|
||||
"test2", 10101, SET_DEFAULT, TAG_NONE, METERED_NO, ROAMING_NO,
|
||||
DEFAULT_NETWORK_NO, 50000L, 25L, 100000L, 50L, 0L);
|
||||
|
||||
NetworkStats.Entry entry4 = new NetworkStats.Entry(
|
||||
"test2", 10101, SET_DBG_VPN_OUT, TAG_NONE, METERED_NO, ROAMING_NO,
|
||||
DEFAULT_NETWORK_NO, 50000L, 25L, 100000L, 50L, 0L);
|
||||
|
||||
NetworkStats stats = new NetworkStats(TEST_START, 4)
|
||||
.addValues(entry1)
|
||||
.addValues(entry2)
|
||||
.addValues(entry3)
|
||||
.addValues(entry4);
|
||||
|
||||
stats.filterDebugEntries();
|
||||
|
||||
assertEquals(2, stats.size());
|
||||
assertEquals(entry1, stats.getValues(0, null));
|
||||
assertEquals(entry3, stats.getValues(1, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApply464xlatAdjustments() {
|
||||
final String v4Iface = "v4-wlan0";
|
||||
|
||||
Reference in New Issue
Block a user