summaryrefslogtreecommitdiffstats
path: root/core/java/android/net
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2014-06-04 12:20:06 +0900
committerLorenzo Colitti <lorenzo@google.com>2014-06-04 12:20:06 +0900
commit4077acbeccd2483e78e83abff874757302388fbe (patch)
treedd55e06d9988852f940828c10bca583ff11edb1f /core/java/android/net
parent07bfc4ba2ed4abb7432e64c228b4fe622f6db264 (diff)
downloadframeworks_base-4077acbeccd2483e78e83abff874757302388fbe.zip
frameworks_base-4077acbeccd2483e78e83abff874757302388fbe.tar.gz
frameworks_base-4077acbeccd2483e78e83abff874757302388fbe.tar.bz2
Make requests for restricted networks not require unrestricted access.
Currently, calling startUsingNetworkFeature for a restricted APN type (e.g., IMS or FOTA) will create a request that requires NET_CAPABILITY_NOT_RESTRICTED. Because these APNs are restricted, when we bring them up we conclude that it does not match the unrestricted requirement, and we tear them down. 1. Clear the NET_CAPABILITY_NOT_RESTRICTED capability when creating requests in startUsingNetworkFeature. 2. Refactor the code to a common function so this cannot happen again. Bug: 15191336 Change-Id: Id1ec79c58ff79b1a83457ffaecc57d50b61ed4e4
Diffstat (limited to 'core/java/android/net')
-rw-r--r--core/java/android/net/ConnectivityManager.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index a48a388..c4cbdd5 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -870,6 +870,26 @@ public class ConnectivityManager {
return 1;
}
+ /**
+ * Removes the NET_CAPABILITY_NOT_RESTRICTED capability from the given
+ * NetworkCapabilities object if it lists any capabilities that are
+ * typically provided by retricted networks.
+ * @hide
+ */
+ public static void maybeMarkCapabilitiesRestricted(NetworkCapabilities nc) {
+ for (Integer capability: nc.getNetworkCapabilities()) {
+ switch (capability.intValue()) {
+ case NetworkCapabilities.NET_CAPABILITY_CBS:
+ case NetworkCapabilities.NET_CAPABILITY_DUN:
+ case NetworkCapabilities.NET_CAPABILITY_FOTA:
+ case NetworkCapabilities.NET_CAPABILITY_IA:
+ case NetworkCapabilities.NET_CAPABILITY_IMS:
+ nc.removeNetworkCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED);
+ break;
+ }
+ }
+ }
+
private NetworkCapabilities networkCapabilitiesForFeature(int networkType, String feature) {
if (networkType == TYPE_MOBILE) {
int cap = -1;
@@ -893,12 +913,14 @@ public class ConnectivityManager {
NetworkCapabilities netCap = new NetworkCapabilities();
netCap.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
netCap.addNetworkCapability(cap);
+ maybeMarkCapabilitiesRestricted(netCap);
return netCap;
} else if (networkType == TYPE_WIFI) {
if ("p2p".equals(feature)) {
NetworkCapabilities netCap = new NetworkCapabilities();
netCap.addTransportType(NetworkCapabilities.TRANSPORT_WIFI);
netCap.addNetworkCapability(NetworkCapabilities.NET_CAPABILITY_WIFI_P2P);
+ maybeMarkCapabilitiesRestricted(netCap);
return netCap;
}
}