-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrafficStatsGuard.java
37 lines (33 loc) · 1.24 KB
/
TrafficStatsGuard.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package edu.nctu.wirelab.testsignalv1;
import android.net.TrafficStats;
import android.os.Handler;
import android.util.Log;
public class TrafficStatsGuard extends TrafficStats {
private final String TagName = "TrafficStatsGuard";
private String TrafficMsg;
private long initRxBytes, initTxBytes;
Handler TrafficHandler;
public TrafficStatsGuard(){
super();
TrafficHandler = new Handler();
}
public void TaskStart(){
TrafficHandler.post(SenseTrafficRunnable);
initRxBytes = getTotalRxBytes();
initTxBytes = getTotalTxBytes();
}
public void TrafficStatsGuardFinish(){
TrafficHandler.removeCallbacks(SenseTrafficRunnable);
}
private Runnable SenseTrafficRunnable = new Runnable() {
public void run() {
TrafficMsg = "getMobileRxBytes: "+getMobileRxBytes()+
"\ngetMobileTxBytes: "+getMobileTxBytes()+
"\ngetTotalRxBytes: "+getTotalRxBytes()+
"\ngetTotalTxBytes: "+getTotalTxBytes();
//Log.d(TagName, TrafficMsg);
ShowMsg.NoticeChange(ShowMsg.TrafficInfo, TrafficMsg);
TrafficHandler.postDelayed(SenseTrafficRunnable, MainActivity.FlashInterval);
}
};
}