TrafficStatsCompat

Added in 1.1.0

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

Added in 1.1.0
Deprecated in 1.1.0
public static void clearThreadStatsTag()

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

getThreadStatsTag

Added in 1.1.0
Deprecated in 1.1.0
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

Added in 1.1.0
Deprecated in 1.1.0
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

Added in 1.1.0
Deprecated in 1.1.0
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

Added in 1.1.0
Deprecated in 1.1.0
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

Added in 1.1.0
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.

tagSocket

Added in 1.1.0
Deprecated in 1.1.0
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.

untagDatagramSocket

Added in 1.1.0
public static void untagDatagramSocket(@NonNull DatagramSocket socket)

Remove any statistics parameters from the given DatagramSocket.

untagSocket

Added in 1.1.0
Deprecated in 1.1.0
public static void untagSocket(Socket socket)

Remove any statistics parameters from the given Socket.