Check if NetworkSpecifier is an instance of MatchAllNetworkSpecifier
To prevent mainline module related file to access a hidden API, check whether the NetworkSpecifier is an instance of MatchAllNetworkSpecifier by itself. Bug: 172183305 Test: atest FrameworksNetTests Change-Id: I4d49cb70ff3c8a7e1ffa32e38207c74a6375e51a
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5580,7 +5580,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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user