From c3207fbf8d436b92aa6b0f793aa01048d7faea97 Mon Sep 17 00:00:00 2001 From: Chiachang Wang Date: Wed, 23 Sep 2020 19:11:33 +0800 Subject: Prevent going through unnecessary networks The outer interface is taken in the constructor of LegacyVpnRunner. The interface is used to set the type of connection type. One interface should not map to more than one network. Go through all the network is unnecessary if the target connection is found. Thus, skip other networks if target network is found. Bug: 169215213 Test: atest FrameworksNetTests Test: build and manually test to add legacy vpn Change-Id: I31096d07177f5ae168becb1b4311f7b8eeac855a --- services/core/java/com/android/server/connectivity/Vpn.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java index 8e1fccd07f7a..b55fd49a434a 100644 --- a/services/core/java/com/android/server/connectivity/Vpn.java +++ b/services/core/java/com/android/server/connectivity/Vpn.java @@ -2755,7 +2755,10 @@ public class Vpn { final LinkProperties lp = cm.getLinkProperties(network); if (lp != null && lp.getAllInterfaceNames().contains(mOuterInterface)) { final NetworkInfo networkInfo = cm.getNetworkInfo(network); - if (networkInfo != null) mOuterConnection.set(networkInfo.getType()); + if (networkInfo != null) { + mOuterConnection.set(networkInfo.getType()); + break; + } } } } -- cgit v1.2.3-59-g8ed1b