Fix network usage stats on 464xlat tethered.

Usage stats corrections for 464xlat in NetworkStatsFactory are not applied
to tethered traffic. Add adjustments in NetworkStatsService. After
migrating external callers off NetworkStatsFactory, we will be able to
only apply adjustments in NetworkStatsService and remove stacked
interface tracking from NetworkStatsFactory.
Bug: 72107146
Fixes: 72107146
Test: runtest frameworks-net & manual - checked corrected network usage
Merged-In: Ieb25c41c651499fdd01225ae5ac21d95e3d823f5
Merged-In: I016722f3a0ae2ae0a1d48bfacc4fe07ee3578ef7
(cherry-pick of aosp I5ce450e616b4fddf21f2a491fe5d0c9e9f969bda)

Change-Id: Id41cf22a0f9a63cb1832e9375bfb045861f08e52
This commit is contained in:
Remi NGUYEN VAN
2018-02-27 16:47:22 +09:00
parent 4cac91f292
commit 0023be9ea9
3 changed files with 92 additions and 51 deletions

View File

@@ -148,7 +148,6 @@ import java.time.ZoneOffset;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
/**
* Collect and persist detailed network statistics, and provide this data to
@@ -769,7 +768,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
public NetworkStats getDetailedUidStats(String[] requiredIfaces) {
try {
final String[] ifacesToQuery =
NetworkStatsFactory.augmentWithStackedInterfacesLocked(requiredIfaces);
NetworkStatsFactory.augmentWithStackedInterfaces(requiredIfaces);
return getNetworkStatsUidDetail(ifacesToQuery);
} catch (RemoteException e) {
Log.wtf(TAG, "Error compiling UID stats", e);
@@ -1527,12 +1526,14 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
private NetworkStats getNetworkStatsUidDetail(String[] ifaces)
throws RemoteException {
// TODO: remove 464xlat adjustments from NetworkStatsFactory and apply all at once here.
final NetworkStats uidSnapshot = mNetworkManager.getNetworkStatsUidDetail(UID_ALL,
ifaces);
// fold tethering stats and operations into uid snapshot
final NetworkStats tetherSnapshot = getNetworkStatsTethering(STATS_PER_UID);
tetherSnapshot.filter(UID_ALL, ifaces, TAG_ALL);
NetworkStatsFactory.apply464xlatAdjustments(uidSnapshot, tetherSnapshot);
uidSnapshot.combineAllValues(tetherSnapshot);
final TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(
@@ -1542,13 +1543,12 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
final NetworkStats vtStats = telephonyManager.getVtDataUsage(STATS_PER_UID);
if (vtStats != null) {
vtStats.filter(UID_ALL, ifaces, TAG_ALL);
NetworkStatsFactory.apply464xlatAdjustments(uidSnapshot, vtStats);
uidSnapshot.combineAllValues(vtStats);
}
uidSnapshot.combineAllValues(mUidOperations);
// TODO: apply tethering & VC 464xlat adjustments here
return uidSnapshot;
}