Merge commit '98e12851336b7db16e583f9afac63ecc97465980' from

oc-mr1-dev-plus-aosp-without-vendor into stage-aosp-master.

Change-Id: Ia7b8da4a00d215160e4a4fa40f6044208d1297b7
Merged-In: I19846d2a3ee27aecbae2367a74ee49082eea154d
This commit is contained in:
Xin Li
2017-11-14 12:31:11 -08:00
8 changed files with 395 additions and 126 deletions

View File

@@ -18,6 +18,7 @@ package android.net;
import static android.net.NetworkCapabilities.LINK_BANDWIDTH_UNSPECIFIED;
import static android.net.NetworkCapabilities.NET_CAPABILITY_CBS;
import static android.net.NetworkCapabilities.NET_CAPABILITY_DUN;
import static android.net.NetworkCapabilities.NET_CAPABILITY_EIMS;
import static android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET;
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_METERED;
@@ -143,6 +144,14 @@ public class NetworkCapabilitiesTest {
assertEquals("", nc1.describeImmutableDifferences(nc2));
assertEquals("", nc1.describeImmutableDifferences(nc1));
// DUN changing (http://b/65257223)
nc1 = new NetworkCapabilities()
.addCapability(NET_CAPABILITY_DUN)
.addCapability(NET_CAPABILITY_INTERNET);
nc2 = new NetworkCapabilities().addCapability(NET_CAPABILITY_INTERNET);
assertEquals("", nc1.describeImmutableDifferences(nc2));
assertEquals("", nc1.describeImmutableDifferences(nc1));
// Immutable capability changing
nc1 = new NetworkCapabilities()
.addCapability(NET_CAPABILITY_INTERNET)

View File

@@ -485,6 +485,21 @@ public class NetworkStatsHistoryTest extends AndroidTestCase {
assertTrue(stats.intersects(Long.MIN_VALUE, TEST_START + 1));
}
public void testSetValues() throws Exception {
stats = new NetworkStatsHistory(HOUR_IN_MILLIS);
stats.recordData(TEST_START, TEST_START + 1,
new NetworkStats.Entry(1024L, 10L, 2048L, 20L, 2L));
assertEquals(1024L + 2048L, stats.getTotalBytes());
final NetworkStatsHistory.Entry entry = stats.getValues(0, null);
entry.rxBytes /= 2;
entry.txBytes *= 2;
stats.setValues(0, entry);
assertEquals(512L + 4096L, stats.getTotalBytes());
}
private static void assertIndexBeforeAfter(
NetworkStatsHistory stats, int before, int after, long time) {
assertEquals("unexpected before", before, stats.getIndexBefore(time));