From 011f29dfc90019af2caf01a0ff13c2442e29c54b Mon Sep 17 00:00:00 2001 From: Lorenzo Colitti Date: Tue, 15 Dec 2020 00:49:41 +0900 Subject: [PATCH] Stop using VPNs in getDefaultNetworkCapabilitiesForUser. This was the last place in CS that fetched underlying networks from Vpn. Therefore, delete Vpn#getUnderlyingNetworks, which is no longer used. Bug: 173331190 Test: new tests in ConnectivityServiceTest added in previous CL Change-Id: Iec22ff636de0c02193576fe2e2d36b8bc7380457 --- .../android/server/ConnectivityService.java | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 0f677c427a..d6ea171f29 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -1562,22 +1562,14 @@ public class ConnectivityService extends IConnectivityManager.Stub nc, mDeps.getCallingUid(), callingPackageName)); } - synchronized (mVpns) { - if (!mLockdownEnabled) { - Vpn vpn = mVpns.get(userId); - if (vpn != null) { - Network[] networks = vpn.getUnderlyingNetworks(); - if (networks != null) { - for (Network network : networks) { - nc = getNetworkCapabilitiesInternal(network); - if (nc != null) { - result.put( - network, - maybeSanitizeLocationInfoForCaller( - nc, mDeps.getCallingUid(), callingPackageName)); - } - } - } + // No need to check mLockdownEnabled. If it's true, getVpnUnderlyingNetworks returns null. + final Network[] networks = getVpnUnderlyingNetworks(Binder.getCallingUid()); + if (networks != null) { + for (Network network : networks) { + nc = getNetworkCapabilitiesInternal(network); + if (nc != null) { + result.put(network, maybeSanitizeLocationInfoForCaller( + nc, mDeps.getCallingUid(), callingPackageName)); } } }