Fix tethering stability issues

This commit is contained in:
Mygod
2018-01-21 03:07:26 -08:00
parent e2455cdd84
commit 7f93b1e62b
7 changed files with 105 additions and 63 deletions

View File

@@ -20,7 +20,10 @@ class IpNeighbourMonitor private constructor() {
monitor = IpNeighbourMonitor()
instance = monitor
monitor.flush()
} else synchronized(monitor.neighbours) { callback.onIpNeighbourAvailable(monitor.neighbours) }
} else {
synchronized(monitor.neighbours) { callback.onIpNeighbourAvailable(monitor.neighbours) }
callback.postIpNeighbourAvailable()
}
}
fun unregisterCallback(callback: Callback) {
if (!callbacks.remove(callback) || callbacks.isNotEmpty()) return
@@ -43,7 +46,7 @@ class IpNeighbourMonitor private constructor() {
interface Callback {
fun onIpNeighbourAvailable(neighbours: Map<String, IpNeighbour>)
fun postIpNeighbourAvailable() { }
fun postIpNeighbourAvailable()
}
private val handler = Handler()