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
This commit is contained in:
committed by
The Android Automerger
parent
4e2f3b1df9
commit
f7208e9857
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user