Merge "Check if NetworkSpecifier is an instance of MatchAllNetworkSpecifier"

This commit is contained in:
Lucas Lin
2021-01-28 04:01:49 +00:00
committed by Gerrit Code Review
2 changed files with 6 additions and 2 deletions

View File

@@ -353,7 +353,9 @@ public class NetworkRequest implements Parcelable {
* NetworkSpecifier. * NetworkSpecifier.
*/ */
public Builder setNetworkSpecifier(NetworkSpecifier networkSpecifier) { public Builder setNetworkSpecifier(NetworkSpecifier networkSpecifier) {
MatchAllNetworkSpecifier.checkNotMatchAllNetworkSpecifier(networkSpecifier); if (networkSpecifier instanceof MatchAllNetworkSpecifier) {
throw new IllegalArgumentException("A MatchAllNetworkSpecifier is not permitted");
}
mNetworkCapabilities.setNetworkSpecifier(networkSpecifier); mNetworkCapabilities.setNetworkSpecifier(networkSpecifier);
return this; return this;
} }

View File

@@ -5658,7 +5658,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (ns == null) { if (ns == null) {
return; return;
} }
MatchAllNetworkSpecifier.checkNotMatchAllNetworkSpecifier(ns); if (ns instanceof MatchAllNetworkSpecifier) {
throw new IllegalArgumentException("A MatchAllNetworkSpecifier is not permitted");
}
} }
private void ensureValid(NetworkCapabilities nc) { private void ensureValid(NetworkCapabilities nc) {