Merge "Have a new method in NetworkAgentConfig.Builder to set allowBypass" am: 14f7c0273f am: 07a92ecbd9 am: 702f7447ff

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

Change-Id: Ibc6553b1471ee8e0ab362979ba9525c2e328a275
This commit is contained in:
Lorenzo Colitti
2021-03-23 14:02:47 +00:00
committed by Automerger Merge Worker
3 changed files with 28 additions and 2 deletions

View File

@@ -37,9 +37,11 @@ package android.net {
public final class NetworkAgentConfig implements android.os.Parcelable {
method @Nullable public String getSubscriberId();
method public boolean isBypassableVpn();
}
public static final class NetworkAgentConfig.Builder {
method @NonNull public android.net.NetworkAgentConfig.Builder setBypassableVpn(boolean);
method @NonNull public android.net.NetworkAgentConfig.Builder setSubscriberId(@Nullable String);
}

View File

@@ -63,6 +63,16 @@ public final class NetworkAgentConfig implements Parcelable {
return explicitlySelected;
}
/**
* @return whether this VPN connection can be bypassed by the apps.
*
* @hide
*/
@SystemApi(client = MODULE_LIBRARIES)
public boolean isBypassableVpn() {
return allowBypass;
}
/**
* Set if the user desires to use this network even if it is unvalidated. This field has meaning
* only if {@link explicitlySelected} is true. If it is, this field must also be set to the
@@ -381,6 +391,19 @@ public final class NetworkAgentConfig implements Parcelable {
return this;
}
/**
* Sets whether the apps can bypass the VPN connection.
*
* @return this builder, to facilitate chaining.
* @hide
*/
@NonNull
@SystemApi(client = MODULE_LIBRARIES)
public Builder setBypassableVpn(boolean allowBypass) {
mConfig.allowBypass = allowBypass;
return this;
}
/**
* Returns the constructed {@link NetworkAgentConfig} object.
*/

View File

@@ -1248,8 +1248,9 @@ public class Vpn {
mLegacyState = LegacyVpnInfo.STATE_CONNECTING;
updateState(DetailedState.CONNECTING, "agentConnect");
NetworkAgentConfig networkAgentConfig = new NetworkAgentConfig.Builder().build();
networkAgentConfig.allowBypass = mConfig.allowBypass && !mLockdown;
final NetworkAgentConfig networkAgentConfig = new NetworkAgentConfig.Builder()
.setBypassableVpn(mConfig.allowBypass && !mLockdown)
.build();
capsBuilder.setOwnerUid(mOwnerUID);
capsBuilder.setAdministratorUids(new int[] {mOwnerUID});