diff options
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiNetworkFactory.java | 28 |
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; } |