From d7ff8770a7eeab289be56c718acea45c36d68a92 Mon Sep 17 00:00:00 2001 From: Mygod Date: Sun, 15 May 2022 17:08:01 -0400 Subject: [PATCH] Fix a race condition --- .../java/be/mygod/vpnhotspot/IpNeighbourMonitoringService.kt | 2 +- mobile/src/main/java/be/mygod/vpnhotspot/TetheringService.kt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/IpNeighbourMonitoringService.kt b/mobile/src/main/java/be/mygod/vpnhotspot/IpNeighbourMonitoringService.kt index 9a25e821..c93bd864 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/IpNeighbourMonitoringService.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/IpNeighbourMonitoringService.kt @@ -15,7 +15,7 @@ abstract class IpNeighbourMonitoringService : Service(), IpNeighbourMonitor.Call this.neighbours = neighbours updateNotification() } - protected fun updateNotification() { + protected open fun updateNotification() { val sizeLookup = neighbours.groupBy { it.dev }.mapValues { (_, neighbours) -> neighbours .filter { it.ip is Inet4Address && it.state == IpNeighbour.State.VALID } diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/TetheringService.kt b/mobile/src/main/java/be/mygod/vpnhotspot/TetheringService.kt index 28951a4d..7fab57e1 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/TetheringService.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/TetheringService.kt @@ -155,4 +155,8 @@ class TetheringService : IpNeighbourMonitoringService(), TetheringManager.Tether callbackRegistered = false } } + + override fun updateNotification() { + launch { super.updateNotification() } + } }