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
This commit is contained in:
Lorenzo Colitti
2020-12-15 00:49:41 +09:00
parent e8ce205f6d
commit 011f29dfc9

View File

@@ -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));
}
}
}