IT. Expert System.

Android Reference

TrafficStats


android.net

Class TrafficStats



  • public class TrafficStats
    extends Object
    Class that provides network traffic statistics. These statistics include bytes transmitted and received and network packets transmitted and received, over all interfaces, over the mobile interface, and on a per-UID basis.

    These statistics may not be available on all platforms. If the statistics are not supported by this device, UNSUPPORTED will be returned.

    • Constructor Detail

      • TrafficStats

        public TrafficStats()
    • Method Detail

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

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

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

        public static void clearThreadStatsTag()
      • setThreadStatsUid

        public static void setThreadStatsUid(int uid)
        Set specific UID to use when accounting Socket traffic originating from the current thread. Designed for use when performing an operation on behalf of another application.

        Changes only take effect during subsequent calls to tagSocket(Socket).

        To take effect, caller must hold android.Manifest.permission#UPDATE_DEVICE_STATS permission.

      • clearThreadStatsUid

        public static void clearThreadStatsUid()
      • startDataProfiling

        public static void startDataProfiling(Context context)
        Start profiling data usage for current UID. Only one profiling session can be active at a time.
      • 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:
        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:
        tag - Accounting tag used in setThreadStatsTag(int).
        operationCount - Number of operations to increment count by.
      • closeQuietly

        public static void closeQuietly(INetworkStatsSession session)
      • getMobileTxPackets

        public static long getMobileTxPackets()
        Get the total number of packets transmitted through the mobile interface.
        Returns:
        number of packets. If the statistics are not supported by this device, UNSUPPORTED will be returned.
      • getMobileRxPackets

        public static long getMobileRxPackets()
        Get the total number of packets received through the mobile interface.
        Returns:
        number of packets. If the statistics are not supported by this device, UNSUPPORTED will be returned.
      • getMobileTxBytes

        public static long getMobileTxBytes()
        Get the total number of bytes transmitted through the mobile interface.
        Returns:
        number of bytes. If the statistics are not supported by this device, UNSUPPORTED will be returned.
      • getMobileRxBytes

        public static long getMobileRxBytes()
        Get the total number of bytes received through the mobile interface.
        Returns:
        number of bytes. If the statistics are not supported by this device, UNSUPPORTED will be returned.
      • getTxPackets

        public static long getTxPackets(String iface)
        Get the total number of packets transmitted through the specified interface.
        Returns:
        number of packets. If the statistics are not supported by this interface, UNSUPPORTED will be returned.
      • getRxPackets

        public static long getRxPackets(String iface)
        Get the total number of packets received through the specified interface.
        Returns:
        number of packets. If the statistics are not supported by this interface, UNSUPPORTED will be returned.
      • getTxBytes

        public static long getTxBytes(String iface)
        Get the total number of bytes transmitted through the specified interface.
        Returns:
        number of bytes. If the statistics are not supported by this interface, UNSUPPORTED will be returned.
      • getRxBytes

        public static long getRxBytes(String iface)
        Get the total number of bytes received through the specified interface.
        Returns:
        number of bytes. If the statistics are not supported by this interface, UNSUPPORTED will be returned.
      • getTotalTxPackets

        public static long getTotalTxPackets()
        Get the total number of packets sent through all network interfaces.
        Returns:
        the number of packets. If the statistics are not supported by this device, UNSUPPORTED will be returned.
      • getTotalRxPackets

        public static long getTotalRxPackets()
        Get the total number of packets received through all network interfaces.
        Returns:
        number of packets. If the statistics are not supported by this device, UNSUPPORTED will be returned.
      • getTotalTxBytes

        public static long getTotalTxBytes()
        Get the total number of bytes sent through all network interfaces.
        Returns:
        number of bytes. If the statistics are not supported by this device, UNSUPPORTED will be returned.
      • getTotalRxBytes

        public static long getTotalRxBytes()
        Get the total number of bytes received through all network interfaces.
        Returns:
        number of bytes. If the statistics are not supported by this device, UNSUPPORTED will be returned.
      • getUidTxBytes

        public static long getUidTxBytes(int uid)
        Get the number of bytes sent through the network for this UID. The statistics are across all interfaces. Process.myUid().
        Parameters:
        uid - The UID of the process to examine.
        Returns:
        number of bytes. If the statistics are not supported by this device, UNSUPPORTED will be returned.
      • getUidRxBytes

        public static long getUidRxBytes(int uid)
        Get the number of bytes received through the network for this UID. The statistics are across all interfaces. Process.myUid().
        Parameters:
        uid - The UID of the process to examine.
        Returns:
        number of bytes
      • getUidTxPackets

        public static long getUidTxPackets(int uid)
        Get the number of packets (TCP segments + UDP) sent through the network for this UID. The statistics are across all interfaces. Process.myUid().
        Parameters:
        uid - The UID of the process to examine.
        Returns:
        number of packets. If the statistics are not supported by this device, UNSUPPORTED will be returned.
      • getUidRxPackets

        public static long getUidRxPackets(int uid)
        Get the number of packets (TCP segments + UDP) received through the network for this UID. The statistics are across all interfaces. Process.myUid().
        Parameters:
        uid - The UID of the process to examine.
        Returns:
        number of packets
      • getUidTcpTxBytes

        public static long getUidTcpTxBytes(int uid)
        Get the number of TCP payload bytes sent for this UID. This total does not include protocol and control overheads at the transport and the lower layers of the networking stack. The statistics are across all interfaces. Process.myUid().
        Parameters:
        uid - The UID of the process to examine.
        Returns:
        number of bytes. If the statistics are not supported by this device, UNSUPPORTED will be returned.
      • getUidTcpRxBytes

        public static long getUidTcpRxBytes(int uid)
        Get the number of TCP payload bytes received for this UID. This total does not include protocol and control overheads at the transport and the lower layers of the networking stack. The statistics are across all interfaces. Process.myUid().
        Parameters:
        uid - The UID of the process to examine.
        Returns:
        number of bytes. If the statistics are not supported by this device, UNSUPPORTED will be returned.
      • getUidUdpTxBytes

        public static long getUidUdpTxBytes(int uid)
        Get the number of UDP payload bytes sent for this UID. This total does not include protocol and control overheads at the transport and the lower layers of the networking stack. The statistics are across all interfaces. Process.myUid().
        Parameters:
        uid - The UID of the process to examine.
        Returns:
        number of bytes. If the statistics are not supported by this device, UNSUPPORTED will be returned.
      • getUidUdpRxBytes

        public static long getUidUdpRxBytes(int uid)
        Get the number of UDP payload bytes received for this UID. This total does not include protocol and control overheads at the transport and the lower layers of the networking stack. The statistics are across all interfaces. Process.myUid().
        Parameters:
        uid - The UID of the process to examine.
        Returns:
        number of bytes. If the statistics are not supported by this device, UNSUPPORTED will be returned.
      • getUidTcpTxSegments

        public static long getUidTcpTxSegments(int uid)
        Get the number of TCP segments sent for this UID. Does not include TCP control packets (SYN/ACKs/FIN/..). The statistics are across all interfaces. Process.myUid().
        Parameters:
        uid - The UID of the process to examine.
        Returns:
        number of TCP segments. If the statistics are not supported by this device, UNSUPPORTED will be returned.
      • getUidTcpRxSegments

        public static long getUidTcpRxSegments(int uid)
        Get the number of TCP segments received for this UID. Does not include TCP control packets (SYN/ACKs/FIN/..). The statistics are across all interfaces. Process.myUid().
        Parameters:
        uid - The UID of the process to examine.
        Returns:
        number of TCP segments. If the statistics are not supported by this device, UNSUPPORTED will be returned.
      • getUidUdpTxPackets

        public static long getUidUdpTxPackets(int uid)
        Get the number of UDP packets sent for this UID. Includes DNS requests. The statistics are across all interfaces. Process.myUid().
        Parameters:
        uid - The UID of the process to examine.
        Returns:
        number of packets. If the statistics are not supported by this device, UNSUPPORTED will be returned.
      • getUidUdpRxPackets

        public static long getUidUdpRxPackets(int uid)
        Get the number of UDP packets received for this UID. Includes DNS responses. The statistics are across all interfaces. Process.myUid().
        Parameters:
        uid - The UID of the process to examine.
        Returns:
        number of packets. If the statistics are not supported by this device, UNSUPPORTED will be returned.


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 346 / 158856260. Delta: 0.03658 с