Commit 7b67e270 authored by Max Lv's avatar Max Lv

avoid off-screen notification

parent 46c1a66e
......@@ -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 {
......
......@@ -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)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment