summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorAaron Huang <huangaaron@google.com>2019-12-06 10:59:11 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-12-06 10:59:11 +0000
commit8aed6e69f02074f74ee5016df5a27cb86f347b9d (patch)
treeb1610bac568250b65d00dad165a40057584a00d3 /core/java/android
parent7f81046bed98048bf12e672e04f6cf11703d5f3e (diff)
parent29667d2942de3bebacad29638288811e3f7792b1 (diff)
Merge "Add TrafficStats methods to public APIs"
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/net/TrafficStats.java23
1 files changed, 19 insertions, 4 deletions
diff --git a/core/java/android/net/TrafficStats.java b/core/java/android/net/TrafficStats.java
index 1c6a48434adc..bf4884aa96a7 100644
--- a/core/java/android/net/TrafficStats.java
+++ b/core/java/android/net/TrafficStats.java
@@ -16,6 +16,7 @@
package android.net;
+import android.annotation.NonNull;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.annotation.TestApi;
@@ -595,8 +596,15 @@ public class TrafficStats {
return total;
}
- /** {@hide} */
- public static long getTxPackets(String iface) {
+ /**
+ * Return the number of packets transmitted on the specified interface since
+ * device boot. Statistics are measured at the network layer, so both TCP and
+ * UDP usage are included.
+ *
+ * @param iface The name of the interface.
+ * @return The number of transmitted packets.
+ */
+ public static long getTxPackets(@NonNull String iface) {
try {
return getStatsService().getIfaceStats(iface, TYPE_TX_PACKETS);
} catch (RemoteException e) {
@@ -604,8 +612,15 @@ public class TrafficStats {
}
}
- /** {@hide} */
- public static long getRxPackets(String iface) {
+ /**
+ * Return the number of packets received on the specified interface since
+ * device boot. Statistics are measured at the network layer, so both TCP
+ * and UDP usage are included.
+ *
+ * @param iface The name of the interface.
+ * @return The number of received packets.
+ */
+ public static long getRxPackets(@NonNull String iface) {
try {
return getStatsService().getIfaceStats(iface, TYPE_RX_PACKETS);
} catch (RemoteException e) {