only show app's traffic stats
This commit is contained in:
@@ -119,8 +119,8 @@ class ShadowsocksService extends Service {
|
|||||||
private var mStopForegroundArgs = new Array[AnyRef](1)
|
private var mStopForegroundArgs = new Array[AnyRef](1)
|
||||||
|
|
||||||
private var state = State.INIT
|
private var state = State.INIT
|
||||||
private var last = new TrafficStat(TrafficStats.getTotalTxBytes,
|
private var last = new TrafficStat(TrafficStats.getUidTxBytes(getApplicationInfo.uid),
|
||||||
TrafficStats.getTotalRxBytes, java.lang.System.currentTimeMillis())
|
TrafficStats.getUidRxBytes(getApplicationInfo.uid), java.lang.System.currentTimeMillis())
|
||||||
private var lastTxRate = 0
|
private var lastTxRate = 0
|
||||||
private var lastRxRate = 0
|
private var lastRxRate = 0
|
||||||
private val timer = new Timer(true)
|
private val timer = new Timer(true)
|
||||||
@@ -408,8 +408,8 @@ class ShadowsocksService extends Service {
|
|||||||
// initialize timer
|
// initialize timer
|
||||||
val task = new TimerTask {
|
val task = new TimerTask {
|
||||||
def run() {
|
def run() {
|
||||||
val now = new TrafficStat(TrafficStats.getTotalTxBytes,
|
val now = new TrafficStat(TrafficStats.getUidTxBytes(getApplicationInfo.uid),
|
||||||
TrafficStats.getTotalRxBytes, java.lang.System.currentTimeMillis())
|
TrafficStats.getUidRxBytes(getApplicationInfo.uid), java.lang.System.currentTimeMillis())
|
||||||
val txRate = ((now.tx - last.tx) / 1024 / TIMER_INTERVAL).toInt
|
val txRate = ((now.tx - last.tx) / 1024 / TIMER_INTERVAL).toInt
|
||||||
val rxRate = ((now.rx - last.rx) / 1024 / TIMER_INTERVAL).toInt
|
val rxRate = ((now.rx - last.rx) / 1024 / TIMER_INTERVAL).toInt
|
||||||
last = now
|
last = now
|
||||||
|
|||||||
Reference in New Issue
Block a user