Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1a0836e3 authored by Lorenzo Colitti's avatar Lorenzo Colitti
Browse files

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
parent 282ed251
Loading
Loading
Loading
Loading
+8 −16
Original line number Diff line number Diff line
@@ -1562,25 +1562,17 @@ 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();
        // 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(
                    result.put(network, maybeSanitizeLocationInfoForCaller(
                                    nc, mDeps.getCallingUid(), callingPackageName));
                }
            }
        }
                }
            }
        }

        NetworkCapabilities[] out = new NetworkCapabilities[result.size()];
        out = result.values().toArray(out);
+0 −10
Original line number Diff line number Diff line
@@ -1787,9 +1787,6 @@ public class Vpn {

    /**
     * Updates underlying network set.
     *
     * <p>Note: Does not updates capabilities. Call {@link #updateCapabilities} from
     * ConnectivityService thread to get updated capabilities.
     */
    public synchronized boolean setUnderlyingNetworks(Network[] networks) {
        if (!isCallerEstablishedOwnerLocked()) {
@@ -1812,13 +1809,6 @@ public class Vpn {
        return true;
    }

    public synchronized Network[] getUnderlyingNetworks() {
        if (!isRunningLocked()) {
            return null;
        }
        return mConfig.underlyingNetworks;
    }

    /**
     * This method should only be called by ConnectivityService because it doesn't
     * have enough data to fill VpnInfo.primaryUnderlyingIface field.