public class DataFlowStatistics extends Object
This class provides interfaces to query overall traffic statistics and traffic statistics of the specified cellular network, application, and NIC.
| 构造器 | 说明 |
|---|---|
DataFlowStatistics() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
static void |
addOperation(int operations) |
Adds a specified number of networks for the
DataFlowStatistics object of this thread. |
static void |
addOperation(int tag,
int operations) |
Adds a specified number of networks for a given
DataFlowStatistics tag. |
static void |
clearDataFlowTag() |
Clears the
DataFlowStatistics tag of this thread. |
static long |
getAllRxBytes() |
Queries the data traffic (including all TCP and UDP data packets) received through all NICs.
|
static long |
getAllTxBytes() |
Queries the data traffic (including all TCP and UDP data packets) sent through all NICs.
|
static long |
getCellularRxBytes() |
Queries the data traffic (including all TCP and UDP data packets) received through the cellular network.
|
static long |
getCellularTxBytes() |
Queries the data traffic (including all TCP and UDP data packets) sent through the cellular network.
|
static int |
getDataFlowTag() |
Obtains the
DataFlowStatistics tag of this thread. |
static long |
getIfaceRxBytes(String nic) |
Queries the data traffic (including all TCP and UDP data packets) received through a specified NIC.
|
static long |
getIfaceTxBytes(String nic) |
Queries the data traffic (including all TCP and UDP data packets) sent through a specified NIC.
|
static long |
getUidRxBytes(int uid) |
Queries the data traffic (including all TCP and UDP data packets) received by a specified application.
|
static long |
getUidTxBytes(int uid) |
Queries the data traffic (including all TCP and UDP data packets) sent by a specified application.
|
static void |
removeDatagramSocketTag(DatagramSocket socket) |
Removes a specified datagram socket from the
DataFlowStatistics tag of this thread. |
static void |
removeSocketTag(Socket socket) |
Removes a specified socket from the
DataFlowStatistics tag of this thread. |
static void |
setDataFlowTag(int tag) |
Sets a
DataFlowStatistics tag for this thread. |
static void |
setDatagramSocketTag(DatagramSocket socket) |
Sets a specified datagram socket for the
DataFlowStatistics tag of this thread. |
static void |
setSocketTag(Socket socket) |
Sets a specified socket for the
DataFlowStatistics tag of this thread. |
public static long getCellularRxBytes()
public static long getCellularTxBytes()
public static long getAllRxBytes()
public static long getAllTxBytes()
public static long getUidRxBytes(int uid)
uid - Indicates the process ID of the application.public static long getUidTxBytes(int uid)
uid - Indicates the process ID of the application.public static long getIfaceRxBytes(String nic)
nic - Indicates the NIC name.public static long getIfaceTxBytes(String nic)
nic - Indicates the NIC name.public static void clearDataFlowTag()
DataFlowStatistics tag of this thread.public static int getDataFlowTag()
DataFlowStatistics tag of this thread.DataFlowStatistics tag.public static void addOperation(int operations)
DataFlowStatistics object of this thread.operations - Indicates the number of networks to add.public static void addOperation(int tag,
int operations)
DataFlowStatistics tag.tag - Indicates the given DataFlowStatistics tag.operations - Indicates the number of networks to add.public static void setDataFlowTag(int tag)
DataFlowStatistics tag for this thread.tag - Indicates the DataFlowStatistics tag to set.public static void setDatagramSocketTag(DatagramSocket socket) throws SocketException
DataFlowStatistics tag of this thread.socket - Indicates the datagram socket to set.SocketException - Throws this exception if the setting fails.public static void setSocketTag(Socket socket) throws SocketException
DataFlowStatistics tag of this thread.socket - Indicates the socket to set.SocketException - Throws this exception if the setting fails.public static void removeDatagramSocketTag(DatagramSocket socket) throws SocketException
DataFlowStatistics tag of this thread.socket - Indicates the datagram socket to remove.SocketException - Throws this exception if the setting fails.public static void removeSocketTag(Socket socket) throws SocketException
DataFlowStatistics tag of this thread.socket - Indicates the socket to remove.SocketException - Throws this exception if the setting fails.