Add allowed capabilities on non cellular test networks
This commit expands the allowed capabilities of non cellular test networks to include another three values, so that CTS can verify features that do network selection based on those capabilities. It is relatively safe becuase for apps that request TRANSPORT_CELLULAR and the affected capabilities, test networks will still not become their default networks. Bug: 263415068 Test: atest NetworkCapabilitiesTest(new tests) Change-Id: I2e348e4722ecdaa6e277fe77968916ffa2f16af9
This commit is contained in:
@@ -757,10 +757,10 @@ public final class NetworkCapabilities implements Parcelable {
|
||||
NET_CAPABILITY_PARTIAL_CONNECTIVITY);
|
||||
|
||||
/**
|
||||
* Capabilities that are allowed for test networks. This list must be set so that it is safe
|
||||
* for an unprivileged user to create a network with these capabilities via shell. As such,
|
||||
* it must never contain capabilities that are generally useful to the system, such as
|
||||
* INTERNET, IMS, SUPL, etc.
|
||||
* Capabilities that are allowed for all test networks. This list must be set so that it is safe
|
||||
* for an unprivileged user to create a network with these capabilities via shell. As such, it
|
||||
* must never contain capabilities that are generally useful to the system, such as INTERNET,
|
||||
* IMS, SUPL, etc.
|
||||
*/
|
||||
private static final long TEST_NETWORKS_ALLOWED_CAPABILITIES =
|
||||
BitUtils.packBitList(
|
||||
@@ -773,6 +773,14 @@ public final class NetworkCapabilities implements Parcelable {
|
||||
NET_CAPABILITY_NOT_SUSPENDED,
|
||||
NET_CAPABILITY_NOT_VCN_MANAGED);
|
||||
|
||||
/**
|
||||
* Extra allowed capabilities for test networks that do not have TRANSPORT_CELLULAR. Test
|
||||
* networks with TRANSPORT_CELLULAR must not have those capabilities in order to mitigate
|
||||
* the risk of being used by running apps.
|
||||
*/
|
||||
private static final long TEST_NETWORKS_EXTRA_ALLOWED_CAPABILITIES_ON_NON_CELL =
|
||||
BitUtils.packBitList(NET_CAPABILITY_CBS, NET_CAPABILITY_DUN, NET_CAPABILITY_RCS);
|
||||
|
||||
/**
|
||||
* Adds the given capability to this {@code NetworkCapability} instance.
|
||||
* Note that when searching for a network to satisfy a request, all capabilities
|
||||
@@ -1133,7 +1141,13 @@ public final class NetworkCapabilities implements Parcelable {
|
||||
// If the test network is restricted, then it may declare any transport.
|
||||
mTransportTypes = (originalTransportTypes | (1 << TRANSPORT_TEST));
|
||||
}
|
||||
|
||||
mNetworkCapabilities = originalCapabilities & TEST_NETWORKS_ALLOWED_CAPABILITIES;
|
||||
if (!hasTransport(TRANSPORT_CELLULAR)) {
|
||||
mNetworkCapabilities |=
|
||||
(originalCapabilities & TEST_NETWORKS_EXTRA_ALLOWED_CAPABILITIES_ON_NON_CELL);
|
||||
}
|
||||
|
||||
mNetworkSpecifier = originalSpecifier;
|
||||
mSignalStrength = originalSignalStrength;
|
||||
mTransportInfo = originalTransportInfo;
|
||||
|
||||
Reference in New Issue
Block a user