Migrate buildTemplate* to use NetworkTemplate.Builder
Use new Builder API which was introduced in Android T.
Bug: 238843364
Test: FrameworksNetTests
dumpsys netstats --checkin and check the output
Change-Id: Ieb0a2ee04056a1cedb71274ea710ff5153e2d68c
This commit is contained in:
@@ -28,6 +28,10 @@ import static android.net.NetworkStats.SET_ALL;
|
|||||||
import static android.net.NetworkStats.SET_DEFAULT;
|
import static android.net.NetworkStats.SET_DEFAULT;
|
||||||
import static android.net.NetworkStats.TAG_NONE;
|
import static android.net.NetworkStats.TAG_NONE;
|
||||||
import static android.net.NetworkStats.UID_ALL;
|
import static android.net.NetworkStats.UID_ALL;
|
||||||
|
import static android.net.NetworkTemplate.MATCH_BLUETOOTH;
|
||||||
|
import static android.net.NetworkTemplate.MATCH_ETHERNET;
|
||||||
|
import static android.net.NetworkTemplate.MATCH_MOBILE;
|
||||||
|
import static android.net.NetworkTemplate.MATCH_WIFI;
|
||||||
import static android.net.TrafficStats.UID_REMOVED;
|
import static android.net.TrafficStats.UID_REMOVED;
|
||||||
import static android.text.format.DateUtils.WEEK_IN_MILLIS;
|
import static android.text.format.DateUtils.WEEK_IN_MILLIS;
|
||||||
|
|
||||||
@@ -774,10 +778,11 @@ public class NetworkStatsCollection implements FileRotator.Reader, FileRotator.W
|
|||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void dumpCheckin(PrintWriter pw, long start, long end) {
|
public void dumpCheckin(PrintWriter pw, long start, long end) {
|
||||||
dumpCheckin(pw, start, end, NetworkTemplate.buildTemplateMobileWildcard(), "cell");
|
dumpCheckin(pw, start, end, new NetworkTemplate.Builder(MATCH_MOBILE)
|
||||||
dumpCheckin(pw, start, end, NetworkTemplate.buildTemplateWifiWildcard(), "wifi");
|
.setMeteredness(METERED_YES).build(), "cell");
|
||||||
dumpCheckin(pw, start, end, NetworkTemplate.buildTemplateEthernet(), "eth");
|
dumpCheckin(pw, start, end, new NetworkTemplate.Builder(MATCH_WIFI).build(), "wifi");
|
||||||
dumpCheckin(pw, start, end, NetworkTemplate.buildTemplateBluetooth(), "bt");
|
dumpCheckin(pw, start, end, new NetworkTemplate.Builder(MATCH_ETHERNET).build(), "eth");
|
||||||
|
dumpCheckin(pw, start, end, new NetworkTemplate.Builder(MATCH_BLUETOOTH).build(), "bt");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import static android.net.NetworkStats.IFACE_ALL;
|
|||||||
import static android.net.NetworkStats.IFACE_VT;
|
import static android.net.NetworkStats.IFACE_VT;
|
||||||
import static android.net.NetworkStats.INTERFACES_ALL;
|
import static android.net.NetworkStats.INTERFACES_ALL;
|
||||||
import static android.net.NetworkStats.METERED_ALL;
|
import static android.net.NetworkStats.METERED_ALL;
|
||||||
|
import static android.net.NetworkStats.METERED_YES;
|
||||||
import static android.net.NetworkStats.ROAMING_ALL;
|
import static android.net.NetworkStats.ROAMING_ALL;
|
||||||
import static android.net.NetworkStats.SET_ALL;
|
import static android.net.NetworkStats.SET_ALL;
|
||||||
import static android.net.NetworkStats.SET_DEFAULT;
|
import static android.net.NetworkStats.SET_DEFAULT;
|
||||||
@@ -41,8 +42,8 @@ import static android.net.NetworkStats.TAG_ALL;
|
|||||||
import static android.net.NetworkStats.TAG_NONE;
|
import static android.net.NetworkStats.TAG_NONE;
|
||||||
import static android.net.NetworkStats.UID_ALL;
|
import static android.net.NetworkStats.UID_ALL;
|
||||||
import static android.net.NetworkStatsHistory.FIELD_ALL;
|
import static android.net.NetworkStatsHistory.FIELD_ALL;
|
||||||
import static android.net.NetworkTemplate.buildTemplateMobileWildcard;
|
import static android.net.NetworkTemplate.MATCH_MOBILE;
|
||||||
import static android.net.NetworkTemplate.buildTemplateWifiWildcard;
|
import static android.net.NetworkTemplate.MATCH_WIFI;
|
||||||
import static android.net.TrafficStats.KB_IN_BYTES;
|
import static android.net.TrafficStats.KB_IN_BYTES;
|
||||||
import static android.net.TrafficStats.MB_IN_BYTES;
|
import static android.net.TrafficStats.MB_IN_BYTES;
|
||||||
import static android.net.TrafficStats.UID_TETHERING;
|
import static android.net.TrafficStats.UID_TETHERING;
|
||||||
@@ -2359,7 +2360,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
NetworkStats.Entry uidTotal;
|
NetworkStats.Entry uidTotal;
|
||||||
|
|
||||||
// collect mobile sample
|
// collect mobile sample
|
||||||
template = buildTemplateMobileWildcard();
|
template = new NetworkTemplate.Builder(MATCH_MOBILE).setMeteredness(METERED_YES).build();
|
||||||
devTotal = mDevRecorder.getTotalSinceBootLocked(template);
|
devTotal = mDevRecorder.getTotalSinceBootLocked(template);
|
||||||
xtTotal = mXtRecorder.getTotalSinceBootLocked(template);
|
xtTotal = mXtRecorder.getTotalSinceBootLocked(template);
|
||||||
uidTotal = mUidRecorder.getTotalSinceBootLocked(template);
|
uidTotal = mUidRecorder.getTotalSinceBootLocked(template);
|
||||||
@@ -2371,7 +2372,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
currentTime);
|
currentTime);
|
||||||
|
|
||||||
// collect wifi sample
|
// collect wifi sample
|
||||||
template = buildTemplateWifiWildcard();
|
template = new NetworkTemplate.Builder(MATCH_WIFI).build();
|
||||||
devTotal = mDevRecorder.getTotalSinceBootLocked(template);
|
devTotal = mDevRecorder.getTotalSinceBootLocked(template);
|
||||||
xtTotal = mXtRecorder.getTotalSinceBootLocked(template);
|
xtTotal = mXtRecorder.getTotalSinceBootLocked(template);
|
||||||
uidTotal = mUidRecorder.getTotalSinceBootLocked(template);
|
uidTotal = mUidRecorder.getTotalSinceBootLocked(template);
|
||||||
|
|||||||
@@ -21,11 +21,12 @@ import static android.net.NetworkIdentity.OEM_NONE;
|
|||||||
import static android.net.NetworkStats.DEFAULT_NETWORK_NO;
|
import static android.net.NetworkStats.DEFAULT_NETWORK_NO;
|
||||||
import static android.net.NetworkStats.DEFAULT_NETWORK_YES;
|
import static android.net.NetworkStats.DEFAULT_NETWORK_YES;
|
||||||
import static android.net.NetworkStats.METERED_NO;
|
import static android.net.NetworkStats.METERED_NO;
|
||||||
|
import static android.net.NetworkStats.METERED_YES;
|
||||||
import static android.net.NetworkStats.ROAMING_NO;
|
import static android.net.NetworkStats.ROAMING_NO;
|
||||||
import static android.net.NetworkStats.SET_DEFAULT;
|
import static android.net.NetworkStats.SET_DEFAULT;
|
||||||
import static android.net.NetworkStats.TAG_NONE;
|
import static android.net.NetworkStats.TAG_NONE;
|
||||||
import static android.net.NetworkTemplate.buildTemplateMobileAll;
|
import static android.net.NetworkTemplate.MATCH_MOBILE;
|
||||||
import static android.net.NetworkTemplate.buildTemplateWifiWildcard;
|
import static android.net.NetworkTemplate.MATCH_WIFI;
|
||||||
import static android.net.TrafficStats.MB_IN_BYTES;
|
import static android.net.TrafficStats.MB_IN_BYTES;
|
||||||
import static android.text.format.DateUtils.MINUTE_IN_MILLIS;
|
import static android.text.format.DateUtils.MINUTE_IN_MILLIS;
|
||||||
|
|
||||||
@@ -67,6 +68,7 @@ import org.mockito.MockitoAnnotations;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link NetworkStatsObservers}.
|
* Tests for {@link NetworkStatsObservers}.
|
||||||
@@ -84,10 +86,13 @@ public class NetworkStatsObserversTest {
|
|||||||
private static final int SUBID_1 = 1;
|
private static final int SUBID_1 = 1;
|
||||||
private static final String TEST_SSID = "AndroidAP";
|
private static final String TEST_SSID = "AndroidAP";
|
||||||
|
|
||||||
private static NetworkTemplate sTemplateWifi = buildTemplateWifiWildcard();
|
private static NetworkTemplate sTemplateWifi = new NetworkTemplate.Builder(MATCH_WIFI).build();
|
||||||
private static NetworkTemplate sTemplateImsi1 = buildTemplateMobileAll(IMSI_1);
|
private static NetworkTemplate sTemplateImsi1 = new NetworkTemplate.Builder(MATCH_MOBILE)
|
||||||
private static NetworkTemplate sTemplateImsi2 = buildTemplateMobileAll(IMSI_2);
|
.setSubscriberIds(Set.of(IMSI_1))
|
||||||
|
.setMeteredness(METERED_YES).build();
|
||||||
|
private static NetworkTemplate sTemplateImsi2 = new NetworkTemplate.Builder(MATCH_MOBILE)
|
||||||
|
.setSubscriberIds(Set.of(IMSI_2))
|
||||||
|
.setMeteredness(METERED_YES).build();
|
||||||
private static final int PID_SYSTEM = 1234;
|
private static final int PID_SYSTEM = 1234;
|
||||||
private static final int PID_RED = 1235;
|
private static final int PID_RED = 1235;
|
||||||
private static final int PID_BLUE = 1236;
|
private static final int PID_BLUE = 1236;
|
||||||
|
|||||||
@@ -46,14 +46,10 @@ import static android.net.NetworkStats.TAG_ALL;
|
|||||||
import static android.net.NetworkStats.TAG_NONE;
|
import static android.net.NetworkStats.TAG_NONE;
|
||||||
import static android.net.NetworkStats.UID_ALL;
|
import static android.net.NetworkStats.UID_ALL;
|
||||||
import static android.net.NetworkStatsHistory.FIELD_ALL;
|
import static android.net.NetworkStatsHistory.FIELD_ALL;
|
||||||
import static android.net.NetworkTemplate.MATCH_MOBILE_WILDCARD;
|
import static android.net.NetworkTemplate.MATCH_MOBILE;
|
||||||
import static android.net.NetworkTemplate.NETWORK_TYPE_ALL;
|
import static android.net.NetworkTemplate.MATCH_WIFI;
|
||||||
import static android.net.NetworkTemplate.OEM_MANAGED_NO;
|
import static android.net.NetworkTemplate.OEM_MANAGED_NO;
|
||||||
import static android.net.NetworkTemplate.OEM_MANAGED_YES;
|
import static android.net.NetworkTemplate.OEM_MANAGED_YES;
|
||||||
import static android.net.NetworkTemplate.buildTemplateMobileAll;
|
|
||||||
import static android.net.NetworkTemplate.buildTemplateMobileWithRatType;
|
|
||||||
import static android.net.NetworkTemplate.buildTemplateWifi;
|
|
||||||
import static android.net.NetworkTemplate.buildTemplateWifiWildcard;
|
|
||||||
import static android.net.TrafficStats.MB_IN_BYTES;
|
import static android.net.TrafficStats.MB_IN_BYTES;
|
||||||
import static android.net.TrafficStats.UID_REMOVED;
|
import static android.net.TrafficStats.UID_REMOVED;
|
||||||
import static android.net.TrafficStats.UID_TETHERING;
|
import static android.net.TrafficStats.UID_TETHERING;
|
||||||
@@ -65,7 +61,6 @@ import static android.text.format.DateUtils.HOUR_IN_MILLIS;
|
|||||||
import static android.text.format.DateUtils.MINUTE_IN_MILLIS;
|
import static android.text.format.DateUtils.MINUTE_IN_MILLIS;
|
||||||
import static android.text.format.DateUtils.WEEK_IN_MILLIS;
|
import static android.text.format.DateUtils.WEEK_IN_MILLIS;
|
||||||
|
|
||||||
import static com.android.net.module.util.NetworkStatsUtils.SUBSCRIBER_ID_MATCH_RULE_EXACT;
|
|
||||||
import static com.android.server.net.NetworkStatsService.ACTION_NETWORK_STATS_POLL;
|
import static com.android.server.net.NetworkStatsService.ACTION_NETWORK_STATS_POLL;
|
||||||
import static com.android.server.net.NetworkStatsService.NETSTATS_IMPORT_ATTEMPTS_COUNTER_NAME;
|
import static com.android.server.net.NetworkStatsService.NETSTATS_IMPORT_ATTEMPTS_COUNTER_NAME;
|
||||||
import static com.android.server.net.NetworkStatsService.NETSTATS_IMPORT_FALLBACKS_COUNTER_NAME;
|
import static com.android.server.net.NetworkStatsService.NETSTATS_IMPORT_FALLBACKS_COUNTER_NAME;
|
||||||
@@ -192,11 +187,14 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
private static final String IMSI_2 = "310260";
|
private static final String IMSI_2 = "310260";
|
||||||
private static final String TEST_WIFI_NETWORK_KEY = "WifiNetworkKey";
|
private static final String TEST_WIFI_NETWORK_KEY = "WifiNetworkKey";
|
||||||
|
|
||||||
private static NetworkTemplate sTemplateWifi = buildTemplateWifi(TEST_WIFI_NETWORK_KEY);
|
private static NetworkTemplate sTemplateWifi = new NetworkTemplate.Builder(MATCH_WIFI)
|
||||||
private static NetworkTemplate sTemplateCarrierWifi1 =
|
.setWifiNetworkKeys(Set.of(TEST_WIFI_NETWORK_KEY)).build();
|
||||||
buildTemplateWifi(NetworkTemplate.WIFI_NETWORKID_ALL, IMSI_1);
|
private static NetworkTemplate sTemplateCarrierWifi1 = new NetworkTemplate.Builder(MATCH_WIFI)
|
||||||
private static NetworkTemplate sTemplateImsi1 = buildTemplateMobileAll(IMSI_1);
|
.setSubscriberIds(Set.of(IMSI_1)).build();
|
||||||
private static NetworkTemplate sTemplateImsi2 = buildTemplateMobileAll(IMSI_2);
|
private static NetworkTemplate sTemplateImsi1 = new NetworkTemplate.Builder(MATCH_MOBILE)
|
||||||
|
.setMeteredness(METERED_YES).setSubscriberIds(Set.of(IMSI_1)).build();
|
||||||
|
private static NetworkTemplate sTemplateImsi2 = new NetworkTemplate.Builder(MATCH_MOBILE)
|
||||||
|
.setMeteredness(METERED_YES).setSubscriberIds(Set.of(IMSI_2)).build();
|
||||||
|
|
||||||
private static final Network WIFI_NETWORK = new Network(100);
|
private static final Network WIFI_NETWORK = new Network(100);
|
||||||
private static final Network MOBILE_NETWORK = new Network(101);
|
private static final Network MOBILE_NETWORK = new Network(101);
|
||||||
@@ -833,15 +831,15 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMobileStatsByRatType() throws Exception {
|
public void testMobileStatsByRatType() throws Exception {
|
||||||
final NetworkTemplate template3g =
|
final NetworkTemplate template3g = new NetworkTemplate.Builder(MATCH_MOBILE)
|
||||||
buildTemplateMobileWithRatType(null, TelephonyManager.NETWORK_TYPE_UMTS,
|
.setRatType(TelephonyManager.NETWORK_TYPE_UMTS)
|
||||||
METERED_YES);
|
.setMeteredness(METERED_YES).build();
|
||||||
final NetworkTemplate template4g =
|
final NetworkTemplate template4g = new NetworkTemplate.Builder(MATCH_MOBILE)
|
||||||
buildTemplateMobileWithRatType(null, TelephonyManager.NETWORK_TYPE_LTE,
|
.setRatType(TelephonyManager.NETWORK_TYPE_LTE)
|
||||||
METERED_YES);
|
.setMeteredness(METERED_YES).build();
|
||||||
final NetworkTemplate template5g =
|
final NetworkTemplate template5g = new NetworkTemplate.Builder(MATCH_MOBILE)
|
||||||
buildTemplateMobileWithRatType(null, TelephonyManager.NETWORK_TYPE_NR,
|
.setRatType(TelephonyManager.NETWORK_TYPE_NR)
|
||||||
METERED_YES);
|
.setMeteredness(METERED_YES).build();
|
||||||
final NetworkStateSnapshot[] states =
|
final NetworkStateSnapshot[] states =
|
||||||
new NetworkStateSnapshot[]{buildMobileState(IMSI_1)};
|
new NetworkStateSnapshot[]{buildMobileState(IMSI_1)};
|
||||||
|
|
||||||
@@ -912,12 +910,13 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testMobileStatsMeteredness() throws Exception {
|
public void testMobileStatsMeteredness() throws Exception {
|
||||||
// Create metered 5g template.
|
// Create metered 5g template.
|
||||||
final NetworkTemplate templateMetered5g =
|
final NetworkTemplate templateMetered5g = new NetworkTemplate.Builder(MATCH_MOBILE)
|
||||||
buildTemplateMobileWithRatType(null, TelephonyManager.NETWORK_TYPE_NR,
|
.setRatType(TelephonyManager.NETWORK_TYPE_NR)
|
||||||
METERED_YES);
|
.setMeteredness(METERED_YES).build();
|
||||||
// Create non-metered 5g template
|
// Create non-metered 5g template
|
||||||
final NetworkTemplate templateNonMetered5g =
|
final NetworkTemplate templateNonMetered5g = new NetworkTemplate.Builder(MATCH_MOBILE)
|
||||||
buildTemplateMobileWithRatType(null, TelephonyManager.NETWORK_TYPE_NR, METERED_NO);
|
.setRatType(TelephonyManager.NETWORK_TYPE_NR)
|
||||||
|
.setMeteredness(METERED_NO).build();
|
||||||
|
|
||||||
expectDefaultSettings();
|
expectDefaultSettings();
|
||||||
expectNetworkStatsSummary(buildEmptyStats());
|
expectNetworkStatsSummary(buildEmptyStats());
|
||||||
@@ -950,33 +949,20 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMobileStatsOemManaged() throws Exception {
|
public void testMobileStatsOemManaged() throws Exception {
|
||||||
final NetworkTemplate templateOemPaid = new NetworkTemplate(MATCH_MOBILE_WILDCARD,
|
final NetworkTemplate templateOemPaid = new NetworkTemplate.Builder(MATCH_MOBILE)
|
||||||
/*subscriberId=*/null, /*matchSubscriberIds=*/null,
|
.setOemManaged(OEM_PAID).build();
|
||||||
/*matchWifiNetworkKeys=*/new String[0], METERED_ALL, ROAMING_ALL,
|
|
||||||
DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_PAID, SUBSCRIBER_ID_MATCH_RULE_EXACT);
|
|
||||||
|
|
||||||
final NetworkTemplate templateOemPrivate = new NetworkTemplate(MATCH_MOBILE_WILDCARD,
|
final NetworkTemplate templateOemPrivate = new NetworkTemplate.Builder(MATCH_MOBILE)
|
||||||
/*subscriberId=*/null, /*matchSubscriberIds=*/null,
|
.setOemManaged(OEM_PRIVATE).build();
|
||||||
/*matchWifiNetworkKeys=*/new String[0], METERED_ALL, ROAMING_ALL,
|
|
||||||
DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_PRIVATE, SUBSCRIBER_ID_MATCH_RULE_EXACT);
|
|
||||||
|
|
||||||
final NetworkTemplate templateOemAll = new NetworkTemplate(MATCH_MOBILE_WILDCARD,
|
final NetworkTemplate templateOemAll = new NetworkTemplate.Builder(MATCH_MOBILE)
|
||||||
/*subscriberId=*/null, /*matchSubscriberIds=*/null,
|
.setOemManaged(OEM_PAID | OEM_PRIVATE).build();
|
||||||
/*matchWifiNetworkKeys=*/new String[0], METERED_ALL, ROAMING_ALL,
|
|
||||||
DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_PAID | OEM_PRIVATE,
|
|
||||||
SUBSCRIBER_ID_MATCH_RULE_EXACT);
|
|
||||||
|
|
||||||
final NetworkTemplate templateOemYes = new NetworkTemplate(MATCH_MOBILE_WILDCARD,
|
final NetworkTemplate templateOemYes = new NetworkTemplate.Builder(MATCH_MOBILE)
|
||||||
/*subscriberId=*/null, /*matchSubscriberIds=*/null,
|
.setOemManaged(OEM_MANAGED_YES).build();
|
||||||
/*matchWifiNetworkKeys=*/new String[0], METERED_ALL, ROAMING_ALL,
|
|
||||||
DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_YES,
|
|
||||||
SUBSCRIBER_ID_MATCH_RULE_EXACT);
|
|
||||||
|
|
||||||
final NetworkTemplate templateOemNone = new NetworkTemplate(MATCH_MOBILE_WILDCARD,
|
final NetworkTemplate templateOemNone = new NetworkTemplate.Builder(MATCH_MOBILE)
|
||||||
/*subscriberId=*/null, /*matchSubscriberIds=*/null,
|
.setOemManaged(OEM_MANAGED_NO).build();
|
||||||
/*matchWifiNetworkKeys=*/new String[0], METERED_ALL, ROAMING_ALL,
|
|
||||||
DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_NO,
|
|
||||||
SUBSCRIBER_ID_MATCH_RULE_EXACT);
|
|
||||||
|
|
||||||
// OEM_PAID network comes online.
|
// OEM_PAID network comes online.
|
||||||
NetworkStateSnapshot[] states = new NetworkStateSnapshot[]{
|
NetworkStateSnapshot[] states = new NetworkStateSnapshot[]{
|
||||||
@@ -1156,7 +1142,9 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
final ZonedDateTime end =
|
final ZonedDateTime end =
|
||||||
ZonedDateTime.ofInstant(mClock.instant(), ZoneId.systemDefault());
|
ZonedDateTime.ofInstant(mClock.instant(), ZoneId.systemDefault());
|
||||||
final ZonedDateTime start = end.truncatedTo(ChronoUnit.HOURS);
|
final ZonedDateTime start = end.truncatedTo(ChronoUnit.HOURS);
|
||||||
NetworkStats stats = mSession.getSummaryForNetwork(buildTemplateWifi(TEST_WIFI_NETWORK_KEY),
|
NetworkStats stats = mSession.getSummaryForNetwork(
|
||||||
|
new NetworkTemplate.Builder(MATCH_WIFI)
|
||||||
|
.setWifiNetworkKeys(Set.of(TEST_WIFI_NETWORK_KEY)).build(),
|
||||||
start.toInstant().toEpochMilli(), end.toInstant().toEpochMilli());
|
start.toInstant().toEpochMilli(), end.toInstant().toEpochMilli());
|
||||||
assertEquals(1, stats.size());
|
assertEquals(1, stats.size());
|
||||||
assertValues(stats, IFACE_ALL, UID_ALL, SET_ALL, TAG_NONE, METERED_ALL, ROAMING_ALL,
|
assertValues(stats, IFACE_ALL, UID_ALL, SET_ALL, TAG_NONE, METERED_ALL, ROAMING_ALL,
|
||||||
@@ -1668,14 +1656,14 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
public void testDynamicWatchForNetworkRatTypeChanges() throws Exception {
|
public void testDynamicWatchForNetworkRatTypeChanges() throws Exception {
|
||||||
// Build 3G template, type unknown template to get stats while network type is unknown
|
// Build 3G template, type unknown template to get stats while network type is unknown
|
||||||
// and type all template to get the sum of all network type stats.
|
// and type all template to get the sum of all network type stats.
|
||||||
final NetworkTemplate template3g =
|
final NetworkTemplate template3g = new NetworkTemplate.Builder(MATCH_MOBILE)
|
||||||
buildTemplateMobileWithRatType(null, TelephonyManager.NETWORK_TYPE_UMTS,
|
.setRatType(TelephonyManager.NETWORK_TYPE_UMTS)
|
||||||
METERED_YES);
|
.setMeteredness(METERED_YES).build();
|
||||||
final NetworkTemplate templateUnknown =
|
final NetworkTemplate templateUnknown = new NetworkTemplate.Builder(MATCH_MOBILE)
|
||||||
buildTemplateMobileWithRatType(null, TelephonyManager.NETWORK_TYPE_UNKNOWN,
|
.setRatType(TelephonyManager.NETWORK_TYPE_UNKNOWN)
|
||||||
METERED_YES);
|
.setMeteredness(METERED_YES).build();
|
||||||
final NetworkTemplate templateAll =
|
final NetworkTemplate templateAll = new NetworkTemplate.Builder(MATCH_MOBILE)
|
||||||
buildTemplateMobileWithRatType(null, NETWORK_TYPE_ALL, METERED_YES);
|
.setMeteredness(METERED_YES).build();
|
||||||
final NetworkStateSnapshot[] states =
|
final NetworkStateSnapshot[] states =
|
||||||
new NetworkStateSnapshot[]{buildMobileState(IMSI_1)};
|
new NetworkStateSnapshot[]{buildMobileState(IMSI_1)};
|
||||||
|
|
||||||
@@ -1772,8 +1760,8 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
forcePollAndWaitForIdle();
|
forcePollAndWaitForIdle();
|
||||||
|
|
||||||
// Verify mobile summary is not changed by the operation count.
|
// Verify mobile summary is not changed by the operation count.
|
||||||
final NetworkTemplate templateMobile =
|
final NetworkTemplate templateMobile = new NetworkTemplate.Builder(MATCH_MOBILE)
|
||||||
buildTemplateMobileWithRatType(null, NETWORK_TYPE_ALL, METERED_YES);
|
.setMeteredness(METERED_YES).build();
|
||||||
final NetworkStats statsMobile = mSession.getSummaryForAllUid(
|
final NetworkStats statsMobile = mSession.getSummaryForAllUid(
|
||||||
templateMobile, Long.MIN_VALUE, Long.MAX_VALUE, true);
|
templateMobile, Long.MIN_VALUE, Long.MAX_VALUE, true);
|
||||||
assertValues(statsMobile, IFACE_ALL, UID_RED, SET_ALL, TAG_NONE, METERED_ALL, ROAMING_ALL,
|
assertValues(statsMobile, IFACE_ALL, UID_RED, SET_ALL, TAG_NONE, METERED_ALL, ROAMING_ALL,
|
||||||
@@ -1784,7 +1772,7 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
// Verify the operation count is blamed onto the default network.
|
// Verify the operation count is blamed onto the default network.
|
||||||
// TODO: Blame onto the default network is not very reasonable. Consider blame onto the
|
// TODO: Blame onto the default network is not very reasonable. Consider blame onto the
|
||||||
// network that generates the traffic.
|
// network that generates the traffic.
|
||||||
final NetworkTemplate templateWifi = buildTemplateWifiWildcard();
|
final NetworkTemplate templateWifi = new NetworkTemplate.Builder(MATCH_WIFI).build();
|
||||||
final NetworkStats statsWifi = mSession.getSummaryForAllUid(
|
final NetworkStats statsWifi = mSession.getSummaryForAllUid(
|
||||||
templateWifi, Long.MIN_VALUE, Long.MAX_VALUE, true);
|
templateWifi, Long.MIN_VALUE, Long.MAX_VALUE, true);
|
||||||
assertValues(statsWifi, IFACE_ALL, UID_RED, SET_ALL, 0xF00D, METERED_ALL, ROAMING_ALL,
|
assertValues(statsWifi, IFACE_ALL, UID_RED, SET_ALL, 0xF00D, METERED_ALL, ROAMING_ALL,
|
||||||
|
|||||||
Reference in New Issue
Block a user