Ignore lost devices in notification

This commit is contained in:
Mygod
2018-02-11 00:25:41 -08:00
parent 6a9adf328b
commit bd34491ad4

View File

@@ -100,7 +100,9 @@ class TetheringService : Service(), VpnMonitor.Callback, IpNeighbourMonitor.Call
this.neighbours = neighbours.values.toList() this.neighbours = neighbours.values.toList()
} }
override fun postIpNeighbourAvailable() { override fun postIpNeighbourAvailable() {
val sizeLookup = neighbours.groupBy { it.dev }.mapValues { (_, neighbours) -> neighbours.size } val sizeLookup = neighbours.groupBy { it.dev }.mapValues { (_, neighbours) ->
neighbours.count { it.state != IpNeighbour.State.FAILED }
}
ServiceNotification.startForeground(this, routings.keys.associate { Pair(it, sizeLookup[it] ?: 0) }) ServiceNotification.startForeground(this, routings.keys.associate { Pair(it, sizeLookup[it] ?: 0) })
} }