Allow VPN network agent to exclude local traffic
Add API to allow network agent to set whether the local traffic is excluded from the network. This commit is nonfunctional currently but only storing the boolean inside the NAI. Bug: 184750836 Test: atest FrameworksNetTests Change-Id: I3799216ac8fdf22eb4bcabc6c6136d8edbf69360
This commit is contained in:
@@ -232,6 +232,20 @@ public final class NetworkAgentConfig implements Parcelable {
|
||||
return mLegacyExtraInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the {@link Network} is a VPN, whether the local traffic is exempted from the VPN.
|
||||
* @hide
|
||||
*/
|
||||
public boolean excludeLocalRouteVpn = false;
|
||||
|
||||
/**
|
||||
* @return whether local traffic is excluded from the VPN network.
|
||||
* @hide
|
||||
*/
|
||||
public boolean getExcludeLocalRouteVpn() {
|
||||
return excludeLocalRouteVpn;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public NetworkAgentConfig() {
|
||||
}
|
||||
@@ -251,6 +265,7 @@ public final class NetworkAgentConfig implements Parcelable {
|
||||
legacySubType = nac.legacySubType;
|
||||
legacySubTypeName = nac.legacySubTypeName;
|
||||
mLegacyExtraInfo = nac.mLegacyExtraInfo;
|
||||
excludeLocalRouteVpn = nac.excludeLocalRouteVpn;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,6 +421,17 @@ public final class NetworkAgentConfig implements Parcelable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the local traffic is exempted from VPN.
|
||||
*
|
||||
* @return this builder, to facilitate chaining.
|
||||
* @hide TODO(184750836): Unhide once the implementation is completed.
|
||||
*/
|
||||
public Builder setExcludeLocalRoutesVpn(boolean excludeLocalRoutes) {
|
||||
mConfig.excludeLocalRouteVpn = excludeLocalRoutes;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the constructed {@link NetworkAgentConfig} object.
|
||||
*/
|
||||
@@ -429,14 +455,15 @@ public final class NetworkAgentConfig implements Parcelable {
|
||||
&& legacyType == that.legacyType
|
||||
&& Objects.equals(subscriberId, that.subscriberId)
|
||||
&& Objects.equals(legacyTypeName, that.legacyTypeName)
|
||||
&& Objects.equals(mLegacyExtraInfo, that.mLegacyExtraInfo);
|
||||
&& Objects.equals(mLegacyExtraInfo, that.mLegacyExtraInfo)
|
||||
&& excludeLocalRouteVpn == that.excludeLocalRouteVpn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(allowBypass, explicitlySelected, acceptUnvalidated,
|
||||
acceptPartialConnectivity, provisioningNotificationDisabled, subscriberId,
|
||||
skip464xlat, legacyType, legacyTypeName, mLegacyExtraInfo);
|
||||
skip464xlat, legacyType, legacyTypeName, mLegacyExtraInfo, excludeLocalRouteVpn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -453,6 +480,7 @@ public final class NetworkAgentConfig implements Parcelable {
|
||||
+ ", hasShownBroken = " + hasShownBroken
|
||||
+ ", legacyTypeName = '" + legacyTypeName + '\''
|
||||
+ ", legacyExtraInfo = '" + mLegacyExtraInfo + '\''
|
||||
+ ", excludeLocalRouteVpn = '" + excludeLocalRouteVpn + '\''
|
||||
+ "}";
|
||||
}
|
||||
|
||||
@@ -475,6 +503,7 @@ public final class NetworkAgentConfig implements Parcelable {
|
||||
out.writeInt(legacySubType);
|
||||
out.writeString(legacySubTypeName);
|
||||
out.writeString(mLegacyExtraInfo);
|
||||
out.writeInt(excludeLocalRouteVpn ? 1 : 0);
|
||||
}
|
||||
|
||||
public static final @NonNull Creator<NetworkAgentConfig> CREATOR =
|
||||
@@ -494,6 +523,7 @@ public final class NetworkAgentConfig implements Parcelable {
|
||||
networkAgentConfig.legacySubType = in.readInt();
|
||||
networkAgentConfig.legacySubTypeName = in.readString();
|
||||
networkAgentConfig.mLegacyExtraInfo = in.readString();
|
||||
networkAgentConfig.excludeLocalRouteVpn = in.readInt() != 0;
|
||||
return networkAgentConfig;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user