Reduce battery usage - prevent unnecessary notification updates

This commit is contained in:
Mygod
2015-12-26 20:00:12 +08:00
parent ef162cd47e
commit 8dcfd5a8c5
2 changed files with 34 additions and 9 deletions
@@ -86,8 +86,7 @@ trait BaseService extends Service {
if (callbackCount == 0 && timer == null) {
val task = new TimerTask {
def run {
TrafficMonitor.updateRate()
updateTrafficRate()
if (TrafficMonitor.updateRate()) updateTrafficRate()
}
}
timer = new Timer(true)
@@ -95,6 +94,9 @@ trait BaseService extends Service {
}
callbacks.register(cb)
callbackCount += 1
TrafficMonitor.updateRate()
cb.trafficUpdated(TrafficMonitor.getTxRate, TrafficMonitor.getRxRate,
TrafficMonitor.getTxTotal, TrafficMonitor.getRxTotal)
}
}