diff --git a/project/Build.scala b/project/Build.scala index f2e6a431..d74bcc5a 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -5,8 +5,8 @@ import sbtandroid._ import sbtandroid.AndroidKeys._ object App { - val version = "1.7.1" - val versionCode = 38 + val version = "1.7.2" + val versionCode = 39 } object General { diff --git a/src/main/scala/com/github/shadowsocks/ShadowsocksService.scala b/src/main/scala/com/github/shadowsocks/ShadowsocksService.scala index d1bc282c..3271461e 100644 --- a/src/main/scala/com/github/shadowsocks/ShadowsocksService.scala +++ b/src/main/scala/com/github/shadowsocks/ShadowsocksService.scala @@ -197,6 +197,7 @@ class ShadowsocksService extends Service { // initialize timer val task = new TimerTask { def run() { + val pm = getSystemService(Context.POWER_SERVICE).asInstanceOf[PowerManager] val now = new TrafficStat(TrafficStats.getTotalTxBytes, TrafficStats.getTotalRxBytes, java.lang.System.currentTimeMillis()) val txRate = ((now.tx - last.tx) / 1024 / TIMER_INTERVAL).toInt @@ -208,7 +209,7 @@ class ShadowsocksService extends Service { lastTxRate = txRate lastRxRate = rxRate } - if (state == State.CONNECTED) { + if (pm.isScreenOn && state == State.CONNECTED) { notifyForegroundAlert(getString(R.string.forward_success), getString(R.string.service_status).format(txRate, rxRate), txRate + rxRate) }