Stay organized with collections Save and categorize content based on your preferences.

TrafficStatsCompat

public final class TrafficStatsCompat


Helper for accessing features in TrafficStats.

Summary

Public methods

static void

This method is deprecated.

Use clearThreadStatsTag directly.

static int

This method is deprecated.

Use getThreadStatsTag directly.

static void
incrementOperationCount(int operationCount)

This method is deprecated.

Use incrementOperationCount directly.

static void
incrementOperationCount(int tag, int operationCount)

This method is deprecated.

Use incrementOperationCount directly.

static void

This method is deprecated.

Use setThreadStatsTag directly.

static void

Tag the given DatagramSocket with any statistics parameters active for the current thread.

static void
tagSocket(Socket socket)

This method is deprecated.

Use tagSocket directly.

static void

Remove any statistics parameters from the given DatagramSocket.

static void

This method is deprecated.

Use untagSocket directly.

Public methods

clearThreadStatsTag

public static void clearThreadStatsTag()

Clear active tag used when accounting Socket traffic originating from the current thread.

getThreadStatsTag

public static int getThreadStatsTag()

Get the active tag used when accounting Socket traffic originating from the current thread. Only one active tag per thread is supported. tagSocket.

incrementOperationCount

public static void incrementOperationCount(int operationCount)

Increment count of network operations performed under the accounting tag currently active on the calling thread. This can be used to derive bytes-per-operation.

Parameters
int operationCount

Number of operations to increment count by.

incrementOperationCount

public static void incrementOperationCount(int tag, int operationCount)

Increment count of network operations performed under the given accounting tag. This can be used to derive bytes-per-operation.

Parameters
int tag

Accounting tag used in setThreadStatsTag.

int operationCount

Number of operations to increment count by.

setThreadStatsTag

public static void setThreadStatsTag(int tag)

Set active tag to use when accounting Socket traffic originating from the current thread. Only one active tag per thread is supported.

Changes only take effect during subsequent calls to tagSocket.

Tags between 0xFFFFFF00 and 0xFFFFFFFF are reserved and used internally by system services like DownloadManager when performing traffic on behalf of an application.

tagDatagramSocket

public static void tagDatagramSocket(@NonNull DatagramSocket socket)

Tag the given DatagramSocket with any statistics parameters active for the current thread. Subsequent calls always replace any existing parameters. When finished, call untagDatagramSocket to remove statistics parameters.

Throws
java.net.SocketException java.net.SocketException

tagSocket

public static void tagSocket(Socket socket)

Tag the given Socket with any statistics parameters active for the current thread. Subsequent calls always replace any existing parameters. When finished, call untagSocket to remove statistics parameters.

Throws
java.net.SocketException java.net.SocketException

untagDatagramSocket

public static void untagDatagramSocket(@NonNull DatagramSocket socket)

Remove any statistics parameters from the given DatagramSocket.

Throws
java.net.SocketException java.net.SocketException

untagSocket

public static void untagSocket(Socket socket)

Remove any statistics parameters from the given Socket.

Throws
java.net.SocketException java.net.SocketException