summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunyu Lai <junyulai@google.com>2021-03-23 14:00:35 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2021-03-23 14:00:35 +0000
commit4e6166801eb02d4a90e576a0d3d7244b0a1aa2af (patch)
treef909f850306273178a1aae2f404fd70a7a4ca597
parentfdad0e26a7014a2bf55b815120797e20abbe9f19 (diff)
parent7472deb59b51cf38cafe80ec332ba30f1d91d86b (diff)
Merge "Remove the reference of new Network(int) in Vpn.java"
-rw-r--r--services/core/java/com/android/server/connectivity/Vpn.java17
1 files changed, 4 insertions, 13 deletions
diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java
index 9519d80a98b2..c8f99825854a 100644
--- a/services/core/java/com/android/server/connectivity/Vpn.java
+++ b/services/core/java/com/android/server/connectivity/Vpn.java
@@ -1859,22 +1859,13 @@ public class Vpn {
/**
* Updates underlying network set.
*/
- public synchronized boolean setUnderlyingNetworks(Network[] networks) {
+ public synchronized boolean setUnderlyingNetworks(@Nullable Network[] networks) {
if (!isCallerEstablishedOwnerLocked()) {
return false;
}
- if (networks == null) {
- mConfig.underlyingNetworks = null;
- } else {
- 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());
- }
- }
- }
+ // Make defensive copy since the content of array might be altered by the caller.
+ mConfig.underlyingNetworks =
+ (networks != null) ? Arrays.copyOf(networks, networks.length) : null;
mNetworkAgent.setUnderlyingNetworks((mConfig.underlyingNetworks != null)
? Arrays.asList(mConfig.underlyingNetworks) : null);
return true;