diff --git a/core/java/android/net/TrafficStats.java b/core/java/android/net/TrafficStats.java index 2137c3a30a..e82485da32 100644 --- a/core/java/android/net/TrafficStats.java +++ b/core/java/android/net/TrafficStats.java @@ -28,6 +28,7 @@ import com.android.server.NetworkManagementSocketTagger; import dalvik.system.SocketTagger; +import java.net.DatagramSocket; import java.net.Socket; import java.net.SocketException; @@ -225,6 +226,27 @@ public class TrafficStats { SocketTagger.get().untag(socket); } + /** + * Tag the given {@link DatagramSocket} with any statistics parameters + * active for the current thread. Subsequent calls always replace any + * existing parameters. When finished, call + * {@link #untagDatagramSocket(DatagramSocket)} to remove statistics + * parameters. + * + * @see #setThreadStatsTag(int) + * @see #setThreadStatsUid(int) + */ + public static void tagDatagramSocket(DatagramSocket socket) throws SocketException { + SocketTagger.get().tag(socket); + } + + /** + * Remove any statistics parameters from the given {@link DatagramSocket}. + */ + public static void untagDatagramSocket(DatagramSocket socket) throws SocketException { + SocketTagger.get().untag(socket); + } + /** * Start profiling data usage for current UID. Only one profiling session * can be active at a time.