[SP23] Address misc API review comment about NetworkStats

This change add several javadoc for NetworkStats and its Entry
class. Also remove IFACE_ALL constant accordlingly.

Test: atest FrameworkNetTests
Test: m doc-comment-check-docs
Bug: 148895143
Change-Id: Id1b8f41be79f847ad73197ff0e18258b6ee8a730
This commit is contained in:
junyulai
2020-03-13 16:12:35 +08:00
parent 9a4eeaea2f
commit c7e8100faa

View File

@@ -21,7 +21,6 @@ import static android.os.Process.CLAT_UID;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.compat.annotation.UnsupportedAppUsage;
import android.os.Parcel;
@@ -58,9 +57,12 @@ import java.util.function.Predicate;
public final class NetworkStats implements Parcelable {
private static final String TAG = "NetworkStats";
/** {@link #iface} value when interface details unavailable. */
@SuppressLint("CompileTimeConstant")
/**
* {@link #iface} value when interface details unavailable.
* @hide
*/
@Nullable public static final String IFACE_ALL = null;
/**
* Virtual network interface for video telephony. This is for VT data usage counting
* purpose.
@@ -248,7 +250,13 @@ public final class NetworkStats implements Parcelable {
@UnsupportedAppUsage
private long[] operations;
/** @hide */
/**
* Basic element of network statistics. Contains the number of packets and number of bytes
* transferred on both directions in a given set of conditions. See
* {@link Entry#Entry(String, int, int, int, int, int, int, long, long, long, long, long)}.
*
* @hide
*/
@SystemApi
public static class Entry {
/** @hide */
@@ -319,6 +327,35 @@ public final class NetworkStats implements Parcelable {
rxBytes, rxPackets, txBytes, txPackets, operations);
}
/**
* Construct a {@link Entry} object by giving statistics of packet and byte transferred on
* both direction, and associated with a set of given conditions.
*
* @param iface interface name of this {@link Entry}. Or null if not specified.
* @param uid uid of this {@link Entry}. {@link #UID_TETHERING} if this {@link Entry} is
* for tethering. Or {@link #UID_ALL} if this {@link NetworkStats} is only
* counting iface stats.
* @param set usage state of this {@link Entry}. Should be one of the following
* values: {@link #SET_DEFAULT}, {@link #SET_FOREGROUND}.
* @param tag tag of this {@link Entry}.
* @param metered metered state of this {@link Entry}. Should be one of the following
* values: {link #METERED_YES}, {link #METERED_NO}.
* @param roaming roaming state of this {@link Entry}. Should be one of the following
* values: {link #ROAMING_YES}, {link #ROAMING_NO}.
* @param defaultNetwork default network status of this {@link Entry}. Should be one
* of the following values: {link #DEFAULT_NETWORK_YES},
* {link #DEFAULT_NETWORK_NO}.
* @param rxBytes Number of bytes received for this {@link Entry}. Statistics should
* represent the contents of IP packets, including IP headers.
* @param rxPackets Number of packets received for this {@link Entry}. Statistics should
* represent the contents of IP packets, including IP headers.
* @param txBytes Number of bytes transmitted for this {@link Entry}. Statistics should
* represent the contents of IP packets, including IP headers.
* @param txPackets Number of bytes transmitted for this {@link Entry}. Statistics should
* represent the contents of IP packets, including IP headers.
* @param operations count of network operations performed for this {@link Entry}. This can
* be used to derive bytes-per-operation.
*/
public Entry(@Nullable String iface, int uid, @State int set, int tag,
@Meteredness int metered, @Roaming int roaming, @DefaultNetwork int defaultNetwork,
long rxBytes, long rxPackets, long txBytes, long txPackets, long operations) {