The Android Developer Challenge is back! Submit your idea before December 2.

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

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

static Unit
tagSocket(socket: Socket!)

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

static Unit

Remove any statistics parameters from the given DatagramSocket.

static Unit
untagSocket(socket: Socket!)

Remove any statistics parameters from the given Socket.

Public methods

clearThreadStatsTag

static fun clearThreadStatsTag(): Unit

Deprecated: Use TrafficStats#clearThreadStatsTag() directly.

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

getThreadStatsTag

static fun getThreadStatsTag(): Int

Deprecated: Use TrafficStats#getThreadStatsTag() directly.

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

Deprecated: Use TrafficStats#incrementOperationCount(int) directly.

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

Deprecated: Use TrafficStats#incrementOperationCount(int, int) directly.

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

Deprecated: Use TrafficStats#setThreadStatsTag(int) directly.

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.

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.

tagSocket

static fun tagSocket(socket: Socket!): Unit

Deprecated: Use TrafficStats#tagSocket(Socket) directly.

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.

untagDatagramSocket

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

Remove any statistics parameters from the given DatagramSocket.

untagSocket

static fun untagSocket(socket: Socket!): Unit

Deprecated: Use TrafficStats#untagSocket(Socket) directly.

Remove any statistics parameters from the given Socket.