refine the traffic stat
This commit is contained in:
@@ -471,7 +471,11 @@ class Shadowsocks
|
||||
// initialize timer
|
||||
val task = new TimerTask {
|
||||
def run() {
|
||||
TrafficMonitor.update()
|
||||
if (state == State.CONNECTED) {
|
||||
TrafficMonitor.update()
|
||||
} else {
|
||||
TrafficMonitor.reset()
|
||||
}
|
||||
val pm = getSystemService(Context.POWER_SERVICE).asInstanceOf[PowerManager]
|
||||
if (pm.isScreenOn) {
|
||||
val trafficStat = getString(R.string.stat_summary).formatLocal(Locale.ENGLISH,
|
||||
|
||||
@@ -20,8 +20,8 @@ object TrafficMonitor {
|
||||
var rxTotal: Long = 0
|
||||
|
||||
def getTraffic(): Traffic = {
|
||||
new Traffic(TrafficStats.getUidTxBytes(uid),
|
||||
TrafficStats.getUidRxBytes(uid), System.currentTimeMillis())
|
||||
new Traffic(TrafficStats.getTotalTxBytes - TrafficStats.getUidTxBytes(uid),
|
||||
TrafficStats.getTotalRxBytes - TrafficStats.getUidRxBytes(uid), System.currentTimeMillis())
|
||||
}
|
||||
|
||||
def formatTraffic(n: Long): String = {
|
||||
|
||||
Reference in New Issue
Block a user