Add a NetworkTemplate matcher for ConnectivityManager#TYPE_PROXY.
Change-Id: I48c0a7bc39e2efcc5b4120a4fa2ecf6dfd54ac27
diff --git a/core/java/android/net/NetworkTemplate.java b/core/java/android/net/NetworkTemplate.java
index d847cd0..b32b2cc 100644
--- a/core/java/android/net/NetworkTemplate.java
+++ b/core/java/android/net/NetworkTemplate.java
@@ -18,6 +18,7 @@
import static android.net.ConnectivityManager.TYPE_BLUETOOTH;
import static android.net.ConnectivityManager.TYPE_ETHERNET;
+import static android.net.ConnectivityManager.TYPE_PROXY;
import static android.net.ConnectivityManager.TYPE_WIFI;
import static android.net.ConnectivityManager.TYPE_WIFI_P2P;
import static android.net.ConnectivityManager.TYPE_WIMAX;
@@ -68,6 +69,7 @@
public static final int MATCH_MOBILE_WILDCARD = 6;
public static final int MATCH_WIFI_WILDCARD = 7;
public static final int MATCH_BLUETOOTH = 8;
+ public static final int MATCH_PROXY = 9;
/**
* Set of {@link NetworkInfo#getType()} that reflect data usage.
@@ -157,6 +159,14 @@
return new NetworkTemplate(MATCH_BLUETOOTH, null, null);
}
+ /**
+ * Template to combine all {@link ConnectivityManager#TYPE_PROXY} style
+ * networks together.
+ */
+ public static NetworkTemplate buildTemplateProxy() {
+ return new NetworkTemplate(MATCH_PROXY, null, null);
+ }
+
private final int mMatchRule;
private final String mSubscriberId;
@@ -293,6 +303,8 @@
return matchesWifiWildcard(ident);
case MATCH_BLUETOOTH:
return matchesBluetooth(ident);
+ case MATCH_PROXY:
+ return matchesProxy(ident);
default:
throw new IllegalArgumentException("unknown network template");
}
@@ -401,6 +413,13 @@
return false;
}
+ /**
+ * Check if matches Proxy network template.
+ */
+ private boolean matchesProxy(NetworkIdentity ident) {
+ return ident.mType == TYPE_PROXY;
+ }
+
private static String getMatchRuleName(int matchRule) {
switch (matchRule) {
case MATCH_MOBILE_3G_LOWER:
@@ -419,6 +438,8 @@
return "WIFI_WILDCARD";
case MATCH_BLUETOOTH:
return "BLUETOOTH";
+ case MATCH_PROXY:
+ return "PROXY";
default:
return "UNKNOWN";
}