From f9868455f9d4775711112772f3bf410abad4d8f8 Mon Sep 17 00:00:00 2001 From: Chiachang Wang Date: Thu, 6 Jan 2022 16:59:24 +0800 Subject: [PATCH] Allow excludeLocalRoutes set only in bypassable profile If excludeLocalRoutes is set, it means the VPN is not fully-routed. The bypassable bit should also be set to reflect the behavior in the VPN profile. Thus, verify it in the constructor to ensure the behavior. Bug: 184750836 Test: atest FrameworksNetTests Change-Id: I5d2c7bea2e0d5e77f9241c1efc295b3929e1dae3 --- core/java/android/net/Ikev2VpnProfile.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/java/android/net/Ikev2VpnProfile.java b/core/java/android/net/Ikev2VpnProfile.java index fab692cba2f6a..726d870c7761b 100644 --- a/core/java/android/net/Ikev2VpnProfile.java +++ b/core/java/android/net/Ikev2VpnProfile.java @@ -163,6 +163,10 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile { // UnmodifiableList doesn't make a defensive copy by default. mAllowedAlgorithms = Collections.unmodifiableList(new ArrayList<>(allowedAlgorithms)); + if (excludeLocalRoutes && !isBypassable) { + throw new IllegalArgumentException( + "Vpn should be byassable if excludeLocalRoutes is set"); + } mIsBypassable = isBypassable; mIsMetered = isMetered;