Merge "Remove the reference of new Network(int) in Vpn.java" into sc-dev

This commit is contained in:
TreeHugger Robot
2021-03-23 09:06:45 +00:00
committed by Android (Google) Code Review

View File

@@ -1858,22 +1858,13 @@ public class Vpn {
/** /**
* Updates underlying network set. * Updates underlying network set.
*/ */
public synchronized boolean setUnderlyingNetworks(Network[] networks) { public synchronized boolean setUnderlyingNetworks(@Nullable Network[] networks) {
if (!isCallerEstablishedOwnerLocked()) { if (!isCallerEstablishedOwnerLocked()) {
return false; return false;
} }
if (networks == null) { // Make defensive copy since the content of array might be altered by the caller.
mConfig.underlyingNetworks = null; mConfig.underlyingNetworks =
} else { (networks != null) ? Arrays.copyOf(networks, networks.length) : null;
mConfig.underlyingNetworks = new Network[networks.length];
for (int i = 0; i < networks.length; ++i) {
if (networks[i] == null) {
mConfig.underlyingNetworks[i] = null;
} else {
mConfig.underlyingNetworks[i] = new Network(networks[i].getNetId());
}
}
}
mNetworkAgent.setUnderlyingNetworks((mConfig.underlyingNetworks != null) mNetworkAgent.setUnderlyingNetworks((mConfig.underlyingNetworks != null)
? Arrays.asList(mConfig.underlyingNetworks) : null); ? Arrays.asList(mConfig.underlyingNetworks) : null);
return true; return true;