Commit 3f8acd85 authored by Mygod's avatar Mygod

Optimize timer code.

Apparently onStop will be executed when the screen goes off.
parent 14414c64
...@@ -475,8 +475,6 @@ class Shadowsocks ...@@ -475,8 +475,6 @@ class Shadowsocks
} else { } else {
TrafficMonitor.reset() TrafficMonitor.reset()
} }
val pm = getSystemService(Context.POWER_SERVICE).asInstanceOf[PowerManager]
if (pm.isScreenOn) {
val trafficStat = getString(R.string.stat_summary).formatLocal(Locale.ENGLISH, val trafficStat = getString(R.string.stat_summary).formatLocal(Locale.ENGLISH,
TrafficMonitor.getTxRate, TrafficMonitor.getRxRate, TrafficMonitor.getTxRate, TrafficMonitor.getRxRate,
TrafficMonitor.getTxTotal, TrafficMonitor.getRxTotal) TrafficMonitor.getTxTotal, TrafficMonitor.getRxTotal)
...@@ -485,7 +483,6 @@ class Shadowsocks ...@@ -485,7 +483,6 @@ class Shadowsocks
}) })
} }
} }
}
timer = new Timer(true) timer = new Timer(true)
timer.schedule(task, TIMER_INTERVAL * 1000, TIMER_INTERVAL * 1000) timer.schedule(task, TIMER_INTERVAL * 1000, TIMER_INTERVAL * 1000)
} }
......
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