From b84936e0489faf5c6abc70001c3c6ff5226e1ede Mon Sep 17 00:00:00 2001 From: Max Lv Date: Sat, 22 Jun 2013 13:20:49 +0800 Subject: [PATCH] fix a FC --- .../com/github/shadowsocks/ShadowsocksService.scala | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/shadowsocks/ShadowsocksService.scala b/src/main/scala/com/github/shadowsocks/ShadowsocksService.scala index 1eb65def..4a5f030d 100644 --- a/src/main/scala/com/github/shadowsocks/ShadowsocksService.scala +++ b/src/main/scala/com/github/shadowsocks/ShadowsocksService.scala @@ -119,8 +119,7 @@ class ShadowsocksService extends Service { private var mStopForegroundArgs = new Array[AnyRef](1) private var state = State.INIT - private var last = new TrafficStat(TrafficStats.getUidTxBytes(getApplicationInfo.uid), - TrafficStats.getUidRxBytes(getApplicationInfo.uid), java.lang.System.currentTimeMillis()) + private var last: TrafficStat = null private var lastTxRate = 0 private var lastRxRate = 0 private val timer = new Timer(true) @@ -379,10 +378,10 @@ class ShadowsocksService extends Service { mStopForeground = getClass.getMethod("stopForeground", mStopForegroundSignature: _*) } catch { case e: NoSuchMethodException => { - mStartForeground = ({ + mStartForeground = { mStopForeground = null mStopForeground - }) + } } } try { @@ -425,6 +424,8 @@ class ShadowsocksService extends Service { } } } + last = new TrafficStat(TrafficStats.getUidTxBytes(getApplicationInfo.uid), + TrafficStats.getUidRxBytes(getApplicationInfo.uid), java.lang.System.currentTimeMillis()) timer.schedule(task, TIMER_INTERVAL*1000, TIMER_INTERVAL*1000) }