TrafficStatsCompat

class TrafficStatsCompat
kotlin.Any
   ↳ androidx.core.net.TrafficStatsCompat

Helper for accessing features in TrafficStats.

Summary

Public methods
static Unit

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

static Int

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

static Unit
incrementOperationCount(operationCount: Int)

Increment count of network operations performed under the accounting tag currently active on the calling thread.

static Unit
incrementOperationCount(tag: Int, operationCount: Int)

Increment count of network operations performed under the given accounting tag.

static Unit

Set active tag to use when accounting Socket traffic originating from the current thread.

static Unit
tagSocket(socket: Socket!)

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

static Unit
untagSocket(socket: Socket!)

Remove any statistics parameters from the given Socket.

static Unit

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

static Unit

Remove any statistics parameters from the given DatagramSocket.

Public methods

clearThreadStatsTag

static fun clearThreadStatsTag(): Unit

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

getThreadStatsTag

static fun getThreadStatsTag(): Int

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

incrementOperationCount

static fun incrementOperationCount(operationCount: Int): Unit

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
operationCount Int: Number of operations to increment count by.

incrementOperationCount

static fun incrementOperationCount(tag: Int, operationCount: Int): Unit

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

Parameters
tag Int: Accounting tag used in setThreadStatsTag(int).
operationCount Int: Number of operations to increment count by.

setThreadStatsTag

static fun setThreadStatsTag(tag: Int): Unit

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(Socket).

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

tagSocket

static fun tagSocket(socket: Socket!): Unit

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

untagSocket

static fun untagSocket(socket: Socket!): Unit

Remove any statistics parameters from the given Socket.

tagDatagramSocket

static fun tagDatagramSocket(@NonNull socket: DatagramSocket): Unit

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

untagDatagramSocket

static fun untagDatagramSocket(@NonNull socket: DatagramSocket): Unit

Remove any statistics parameters from the given DatagramSocket.