add TrafficMonitor to the main activity

This commit is contained in:
Max Lv
2015-11-18 14:02:29 +08:00
parent 92e72830bb
commit f0abbb7304
8 changed files with 48 additions and 6 deletions
@@ -68,6 +68,7 @@ object Key {
val profiles = "profiles"
val isNAT = "isNAT"
val route = "route"
val stat = "stat"
val isRunning = "isRunning"
val isAutoConnect = "isAutoConnect"
@@ -38,16 +38,16 @@ object TrafficMonitor {
}
}
def updateTraffic() {
def update() {
val now = getTraffic
txRate = ((now.tx - last.tx) / 1024 / (now.timestamp - last.timestamp))
rxRate = ((now.rx - last.rx) / 1024 / (now.timestamp - last.timestamp))
txRate = (now.tx - last.tx) / (now.timestamp - last.timestamp)
rxRate = (now.rx - last.rx) / (now.timestamp - last.timestamp)
txTotal += (now.tx - last.tx) / 1024
rxTotal += (now.rx - last.rx) / 1024
last = now
}
def resetTraffic() {
def reset() {
txRate = 0
rxRate = 0
txTotal = 0