Skip to content

Commit

Permalink
Fixed: NetEase#46 remove invalid code in TrafficInfo.java
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewleo committed Sep 7, 2015
1 parent 7cbf2b8 commit a24e18d
Showing 1 changed file with 0 additions and 36 deletions.
36 changes: 0 additions & 36 deletions src/com/netease/qa/emmagee/utils/TrafficInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ public TrafficInfo(String uid) {
* @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;
Expand All @@ -58,40 +56,6 @@ public long getTrafficInfo() {
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
Expand Down

0 comments on commit a24e18d

Please sign in to comment.