Commit 28ee28ce authored by Mygod's avatar Mygod

Fix a race condition

parent 78413444
...@@ -106,6 +106,7 @@ object BaseService { ...@@ -106,6 +106,7 @@ object BaseService {
val t = Timer(true) val t = Timer(true)
t.schedule(object : TimerTask() { t.schedule(object : TimerTask() {
override fun run() { override fun run() {
val profile = profile ?: return
if (state == CONNECTED && TrafficMonitor.updateRate()) app.handler.post { if (state == CONNECTED && TrafficMonitor.updateRate()) app.handler.post {
if (bandwidthListeners.isNotEmpty()) { if (bandwidthListeners.isNotEmpty()) {
val txRate = TrafficMonitor.txRate val txRate = TrafficMonitor.txRate
...@@ -116,7 +117,7 @@ object BaseService { ...@@ -116,7 +117,7 @@ object BaseService {
for (i in 0 until n) try { for (i in 0 until n) try {
val item = callbacks.getBroadcastItem(i) val item = callbacks.getBroadcastItem(i)
if (bandwidthListeners.contains(item.asBinder())) if (bandwidthListeners.contains(item.asBinder()))
item.trafficUpdated(profile!!.id, txRate, rxRate, txTotal, rxTotal) item.trafficUpdated(profile.id, txRate, rxRate, txTotal, rxTotal)
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
app.track(e) app.track(e)
......
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