From a24e18d7ce0e7c585b1338d621030b1481eb2c62 Mon Sep 17 00:00:00 2001 From: andrewleo Date: Mon, 7 Sep 2015 11:51:42 +0800 Subject: [PATCH] Fixed: #46 remove invalid code in TrafficInfo.java --- .../netease/qa/emmagee/utils/TrafficInfo.java | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/src/com/netease/qa/emmagee/utils/TrafficInfo.java b/src/com/netease/qa/emmagee/utils/TrafficInfo.java index ee33bfa..4d597af 100644 --- a/src/com/netease/qa/emmagee/utils/TrafficInfo.java +++ b/src/com/netease/qa/emmagee/utils/TrafficInfo.java @@ -46,9 +46,7 @@ public class TrafficInfo { * @return total traffic include received and send traffic */ public long getTrafficInfo() { - Log.i(LOG_TAG, "get traffic information"); - Log.d(LOG_TAG, "uid===" + uid); long rcvTraffic = UNSUPPORTED; long sndTraffic = UNSUPPORTED; @@ -58,40 +56,6 @@ public class TrafficInfo { rcvTraffic = TrafficStats.getUidRxBytes(Integer.parseInt(uid)); sndTraffic = TrafficStats.getUidTxBytes(Integer.parseInt(uid)); - if (rcvTraffic == UNSUPPORTED || sndTraffic == UNSUPPORTED) { - return UNSUPPORTED; - } - - RandomAccessFile rafRcv = null, rafSnd = null; - String rcvPath = "/proc/uid_stat/" + uid + "/tcp_rcv"; - String sndPath = "/proc/uid_stat/" + uid + "/tcp_snd"; - - try { - rafRcv = new RandomAccessFile(rcvPath, "r"); - rafSnd = new RandomAccessFile(sndPath, "r"); - rcvTraffic = Long.parseLong(rafRcv.readLine()); - sndTraffic = Long.parseLong(rafSnd.readLine()); - } catch (FileNotFoundException e) { - rcvTraffic = UNSUPPORTED; - sndTraffic = UNSUPPORTED; - } catch (NumberFormatException e) { - Log.e(LOG_TAG, "NumberFormatException: " + e.getMessage()); - e.printStackTrace(); - } catch (IOException e) { - Log.e(LOG_TAG, "IOException: " + e.getMessage()); - e.printStackTrace(); - } finally { - try { - if (rafRcv != null) { - rafRcv.close(); - } - if (rafSnd != null) - rafSnd.close(); - } catch (IOException e) { - Log.w(LOG_TAG, "Close randomAccessFile exception: " + e.getMessage()); - } - } - if (rcvTraffic == UNSUPPORTED || sndTraffic == UNSUPPORTED) { return UNSUPPORTED; } else -- GitLab