OSDN Git Service

Add tether offload traffic to interface stats as well.
authorLorenzo Colitti <lorenzo@google.com>
Thu, 17 Aug 2017 10:23:08 +0000 (19:23 +0900)
committerLorenzo Colitti <lorenzo@google.com>
Sat, 19 Aug 2017 01:12:05 +0000 (10:12 +0900)
commitf1912ca49ac0f5bcdad063a7c042153ba791145d
treefb57a8fedcb219224f8d44796c3998c383961cdc
parent9f0baa94ca28f67e162d3ad04ca6d0e17ee5e314
Add tether offload traffic to interface stats as well.

Currently, we only count add tethering traffic to per-UID
stats, but not to total data usage (i.e., dev and XT stats). This
is correct for software tethering, because all software forwarded
packets are already included in interface counters, but it is
incorrect for hardware offload, because such packets do not
increment interface counters.

To fix this:
1. Add an argument to ITetheringStatsProvider#getTetherStats to
   indicate whether per-UID stats are requested. For clarity,
   define integer constants STATS_PER_IFACE and STATS_PER_UID
   to represent these operations.
2. Make NetdTetheringStatsProvider return stats only if per-UID
   stats are requested. (Otherwise tethering traffic would be
   double-counted).
3. Make OffloadController's stats provider return the same
   stats regardless of whether per-UID stats were requested or
   not.
4. Make NetworkStatsService add non-per-UID tethering stats to
   the dev and XT snapshots. The per-UID snapshots were already
   correctly adding in per-UID stats.

(cherry picked from commit 5356a35c3bcfcdf2d184c620af6bfbf9bddf35c5)

Bug: 29337859
Bug: 32163131
Test: runtest frameworks-net
Test: runtest frameworks-telephony
Change-Id: I325b13d50e88841dfb0db4c35e7e27f163ee72fe
Merged-In: I4e8e923d68dce1a4a68608dbd6c75a91165aa4ee
core/java/android/net/ITetheringStatsProvider.aidl
core/java/android/net/NetworkStats.java
core/java/android/os/INetworkManagementService.aidl
services/core/java/com/android/server/NetworkManagementService.java
services/core/java/com/android/server/connectivity/tethering/OffloadController.java
services/core/java/com/android/server/net/NetworkStatsService.java
telephony/java/android/telephony/TelephonyManager.java
tests/net/java/com/android/server/connectivity/tethering/OffloadControllerTest.java
tests/net/java/com/android/server/net/NetworkStatsServiceTest.java