From 5b4e36cd5ea71b0066a3f45f0704236abfd3f8e8 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Sat, 22 Jun 2013 13:09:37 +0800 Subject: [PATCH] only show app's traffic stats --- .../scala/com/github/shadowsocks/ShadowsocksService.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/shadowsocks/ShadowsocksService.scala b/src/main/scala/com/github/shadowsocks/ShadowsocksService.scala index 4e153958..1eb65def 100644 --- a/src/main/scala/com/github/shadowsocks/ShadowsocksService.scala +++ b/src/main/scala/com/github/shadowsocks/ShadowsocksService.scala @@ -119,8 +119,8 @@ class ShadowsocksService extends Service { private var mStopForegroundArgs = new Array[AnyRef](1) private var state = State.INIT - private var last = new TrafficStat(TrafficStats.getTotalTxBytes, - TrafficStats.getTotalRxBytes, java.lang.System.currentTimeMillis()) + private var last = new TrafficStat(TrafficStats.getUidTxBytes(getApplicationInfo.uid), + TrafficStats.getUidRxBytes(getApplicationInfo.uid), java.lang.System.currentTimeMillis()) private var lastTxRate = 0 private var lastRxRate = 0 private val timer = new Timer(true) @@ -408,8 +408,8 @@ class ShadowsocksService extends Service { // initialize timer val task = new TimerTask { def run() { - val now = new TrafficStat(TrafficStats.getTotalTxBytes, - TrafficStats.getTotalRxBytes, java.lang.System.currentTimeMillis()) + val now = new TrafficStat(TrafficStats.getUidTxBytes(getApplicationInfo.uid), + TrafficStats.getUidRxBytes(getApplicationInfo.uid), java.lang.System.currentTimeMillis()) val txRate = ((now.tx - last.tx) / 1024 / TIMER_INTERVAL).toInt val rxRate = ((now.rx - last.rx) / 1024 / TIMER_INTERVAL).toInt last = now