Merge "Set local routes exclusion in the networkAgent" am: 4734b5810b am: b8cda9d7e0

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1978095

Change-Id: I46931b7926b1da889989384159b012826e02d96a
This commit is contained in:
Chiachang Wang
2022-03-07 08:09:05 +00:00
committed by Automerger Merge Worker
2 changed files with 8 additions and 1 deletions

View File

@@ -106,6 +106,7 @@ public class VpnConfig implements Parcelable {
public boolean allowIPv6; public boolean allowIPv6;
public boolean isMetered = true; public boolean isMetered = true;
public boolean requiresInternetValidation = false; public boolean requiresInternetValidation = false;
public boolean excludeLocalRoutes = false;
public Network[] underlyingNetworks; public Network[] underlyingNetworks;
public ProxyInfo proxyInfo; public ProxyInfo proxyInfo;
@@ -133,6 +134,7 @@ public class VpnConfig implements Parcelable {
allowIPv6 = other.allowIPv6; allowIPv6 = other.allowIPv6;
isMetered = other.isMetered; isMetered = other.isMetered;
requiresInternetValidation = other.requiresInternetValidation; requiresInternetValidation = other.requiresInternetValidation;
excludeLocalRoutes = other.excludeLocalRoutes;
underlyingNetworks = other.underlyingNetworks != null ? Arrays.copyOf( underlyingNetworks = other.underlyingNetworks != null ? Arrays.copyOf(
other.underlyingNetworks, other.underlyingNetworks.length) : null; other.underlyingNetworks, other.underlyingNetworks.length) : null;
proxyInfo = other.proxyInfo; proxyInfo = other.proxyInfo;
@@ -192,6 +194,7 @@ public class VpnConfig implements Parcelable {
out.writeInt(allowIPv6 ? 1 : 0); out.writeInt(allowIPv6 ? 1 : 0);
out.writeInt(isMetered ? 1 : 0); out.writeInt(isMetered ? 1 : 0);
out.writeInt(requiresInternetValidation ? 1 : 0); out.writeInt(requiresInternetValidation ? 1 : 0);
out.writeInt(excludeLocalRoutes ? 1 : 0);
out.writeTypedArray(underlyingNetworks, flags); out.writeTypedArray(underlyingNetworks, flags);
out.writeParcelable(proxyInfo, flags); out.writeParcelable(proxyInfo, flags);
} }
@@ -220,6 +223,7 @@ public class VpnConfig implements Parcelable {
config.allowIPv6 = in.readInt() != 0; config.allowIPv6 = in.readInt() != 0;
config.isMetered = in.readInt() != 0; config.isMetered = in.readInt() != 0;
config.requiresInternetValidation = in.readInt() != 0; config.requiresInternetValidation = in.readInt() != 0;
config.excludeLocalRoutes = in.readInt() != 0;
config.underlyingNetworks = in.createTypedArray(Network.CREATOR); config.underlyingNetworks = in.createTypedArray(Network.CREATOR);
config.proxyInfo = in.readParcelable(null); config.proxyInfo = in.readParcelable(null);
return config; return config;
@@ -253,7 +257,8 @@ public class VpnConfig implements Parcelable {
.append(", allowIPv4=").append(allowIPv4) .append(", allowIPv4=").append(allowIPv4)
.append(", allowIPv6=").append(allowIPv6) .append(", allowIPv6=").append(allowIPv6)
.append(", isMetered=").append(isMetered) .append(", isMetered=").append(isMetered)
.append(", requiresInternetValidation").append(requiresInternetValidation) .append(", requiresInternetValidation=").append(requiresInternetValidation)
.append(", excludeLocalRoutes=").append(excludeLocalRoutes)
.append(", underlyingNetworks=").append(Arrays.toString(underlyingNetworks)) .append(", underlyingNetworks=").append(Arrays.toString(underlyingNetworks))
.append(", proxyInfo=").append(proxyInfo) .append(", proxyInfo=").append(proxyInfo)
.append("}") .append("}")

View File

@@ -1320,6 +1320,7 @@ public class Vpn {
.setLegacyTypeName("VPN") .setLegacyTypeName("VPN")
.setBypassableVpn(mConfig.allowBypass && !mLockdown) .setBypassableVpn(mConfig.allowBypass && !mLockdown)
.setVpnRequiresValidation(mConfig.requiresInternetValidation) .setVpnRequiresValidation(mConfig.requiresInternetValidation)
.setLocalRoutesExcludedForVpn(mConfig.excludeLocalRoutes)
.build(); .build();
capsBuilder.setOwnerUid(mOwnerUID); capsBuilder.setOwnerUid(mOwnerUID);
@@ -3386,6 +3387,7 @@ public class Vpn {
mConfig.startTime = SystemClock.elapsedRealtime(); mConfig.startTime = SystemClock.elapsedRealtime();
mConfig.proxyInfo = profile.proxy; mConfig.proxyInfo = profile.proxy;
mConfig.requiresInternetValidation = profile.requiresInternetValidation; mConfig.requiresInternetValidation = profile.requiresInternetValidation;
mConfig.excludeLocalRoutes = profile.excludeLocalRoutes;
switch (profile.type) { switch (profile.type) {
case VpnProfile.TYPE_IKEV2_IPSEC_USER_PASS: case VpnProfile.TYPE_IKEV2_IPSEC_USER_PASS: