Merge changes from topic 'framework-net-aosp'

* changes:
  DO NOT MERGE: IpConnectivityMetrics: rate limit ApfProgramEvents
  DO NOT MERGE: TokenBucket for rate-limiting and throttling
  DO NOT MERGE: IpConnectivityMetrics reads buffer size in settings
  DO NOT MERGE: CaptivePortalLogin: set mixed content policy to compatibility.
  DO NOT MERGE: Add IP conn metrics to dumpsys and bug reports
  DO NOT MERGE: IpConnectivity metrics: add version number
This commit is contained in:
Treehugger Robot
2016-12-09 03:19:13 +00:00
committed by Gerrit Code Review
2 changed files with 47 additions and 13 deletions

View File

@@ -71,7 +71,8 @@ public class IpConnectivityEventBuilderTest extends TestCase {
" transport_types: 3",
" >",
" time_ms: 1",
">");
">",
"version: 2");
verifySerialization(want, ev);
}
@@ -93,7 +94,8 @@ public class IpConnectivityEventBuilderTest extends TestCase {
" state_transition: \"SomeState\"",
" >",
" time_ms: 1",
">");
">",
"version: 2");
verifySerialization(want, ev);
}
@@ -114,7 +116,8 @@ public class IpConnectivityEventBuilderTest extends TestCase {
" state_transition: \"\"",
" >",
" time_ms: 1",
">");
">",
"version: 2");
verifySerialization(want, ev);
}
@@ -160,7 +163,8 @@ public class IpConnectivityEventBuilderTest extends TestCase {
" return_codes: 178",
" >",
" time_ms: 1",
">");
">",
"version: 2");
verifySerialization(want, ev);
}
@@ -181,7 +185,8 @@ public class IpConnectivityEventBuilderTest extends TestCase {
" latency_ms: 5678",
" >",
" time_ms: 1",
">");
">",
"version: 2");
verifySerialization(want, ev);
}
@@ -200,7 +205,8 @@ public class IpConnectivityEventBuilderTest extends TestCase {
" if_name: \"wlan0\"",
" >",
" time_ms: 1",
">");
">",
"version: 2");
verifySerialization(want, ev);
}
@@ -223,7 +229,8 @@ public class IpConnectivityEventBuilderTest extends TestCase {
" >",
" >",
" time_ms: 1",
">");
">",
"version: 2");
verifySerialization(want, ev);
}
@@ -248,7 +255,8 @@ public class IpConnectivityEventBuilderTest extends TestCase {
" probe_result: 204",
" probe_type: 1",
" >",
">");
">",
"version: 2");
verifySerialization(want, ev);
}
@@ -274,7 +282,8 @@ public class IpConnectivityEventBuilderTest extends TestCase {
" program_length: 2048",
" >",
" time_ms: 1",
">");
">",
"version: 2");
verifySerialization(want, ev);
}
@@ -305,7 +314,8 @@ public class IpConnectivityEventBuilderTest extends TestCase {
" zero_lifetime_ras: 1",
" >",
" time_ms: 1",
">");
">",
"version: 2");
verifySerialization(want, ev);
}
@@ -332,7 +342,8 @@ public class IpConnectivityEventBuilderTest extends TestCase {
" router_lifetime: 2000",
" >",
" time_ms: 1",
">");
">",
"version: 2");
verifySerialization(want, ev);
}

View File

@@ -19,6 +19,7 @@ package com.android.server.connectivity;
import android.content.Context;
import android.net.ConnectivityMetricsEvent;
import android.net.IIpConnectivityMetrics;
import android.net.metrics.ApfProgramEvent;
import android.net.metrics.ApfStats;
import android.net.metrics.DefaultNetworkEvent;
import android.net.metrics.DhcpClientEvent;
@@ -57,7 +58,7 @@ public class IpConnectivityMetricsTest extends TestCase {
public void setUp() {
MockitoAnnotations.initMocks(this);
mService = new IpConnectivityMetrics(mCtx);
mService = new IpConnectivityMetrics(mCtx, (ctx) -> 2000);
}
public void testLoggingEvents() throws Exception {
@@ -112,6 +113,27 @@ public class IpConnectivityMetricsTest extends TestCase {
assertEquals("", output3);
}
public void testRateLimiting() {
final IpConnectivityLog logger = new IpConnectivityLog(mService.impl);
final ApfProgramEvent ev = new ApfProgramEvent(0, 0, 0, 0, 0);
final long fakeTimestamp = 1;
int attempt = 100; // More than burst quota, but less than buffer size.
for (int i = 0; i < attempt; i++) {
logger.log(ev);
}
String output1 = getdump("flush");
assertFalse("".equals(output1));
for (int i = 0; i < attempt; i++) {
assertFalse("expected event to be dropped", logger.log(fakeTimestamp, ev));
}
String output2 = getdump("flush");
assertEquals("", output2);
}
public void testEndToEndLogging() {
IpConnectivityLog logger = new IpConnectivityLog(mService.impl);
@@ -204,7 +226,8 @@ public class IpConnectivityMetricsTest extends TestCase {
" router_lifetime: 2000",
" >",
" time_ms: 700",
">");
">",
"version: 2");
verifySerialization(want, getdump("flush"));
}