Filter debug entries for each vpn

NetworkStats calculation needs to filter out debug entries to
prevent over counting. While NetworkStatsFactory migrates data
usage over a VPN to the TUN network, NetworkStatsFactory does
not filter out debug entries per vpn which will cause debug
entries left and cause exception.

Bug: 152678151
Test: atest com.android.server.net.NetworkStatsFactoryTest
      and verify no exception
Change-Id: I3525edc385b07858b48c7add2d331c4b5a2e84ad
Merged-In: I3525edc385b07858b48c7add2d331c4b5a2e84ad
This commit is contained in:
Chiachang Wang
2020-04-28 22:15:56 +08:00
parent 0f3164c79d
commit abfadbefef

View File

@@ -385,11 +385,10 @@ public class NetworkStatsFactory {
// Migrate data usage over a VPN to the TUN network. // Migrate data usage over a VPN to the TUN network.
for (VpnInfo info : vpnArray) { for (VpnInfo info : vpnArray) {
delta.migrateTun(info.ownerUid, info.vpnIface, info.underlyingIfaces); delta.migrateTun(info.ownerUid, info.vpnIface, info.underlyingIfaces);
// Filter out debug entries as that may lead to over counting.
delta.filterDebugEntries();
} }
// Filter out debug entries as that may lead to over counting.
delta.filterDebugEntries();
// Update mTunAnd464xlatAdjustedStats with migrated delta. // Update mTunAnd464xlatAdjustedStats with migrated delta.
mTunAnd464xlatAdjustedStats.combineAllValues(delta); mTunAnd464xlatAdjustedStats.combineAllValues(delta);
mTunAnd464xlatAdjustedStats.setElapsedRealtime(uidDetailStats.getElapsedRealtime()); mTunAnd464xlatAdjustedStats.setElapsedRealtime(uidDetailStats.getElapsedRealtime());