From 0838c8fb537b2b2a6f92ab5d2aec974f69392339 Mon Sep 17 00:00:00 2001 From: Yan Yan Date: Sat, 10 Dec 2022 01:56:30 +0000 Subject: [PATCH] Expose APIs to configure transports to be restricted by VCN This commit exposes APIs to allow caller to configure transports that willl be marked as restricted by VCN. This API allows carriers to restrict the access to the carrier owned networks and thus prevent apps from circumventing the VCN. Bug: 239104955 Test: make update-api CTS-Coverage-Bug: 262263040 Change-Id: I21aaab57e3d51f4f206c613c94c95ee02150b929 --- core/api/current.txt | 2 ++ core/java/android/net/vcn/VcnConfig.java | 9 ++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index 2ba2f5bd2c859..7ecaf684ce967 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -27285,6 +27285,7 @@ package android.net.vcn { public final class VcnConfig implements android.os.Parcelable { method public int describeContents(); method @NonNull public java.util.Set getGatewayConnectionConfigs(); + method @NonNull public java.util.Set getRestrictedUnderlyingNetworkTransports(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator CREATOR; } @@ -27293,6 +27294,7 @@ package android.net.vcn { ctor public VcnConfig.Builder(@NonNull android.content.Context); method @NonNull public android.net.vcn.VcnConfig.Builder addGatewayConnectionConfig(@NonNull android.net.vcn.VcnGatewayConnectionConfig); method @NonNull public android.net.vcn.VcnConfig build(); + method @NonNull public android.net.vcn.VcnConfig.Builder setRestrictedUnderlyingNetworkTransports(@NonNull java.util.Set); } public final class VcnGatewayConnectionConfig { diff --git a/core/java/android/net/vcn/VcnConfig.java b/core/java/android/net/vcn/VcnConfig.java index 8627f5c7a1ba3..dcf002613b80e 100644 --- a/core/java/android/net/vcn/VcnConfig.java +++ b/core/java/android/net/vcn/VcnConfig.java @@ -25,6 +25,7 @@ import static com.android.server.vcn.util.PersistableBundleUtils.INTEGER_SERIALI import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; +import android.net.NetworkCapabilities; import android.net.NetworkRequest; import android.os.Parcel; import android.os.Parcelable; @@ -158,10 +159,9 @@ public final class VcnConfig implements Parcelable { } /** - * Retrieve the transports that need to be restricted by VCN. + * Retrieve the transports that will be restricted by the VCN. * * @see Builder#setRestrictedUnderlyingNetworkTransports(Set) - * @hide */ @NonNull public Set getRestrictedUnderlyingNetworkTransports() { @@ -306,16 +306,15 @@ public final class VcnConfig implements Parcelable { } /** - * Sets transports that need to be restricted by VCN. + * Sets transports that will be restricted by the VCN. * - * @param transports transports that need to be restricted by VCN. Networks that include any + * @param transports transports that will be restricted by VCN. Networks that include any * of the transports will be marked as restricted. Only {@link * NetworkCapabilities#TRANSPORT_WIFI} and {@link * NetworkCapabilities#TRANSPORT_CELLULAR} are allowed. {@link * NetworkCapabilities#TRANSPORT_WIFI} is marked restricted by default. * @return this {@link Builder} instance, for chaining * @throws IllegalArgumentException if the input contains unsupported transport types. - * @hide */ @NonNull public Builder setRestrictedUnderlyingNetworkTransports(@NonNull Set transports) {