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

Commit 70770a8b authored by Hansen Kurli's avatar Hansen Kurli
Browse files

Remove findIPv4DefaultRoute

Remove unused findIPv4DefaultRoute. This allows startLegacyVpnPrivileged
to run on IPv6 and removes the "Unable to find IPv4 default gateway"
exception.

Bug: 161776767
Test: Test updated in ConnectivityServiceTest: atest FrameworksNetTests
Change-Id: Ie3e3dfdce8051dc70df704502d056645ea030245
parent 4fa38a5c
Loading
Loading
Loading
Loading
+0 −15
Original line number Diff line number Diff line
@@ -2542,17 +2542,6 @@ public class Vpn {
    private native boolean jniAddAddress(String interfaze, String address, int prefixLen);
    private native boolean jniDelAddress(String interfaze, String address, int prefixLen);

    private static RouteInfo findIPv4DefaultRoute(LinkProperties prop) {
        for (RouteInfo route : prop.getAllRoutes()) {
            // Currently legacy VPN only works on IPv4.
            if (route.isDefaultRoute() && route.getGateway() instanceof Inet4Address) {
                return route;
            }
        }

        throw new IllegalStateException("Unable to find IPv4 default gateway");
    }

    private void enforceNotRestrictedUser() {
        final long token = Binder.clearCallingIdentity();
        try {
@@ -2651,10 +2640,6 @@ public class Vpn {
            throw new SecurityException("Restricted users cannot establish VPNs");
        }

        final RouteInfo ipv4DefaultRoute = findIPv4DefaultRoute(egress);
        final String gateway = ipv4DefaultRoute.getGateway().getHostAddress();
        final String iface = ipv4DefaultRoute.getInterface();

        // Load certificates.
        String privateKey = "";
        String userCert = "";