summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2019-06-07 11:27:34 -0700
committerRoshan Pius <rpius@google.com>2019-06-07 13:35:59 -0700
commit5574a79d435528ded31153e07c24acd25127c703 (patch)
treeac28e770c767b3d6bb847373ffe0389bd421b2a4 /service
parent92f61910b2b2615d6a062366dc365a5f3597468d (diff)
WifiNetworkFactory: Reject requests for internet with specifier
Reject any NetworkRequest with WifiNetworkSpecifier attached and has INTERNET capability set. This will otherwise trigger an unwanted connection which will be torn down by connectivity service immediately (because WifiNetworkAgent will not have INTERNET capability & hence will never match the app's request). Bug: 134735892 Test: atest com.android.server.wifi Test: act.py -c wifi_manager_cross.config -tb dut-name -tc WifiNetworkRequestTest Test: CtsVerifier tests Change-Id: Ia9932379825cec7777baf92e058cd04d181ffc0b
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkFactory.java28
1 files changed, 21 insertions, 7 deletions
diff --git a/service/java/com/android/server/wifi/WifiNetworkFactory.java b/service/java/com/android/server/wifi/WifiNetworkFactory.java
index 65d78e6aa..ecc1a9f18 100644
--- a/service/java/com/android/server/wifi/WifiNetworkFactory.java
+++ b/service/java/com/android/server/wifi/WifiNetworkFactory.java
@@ -478,6 +478,23 @@ public class WifiNetworkFactory extends NetworkFactory {
return false;
}
+ boolean isRequestWithNetworkSpecifierValid(NetworkRequest networkRequest) {
+ NetworkSpecifier ns = networkRequest.networkCapabilities.getNetworkSpecifier();
+ // Invalid network specifier.
+ if (!(ns instanceof WifiNetworkSpecifier)) {
+ Log.e(TAG, "Invalid network specifier mentioned. Rejecting");
+ return false;
+ }
+ // Request cannot have internet capability since such a request can never be fulfilled.
+ // (NetworkAgent for connection with WifiNetworkSpecifier will not have internet capability)
+ if (networkRequest.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)) {
+ Log.e(TAG, "Request with wifi network specifier cannot contain "
+ + "NET_CAPABILITY_INTERNET. Rejecting");
+ return false;
+ }
+ return true;
+ }
+
/**
* Check whether to accept the new network connection request.
*
@@ -486,13 +503,11 @@ public class WifiNetworkFactory extends NetworkFactory {
@Override
public boolean acceptRequest(NetworkRequest networkRequest, int score) {
NetworkSpecifier ns = networkRequest.networkCapabilities.getNetworkSpecifier();
- // Generic wifi request. Always accept.
if (ns == null) {
// Generic wifi request. Always accept.
} else {
- // Invalid network specifier.
- if (!(ns instanceof WifiNetworkSpecifier)) {
- Log.e(TAG, "Invalid network specifier mentioned. Rejecting");
+ // Invalid request with network specifier.
+ if (!isRequestWithNetworkSpecifierValid(networkRequest)) {
releaseRequestAsUnfulfillableByAnyFactory(networkRequest);
return false;
}
@@ -569,9 +584,8 @@ public class WifiNetworkFactory extends NetworkFactory {
mWifiConnectivityManager.setTrustedConnectionAllowed(true);
}
} else {
- // Invalid network specifier.
- if (!(ns instanceof WifiNetworkSpecifier)) {
- Log.e(TAG, "Invalid network specifier mentioned. Rejecting");
+ // Invalid request with network specifier.
+ if (!isRequestWithNetworkSpecifierValid(networkRequest)) {
releaseRequestAsUnfulfillableByAnyFactory(networkRequest);
return;
}