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
This commit is contained in:
Chiachang Wang
2022-01-06 16:59:24 +08:00
parent 692533e342
commit f9868455f9

View File

@@ -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;