Merge "Cleanup constructor of NetworkStats#Entry"
This commit is contained in:
@@ -302,20 +302,8 @@ public final class NetworkStats implements Parcelable, Iterable<NetworkStats.Ent
|
|||||||
/** @hide */
|
/** @hide */
|
||||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
|
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
|
||||||
public Entry() {
|
public Entry() {
|
||||||
this(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, 0L, 0L, 0L, 0L, 0L);
|
this(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO, ROAMING_NO,
|
||||||
}
|
DEFAULT_NETWORK_NO, 0L, 0L, 0L, 0L, 0L);
|
||||||
|
|
||||||
/** @hide */
|
|
||||||
public Entry(long rxBytes, long rxPackets, long txBytes, long txPackets, long operations) {
|
|
||||||
this(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, rxBytes, rxPackets, txBytes, txPackets,
|
|
||||||
operations);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @hide */
|
|
||||||
public Entry(String iface, int uid, int set, int tag, long rxBytes, long rxPackets,
|
|
||||||
long txBytes, long txPackets, long operations) {
|
|
||||||
this(iface, uid, set, tag, METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO,
|
|
||||||
rxBytes, rxPackets, txBytes, txPackets, operations);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -607,7 +595,8 @@ public final class NetworkStats implements Parcelable, Iterable<NetworkStats.Ent
|
|||||||
public NetworkStats insertEntry(
|
public NetworkStats insertEntry(
|
||||||
String iface, long rxBytes, long rxPackets, long txBytes, long txPackets) {
|
String iface, long rxBytes, long rxPackets, long txBytes, long txPackets) {
|
||||||
return insertEntry(
|
return insertEntry(
|
||||||
iface, UID_ALL, SET_DEFAULT, TAG_NONE, rxBytes, rxPackets, txBytes, txPackets, 0L);
|
iface, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO,
|
||||||
|
rxBytes, rxPackets, txBytes, txPackets, 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@@ -615,7 +604,8 @@ public final class NetworkStats implements Parcelable, Iterable<NetworkStats.Ent
|
|||||||
public NetworkStats insertEntry(String iface, int uid, int set, int tag, long rxBytes,
|
public NetworkStats insertEntry(String iface, int uid, int set, int tag, long rxBytes,
|
||||||
long rxPackets, long txBytes, long txPackets, long operations) {
|
long rxPackets, long txBytes, long txPackets, long operations) {
|
||||||
return insertEntry(new Entry(
|
return insertEntry(new Entry(
|
||||||
iface, uid, set, tag, rxBytes, rxPackets, txBytes, txPackets, operations));
|
iface, uid, set, tag, METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO,
|
||||||
|
rxBytes, rxPackets, txBytes, txPackets, operations));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@@ -787,7 +777,8 @@ public final class NetworkStats implements Parcelable, Iterable<NetworkStats.Ent
|
|||||||
public NetworkStats combineValues(String iface, int uid, int set, int tag,
|
public NetworkStats combineValues(String iface, int uid, int set, int tag,
|
||||||
long rxBytes, long rxPackets, long txBytes, long txPackets, long operations) {
|
long rxBytes, long rxPackets, long txBytes, long txPackets, long operations) {
|
||||||
return combineValues(new Entry(
|
return combineValues(new Entry(
|
||||||
iface, uid, set, tag, rxBytes, rxPackets, txBytes, txPackets, operations));
|
iface, uid, set, tag, METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO,
|
||||||
|
rxBytes, rxPackets, txBytes, txPackets, operations));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -309,7 +309,8 @@ public class NetworkStatsCollection implements FileRotator.Reader, FileRotator.W
|
|||||||
// ourselves something to scale with.
|
// ourselves something to scale with.
|
||||||
if (entry.rxBytes == 0 || entry.txBytes == 0) {
|
if (entry.rxBytes == 0 || entry.txBytes == 0) {
|
||||||
combined.recordData(augmentStart, augmentEnd,
|
combined.recordData(augmentStart, augmentEnd,
|
||||||
new NetworkStats.Entry(1, 0, 1, 0, 0));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE,
|
||||||
|
METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO, 1L, 0L, 1L, 0L, 0L));
|
||||||
combined.getValues(augmentStart, augmentEnd, entry);
|
combined.getValues(augmentStart, augmentEnd, entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,10 @@
|
|||||||
package android.net;
|
package android.net;
|
||||||
|
|
||||||
import static android.annotation.SystemApi.Client.MODULE_LIBRARIES;
|
import static android.annotation.SystemApi.Client.MODULE_LIBRARIES;
|
||||||
|
import static android.net.NetworkStats.DEFAULT_NETWORK_NO;
|
||||||
import static android.net.NetworkStats.IFACE_ALL;
|
import static android.net.NetworkStats.IFACE_ALL;
|
||||||
|
import static android.net.NetworkStats.METERED_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.NetworkStats.UID_ALL;
|
import static android.net.NetworkStats.UID_ALL;
|
||||||
@@ -529,7 +532,8 @@ public final class NetworkStatsHistory implements Parcelable {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public void recordData(long start, long end, long rxBytes, long txBytes) {
|
public void recordData(long start, long end, long rxBytes, long txBytes) {
|
||||||
recordData(start, end, new NetworkStats.Entry(
|
recordData(start, end, new NetworkStats.Entry(
|
||||||
IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, rxBytes, 0L, txBytes, 0L, 0L));
|
IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO, ROAMING_NO,
|
||||||
|
DEFAULT_NETWORK_NO, rxBytes, 0L, txBytes, 0L, 0L));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -611,7 +615,8 @@ public final class NetworkStatsHistory implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
public void recordHistory(NetworkStatsHistory input, long start, long end) {
|
public void recordHistory(NetworkStatsHistory input, long start, long end) {
|
||||||
final NetworkStats.Entry entry = new NetworkStats.Entry(
|
final NetworkStats.Entry entry = new NetworkStats.Entry(
|
||||||
IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, 0L, 0L, 0L, 0L, 0L);
|
IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO, ROAMING_NO,
|
||||||
|
DEFAULT_NETWORK_NO, 0L, 0L, 0L, 0L, 0L);
|
||||||
for (int i = 0; i < input.bucketCount; i++) {
|
for (int i = 0; i < input.bucketCount; i++) {
|
||||||
final long bucketStart = input.bucketStart[i];
|
final long bucketStart = input.bucketStart[i];
|
||||||
final long bucketEnd = bucketStart + input.bucketDuration;
|
final long bucketEnd = bucketStart + input.bucketDuration;
|
||||||
@@ -854,7 +859,8 @@ public final class NetworkStatsHistory implements Parcelable {
|
|||||||
ensureBuckets(start, end);
|
ensureBuckets(start, end);
|
||||||
|
|
||||||
final NetworkStats.Entry entry = new NetworkStats.Entry(
|
final NetworkStats.Entry entry = new NetworkStats.Entry(
|
||||||
IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, 0L, 0L, 0L, 0L, 0L);
|
IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO, ROAMING_NO,
|
||||||
|
DEFAULT_NETWORK_NO, 0L, 0L, 0L, 0L, 0L);
|
||||||
while (rxBytes > 1024 || rxPackets > 128 || txBytes > 1024 || txPackets > 128
|
while (rxBytes > 1024 || rxPackets > 128 || txBytes > 1024 || txPackets > 128
|
||||||
|| operations > 32) {
|
|| operations > 32) {
|
||||||
final long curStart = randomLong(r, start, end);
|
final long curStart = randomLong(r, start, end);
|
||||||
|
|||||||
@@ -27,12 +27,15 @@ import static android.content.Intent.EXTRA_UID;
|
|||||||
import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR;
|
import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR;
|
||||||
import static android.net.NetworkCapabilities.TRANSPORT_WIFI;
|
import static android.net.NetworkCapabilities.TRANSPORT_WIFI;
|
||||||
import static android.net.NetworkStats.DEFAULT_NETWORK_ALL;
|
import static android.net.NetworkStats.DEFAULT_NETWORK_ALL;
|
||||||
|
import static android.net.NetworkStats.DEFAULT_NETWORK_NO;
|
||||||
import static android.net.NetworkStats.IFACE_ALL;
|
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_NO;
|
||||||
import static android.net.NetworkStats.METERED_YES;
|
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.ROAMING_NO;
|
||||||
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;
|
||||||
import static android.net.NetworkStats.SET_FOREGROUND;
|
import static android.net.NetworkStats.SET_FOREGROUND;
|
||||||
@@ -2922,7 +2925,8 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
for (TetherStatsParcel tetherStats : tetherStatsParcels) {
|
for (TetherStatsParcel tetherStats : tetherStatsParcels) {
|
||||||
try {
|
try {
|
||||||
stats.combineValues(new NetworkStats.Entry(tetherStats.iface, UID_TETHERING,
|
stats.combineValues(new NetworkStats.Entry(tetherStats.iface, UID_TETHERING,
|
||||||
SET_DEFAULT, TAG_NONE, tetherStats.rxBytes, tetherStats.rxPackets,
|
SET_DEFAULT, TAG_NONE, METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO,
|
||||||
|
tetherStats.rxBytes, tetherStats.rxPackets,
|
||||||
tetherStats.txBytes, tetherStats.txPackets, 0L));
|
tetherStats.txBytes, tetherStats.txPackets, 0L));
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
throw new IllegalStateException("invalid tethering stats " + e);
|
throw new IllegalStateException("invalid tethering stats " + e);
|
||||||
|
|||||||
@@ -88,20 +88,28 @@ public class NetworkStatsManagerTest {
|
|||||||
|
|
||||||
Entry uid1Entry1 = new Entry("if1", uid1,
|
Entry uid1Entry1 = new Entry("if1", uid1,
|
||||||
android.net.NetworkStats.SET_DEFAULT, android.net.NetworkStats.TAG_NONE,
|
android.net.NetworkStats.SET_DEFAULT, android.net.NetworkStats.TAG_NONE,
|
||||||
|
android.net.NetworkStats.METERED_NO, android.net.NetworkStats.ROAMING_NO,
|
||||||
|
android.net.NetworkStats.DEFAULT_NETWORK_NO,
|
||||||
100, 10, 200, 20, 0);
|
100, 10, 200, 20, 0);
|
||||||
|
|
||||||
Entry uid1Entry2 = new Entry(
|
Entry uid1Entry2 = new Entry(
|
||||||
"if2", uid1,
|
"if2", uid1,
|
||||||
android.net.NetworkStats.SET_DEFAULT, android.net.NetworkStats.TAG_NONE,
|
android.net.NetworkStats.SET_DEFAULT, android.net.NetworkStats.TAG_NONE,
|
||||||
|
android.net.NetworkStats.METERED_NO, android.net.NetworkStats.ROAMING_NO,
|
||||||
|
android.net.NetworkStats.DEFAULT_NETWORK_NO,
|
||||||
100, 10, 200, 20, 0);
|
100, 10, 200, 20, 0);
|
||||||
|
|
||||||
Entry uid2Entry1 = new Entry("if1", uid2,
|
Entry uid2Entry1 = new Entry("if1", uid2,
|
||||||
android.net.NetworkStats.SET_DEFAULT, android.net.NetworkStats.TAG_NONE,
|
android.net.NetworkStats.SET_DEFAULT, android.net.NetworkStats.TAG_NONE,
|
||||||
|
android.net.NetworkStats.METERED_NO, android.net.NetworkStats.ROAMING_NO,
|
||||||
|
android.net.NetworkStats.DEFAULT_NETWORK_NO,
|
||||||
150, 10, 250, 20, 0);
|
150, 10, 250, 20, 0);
|
||||||
|
|
||||||
Entry uid2Entry2 = new Entry(
|
Entry uid2Entry2 = new Entry(
|
||||||
"if2", uid2,
|
"if2", uid2,
|
||||||
android.net.NetworkStats.SET_DEFAULT, android.net.NetworkStats.TAG_NONE,
|
android.net.NetworkStats.SET_DEFAULT, android.net.NetworkStats.TAG_NONE,
|
||||||
|
android.net.NetworkStats.METERED_NO, android.net.NetworkStats.ROAMING_NO,
|
||||||
|
android.net.NetworkStats.DEFAULT_NETWORK_NO,
|
||||||
150, 10, 250, 20, 0);
|
150, 10, 250, 20, 0);
|
||||||
|
|
||||||
NetworkStatsHistory history1 = new NetworkStatsHistory(10, 2);
|
NetworkStatsHistory history1 = new NetworkStatsHistory(10, 2);
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ package android.net;
|
|||||||
|
|
||||||
import static android.net.ConnectivityManager.TYPE_MOBILE;
|
import static android.net.ConnectivityManager.TYPE_MOBILE;
|
||||||
import static android.net.NetworkIdentity.OEM_NONE;
|
import static android.net.NetworkIdentity.OEM_NONE;
|
||||||
|
import static android.net.NetworkStats.DEFAULT_NETWORK_NO;
|
||||||
|
import static android.net.NetworkStats.IFACE_ALL;
|
||||||
|
import static android.net.NetworkStats.METERED_NO;
|
||||||
|
import static android.net.NetworkStats.ROAMING_NO;
|
||||||
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;
|
||||||
import static android.net.NetworkStats.TAG_NONE;
|
import static android.net.NetworkStats.TAG_NONE;
|
||||||
@@ -480,7 +484,8 @@ public class NetworkStatsCollectionTest {
|
|||||||
ident.add(new NetworkIdentity(ConnectivityManager.TYPE_MOBILE, -1, TEST_IMSI, null,
|
ident.add(new NetworkIdentity(ConnectivityManager.TYPE_MOBILE, -1, TEST_IMSI, null,
|
||||||
false, true, true, OEM_NONE, TEST_SUBID));
|
false, true, true, OEM_NONE, TEST_SUBID));
|
||||||
large.recordData(ident, UID_ALL, SET_ALL, TAG_NONE, TIME_A, TIME_B,
|
large.recordData(ident, UID_ALL, SET_ALL, TAG_NONE, TIME_A, TIME_B,
|
||||||
new NetworkStats.Entry(12_730_893_164L, 1, 0, 0, 0));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, 12_730_893_164L, 1, 0, 0, 0));
|
||||||
|
|
||||||
// Verify untouched total
|
// Verify untouched total
|
||||||
assertEquals(12_730_893_164L, getHistory(large, null, TIME_A, TIME_C).getTotalBytes());
|
assertEquals(12_730_893_164L, getHistory(large, null, TIME_A, TIME_C).getTotalBytes());
|
||||||
@@ -659,26 +664,33 @@ public class NetworkStatsCollectionTest {
|
|||||||
|
|
||||||
private static void assertEntry(long rxBytes, long rxPackets, long txBytes, long txPackets,
|
private static void assertEntry(long rxBytes, long rxPackets, long txBytes, long txPackets,
|
||||||
NetworkStats.Entry actual) {
|
NetworkStats.Entry actual) {
|
||||||
assertEntry(new NetworkStats.Entry(rxBytes, rxPackets, txBytes, txPackets, 0L), actual);
|
assertEntry(new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, rxBytes, rxPackets, txBytes, txPackets, 0L),
|
||||||
|
actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertEntry(long rxBytes, long rxPackets, long txBytes, long txPackets,
|
private static void assertEntry(long rxBytes, long rxPackets, long txBytes, long txPackets,
|
||||||
NetworkStatsHistory.Entry actual) {
|
NetworkStatsHistory.Entry actual) {
|
||||||
assertEntry(new NetworkStats.Entry(rxBytes, rxPackets, txBytes, txPackets, 0L), actual);
|
assertEntry(new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, rxBytes, rxPackets, txBytes, txPackets, 0L),
|
||||||
|
actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertEntry(NetworkStats.Entry expected,
|
private static void assertEntry(NetworkStats.Entry expected,
|
||||||
NetworkStatsHistory.Entry actual) {
|
NetworkStatsHistory.Entry actual) {
|
||||||
assertEntry(expected, new NetworkStats.Entry(actual.rxBytes, actual.rxPackets,
|
assertEntry(expected, new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE,
|
||||||
|
METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO, actual.rxBytes, actual.rxPackets,
|
||||||
actual.txBytes, actual.txPackets, 0L));
|
actual.txBytes, actual.txPackets, 0L));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertEntry(NetworkStatsHistory.Entry expected,
|
private static void assertEntry(NetworkStatsHistory.Entry expected,
|
||||||
NetworkStatsHistory.Entry actual) {
|
NetworkStatsHistory.Entry actual) {
|
||||||
assertEntry(new NetworkStats.Entry(actual.rxBytes, actual.rxPackets,
|
assertEntry(new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
actual.txBytes, actual.txPackets, 0L),
|
ROAMING_NO, DEFAULT_NETWORK_NO, actual.rxBytes, actual.rxPackets,
|
||||||
new NetworkStats.Entry(actual.rxBytes, actual.rxPackets,
|
actual.txBytes, actual.txPackets, 0L),
|
||||||
actual.txBytes, actual.txPackets, 0L));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, actual.rxBytes, actual.rxPackets,
|
||||||
|
actual.txBytes, actual.txPackets, 0L));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertEntry(NetworkStats.Entry expected,
|
private static void assertEntry(NetworkStats.Entry expected,
|
||||||
|
|||||||
@@ -16,6 +16,13 @@
|
|||||||
|
|
||||||
package android.net;
|
package android.net;
|
||||||
|
|
||||||
|
import static android.net.NetworkStats.DEFAULT_NETWORK_NO;
|
||||||
|
import static android.net.NetworkStats.IFACE_ALL;
|
||||||
|
import static android.net.NetworkStats.METERED_NO;
|
||||||
|
import static android.net.NetworkStats.ROAMING_NO;
|
||||||
|
import static android.net.NetworkStats.SET_DEFAULT;
|
||||||
|
import static android.net.NetworkStats.TAG_NONE;
|
||||||
|
import static android.net.NetworkStats.UID_ALL;
|
||||||
import static android.net.NetworkStatsHistory.DataStreamUtils.readVarLong;
|
import static android.net.NetworkStatsHistory.DataStreamUtils.readVarLong;
|
||||||
import static android.net.NetworkStatsHistory.DataStreamUtils.writeVarLong;
|
import static android.net.NetworkStatsHistory.DataStreamUtils.writeVarLong;
|
||||||
import static android.net.NetworkStatsHistory.Entry.UNKNOWN;
|
import static android.net.NetworkStatsHistory.Entry.UNKNOWN;
|
||||||
@@ -110,7 +117,8 @@ public class NetworkStatsHistoryTest {
|
|||||||
|
|
||||||
// record data into narrow window to get single bucket
|
// record data into narrow window to get single bucket
|
||||||
stats.recordData(TEST_START, TEST_START + SECOND_IN_MILLIS,
|
stats.recordData(TEST_START, TEST_START + SECOND_IN_MILLIS,
|
||||||
new NetworkStats.Entry(1024L, 10L, 2048L, 20L, 2L));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, 1024L, 10L, 2048L, 20L, 2L));
|
||||||
|
|
||||||
assertEquals(1, stats.size());
|
assertEquals(1, stats.size());
|
||||||
assertValues(stats, 0, SECOND_IN_MILLIS, 1024L, 10L, 2048L, 20L, 2L);
|
assertValues(stats, 0, SECOND_IN_MILLIS, 1024L, 10L, 2048L, 20L, 2L);
|
||||||
@@ -124,7 +132,8 @@ public class NetworkStatsHistoryTest {
|
|||||||
// split equally across two buckets
|
// split equally across two buckets
|
||||||
final long recordStart = TEST_START + (bucketDuration / 2);
|
final long recordStart = TEST_START + (bucketDuration / 2);
|
||||||
stats.recordData(recordStart, recordStart + bucketDuration,
|
stats.recordData(recordStart, recordStart + bucketDuration,
|
||||||
new NetworkStats.Entry(1024L, 10L, 128L, 2L, 2L));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, 1024L, 10L, 128L, 2L, 2L));
|
||||||
|
|
||||||
assertEquals(2, stats.size());
|
assertEquals(2, stats.size());
|
||||||
assertValues(stats, 0, HOUR_IN_MILLIS / 2, 512L, 5L, 64L, 1L, 1L);
|
assertValues(stats, 0, HOUR_IN_MILLIS / 2, 512L, 5L, 64L, 1L, 1L);
|
||||||
@@ -141,7 +150,8 @@ public class NetworkStatsHistoryTest {
|
|||||||
final long recordStart = (TEST_START + BUCKET_SIZE) - MINUTE_IN_MILLIS;
|
final long recordStart = (TEST_START + BUCKET_SIZE) - MINUTE_IN_MILLIS;
|
||||||
final long recordEnd = (TEST_START + (BUCKET_SIZE * 2)) + (MINUTE_IN_MILLIS * 4);
|
final long recordEnd = (TEST_START + (BUCKET_SIZE * 2)) + (MINUTE_IN_MILLIS * 4);
|
||||||
stats.recordData(recordStart, recordEnd,
|
stats.recordData(recordStart, recordEnd,
|
||||||
new NetworkStats.Entry(1000L, 2000L, 5000L, 10000L, 100L));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, 1000L, 2000L, 5000L, 10000L, 100L));
|
||||||
|
|
||||||
assertEquals(3, stats.size());
|
assertEquals(3, stats.size());
|
||||||
// first bucket should have (1/20 of value)
|
// first bucket should have (1/20 of value)
|
||||||
@@ -161,9 +171,11 @@ public class NetworkStatsHistoryTest {
|
|||||||
final long firstStart = TEST_START;
|
final long firstStart = TEST_START;
|
||||||
final long lastStart = TEST_START + WEEK_IN_MILLIS;
|
final long lastStart = TEST_START + WEEK_IN_MILLIS;
|
||||||
stats.recordData(firstStart, firstStart + SECOND_IN_MILLIS,
|
stats.recordData(firstStart, firstStart + SECOND_IN_MILLIS,
|
||||||
new NetworkStats.Entry(128L, 2L, 256L, 4L, 1L));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, 128L, 2L, 256L, 4L, 1L));
|
||||||
stats.recordData(lastStart, lastStart + SECOND_IN_MILLIS,
|
stats.recordData(lastStart, lastStart + SECOND_IN_MILLIS,
|
||||||
new NetworkStats.Entry(64L, 1L, 512L, 8L, 2L));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, 64L, 1L, 512L, 8L, 2L));
|
||||||
|
|
||||||
// we should have two buckets, far apart from each other
|
// we should have two buckets, far apart from each other
|
||||||
assertEquals(2, stats.size());
|
assertEquals(2, stats.size());
|
||||||
@@ -174,7 +186,8 @@ public class NetworkStatsHistoryTest {
|
|||||||
final long middleStart = TEST_START + DAY_IN_MILLIS;
|
final long middleStart = TEST_START + DAY_IN_MILLIS;
|
||||||
final long middleEnd = middleStart + (HOUR_IN_MILLIS * 2);
|
final long middleEnd = middleStart + (HOUR_IN_MILLIS * 2);
|
||||||
stats.recordData(middleStart, middleEnd,
|
stats.recordData(middleStart, middleEnd,
|
||||||
new NetworkStats.Entry(2048L, 4L, 2048L, 4L, 2L));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, 2048L, 4L, 2048L, 4L, 2L));
|
||||||
|
|
||||||
// now should have four buckets, with new record in middle two buckets
|
// now should have four buckets, with new record in middle two buckets
|
||||||
assertEquals(4, stats.size());
|
assertEquals(4, stats.size());
|
||||||
@@ -191,10 +204,12 @@ public class NetworkStatsHistoryTest {
|
|||||||
|
|
||||||
// record some data in one bucket, and another overlapping buckets
|
// record some data in one bucket, and another overlapping buckets
|
||||||
stats.recordData(TEST_START, TEST_START + SECOND_IN_MILLIS,
|
stats.recordData(TEST_START, TEST_START + SECOND_IN_MILLIS,
|
||||||
new NetworkStats.Entry(256L, 2L, 256L, 2L, 1L));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, 256L, 2L, 256L, 2L, 1L));
|
||||||
final long midStart = TEST_START + (HOUR_IN_MILLIS / 2);
|
final long midStart = TEST_START + (HOUR_IN_MILLIS / 2);
|
||||||
stats.recordData(midStart, midStart + HOUR_IN_MILLIS,
|
stats.recordData(midStart, midStart + HOUR_IN_MILLIS,
|
||||||
new NetworkStats.Entry(1024L, 10L, 1024L, 10L, 10L));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, 1024L, 10L, 1024L, 10L, 10L));
|
||||||
|
|
||||||
// should have two buckets, with some data mixed together
|
// should have two buckets, with some data mixed together
|
||||||
assertEquals(2, stats.size());
|
assertEquals(2, stats.size());
|
||||||
@@ -371,9 +386,11 @@ public class NetworkStatsHistoryTest {
|
|||||||
MINUTE_IN_MILLIS, 0, FIELD_RX_BYTES | FIELD_TX_BYTES);
|
MINUTE_IN_MILLIS, 0, FIELD_RX_BYTES | FIELD_TX_BYTES);
|
||||||
|
|
||||||
history.recordData(0, MINUTE_IN_MILLIS,
|
history.recordData(0, MINUTE_IN_MILLIS,
|
||||||
new NetworkStats.Entry(1024L, 10L, 2048L, 20L, 4L));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, 1024L, 10L, 2048L, 20L, 4L));
|
||||||
history.recordData(0, 2 * MINUTE_IN_MILLIS,
|
history.recordData(0, 2 * MINUTE_IN_MILLIS,
|
||||||
new NetworkStats.Entry(2L, 2L, 2L, 2L, 2L));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, 2L, 2L, 2L, 2L, 2L));
|
||||||
|
|
||||||
assertFullValues(history, UNKNOWN, 1026L, UNKNOWN, 2050L, UNKNOWN, UNKNOWN);
|
assertFullValues(history, UNKNOWN, 1026L, UNKNOWN, 2050L, UNKNOWN, UNKNOWN);
|
||||||
}
|
}
|
||||||
@@ -385,7 +402,8 @@ public class NetworkStatsHistoryTest {
|
|||||||
MINUTE_IN_MILLIS, 0, FIELD_RX_PACKETS | FIELD_OPERATIONS);
|
MINUTE_IN_MILLIS, 0, FIELD_RX_PACKETS | FIELD_OPERATIONS);
|
||||||
|
|
||||||
full.recordData(0, MINUTE_IN_MILLIS,
|
full.recordData(0, MINUTE_IN_MILLIS,
|
||||||
new NetworkStats.Entry(1024L, 10L, 2048L, 20L, 4L));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, 1024L, 10L, 2048L, 20L, 4L));
|
||||||
partial.recordEntireHistory(full);
|
partial.recordEntireHistory(full);
|
||||||
|
|
||||||
assertFullValues(partial, UNKNOWN, UNKNOWN, 10L, UNKNOWN, UNKNOWN, 4L);
|
assertFullValues(partial, UNKNOWN, UNKNOWN, 10L, UNKNOWN, UNKNOWN, 4L);
|
||||||
@@ -398,7 +416,8 @@ public class NetworkStatsHistoryTest {
|
|||||||
MINUTE_IN_MILLIS, 0, FIELD_RX_PACKETS | FIELD_OPERATIONS);
|
MINUTE_IN_MILLIS, 0, FIELD_RX_PACKETS | FIELD_OPERATIONS);
|
||||||
|
|
||||||
partial.recordData(0, MINUTE_IN_MILLIS,
|
partial.recordData(0, MINUTE_IN_MILLIS,
|
||||||
new NetworkStats.Entry(1024L, 10L, 2048L, 20L, 4L));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, 1024L, 10L, 2048L, 20L, 4L));
|
||||||
full.recordEntireHistory(partial);
|
full.recordEntireHistory(partial);
|
||||||
|
|
||||||
assertFullValues(full, MINUTE_IN_MILLIS, 0L, 10L, 0L, 0L, 4L);
|
assertFullValues(full, MINUTE_IN_MILLIS, 0L, 10L, 0L, 0L, 4L);
|
||||||
@@ -408,9 +427,11 @@ public class NetworkStatsHistoryTest {
|
|||||||
public void testSerialize() throws Exception {
|
public void testSerialize() throws Exception {
|
||||||
final NetworkStatsHistory before = new NetworkStatsHistory(MINUTE_IN_MILLIS, 40, FIELD_ALL);
|
final NetworkStatsHistory before = new NetworkStatsHistory(MINUTE_IN_MILLIS, 40, FIELD_ALL);
|
||||||
before.recordData(0, 4 * MINUTE_IN_MILLIS,
|
before.recordData(0, 4 * MINUTE_IN_MILLIS,
|
||||||
new NetworkStats.Entry(1024L, 10L, 2048L, 20L, 4L));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, 1024L, 10L, 2048L, 20L, 4L));
|
||||||
before.recordData(DAY_IN_MILLIS, DAY_IN_MILLIS + MINUTE_IN_MILLIS,
|
before.recordData(DAY_IN_MILLIS, DAY_IN_MILLIS + MINUTE_IN_MILLIS,
|
||||||
new NetworkStats.Entry(10L, 20L, 30L, 40L, 50L));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, 10L, 20L, 30L, 40L, 50L));
|
||||||
|
|
||||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
before.writeToStream(new DataOutputStream(out));
|
before.writeToStream(new DataOutputStream(out));
|
||||||
@@ -451,11 +472,14 @@ public class NetworkStatsHistoryTest {
|
|||||||
final long THIRD_END = THIRD_START + (2 * HOUR_IN_MILLIS);
|
final long THIRD_END = THIRD_START + (2 * HOUR_IN_MILLIS);
|
||||||
|
|
||||||
stats.recordData(FIRST_START, FIRST_END,
|
stats.recordData(FIRST_START, FIRST_END,
|
||||||
new NetworkStats.Entry(1024L, 10L, 2048L, 20L, 2L));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, 1024L, 10L, 2048L, 20L, 2L));
|
||||||
stats.recordData(SECOND_START, SECOND_END,
|
stats.recordData(SECOND_START, SECOND_END,
|
||||||
new NetworkStats.Entry(1024L, 10L, 2048L, 20L, 2L));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, 1024L, 10L, 2048L, 20L, 2L));
|
||||||
stats.recordData(THIRD_START, THIRD_END,
|
stats.recordData(THIRD_START, THIRD_END,
|
||||||
new NetworkStats.Entry(1024L, 10L, 2048L, 20L, 2L));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, 1024L, 10L, 2048L, 20L, 2L));
|
||||||
|
|
||||||
// should have buckets: 2+1+2
|
// should have buckets: 2+1+2
|
||||||
assertEquals(5, stats.size());
|
assertEquals(5, stats.size());
|
||||||
@@ -494,11 +518,14 @@ public class NetworkStatsHistoryTest {
|
|||||||
final long THIRD_END = THIRD_START + (2 * HOUR_IN_MILLIS);
|
final long THIRD_END = THIRD_START + (2 * HOUR_IN_MILLIS);
|
||||||
|
|
||||||
stats.recordData(FIRST_START, FIRST_END,
|
stats.recordData(FIRST_START, FIRST_END,
|
||||||
new NetworkStats.Entry(1024L, 10L, 2048L, 20L, 2L));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, 1024L, 10L, 2048L, 20L, 2L));
|
||||||
stats.recordData(SECOND_START, SECOND_END,
|
stats.recordData(SECOND_START, SECOND_END,
|
||||||
new NetworkStats.Entry(1024L, 10L, 2048L, 20L, 2L));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, 1024L, 10L, 2048L, 20L, 2L));
|
||||||
stats.recordData(THIRD_START, THIRD_END,
|
stats.recordData(THIRD_START, THIRD_END,
|
||||||
new NetworkStats.Entry(1024L, 10L, 2048L, 20L, 2L));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, 1024L, 10L, 2048L, 20L, 2L));
|
||||||
|
|
||||||
assertFalse(stats.intersects(10, 20));
|
assertFalse(stats.intersects(10, 20));
|
||||||
assertFalse(stats.intersects(TEST_START + YEAR_IN_MILLIS, TEST_START + YEAR_IN_MILLIS + 1));
|
assertFalse(stats.intersects(TEST_START + YEAR_IN_MILLIS, TEST_START + YEAR_IN_MILLIS + 1));
|
||||||
@@ -520,7 +547,8 @@ public class NetworkStatsHistoryTest {
|
|||||||
public void testSetValues() throws Exception {
|
public void testSetValues() throws Exception {
|
||||||
stats = new NetworkStatsHistory(HOUR_IN_MILLIS);
|
stats = new NetworkStatsHistory(HOUR_IN_MILLIS);
|
||||||
stats.recordData(TEST_START, TEST_START + 1,
|
stats.recordData(TEST_START, TEST_START + 1,
|
||||||
new NetworkStats.Entry(1024L, 10L, 2048L, 20L, 2L));
|
new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO,
|
||||||
|
ROAMING_NO, DEFAULT_NETWORK_NO, 1024L, 10L, 2048L, 20L, 2L));
|
||||||
|
|
||||||
assertEquals(1024L + 2048L, stats.getTotalBytes());
|
assertEquals(1024L + 2048L, stats.getTotalBytes());
|
||||||
|
|
||||||
|
|||||||
@@ -960,7 +960,7 @@ public class NetworkStatsTest {
|
|||||||
|
|
||||||
// Ipv4 traffic sent/received by an app on stacked interface.
|
// Ipv4 traffic sent/received by an app on stacked interface.
|
||||||
final NetworkStats.Entry appEntry = new NetworkStats.Entry(
|
final NetworkStats.Entry appEntry = new NetworkStats.Entry(
|
||||||
v4Iface, appUid, SET_DEFAULT, TAG_NONE,
|
v4Iface, appUid, SET_DEFAULT, TAG_NONE, METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO,
|
||||||
30501490 /* rxBytes */,
|
30501490 /* rxBytes */,
|
||||||
22401 /* rxPackets */,
|
22401 /* rxPackets */,
|
||||||
876235 /* txBytes */,
|
876235 /* txBytes */,
|
||||||
@@ -969,7 +969,8 @@ public class NetworkStatsTest {
|
|||||||
|
|
||||||
// Traffic measured for the root uid on the base interface.
|
// Traffic measured for the root uid on the base interface.
|
||||||
final NetworkStats.Entry rootUidEntry = new NetworkStats.Entry(
|
final NetworkStats.Entry rootUidEntry = new NetworkStats.Entry(
|
||||||
baseIface, rootUid, SET_DEFAULT, TAG_NONE,
|
baseIface, rootUid, SET_DEFAULT, TAG_NONE, METERED_NO, ROAMING_NO,
|
||||||
|
DEFAULT_NETWORK_NO,
|
||||||
163577 /* rxBytes */,
|
163577 /* rxBytes */,
|
||||||
187 /* rxPackets */,
|
187 /* rxPackets */,
|
||||||
17607 /* txBytes */,
|
17607 /* txBytes */,
|
||||||
@@ -977,7 +978,8 @@ public class NetworkStatsTest {
|
|||||||
0 /* operations */);
|
0 /* operations */);
|
||||||
|
|
||||||
final NetworkStats.Entry otherEntry = new NetworkStats.Entry(
|
final NetworkStats.Entry otherEntry = new NetworkStats.Entry(
|
||||||
otherIface, appUid, SET_DEFAULT, TAG_NONE,
|
otherIface, appUid, SET_DEFAULT, TAG_NONE, METERED_NO, ROAMING_NO,
|
||||||
|
DEFAULT_NETWORK_NO,
|
||||||
2600 /* rxBytes */,
|
2600 /* rxBytes */,
|
||||||
2 /* rxPackets */,
|
2 /* rxPackets */,
|
||||||
3800 /* txBytes */,
|
3800 /* txBytes */,
|
||||||
@@ -993,14 +995,14 @@ public class NetworkStatsTest {
|
|||||||
|
|
||||||
assertEquals(3, stats.size());
|
assertEquals(3, stats.size());
|
||||||
final NetworkStats.Entry expectedAppUid = new NetworkStats.Entry(
|
final NetworkStats.Entry expectedAppUid = new NetworkStats.Entry(
|
||||||
v4Iface, appUid, SET_DEFAULT, TAG_NONE,
|
v4Iface, appUid, SET_DEFAULT, TAG_NONE, METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO,
|
||||||
30949510,
|
30949510,
|
||||||
22401,
|
22401,
|
||||||
1152335,
|
1152335,
|
||||||
13805,
|
13805,
|
||||||
0);
|
0);
|
||||||
final NetworkStats.Entry expectedRootUid = new NetworkStats.Entry(
|
final NetworkStats.Entry expectedRootUid = new NetworkStats.Entry(
|
||||||
baseIface, 0, SET_DEFAULT, TAG_NONE,
|
baseIface, 0, SET_DEFAULT, TAG_NONE, METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO,
|
||||||
163577,
|
163577,
|
||||||
187,
|
187,
|
||||||
17607,
|
17607,
|
||||||
@@ -1014,14 +1016,16 @@ public class NetworkStatsTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testApply464xlatAdjustments_noStackedIface() {
|
public void testApply464xlatAdjustments_noStackedIface() {
|
||||||
NetworkStats.Entry firstEntry = new NetworkStats.Entry(
|
NetworkStats.Entry firstEntry = new NetworkStats.Entry(
|
||||||
"if1", 10002, SET_DEFAULT, TAG_NONE,
|
"if1", 10002, SET_DEFAULT, TAG_NONE, METERED_NO, ROAMING_NO,
|
||||||
|
DEFAULT_NETWORK_NO,
|
||||||
2600 /* rxBytes */,
|
2600 /* rxBytes */,
|
||||||
2 /* rxPackets */,
|
2 /* rxPackets */,
|
||||||
3800 /* txBytes */,
|
3800 /* txBytes */,
|
||||||
3 /* txPackets */,
|
3 /* txPackets */,
|
||||||
0 /* operations */);
|
0 /* operations */);
|
||||||
NetworkStats.Entry secondEntry = new NetworkStats.Entry(
|
NetworkStats.Entry secondEntry = new NetworkStats.Entry(
|
||||||
"if2", 10002, SET_DEFAULT, TAG_NONE,
|
"if2", 10002, SET_DEFAULT, TAG_NONE, METERED_NO, ROAMING_NO,
|
||||||
|
DEFAULT_NETWORK_NO,
|
||||||
5000 /* rxBytes */,
|
5000 /* rxBytes */,
|
||||||
3 /* rxPackets */,
|
3 /* rxPackets */,
|
||||||
6000 /* txBytes */,
|
6000 /* txBytes */,
|
||||||
|
|||||||
@@ -862,7 +862,7 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
incrementCurrentTime(MINUTE_IN_MILLIS);
|
incrementCurrentTime(MINUTE_IN_MILLIS);
|
||||||
expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 1)
|
expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 1)
|
||||||
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE,
|
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE,
|
||||||
12L, 18L, 14L, 1L, 0L)));
|
METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO, 12L, 18L, 14L, 1L, 0L)));
|
||||||
forcePollAndWaitForIdle();
|
forcePollAndWaitForIdle();
|
||||||
|
|
||||||
// Verify 3g templates gets stats.
|
// Verify 3g templates gets stats.
|
||||||
@@ -877,10 +877,10 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 1)
|
expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 1)
|
||||||
// Append more traffic on existing 3g stats entry.
|
// Append more traffic on existing 3g stats entry.
|
||||||
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE,
|
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE,
|
||||||
16L, 22L, 17L, 2L, 0L))
|
METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO, 16L, 22L, 17L, 2L, 0L))
|
||||||
// Add entry that is new on 4g.
|
// Add entry that is new on 4g.
|
||||||
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_FOREGROUND, TAG_NONE,
|
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_FOREGROUND, TAG_NONE,
|
||||||
33L, 27L, 8L, 10L, 1L)));
|
METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO, 33L, 27L, 8L, 10L, 1L)));
|
||||||
forcePollAndWaitForIdle();
|
forcePollAndWaitForIdle();
|
||||||
|
|
||||||
// Verify ALL_MOBILE template gets all. 3g template counters do not increase.
|
// Verify ALL_MOBILE template gets all. 3g template counters do not increase.
|
||||||
@@ -897,12 +897,12 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 1)
|
expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 1)
|
||||||
// Existing stats remains.
|
// Existing stats remains.
|
||||||
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE,
|
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE,
|
||||||
16L, 22L, 17L, 2L, 0L))
|
METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO, 16L, 22L, 17L, 2L, 0L))
|
||||||
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_FOREGROUND, TAG_NONE,
|
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_FOREGROUND, TAG_NONE,
|
||||||
33L, 27L, 8L, 10L, 1L))
|
METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO, 33L, 27L, 8L, 10L, 1L))
|
||||||
// Add some traffic on 5g.
|
// Add some traffic on 5g.
|
||||||
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE,
|
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE,
|
||||||
5L, 13L, 31L, 9L, 2L)));
|
METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO, 5L, 13L, 31L, 9L, 2L)));
|
||||||
forcePollAndWaitForIdle();
|
forcePollAndWaitForIdle();
|
||||||
|
|
||||||
// Verify ALL_MOBILE template gets all.
|
// Verify ALL_MOBILE template gets all.
|
||||||
@@ -984,7 +984,7 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
incrementCurrentTime(MINUTE_IN_MILLIS);
|
incrementCurrentTime(MINUTE_IN_MILLIS);
|
||||||
expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 1)
|
expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 1)
|
||||||
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE,
|
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE,
|
||||||
36L, 41L, 24L, 96L, 0L)));
|
METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO, 36L, 41L, 24L, 96L, 0L)));
|
||||||
forcePollAndWaitForIdle();
|
forcePollAndWaitForIdle();
|
||||||
|
|
||||||
// OEM_PRIVATE network comes online.
|
// OEM_PRIVATE network comes online.
|
||||||
@@ -999,7 +999,7 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
incrementCurrentTime(MINUTE_IN_MILLIS);
|
incrementCurrentTime(MINUTE_IN_MILLIS);
|
||||||
expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 1)
|
expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 1)
|
||||||
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE,
|
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE,
|
||||||
49L, 71L, 72L, 48L, 0L)));
|
METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO, 49L, 71L, 72L, 48L, 0L)));
|
||||||
forcePollAndWaitForIdle();
|
forcePollAndWaitForIdle();
|
||||||
|
|
||||||
// OEM_PAID + OEM_PRIVATE network comes online.
|
// OEM_PAID + OEM_PRIVATE network comes online.
|
||||||
@@ -1015,7 +1015,7 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
incrementCurrentTime(MINUTE_IN_MILLIS);
|
incrementCurrentTime(MINUTE_IN_MILLIS);
|
||||||
expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 1)
|
expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 1)
|
||||||
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE,
|
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE,
|
||||||
57L, 86L, 83L, 93L, 0L)));
|
METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO, 57L, 86L, 83L, 93L, 0L)));
|
||||||
forcePollAndWaitForIdle();
|
forcePollAndWaitForIdle();
|
||||||
|
|
||||||
// OEM_NONE network comes online.
|
// OEM_NONE network comes online.
|
||||||
@@ -1029,7 +1029,7 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
incrementCurrentTime(MINUTE_IN_MILLIS);
|
incrementCurrentTime(MINUTE_IN_MILLIS);
|
||||||
expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 1)
|
expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 1)
|
||||||
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE,
|
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE,
|
||||||
29L, 73L, 34L, 31L, 0L)));
|
METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO, 29L, 73L, 34L, 31L, 0L)));
|
||||||
forcePollAndWaitForIdle();
|
forcePollAndWaitForIdle();
|
||||||
|
|
||||||
// Verify OEM_PAID template gets only relevant stats.
|
// Verify OEM_PAID template gets only relevant stats.
|
||||||
@@ -1140,7 +1140,8 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
// Increase arbitrary time which does not align to the bucket edge, create some traffic.
|
// Increase arbitrary time which does not align to the bucket edge, create some traffic.
|
||||||
incrementCurrentTime(1751000L);
|
incrementCurrentTime(1751000L);
|
||||||
NetworkStats.Entry entry = new NetworkStats.Entry(
|
NetworkStats.Entry entry = new NetworkStats.Entry(
|
||||||
TEST_IFACE, UID_ALL, SET_DEFAULT, TAG_NONE, 50L, 5L, 51L, 1L, 3L);
|
TEST_IFACE, UID_ALL, SET_DEFAULT, TAG_NONE, METERED_NO, ROAMING_NO,
|
||||||
|
DEFAULT_NETWORK_NO, 50L, 5L, 51L, 1L, 3L);
|
||||||
expectNetworkStatsSummary(new NetworkStats(getElapsedRealtime(), 1).insertEntry(entry));
|
expectNetworkStatsSummary(new NetworkStats(getElapsedRealtime(), 1).insertEntry(entry));
|
||||||
expectNetworkStatsUidDetail(buildEmptyStats());
|
expectNetworkStatsUidDetail(buildEmptyStats());
|
||||||
forcePollAndWaitForIdle();
|
forcePollAndWaitForIdle();
|
||||||
@@ -1174,11 +1175,14 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
new UnderlyingNetworkInfo[0]);
|
new UnderlyingNetworkInfo[0]);
|
||||||
|
|
||||||
NetworkStats.Entry entry1 = new NetworkStats.Entry(
|
NetworkStats.Entry entry1 = new NetworkStats.Entry(
|
||||||
TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE, 50L, 5L, 50L, 5L, 0L);
|
TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE, METERED_NO, ROAMING_NO,
|
||||||
|
DEFAULT_NETWORK_NO, 50L, 5L, 50L, 5L, 0L);
|
||||||
NetworkStats.Entry entry2 = new NetworkStats.Entry(
|
NetworkStats.Entry entry2 = new NetworkStats.Entry(
|
||||||
TEST_IFACE, UID_RED, SET_DEFAULT, 0xF00D, 50L, 5L, 50L, 5L, 0L);
|
TEST_IFACE, UID_RED, SET_DEFAULT, 0xF00D, METERED_NO, ROAMING_NO,
|
||||||
|
DEFAULT_NETWORK_NO, 50L, 5L, 50L, 5L, 0L);
|
||||||
NetworkStats.Entry entry3 = new NetworkStats.Entry(
|
NetworkStats.Entry entry3 = new NetworkStats.Entry(
|
||||||
TEST_IFACE, UID_BLUE, SET_DEFAULT, 0xBEEF, 1024L, 8L, 512L, 4L, 0L);
|
TEST_IFACE, UID_BLUE, SET_DEFAULT, 0xBEEF, METERED_NO, ROAMING_NO,
|
||||||
|
DEFAULT_NETWORK_NO, 1024L, 8L, 512L, 4L, 0L);
|
||||||
|
|
||||||
incrementCurrentTime(HOUR_IN_MILLIS);
|
incrementCurrentTime(HOUR_IN_MILLIS);
|
||||||
expectDefaultSettings();
|
expectDefaultSettings();
|
||||||
@@ -1686,7 +1690,7 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
incrementCurrentTime(MINUTE_IN_MILLIS);
|
incrementCurrentTime(MINUTE_IN_MILLIS);
|
||||||
expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 1)
|
expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 1)
|
||||||
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE,
|
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE,
|
||||||
12L, 18L, 14L, 1L, 0L)));
|
METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO, 12L, 18L, 14L, 1L, 0L)));
|
||||||
forcePollAndWaitForIdle();
|
forcePollAndWaitForIdle();
|
||||||
|
|
||||||
// Since CombineSubtypeEnabled is false by default in unit test, the generated traffic
|
// Since CombineSubtypeEnabled is false by default in unit test, the generated traffic
|
||||||
@@ -1710,9 +1714,10 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
// Append more traffic on existing snapshot.
|
// Append more traffic on existing snapshot.
|
||||||
expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 1)
|
expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 1)
|
||||||
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE,
|
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE,
|
||||||
12L + 4L, 18L + 4L, 14L + 3L, 1L + 1L, 0L))
|
METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO, 12L + 4L, 18L + 4L, 14L + 3L,
|
||||||
|
1L + 1L, 0L))
|
||||||
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_FOREGROUND, TAG_NONE,
|
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_FOREGROUND, TAG_NONE,
|
||||||
35L, 29L, 7L, 11L, 1L)));
|
METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO, 35L, 29L, 7L, 11L, 1L)));
|
||||||
forcePollAndWaitForIdle();
|
forcePollAndWaitForIdle();
|
||||||
|
|
||||||
// Verify 3G counters do not increase, while template with unknown RAT type gets new
|
// Verify 3G counters do not increase, while template with unknown RAT type gets new
|
||||||
@@ -1732,9 +1737,9 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
// Append more traffic on existing snapshot.
|
// Append more traffic on existing snapshot.
|
||||||
expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 1)
|
expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 1)
|
||||||
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE,
|
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE,
|
||||||
22L, 26L, 19L, 5L, 0L))
|
METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO, 22L, 26L, 19L, 5L, 0L))
|
||||||
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_FOREGROUND, TAG_NONE,
|
.addEntry(new NetworkStats.Entry(TEST_IFACE, UID_RED, SET_FOREGROUND, TAG_NONE,
|
||||||
35L, 29L, 7L, 11L, 1L)));
|
METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO, 35L, 29L, 7L, 11L, 1L)));
|
||||||
forcePollAndWaitForIdle();
|
forcePollAndWaitForIdle();
|
||||||
|
|
||||||
// Verify traffic is split by RAT type, no increase on template with unknown RAT type
|
// Verify traffic is split by RAT type, no increase on template with unknown RAT type
|
||||||
|
|||||||
Reference in New Issue
Block a user