OSDN Git Service

NetworkStatsService: Fix getDetailedUidStats to take VPNs into account.
authorVarun Anand <vaanand@google.com>
Sat, 19 Jan 2019 03:22:48 +0000 (19:22 -0800)
committerLorenzo Colitti <lorenzo@google.com>
Wed, 29 May 2019 09:15:24 +0000 (18:15 +0900)
commited11b84131eae1e104af9be2c17fc9b07183eee3
tree33c4cd86fac6002bc6c57df82843b975db318c52
parent917327b1933c6edc8314fe728e5f14f6e29dd5f4
NetworkStatsService: Fix getDetailedUidStats to take VPNs into account.

(cherry picked from commit 29d2ef2fe10ce9686b57a21aa8e10f6481c92a9a)

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
core/java/android/net/NetworkStats.java
services/core/java/com/android/server/net/NetworkStatsFactory.java
services/core/java/com/android/server/net/NetworkStatsService.java
tests/net/java/android/net/NetworkStatsTest.java
tests/net/java/com/android/server/net/NetworkStatsServiceTest.java