Merge "Add configuration whether to exclude local traffic in the VPN" am: 80178db312 am: 0ea8189d38 am: 4974ca5f52
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1926899 Change-Id: I7cd9bc4cb5e7ff27e773137cb73a490733b27170
This commit is contained in:
@@ -142,8 +142,9 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile {
|
|||||||
boolean isBypassable,
|
boolean isBypassable,
|
||||||
boolean isMetered,
|
boolean isMetered,
|
||||||
int maxMtu,
|
int maxMtu,
|
||||||
boolean restrictToTestNetworks) {
|
boolean restrictToTestNetworks,
|
||||||
super(type);
|
boolean excludeLocalRoutes) {
|
||||||
|
super(type, excludeLocalRoutes);
|
||||||
|
|
||||||
checkNotNull(serverAddr, MISSING_PARAM_MSG_TMPL, "Server address");
|
checkNotNull(serverAddr, MISSING_PARAM_MSG_TMPL, "Server address");
|
||||||
checkNotNull(userIdentity, MISSING_PARAM_MSG_TMPL, "User Identity");
|
checkNotNull(userIdentity, MISSING_PARAM_MSG_TMPL, "User Identity");
|
||||||
@@ -403,7 +404,8 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile {
|
|||||||
&& mIsBypassable == other.mIsBypassable
|
&& mIsBypassable == other.mIsBypassable
|
||||||
&& mIsMetered == other.mIsMetered
|
&& mIsMetered == other.mIsMetered
|
||||||
&& mMaxMtu == other.mMaxMtu
|
&& mMaxMtu == other.mMaxMtu
|
||||||
&& mIsRestrictedToTestNetworks == other.mIsRestrictedToTestNetworks;
|
&& mIsRestrictedToTestNetworks == other.mIsRestrictedToTestNetworks
|
||||||
|
&& mExcludeLocalRoutes == other.mExcludeLocalRoutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -417,7 +419,7 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile {
|
|||||||
@NonNull
|
@NonNull
|
||||||
public VpnProfile toVpnProfile() throws IOException, GeneralSecurityException {
|
public VpnProfile toVpnProfile() throws IOException, GeneralSecurityException {
|
||||||
final VpnProfile profile = new VpnProfile("" /* Key; value unused by IKEv2VpnProfile(s) */,
|
final VpnProfile profile = new VpnProfile("" /* Key; value unused by IKEv2VpnProfile(s) */,
|
||||||
mIsRestrictedToTestNetworks);
|
mIsRestrictedToTestNetworks, mExcludeLocalRoutes);
|
||||||
profile.type = mType;
|
profile.type = mType;
|
||||||
profile.server = mServerAddr;
|
profile.server = mServerAddr;
|
||||||
profile.ipsecIdentifier = mUserIdentity;
|
profile.ipsecIdentifier = mUserIdentity;
|
||||||
@@ -518,6 +520,8 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile {
|
|||||||
throw new IllegalArgumentException("Invalid auth method set");
|
throw new IllegalArgumentException("Invalid auth method set");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
builder.setExcludeLocalRoutes(profile.excludeLocalRoutes);
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -657,6 +661,7 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile {
|
|||||||
private boolean mIsMetered = true;
|
private boolean mIsMetered = true;
|
||||||
private int mMaxMtu = PlatformVpnProfile.MAX_MTU_DEFAULT;
|
private int mMaxMtu = PlatformVpnProfile.MAX_MTU_DEFAULT;
|
||||||
private boolean mIsRestrictedToTestNetworks = false;
|
private boolean mIsRestrictedToTestNetworks = false;
|
||||||
|
private boolean mExcludeLocalRoutes = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new builder with the basic parameters of an IKEv2/IPsec VPN.
|
* Creates a new builder with the basic parameters of an IKEv2/IPsec VPN.
|
||||||
@@ -901,6 +906,18 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether the local traffic is exempted from the VPN.
|
||||||
|
*
|
||||||
|
* @hide TODO(184750836): unhide once the implementation is completed
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
@RequiresFeature(PackageManager.FEATURE_IPSEC_TUNNELS)
|
||||||
|
public Builder setExcludeLocalRoutes(boolean excludeLocalRoutes) {
|
||||||
|
mExcludeLocalRoutes = excludeLocalRoutes;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates, builds and provisions the VpnProfile.
|
* Validates, builds and provisions the VpnProfile.
|
||||||
*
|
*
|
||||||
@@ -924,7 +941,8 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile {
|
|||||||
mIsBypassable,
|
mIsBypassable,
|
||||||
mIsMetered,
|
mIsMetered,
|
||||||
mMaxMtu,
|
mMaxMtu,
|
||||||
mIsRestrictedToTestNetworks);
|
mIsRestrictedToTestNetworks,
|
||||||
|
mExcludeLocalRoutes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,15 +66,30 @@ public abstract class PlatformVpnProfile {
|
|||||||
@PlatformVpnType protected final int mType;
|
@PlatformVpnType protected final int mType;
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
PlatformVpnProfile(@PlatformVpnType int type) {
|
protected final boolean mExcludeLocalRoutes;
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
PlatformVpnProfile(@PlatformVpnType int type, boolean excludeLocalRoutes) {
|
||||||
mType = type;
|
mType = type;
|
||||||
|
mExcludeLocalRoutes = excludeLocalRoutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the profile integer type. */
|
/** Returns the profile integer type. */
|
||||||
@PlatformVpnType
|
@PlatformVpnType
|
||||||
public final int getType() {
|
public final int getType() {
|
||||||
return mType;
|
return mType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if the local traffic is exempted from the VPN.
|
||||||
|
*
|
||||||
|
* @hide TODO(184750836): unhide once the implementation is completed
|
||||||
|
*/
|
||||||
|
public final boolean getExcludeLocalRoutes() {
|
||||||
|
return mExcludeLocalRoutes;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns a type string describing the VPN profile type */
|
/** Returns a type string describing the VPN profile type */
|
||||||
@NonNull
|
@NonNull
|
||||||
public final String getTypeString() {
|
public final String getTypeString() {
|
||||||
|
|||||||
@@ -143,17 +143,24 @@ public final class VpnProfile implements Cloneable, Parcelable {
|
|||||||
public boolean areAuthParamsInline = false; // 23
|
public boolean areAuthParamsInline = false; // 23
|
||||||
public final boolean isRestrictedToTestNetworks; // 24
|
public final boolean isRestrictedToTestNetworks; // 24
|
||||||
|
|
||||||
|
public final boolean excludeLocalRoutes; // 25
|
||||||
|
|
||||||
// Helper fields.
|
// Helper fields.
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
public transient boolean saveLogin = false;
|
public transient boolean saveLogin = false;
|
||||||
|
|
||||||
public VpnProfile(String key) {
|
public VpnProfile(String key) {
|
||||||
this(key, false);
|
this(key, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public VpnProfile(String key, boolean isRestrictedToTestNetworks) {
|
public VpnProfile(String key, boolean isRestrictedToTestNetworks) {
|
||||||
|
this(key, isRestrictedToTestNetworks, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public VpnProfile(String key, boolean isRestrictedToTestNetworks, boolean excludeLocalRoutes) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.isRestrictedToTestNetworks = isRestrictedToTestNetworks;
|
this.isRestrictedToTestNetworks = isRestrictedToTestNetworks;
|
||||||
|
this.excludeLocalRoutes = excludeLocalRoutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
@@ -183,6 +190,7 @@ public final class VpnProfile implements Cloneable, Parcelable {
|
|||||||
maxMtu = in.readInt();
|
maxMtu = in.readInt();
|
||||||
areAuthParamsInline = in.readBoolean();
|
areAuthParamsInline = in.readBoolean();
|
||||||
isRestrictedToTestNetworks = in.readBoolean();
|
isRestrictedToTestNetworks = in.readBoolean();
|
||||||
|
excludeLocalRoutes = in.readBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -230,6 +238,7 @@ public final class VpnProfile implements Cloneable, Parcelable {
|
|||||||
out.writeInt(maxMtu);
|
out.writeInt(maxMtu);
|
||||||
out.writeBoolean(areAuthParamsInline);
|
out.writeBoolean(areAuthParamsInline);
|
||||||
out.writeBoolean(isRestrictedToTestNetworks);
|
out.writeBoolean(isRestrictedToTestNetworks);
|
||||||
|
out.writeBoolean(excludeLocalRoutes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -249,8 +258,9 @@ public final class VpnProfile implements Cloneable, Parcelable {
|
|||||||
// 14-19: Standard profile, with option for serverCert, proxy
|
// 14-19: Standard profile, with option for serverCert, proxy
|
||||||
// 24: Standard profile with serverCert, proxy and platform-VPN parameters
|
// 24: Standard profile with serverCert, proxy and platform-VPN parameters
|
||||||
// 25: Standard profile with platform-VPN parameters and isRestrictedToTestNetworks
|
// 25: Standard profile with platform-VPN parameters and isRestrictedToTestNetworks
|
||||||
|
// 26: Standard profile with platform-VPN parameters and excludeLocalRoutes
|
||||||
if ((values.length < 14 || values.length > 19)
|
if ((values.length < 14 || values.length > 19)
|
||||||
&& values.length != 24 && values.length != 25) {
|
&& values.length != 24 && values.length != 25 && values.length != 26) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,7 +271,15 @@ public final class VpnProfile implements Cloneable, Parcelable {
|
|||||||
isRestrictedToTestNetworks = false;
|
isRestrictedToTestNetworks = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
VpnProfile profile = new VpnProfile(key, isRestrictedToTestNetworks);
|
final boolean excludeLocalRoutes;
|
||||||
|
if (values.length >= 26) {
|
||||||
|
excludeLocalRoutes = Boolean.parseBoolean(values[25]);
|
||||||
|
} else {
|
||||||
|
excludeLocalRoutes = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
VpnProfile profile = new VpnProfile(key, isRestrictedToTestNetworks,
|
||||||
|
excludeLocalRoutes);
|
||||||
profile.name = values[0];
|
profile.name = values[0];
|
||||||
profile.type = Integer.parseInt(values[1]);
|
profile.type = Integer.parseInt(values[1]);
|
||||||
if (profile.type < 0 || profile.type > TYPE_MAX) {
|
if (profile.type < 0 || profile.type > TYPE_MAX) {
|
||||||
@@ -371,6 +389,8 @@ public final class VpnProfile implements Cloneable, Parcelable {
|
|||||||
builder.append(VALUE_DELIMITER).append(areAuthParamsInline);
|
builder.append(VALUE_DELIMITER).append(areAuthParamsInline);
|
||||||
builder.append(VALUE_DELIMITER).append(isRestrictedToTestNetworks);
|
builder.append(VALUE_DELIMITER).append(isRestrictedToTestNetworks);
|
||||||
|
|
||||||
|
builder.append(VALUE_DELIMITER).append(excludeLocalRoutes);
|
||||||
|
|
||||||
return builder.toString().getBytes(StandardCharsets.UTF_8);
|
return builder.toString().getBytes(StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,7 +471,7 @@ public final class VpnProfile implements Cloneable, Parcelable {
|
|||||||
key, type, server, username, password, dnsServers, searchDomains, routes, mppe,
|
key, type, server, username, password, dnsServers, searchDomains, routes, mppe,
|
||||||
l2tpSecret, ipsecIdentifier, ipsecSecret, ipsecUserCert, ipsecCaCert, ipsecServerCert,
|
l2tpSecret, ipsecIdentifier, ipsecSecret, ipsecUserCert, ipsecCaCert, ipsecServerCert,
|
||||||
proxy, mAllowedAlgorithms, isBypassable, isMetered, maxMtu, areAuthParamsInline,
|
proxy, mAllowedAlgorithms, isBypassable, isMetered, maxMtu, areAuthParamsInline,
|
||||||
isRestrictedToTestNetworks);
|
isRestrictedToTestNetworks, excludeLocalRoutes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Checks VPN profiles for interior equality. */
|
/** Checks VPN profiles for interior equality. */
|
||||||
@@ -484,7 +504,8 @@ public final class VpnProfile implements Cloneable, Parcelable {
|
|||||||
&& isMetered == other.isMetered
|
&& isMetered == other.isMetered
|
||||||
&& maxMtu == other.maxMtu
|
&& maxMtu == other.maxMtu
|
||||||
&& areAuthParamsInline == other.areAuthParamsInline
|
&& areAuthParamsInline == other.areAuthParamsInline
|
||||||
&& isRestrictedToTestNetworks == other.isRestrictedToTestNetworks;
|
&& isRestrictedToTestNetworks == other.isRestrictedToTestNetworks
|
||||||
|
&& excludeLocalRoutes == other.excludeLocalRoutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
|||||||
Reference in New Issue
Block a user