List of usage examples for android.net TrafficStats getUidUdpTxPackets
@Deprecated public static long getUidUdpTxPackets(int uid)
From source file:fr.inria.ucn.collectors.AppDataUsageCollector.java
@SuppressWarnings("deprecation") @SuppressLint("NewApi") private JSONObject getProcInfo(Context c, int uid) throws JSONException { // uid + related package list JSONObject pinfo = new JSONObject(); pinfo.put("uid", uid); pinfo.put("packages", Helpers.getPackagesForUid(c, uid)); // simple TCP stats JSONObject tcp = new JSONObject(); tcp.put("send", getSysLongValue(PROC_UID_STAT + "/" + uid + "/tcp_snd")); tcp.put("recv", getSysLongValue(PROC_UID_STAT + "/" + uid + "/tcp_rcv")); pinfo.put("proc_uid_stat_tcp", tcp); // complete traffic stats (may not be available) JSONObject tstat = new JSONObject(); tstat.put("uid_rx_bytes", TrafficStats.getUidRxBytes(uid)); tstat.put("uid_tx_bytes", TrafficStats.getUidTxBytes(uid)); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB_MR1) { tstat.put("uid_rx_pkts", TrafficStats.getUidRxPackets(uid)); tstat.put("uid_tx_pkts", TrafficStats.getUidTxPackets(uid)); tstat.put("uid_tcp_rx_pkts", TrafficStats.getUidTcpRxSegments(uid)); tstat.put("uid_tcp_tx_pkts", TrafficStats.getUidTcpTxSegments(uid)); tstat.put("uid_udp_rx_pkts", TrafficStats.getUidUdpRxPackets(uid)); tstat.put("uid_udp_tx_pkts", TrafficStats.getUidUdpTxPackets(uid)); tstat.put("uid_udp_rx_bytes", TrafficStats.getUidUdpRxBytes(uid)); tstat.put("uid_udp_tx_bytes", TrafficStats.getUidUdpTxBytes(uid)); tstat.put("uid_tcp_rx_bytes", TrafficStats.getUidTcpRxBytes(uid)); tstat.put("uid_tcp_tx_bytes", TrafficStats.getUidTcpTxBytes(uid)); }/*from ww w . j ava 2 s. com*/ pinfo.put("android_traffic_stats", tstat); return pinfo; }