diff --git a/core/java/android/net/INetworkStatsSession.aidl b/core/java/android/net/INetworkStatsSession.aidl index f13f2cb664..dfedf6633d 100644 --- a/core/java/android/net/INetworkStatsSession.aidl +++ b/core/java/android/net/INetworkStatsSession.aidl @@ -33,7 +33,17 @@ interface INetworkStatsSession { @UnsupportedAppUsage NetworkStatsHistory getHistoryForNetwork(in NetworkTemplate template, int fields); - /** Return network layer usage summary per UID for traffic that matches template. */ + /** + * Return network layer usage summary per UID for traffic that matches template. + * + *

The resulting {@code NetworkStats#getElapsedRealtime()} contains time delta between + * {@code start} and {@code end}. + * + * @param template - a predicate to filter netstats. + * @param start - start of the range, timestamp in milliseconds since the epoch. + * @param end - end of the range, timestamp in milliseconds since the epoch. + * @param includeTags - includes data usage tags if true. + */ @UnsupportedAppUsage NetworkStats getSummaryForAllUid(in NetworkTemplate template, long start, long end, boolean includeTags); /** Return historical network layer stats for specific UID traffic that matches template. */ diff --git a/core/java/android/net/NetworkStats.java b/core/java/android/net/NetworkStats.java index 46c83df96b..c7ffc19338 100644 --- a/core/java/android/net/NetworkStats.java +++ b/core/java/android/net/NetworkStats.java @@ -220,8 +220,10 @@ public final class NetworkStats implements Parcelable { // TODO: move fields to "mVariable" notation /** - * {@link SystemClock#elapsedRealtime()} timestamp when this data was + * {@link SystemClock#elapsedRealtime()} timestamp in milliseconds when this data was * generated. + * It's a timestamps delta when {@link #subtract()}, + * {@code INetworkStatsSession#getSummaryForAllUid()} methods are used. */ private long elapsedRealtime; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) diff --git a/core/java/android/net/NetworkStatsHistory.java b/core/java/android/net/NetworkStatsHistory.java index f41306301d..a875e1ad45 100644 --- a/core/java/android/net/NetworkStatsHistory.java +++ b/core/java/android/net/NetworkStatsHistory.java @@ -526,6 +526,13 @@ public class NetworkStatsHistory implements Parcelable { /** * Return interpolated data usage across the requested range. Interpolates * across buckets, so values may be rounded slightly. + * + *

If the active bucket is not completed yet, it returns the proportional value of it + * based on its duration and the {@code end} param. + * + * @param start - start of the range, timestamp in milliseconds since the epoch. + * @param end - end of the range, timestamp in milliseconds since the epoch. + * @param recycle - entry instance for performance, could be null. */ @UnsupportedAppUsage public Entry getValues(long start, long end, Entry recycle) { @@ -535,6 +542,11 @@ public class NetworkStatsHistory implements Parcelable { /** * Return interpolated data usage across the requested range. Interpolates * across buckets, so values may be rounded slightly. + * + * @param start - start of the range, timestamp in milliseconds since the epoch. + * @param end - end of the range, timestamp in milliseconds since the epoch. + * @param now - current timestamp in milliseconds since the epoch (wall clock). + * @param recycle - entry instance for performance, could be null. */ @UnsupportedAppUsage public Entry getValues(long start, long end, long now, Entry recycle) { diff --git a/services/core/java/com/android/server/net/NetworkStatsCollection.java b/services/core/java/com/android/server/net/NetworkStatsCollection.java index df372b1459..213ea402f5 100644 --- a/services/core/java/com/android/server/net/NetworkStatsCollection.java +++ b/services/core/java/com/android/server/net/NetworkStatsCollection.java @@ -59,16 +59,15 @@ import com.android.internal.util.FastDataOutput; import com.android.internal.util.FileRotator; import com.android.internal.util.IndentingPrintWriter; -import libcore.io.IoUtils; - import com.google.android.collect.Lists; import com.google.android.collect.Maps; +import libcore.io.IoUtils; + import java.io.BufferedInputStream; import java.io.DataInput; import java.io.DataInputStream; import java.io.DataOutput; -import java.io.DataOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; @@ -335,7 +334,13 @@ public class NetworkStatsCollection implements FileRotator.Reader, FileRotator.W /** * Summarize all {@link NetworkStatsHistory} in this collection which match - * the requested parameters. + * the requested parameters across the requested range. + * + * @param template - a predicate for filtering netstats. + * @param start - start of the range, timestamp in milliseconds since the epoch. + * @param end - end of the range, timestamp in milliseconds since the epoch. + * @param accessLevel - caller access level. + * @param callerUid - caller UID. */ public NetworkStats getSummary(NetworkTemplate template, long start, long end, @NetworkStatsAccess.Level int accessLevel, int callerUid) {