avoid off-screen notification

This commit is contained in:
Max Lv
2013-07-08 13:36:22 +08:00
parent 46c1a66e42
commit 7b67e27002
2 changed files with 4 additions and 3 deletions
+2 -2
View File
@@ -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)
}