Add hardware tethering traffic in testTethering test
Test: atest com.android.server.net.NetworkStatsServiceTest#testTethering Bug: 162292214 Change-Id: Ifec6bde5fd3231f2135f12536c42e42ec6b707de
This commit is contained in:
@@ -993,7 +993,7 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
public void testTethering() throws Exception {
|
public void testTethering() throws Exception {
|
||||||
// pretend first mobile network comes online
|
// pretend first mobile network comes online
|
||||||
expectDefaultSettings();
|
expectDefaultSettings();
|
||||||
NetworkState[] states = new NetworkState[] {buildMobile3gState(IMSI_1)};
|
final NetworkState[] states = new NetworkState[]{buildMobile3gState(IMSI_1)};
|
||||||
expectNetworkStatsSummary(buildEmptyStats());
|
expectNetworkStatsSummary(buildEmptyStats());
|
||||||
expectNetworkStatsUidDetail(buildEmptyStats());
|
expectNetworkStatsUidDetail(buildEmptyStats());
|
||||||
|
|
||||||
@@ -1003,21 +1003,39 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
incrementCurrentTime(HOUR_IN_MILLIS);
|
incrementCurrentTime(HOUR_IN_MILLIS);
|
||||||
expectDefaultSettings();
|
expectDefaultSettings();
|
||||||
|
|
||||||
// Traffic seen by kernel counters (includes software tethering).
|
// Register custom provider and retrieve callback.
|
||||||
final NetworkStats ifaceStats = new NetworkStats(getElapsedRealtime(), 1)
|
final TestableNetworkStatsProviderBinder provider =
|
||||||
.insertEntry(TEST_IFACE, 2048L, 16L, 512L, 4L);
|
new TestableNetworkStatsProviderBinder();
|
||||||
// TODO: add hardware tethering traffic, not seen by kernel counters.
|
final INetworkStatsProviderCallback cb =
|
||||||
|
mService.registerNetworkStatsProvider("TEST-TETHERING-OFFLOAD", provider);
|
||||||
|
assertNotNull(cb);
|
||||||
|
final long now = getElapsedRealtime();
|
||||||
|
|
||||||
// Traffic for UID_RED.
|
// Traffic seen by kernel counters (includes software tethering).
|
||||||
final NetworkStats uidStats = new NetworkStats(getElapsedRealtime(), 1)
|
final NetworkStats swIfaceStats = new NetworkStats(now, 1)
|
||||||
|
.insertEntry(TEST_IFACE, 1536L, 12L, 384L, 3L);
|
||||||
|
// Hardware tethering traffic, not seen by kernel counters.
|
||||||
|
final NetworkStats tetherHwIfaceStats = new NetworkStats(now, 1)
|
||||||
|
.insertEntry(new NetworkStats.Entry(TEST_IFACE, UID_ALL, SET_DEFAULT,
|
||||||
|
TAG_NONE, METERED_YES, ROAMING_NO, DEFAULT_NETWORK_YES,
|
||||||
|
512L, 4L, 128L, 1L, 0L));
|
||||||
|
final NetworkStats tetherHwUidStats = new NetworkStats(now, 1)
|
||||||
|
.insertEntry(new NetworkStats.Entry(TEST_IFACE, UID_TETHERING, SET_DEFAULT,
|
||||||
|
TAG_NONE, METERED_YES, ROAMING_NO, DEFAULT_NETWORK_YES,
|
||||||
|
512L, 4L, 128L, 1L, 0L));
|
||||||
|
cb.notifyStatsUpdated(0 /* unused */, tetherHwIfaceStats, tetherHwUidStats);
|
||||||
|
|
||||||
|
// Fake some traffic done by apps on the device (as opposed to tethering), and record it
|
||||||
|
// into UID stats (as opposed to iface stats).
|
||||||
|
final NetworkStats localUidStats = new NetworkStats(now, 1)
|
||||||
.insertEntry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE, 128L, 2L, 128L, 2L, 0L);
|
.insertEntry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE, 128L, 2L, 128L, 2L, 0L);
|
||||||
// All software tethering traffic.
|
// Software per-uid tethering traffic.
|
||||||
final NetworkStats tetherStats = new NetworkStats(getElapsedRealtime(), 1)
|
final NetworkStats tetherSwUidStats = new NetworkStats(now, 1)
|
||||||
.insertEntry(TEST_IFACE, UID_TETHERING, SET_DEFAULT, TAG_NONE, 1920L, 14L, 384L, 2L,
|
.insertEntry(TEST_IFACE, UID_TETHERING, SET_DEFAULT, TAG_NONE, 1408L, 10L, 256L, 1L,
|
||||||
0L);
|
0L);
|
||||||
|
|
||||||
expectNetworkStatsSummary(ifaceStats);
|
expectNetworkStatsSummary(swIfaceStats);
|
||||||
expectNetworkStatsUidDetail(uidStats, tetherStats);
|
expectNetworkStatsUidDetail(localUidStats, tetherSwUidStats);
|
||||||
forcePollAndWaitForIdle();
|
forcePollAndWaitForIdle();
|
||||||
|
|
||||||
// verify service recorded history
|
// verify service recorded history
|
||||||
|
|||||||
Reference in New Issue
Block a user