diff --git a/common/flags.aconfig b/common/flags.aconfig index 9fcd981be9..9905a5e27b 100644 --- a/common/flags.aconfig +++ b/common/flags.aconfig @@ -199,3 +199,12 @@ flag { bug: "406146808" is_fixed_read_only: true } + +flag { + name: "netstats_transport_type" + is_exported: true + namespace: "android_core_networking" + description: "Flag for NetworkTemplate#get/setTransportType API" + bug: "419123367" + is_fixed_read_only: true +} diff --git a/framework-t/api/module-lib-current.txt b/framework-t/api/module-lib-current.txt index 5a8d47b5f5..d14cff2a5d 100644 --- a/framework-t/api/module-lib-current.txt +++ b/framework-t/api/module-lib-current.txt @@ -159,6 +159,7 @@ package android.net { method public int getRatType(); method public int getRoaming(); method @NonNull public java.util.Set getSubscriberIds(); + method @FlaggedApi("com.android.net.flags.netstats_transport_type") public int getTransportType(); method @NonNull public java.util.Set getWifiNetworkKeys(); method public boolean matches(@NonNull android.net.NetworkIdentity); method public void writeToParcel(@NonNull android.os.Parcel, int); @@ -179,6 +180,7 @@ package android.net { public static final class NetworkTemplate.Builder { ctor public NetworkTemplate.Builder(int); + ctor @FlaggedApi("com.android.net.flags.netstats_transport_type") public NetworkTemplate.Builder(); method @NonNull public android.net.NetworkTemplate build(); method @NonNull public android.net.NetworkTemplate.Builder setDefaultNetworkStatus(int); method @NonNull public android.net.NetworkTemplate.Builder setMeteredness(int); @@ -186,6 +188,7 @@ package android.net { method @NonNull public android.net.NetworkTemplate.Builder setRatType(int); method @NonNull public android.net.NetworkTemplate.Builder setRoaming(int); method @NonNull public android.net.NetworkTemplate.Builder setSubscriberIds(@NonNull java.util.Set); + method @FlaggedApi("com.android.net.flags.netstats_transport_type") @NonNull public android.net.NetworkTemplate.Builder setTransportType(int); method @NonNull public android.net.NetworkTemplate.Builder setWifiNetworkKeys(@NonNull java.util.Set); } diff --git a/framework-t/src/android/net/NetworkTemplate.java b/framework-t/src/android/net/NetworkTemplate.java index af44cf7da5..702121761c 100644 --- a/framework-t/src/android/net/NetworkTemplate.java +++ b/framework-t/src/android/net/NetworkTemplate.java @@ -41,6 +41,7 @@ import static com.android.net.module.util.NetworkCapabilitiesUtils.TYPE_TEST; import static java.util.Objects.requireNonNull; +import android.annotation.FlaggedApi; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; @@ -57,6 +58,7 @@ import android.util.Log; import com.android.internal.annotations.VisibleForTesting; import com.android.modules.utils.build.SdkLevel; +import com.android.net.flags.Flags; import com.android.net.module.util.BitUtils; import com.android.net.module.util.CollectionUtils; import com.android.net.module.util.NetworkIdentityUtils; @@ -748,8 +750,8 @@ public final class NetworkTemplate implements Parcelable { * * This is only valid when the template is constructed by using * {@link NetworkTemplate.Builder}. - * @hide */ + @FlaggedApi(Flags.FLAG_NETSTATS_TRANSPORT_TYPE) public int getTransportType() { if (mTransportTypesBits == TRANSPORT_TYPES_ALL) { throw new IllegalStateException("Transport was not set"); @@ -1140,8 +1142,8 @@ public final class NetworkTemplate implements Parcelable { * * Note that {@link #setTransportType} MUST be called to specify * the transport type filter. - * @hide */ + @FlaggedApi(Flags.FLAG_NETSTATS_TRANSPORT_TYPE) public Builder() { this(MATCH_ALL); } @@ -1246,8 +1248,8 @@ public final class NetworkTemplate implements Parcelable { * * @param transportType {@code NetworkCapabilities#TRANSPORT_*} constant. * @return This {@code Builder} for chaining. - @hide */ + @FlaggedApi(Flags.FLAG_NETSTATS_TRANSPORT_TYPE) @NonNull public Builder setTransportType(int transportType) { if (mMatchRule != MATCH_ALL) {