Allow test networks to be rate limited

Test: atest FrameworksNetTests
Change-Id: I7e6e84baf446ecf4b395f6a611e625871745a20e
This commit is contained in:
Patrick Rohr
2022-02-09 15:15:52 +01:00
parent cdac749eb0
commit ff3b3f8d96

View File

@@ -10684,8 +10684,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
private boolean canNetworkBeRateLimited(@NonNull final NetworkAgentInfo networkAgent) {
if (!networkAgent.networkCapabilities.hasCapability(NET_CAPABILITY_INTERNET)) {
// rate limits only apply to networks that provide internet connectivity.
final NetworkCapabilities agentCaps = networkAgent.networkCapabilities;
// Only test networks (they cannot hold NET_CAPABILITY_INTERNET) and networks that provide
// internet connectivity can be rate limited.
if (!agentCaps.hasCapability(NET_CAPABILITY_INTERNET) && !agentCaps.hasTransport(
TRANSPORT_TEST)) {
return false;
}