Merge "Expose NetworkTemplate get/set transport type APIs" into main

This commit is contained in:
Junyu Lai 2025-06-10 03:10:42 -07:00 • committed by Android (Google) Code Review
commit 5548278f28
3 changed files with 17 additions and 3 deletions

View file

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

View file

@ -159,6 +159,7 @@ package android.net {
method public int getRatType();
method public int getRoaming();
method @NonNull public java.util.Set<java.lang.String> getSubscriberIds();
method @FlaggedApi("com.android.net.flags.netstats_transport_type") public int getTransportType();
method @NonNull public java.util.Set<java.lang.String> 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<java.lang.String>);
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<java.lang.String>);
}

View file

@ -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) {