Merge "Check if NetworkSpecifier is an instance of MatchAllNetworkSpecifier" am: d15fcc3048

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1556546

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ibd01df52928e13717eae903c49e201f7bf39940e
This commit is contained in:
Lucas Lin
2021-01-28 04:28:10 +00:00
committed by Automerger Merge Worker
2 changed files with 6 additions and 2 deletions

View File

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

View File

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