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

Commit 68e528d4 authored by Chiachang Wang's avatar Chiachang Wang
Browse files

Set local routes exclusion in the networkAgent

Add a field in the VpnConfig to store local route exclusion
bit from VpnProfile, and set the value into the networkAgent
of VPN network.

Bug: 184750836
Test: atest FrameworksNetTests HostsideVpnTests
Change-Id: I22b9a5990a3dab0418b44ec19d2996ead6529231
parent 192941ea
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -106,6 +106,7 @@ public class VpnConfig implements Parcelable {
    public boolean allowIPv6;
    public boolean isMetered = true;
    public boolean requiresInternetValidation = false;
    public boolean excludeLocalRoutes = false;
    public Network[] underlyingNetworks;
    public ProxyInfo proxyInfo;

@@ -133,6 +134,7 @@ public class VpnConfig implements Parcelable {
        allowIPv6 = other.allowIPv6;
        isMetered = other.isMetered;
        requiresInternetValidation = other.requiresInternetValidation;
        excludeLocalRoutes = other.excludeLocalRoutes;
        underlyingNetworks = other.underlyingNetworks != null ? Arrays.copyOf(
                other.underlyingNetworks, other.underlyingNetworks.length) : null;
        proxyInfo = other.proxyInfo;
@@ -192,6 +194,7 @@ public class VpnConfig implements Parcelable {
        out.writeInt(allowIPv6 ? 1 : 0);
        out.writeInt(isMetered ? 1 : 0);
        out.writeInt(requiresInternetValidation ? 1 : 0);
        out.writeInt(excludeLocalRoutes ? 1 : 0);
        out.writeTypedArray(underlyingNetworks, flags);
        out.writeParcelable(proxyInfo, flags);
    }
@@ -220,6 +223,7 @@ public class VpnConfig implements Parcelable {
            config.allowIPv6 = in.readInt() != 0;
            config.isMetered = in.readInt() != 0;
            config.requiresInternetValidation = in.readInt() != 0;
            config.excludeLocalRoutes = in.readInt() != 0;
            config.underlyingNetworks = in.createTypedArray(Network.CREATOR);
            config.proxyInfo = in.readParcelable(null);
            return config;
@@ -253,7 +257,8 @@ public class VpnConfig implements Parcelable {
                .append(", allowIPv4=").append(allowIPv4)
                .append(", allowIPv6=").append(allowIPv6)
                .append(", isMetered=").append(isMetered)
                .append(", requiresInternetValidation").append(requiresInternetValidation)
                .append(", requiresInternetValidation=").append(requiresInternetValidation)
                .append(", excludeLocalRoutes=").append(excludeLocalRoutes)
                .append(", underlyingNetworks=").append(Arrays.toString(underlyingNetworks))
                .append(", proxyInfo=").append(proxyInfo)
                .append("}")
+2 −0
Original line number Diff line number Diff line
@@ -1305,6 +1305,7 @@ public class Vpn {
                .setLegacyTypeName("VPN")
                .setBypassableVpn(mConfig.allowBypass && !mLockdown)
                .setVpnRequiresValidation(mConfig.requiresInternetValidation)
                .setLocalRoutesExcludedForVpn(mConfig.excludeLocalRoutes)
                .build();

        capsBuilder.setOwnerUid(mOwnerUID);
@@ -3370,6 +3371,7 @@ public class Vpn {
            mConfig.startTime = SystemClock.elapsedRealtime();
            mConfig.proxyInfo = profile.proxy;
            mConfig.requiresInternetValidation = profile.requiresInternetValidation;
            mConfig.excludeLocalRoutes = profile.excludeLocalRoutes;

            switch (profile.type) {
                case VpnProfile.TYPE_IKEV2_IPSEC_USER_PASS: