Skip to content
Snippets Groups Projects
Commit 65186a72 authored by Ivo Kay's avatar Ivo Kay
Browse files

Allow to query NetworkStats for TYPE_PROXY

Test: atest FrameworksNetTests CtsNetTestCases
Bug: 307217169

Change-Id: I006e3191a8c6100af3d2906d5d37f4e38a3db519
parent fdcf0111
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,7 @@ 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_PROXY;
import static android.net.NetworkTemplate.MATCH_WIFI;
import static android.net.TrafficStats.UID_REMOVED;
import static android.text.format.DateUtils.WEEK_IN_MILLIS;
......@@ -784,6 +785,7 @@ public class NetworkStatsCollection implements FileRotator.Reader, FileRotator.W
dumpCheckin(pw, start, end, new NetworkTemplate.Builder(MATCH_WIFI).build(), "wifi");
dumpCheckin(pw, start, end, new NetworkTemplate.Builder(MATCH_ETHERNET).build(), "eth");
dumpCheckin(pw, start, end, new NetworkTemplate.Builder(MATCH_BLUETOOTH).build(), "bt");
dumpCheckin(pw, start, end, new NetworkTemplate.Builder(MATCH_PROXY).build(), "proxy");
}
/**
......
......@@ -1170,7 +1170,7 @@ public final class NetworkTemplate implements Parcelable {
* @param matchRule the target match rule to be checked.
*/
private static void assertRequestableMatchRule(final int matchRule) {
if (!isKnownMatchRule(matchRule) || matchRule == MATCH_PROXY) {
if (!isKnownMatchRule(matchRule)) {
throw new IllegalArgumentException("Invalid match rule: "
+ getMatchRuleName(matchRule));
}
......
......@@ -62,11 +62,6 @@ class NetworkTemplateTest {
}
}
// Verify hidden match rules cannot construct templates.
assertFailsWith<IllegalArgumentException> {
NetworkTemplate.Builder(MATCH_PROXY).build()
}
// Verify template which matches metered cellular and carrier networks with
// the given IMSI. See buildTemplateMobileAll and buildTemplateCarrierMetered.
listOf(MATCH_MOBILE, MATCH_CARRIER).forEach { matchRule ->
......@@ -170,9 +165,9 @@ class NetworkTemplateTest {
assertEquals(expectedTemplate, it)
}
// Verify template which matches ethernet and bluetooth networks.
// Verify template which matches ethernet, bluetooth and proxy networks.
// See buildTemplateEthernet and buildTemplateBluetooth.
listOf(MATCH_ETHERNET, MATCH_BLUETOOTH).forEach { matchRule ->
listOf(MATCH_ETHERNET, MATCH_BLUETOOTH, MATCH_PROXY).forEach { matchRule ->
NetworkTemplate.Builder(matchRule).build().let {
val expectedTemplate = NetworkTemplate(matchRule,
emptyArray<String>() /*subscriberIds*/, emptyArray<String>(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment