diff options
| author | Chiachang Wang <chiachangwang@google.com> | 2021-12-28 07:57:43 +0000 |
|---|---|---|
| committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-12-28 07:57:43 +0000 |
| commit | 0ea8189d383a07027d8754c646e00767d2c9ecfc (patch) | |
| tree | 9a89ee255c1088e990184ae8e43eaea5b34230e1 /core/java/android | |
| parent | b633488337d86c2aabc0e5673a44388ea06676e0 (diff) | |
| parent | 80178db312870a0c5a8eb7365893964f854196ec (diff) | |
Merge "Add configuration whether to exclude local traffic in the VPN" am: 80178db312
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1926899
Change-Id: I07a8ea808a99afdf25d970f53089fddee7ee6dca
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/net/Ikev2VpnProfile.java | 28 | ||||
| -rw-r--r-- | core/java/android/net/PlatformVpnProfile.java | 17 |
2 files changed, 39 insertions, 6 deletions
diff --git a/core/java/android/net/Ikev2VpnProfile.java b/core/java/android/net/Ikev2VpnProfile.java index b18e9be28eb5..fab692cba2f6 100644 --- a/core/java/android/net/Ikev2VpnProfile.java +++ b/core/java/android/net/Ikev2VpnProfile.java @@ -142,8 +142,9 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile { boolean isBypassable, boolean isMetered, int maxMtu, - boolean restrictToTestNetworks) { - super(type); + boolean restrictToTestNetworks, + boolean excludeLocalRoutes) { + super(type, excludeLocalRoutes); checkNotNull(serverAddr, MISSING_PARAM_MSG_TMPL, "Server address"); checkNotNull(userIdentity, MISSING_PARAM_MSG_TMPL, "User Identity"); @@ -403,7 +404,8 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile { && mIsBypassable == other.mIsBypassable && mIsMetered == other.mIsMetered && mMaxMtu == other.mMaxMtu - && mIsRestrictedToTestNetworks == other.mIsRestrictedToTestNetworks; + && mIsRestrictedToTestNetworks == other.mIsRestrictedToTestNetworks + && mExcludeLocalRoutes == other.mExcludeLocalRoutes; } /** @@ -417,7 +419,7 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile { @NonNull public VpnProfile toVpnProfile() throws IOException, GeneralSecurityException { final VpnProfile profile = new VpnProfile("" /* Key; value unused by IKEv2VpnProfile(s) */, - mIsRestrictedToTestNetworks); + mIsRestrictedToTestNetworks, mExcludeLocalRoutes); profile.type = mType; profile.server = mServerAddr; profile.ipsecIdentifier = mUserIdentity; @@ -518,6 +520,8 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile { throw new IllegalArgumentException("Invalid auth method set"); } + builder.setExcludeLocalRoutes(profile.excludeLocalRoutes); + return builder.build(); } @@ -657,6 +661,7 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile { private boolean mIsMetered = true; private int mMaxMtu = PlatformVpnProfile.MAX_MTU_DEFAULT; private boolean mIsRestrictedToTestNetworks = false; + private boolean mExcludeLocalRoutes = false; /** * Creates a new builder with the basic parameters of an IKEv2/IPsec VPN. @@ -902,6 +907,18 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile { } /** + * 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. * * @throws IllegalArgumentException if any of the required keys or values were invalid @@ -924,7 +941,8 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile { mIsBypassable, mIsMetered, mMaxMtu, - mIsRestrictedToTestNetworks); + mIsRestrictedToTestNetworks, + mExcludeLocalRoutes); } } } diff --git a/core/java/android/net/PlatformVpnProfile.java b/core/java/android/net/PlatformVpnProfile.java index 445ec91e4f46..777a90c8985c 100644 --- a/core/java/android/net/PlatformVpnProfile.java +++ b/core/java/android/net/PlatformVpnProfile.java @@ -66,15 +66,30 @@ public abstract class PlatformVpnProfile { @PlatformVpnType protected final int mType; /** @hide */ - PlatformVpnProfile(@PlatformVpnType int type) { + protected final boolean mExcludeLocalRoutes; + + /** @hide */ + PlatformVpnProfile(@PlatformVpnType int type, boolean excludeLocalRoutes) { mType = type; + mExcludeLocalRoutes = excludeLocalRoutes; } + /** Returns the profile integer type. */ @PlatformVpnType public final int getType() { 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 */ @NonNull public final String getTypeString() { |
