summaryrefslogtreecommitdiffstats
path: root/core/java/android/net
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2014-06-04 19:59:21 +0900
committerLorenzo Colitti <lorenzo@google.com>2014-06-04 20:04:38 +0900
commitea1984fd3bda53c85c5f789e3e36641145803704 (patch)
tree1eb10cb6e2911d4ce14aa78dce303efb779e4417 /core/java/android/net
parentd55c56b86e9ec7b15f5b9e715ed009aed6ba9bb1 (diff)
downloadframeworks_base-ea1984fd3bda53c85c5f789e3e36641145803704.zip
frameworks_base-ea1984fd3bda53c85c5f789e3e36641145803704.tar.gz
frameworks_base-ea1984fd3bda53c85c5f789e3e36641145803704.tar.bz2
Call a network restricted only if all capabilities are restricted
When guessing whether a network is restricted or not (e.g., when constructing a NetworkCapabilities object from an APN type, or when constructing a request using startUsingNetworkFeature), only assume the network is restricted if all the capabilities it provides are typically provided by restricted networks (e.g., IMS, FOTA, etc.). Previous code would conclude a network was restricted even if it supported one "restricted" capability, so for example an APN that provides both Internet connectivity and FOTA was marked as restricted. This caused it to become ineligible to provide the default Internet connection, because that must be unrestricted. Also expand the list of restricted APN types a bit. Bug: 15417453 Change-Id: I8c385f2cc83c695449dc8cf943d918321716fe58
Diffstat (limited to 'core/java/android/net')
-rw-r--r--core/java/android/net/ConnectivityManager.java24
1 files changed, 19 insertions, 5 deletions
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index c4cbdd5..b96f166 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -872,22 +872,36 @@ public class ConnectivityManager {
/**
* Removes the NET_CAPABILITY_NOT_RESTRICTED capability from the given
- * NetworkCapabilities object if it lists any capabilities that are
- * typically provided by retricted networks.
+ * NetworkCapabilities object if all the capabilities it provides are
+ * typically provided by restricted networks.
+ *
+ * TODO: consider:
+ * - Moving to NetworkCapabilities
+ * - Renaming it to guessRestrictedCapability and make it set the
+ * restricted capability bit in addition to clearing it.
* @hide
*/
public static void maybeMarkCapabilitiesRestricted(NetworkCapabilities nc) {
- for (Integer capability: nc.getNetworkCapabilities()) {
+ for (Integer capability : nc.getNetworkCapabilities()) {
switch (capability.intValue()) {
case NetworkCapabilities.NET_CAPABILITY_CBS:
case NetworkCapabilities.NET_CAPABILITY_DUN:
+ case NetworkCapabilities.NET_CAPABILITY_EIMS:
case NetworkCapabilities.NET_CAPABILITY_FOTA:
case NetworkCapabilities.NET_CAPABILITY_IA:
case NetworkCapabilities.NET_CAPABILITY_IMS:
- nc.removeNetworkCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED);
- break;
+ case NetworkCapabilities.NET_CAPABILITY_RCS:
+ case NetworkCapabilities.NET_CAPABILITY_XCAP:
+ continue;
+ default:
+ // At least one capability usually provided by unrestricted
+ // networks. Conclude that this network is unrestricted.
+ return;
}
}
+ // All the capabilities are typically provided by restricted networks.
+ // Conclude that this network is restricted.
+ nc.removeNetworkCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED);
}
private NetworkCapabilities networkCapabilitiesForFeature(int networkType, String feature) {