Collect and persist tethering stats.
Use new "gettetherstats" netd command to retrieve statistics for
active tethering connections. Keep tethering poll events separate
from UID poll, even though they end up same historical structures.
Bug: 5244846
Change-Id: Ia0c5165f6712c12b51586f86c331a2aad4ad6afb
diff --git a/core/java/android/net/IConnectivityManager.aidl b/core/java/android/net/IConnectivityManager.aidl
index eef658e..7046008 100644
--- a/core/java/android/net/IConnectivityManager.aidl
+++ b/core/java/android/net/IConnectivityManager.aidl
@@ -83,6 +83,12 @@
String[] getTetheredIfaces();
+ /**
+ * Return list of interface pairs that are actively tethered. Even indexes are
+ * remote interface, and odd indexes are corresponding local interfaces.
+ */
+ String[] getTetheredIfacePairs();
+
String[] getTetheringErroredIfaces();
String[] getTetherableUsbRegexs();
diff --git a/core/java/android/net/TrafficStats.java b/core/java/android/net/TrafficStats.java
index 47cfa73..18eb9f6 100644
--- a/core/java/android/net/TrafficStats.java
+++ b/core/java/android/net/TrafficStats.java
@@ -53,25 +53,33 @@
public static final int UID_REMOVED = -4;
/**
+ * Special UID value used when collecting {@link NetworkStatsHistory} for
+ * tethering traffic.
+ *
+ * @hide
+ */
+ public static final int UID_TETHERING = -5;
+
+ /**
* Default tag value for {@link DownloadManager} traffic.
*
* @hide
*/
- public static final int TAG_SYSTEM_DOWNLOAD = 0xFFFF0001;
+ public static final int TAG_SYSTEM_DOWNLOAD = 0xFFFFFF01;
/**
* Default tag value for {@link MediaPlayer} traffic.
*
* @hide
*/
- public static final int TAG_SYSTEM_MEDIA = 0xFFFF0002;
+ public static final int TAG_SYSTEM_MEDIA = 0xFFFFFF02;
/**
* Default tag value for {@link BackupManager} traffic.
*
* @hide
*/
- public static final int TAG_SYSTEM_BACKUP = 0xFFFF0003;
+ public static final int TAG_SYSTEM_BACKUP = 0xFFFFFF03;
/**
* Snapshot of {@link NetworkStats} when the currently active profiling
@@ -90,6 +98,10 @@
* <p>
* Changes only take effect during subsequent calls to
* {@link #tagSocket(Socket)}.
+ * <p>
+ * Tags between {@code 0xFFFFFF00} and {@code 0xFFFFFFFF} are reserved and
+ * used internally by system services like {@link DownloadManager} when
+ * performing traffic on behalf of an application.
*/
public static void setThreadStatsTag(int tag) {
NetworkManagementSocketTagger.setThreadSocketStatsTag(tag);