Loading api/current.txt +4 −0 Original line number Diff line number Diff line Loading @@ -26035,6 +26035,7 @@ package android.net { public class TrafficStats { ctor public TrafficStats(); method public static void clearThreadStatsTag(); method public static void clearThreadStatsUid(); method public static int getAndSetThreadStatsTag(int); method public static long getMobileRxBytes(); method public static long getMobileRxPackets(); Loading @@ -26060,9 +26061,12 @@ package android.net { method public static void incrementOperationCount(int); method public static void incrementOperationCount(int, int); method public static void setThreadStatsTag(int); method public static void setThreadStatsUidSelf(); method public static void tagDatagramSocket(java.net.DatagramSocket) throws java.net.SocketException; method public static void tagFileDescriptor(java.io.FileDescriptor) throws java.io.IOException; method public static void tagSocket(java.net.Socket) throws java.net.SocketException; method public static void untagDatagramSocket(java.net.DatagramSocket) throws java.net.SocketException; method public static void untagFileDescriptor(java.io.FileDescriptor) throws java.io.IOException; method public static void untagSocket(java.net.Socket) throws java.net.SocketException; field public static final int UNSUPPORTED = -1; // 0xffffffff } core/java/android/net/TrafficStats.java +37 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.net; import android.annotation.RequiresPermission; import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.app.DownloadManager; import android.app.backup.BackupManager; Loading @@ -30,6 +31,8 @@ import com.android.server.NetworkManagementSocketTagger; import dalvik.system.SocketTagger; import java.io.FileDescriptor; import java.io.IOException; import java.net.DatagramSocket; import java.net.Socket; import java.net.SocketException; Loading Loading @@ -263,15 +266,26 @@ public class TrafficStats { NetworkManagementSocketTagger.setThreadSocketStatsUid(uid); } /** * Set specific UID to use when accounting {@link Socket} traffic * originating from the current thread as the calling UID. Designed for use * when another application is performing operations on your behalf. * <p> * Changes only take effect during subsequent calls to * {@link #tagSocket(Socket)}. */ public static void setThreadStatsUidSelf() { setThreadStatsUid(android.os.Process.myUid()); } /** * Clear any active UID set to account {@link Socket} traffic originating * from the current thread. * * @see #setThreadStatsUid(int) * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) @SuppressLint("Doclava125") public static void clearThreadStatsUid() { NetworkManagementSocketTagger.setThreadSocketStatsUid(-1); } Loading Loading @@ -315,6 +329,27 @@ public class TrafficStats { SocketTagger.get().untag(socket); } /** * Tag the given {@link FileDescriptor} socket with any statistics * parameters active for the current thread. Subsequent calls always replace * any existing parameters. When finished, call * {@link #untagFileDescriptor(FileDescriptor)} to remove statistics * parameters. * * @see #setThreadStatsTag(int) */ public static void tagFileDescriptor(FileDescriptor fd) throws IOException { SocketTagger.get().tag(fd); } /** * Remove any statistics parameters from the given {@link FileDescriptor} * socket. */ public static void untagFileDescriptor(FileDescriptor fd) throws IOException { SocketTagger.get().untag(fd); } /** * Start profiling data usage for current UID. Only one profiling session * can be active at a time. Loading Loading
api/current.txt +4 −0 Original line number Diff line number Diff line Loading @@ -26035,6 +26035,7 @@ package android.net { public class TrafficStats { ctor public TrafficStats(); method public static void clearThreadStatsTag(); method public static void clearThreadStatsUid(); method public static int getAndSetThreadStatsTag(int); method public static long getMobileRxBytes(); method public static long getMobileRxPackets(); Loading @@ -26060,9 +26061,12 @@ package android.net { method public static void incrementOperationCount(int); method public static void incrementOperationCount(int, int); method public static void setThreadStatsTag(int); method public static void setThreadStatsUidSelf(); method public static void tagDatagramSocket(java.net.DatagramSocket) throws java.net.SocketException; method public static void tagFileDescriptor(java.io.FileDescriptor) throws java.io.IOException; method public static void tagSocket(java.net.Socket) throws java.net.SocketException; method public static void untagDatagramSocket(java.net.DatagramSocket) throws java.net.SocketException; method public static void untagFileDescriptor(java.io.FileDescriptor) throws java.io.IOException; method public static void untagSocket(java.net.Socket) throws java.net.SocketException; field public static final int UNSUPPORTED = -1; // 0xffffffff }
core/java/android/net/TrafficStats.java +37 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.net; import android.annotation.RequiresPermission; import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.app.DownloadManager; import android.app.backup.BackupManager; Loading @@ -30,6 +31,8 @@ import com.android.server.NetworkManagementSocketTagger; import dalvik.system.SocketTagger; import java.io.FileDescriptor; import java.io.IOException; import java.net.DatagramSocket; import java.net.Socket; import java.net.SocketException; Loading Loading @@ -263,15 +266,26 @@ public class TrafficStats { NetworkManagementSocketTagger.setThreadSocketStatsUid(uid); } /** * Set specific UID to use when accounting {@link Socket} traffic * originating from the current thread as the calling UID. Designed for use * when another application is performing operations on your behalf. * <p> * Changes only take effect during subsequent calls to * {@link #tagSocket(Socket)}. */ public static void setThreadStatsUidSelf() { setThreadStatsUid(android.os.Process.myUid()); } /** * Clear any active UID set to account {@link Socket} traffic originating * from the current thread. * * @see #setThreadStatsUid(int) * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) @SuppressLint("Doclava125") public static void clearThreadStatsUid() { NetworkManagementSocketTagger.setThreadSocketStatsUid(-1); } Loading Loading @@ -315,6 +329,27 @@ public class TrafficStats { SocketTagger.get().untag(socket); } /** * Tag the given {@link FileDescriptor} socket with any statistics * parameters active for the current thread. Subsequent calls always replace * any existing parameters. When finished, call * {@link #untagFileDescriptor(FileDescriptor)} to remove statistics * parameters. * * @see #setThreadStatsTag(int) */ public static void tagFileDescriptor(FileDescriptor fd) throws IOException { SocketTagger.get().tag(fd); } /** * Remove any statistics parameters from the given {@link FileDescriptor} * socket. */ public static void untagFileDescriptor(FileDescriptor fd) throws IOException { SocketTagger.get().untag(fd); } /** * Start profiling data usage for current UID. Only one profiling session * can be active at a time. Loading