Merge "Have NetworkStats implements iterable"
This commit is contained in:
@@ -7523,11 +7523,12 @@ package android.net {
|
|||||||
field public static final String PERMISSION_MAINLINE_NETWORK_STACK = "android.permission.MAINLINE_NETWORK_STACK";
|
field public static final String PERMISSION_MAINLINE_NETWORK_STACK = "android.permission.MAINLINE_NETWORK_STACK";
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class NetworkStats implements android.os.Parcelable {
|
public final class NetworkStats implements java.lang.Iterable<android.net.NetworkStats.Entry> android.os.Parcelable {
|
||||||
ctor public NetworkStats(long, int);
|
ctor public NetworkStats(long, int);
|
||||||
method @NonNull public android.net.NetworkStats add(@NonNull android.net.NetworkStats);
|
method @NonNull public android.net.NetworkStats add(@NonNull android.net.NetworkStats);
|
||||||
method @NonNull public android.net.NetworkStats addEntry(@NonNull android.net.NetworkStats.Entry);
|
method @NonNull public android.net.NetworkStats addEntry(@NonNull android.net.NetworkStats.Entry);
|
||||||
method public int describeContents();
|
method public int describeContents();
|
||||||
|
method @NonNull public java.util.Iterator<android.net.NetworkStats.Entry> iterator();
|
||||||
method @NonNull public android.net.NetworkStats subtract(@NonNull android.net.NetworkStats);
|
method @NonNull public android.net.NetworkStats subtract(@NonNull android.net.NetworkStats);
|
||||||
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||||
field @NonNull public static final android.os.Parcelable.Creator<android.net.NetworkStats> CREATOR;
|
field @NonNull public static final android.os.Parcelable.Creator<android.net.NetworkStats> CREATOR;
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -57,7 +58,7 @@ import java.util.function.Predicate;
|
|||||||
*/
|
*/
|
||||||
// @NotThreadSafe
|
// @NotThreadSafe
|
||||||
@SystemApi
|
@SystemApi
|
||||||
public final class NetworkStats implements Parcelable {
|
public final class NetworkStats implements Parcelable, Iterable<NetworkStats.Entry> {
|
||||||
private static final String TAG = "NetworkStats";
|
private static final String TAG = "NetworkStats";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -677,6 +678,35 @@ public final class NetworkStats implements Parcelable {
|
|||||||
operations[i] = entry.operations;
|
operations[i] = entry.operations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Iterate over Entry objects.
|
||||||
|
*
|
||||||
|
* Return an iterator of this object that will iterate through all contained Entry objects.
|
||||||
|
*
|
||||||
|
* This iterator does not support concurrent modification and makes no guarantee of fail-fast
|
||||||
|
* behavior. If any method that can mutate the contents of this object is called while
|
||||||
|
* iteration is in progress, either inside the loop or in another thread, then behavior is
|
||||||
|
* undefined.
|
||||||
|
* The remove() method is not implemented and will throw UnsupportedOperationException.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@SystemApi
|
||||||
|
@NonNull public Iterator<Entry> iterator() {
|
||||||
|
return new Iterator<Entry>() {
|
||||||
|
int mIndex = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return mIndex < size;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Entry next() {
|
||||||
|
return getValues(mIndex++, null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return specific stats entry.
|
* Return specific stats entry.
|
||||||
* @hide
|
* @hide
|
||||||
|
|||||||
Reference in New Issue
Block a user