FileDocCategorySizeDatePackage
TrafficStatsCompat.javaAPI DocAndroid 5.1 API6442Thu Mar 12 22:22:56 GMT 2015android.support.v4.net

TrafficStatsCompat

public class TrafficStatsCompat extends Object
Helper for accessing features in TrafficStats introduced after API level 14 in a backwards compatible fashion.

Fields Summary
private static final TrafficStatsCompatImpl
IMPL
Constructors Summary
Methods Summary
public static voidclearThreadStatsTag()
Clear active tag used when accounting {@link Socket} traffic originating from the current thread.

        if (Build.VERSION.SDK_INT >= 14) {
            IMPL = new IcsTrafficStatsCompatImpl();
        } else {
            IMPL = new BaseTrafficStatsCompatImpl();
        }
    
        IMPL.clearThreadStatsTag();
    
public static intgetThreadStatsTag()
Get the active tag used when accounting {@link Socket} traffic originating from the current thread. Only one active tag per thread is supported. {@link #tagSocket(Socket)}.

        return IMPL.getThreadStatsTag();
    
public static voidincrementOperationCount(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.

param
operationCount Number of operations to increment count by.

        IMPL.incrementOperationCount(operationCount);
    
public static voidincrementOperationCount(int tag, int operationCount)
Increment count of network operations performed under the given accounting tag. This can be used to derive bytes-per-operation.

param
tag Accounting tag used in {@link #setThreadStatsTag(int)}.
param
operationCount Number of operations to increment count by.

        IMPL.incrementOperationCount(tag, operationCount);
    
public static voidsetThreadStatsTag(int tag)
Set active tag to use when accounting {@link Socket} traffic originating from the current thread. Only one active tag per thread is supported.

Changes only take effect during subsequent calls to {@link #tagSocket(Socket)}.

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

        IMPL.setThreadStatsTag(tag);
    
public static voidtagSocket(java.net.Socket socket)
Tag the given {@link Socket} with any statistics parameters active for the current thread. Subsequent calls always replace any existing parameters. When finished, call {@link #untagSocket(Socket)} to remove statistics parameters.

see
#setThreadStatsTag(int)

        IMPL.tagSocket(socket);
    
public static voiduntagSocket(java.net.Socket socket)
Remove any statistics parameters from the given {@link Socket}.

        IMPL.untagSocket(socket);