mirror of
https://github.com/wgtunnel/android.git
synced 2026-07-03 14:07:49 +02:00
fix: network monitoring bug
This commit is contained in:
+8
-3
@@ -61,6 +61,9 @@ class AutoTunnelService : LifecycleService() {
|
||||
|
||||
private val autoTunnelStateFlow = MutableStateFlow(defaultState)
|
||||
|
||||
private var autoTunnelJob: Job? = null
|
||||
private var permissionsJob: Job? = null
|
||||
|
||||
class LocalBinder(service: AutoTunnelService) : Binder() {
|
||||
private val serviceRef = WeakReference(service)
|
||||
|
||||
@@ -89,8 +92,10 @@ class AutoTunnelService : LifecycleService() {
|
||||
|
||||
fun start() {
|
||||
launchWatcherNotification()
|
||||
startAutoTunnelStateJob()
|
||||
startLocationPermissionsNotificationJob()
|
||||
autoTunnelJob?.cancel()
|
||||
autoTunnelJob = startAutoTunnelStateJob()
|
||||
permissionsJob?.cancel()
|
||||
permissionsJob = startLocationPermissionsNotificationJob()
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
@@ -130,7 +135,7 @@ class AutoTunnelService : LifecycleService() {
|
||||
)
|
||||
}
|
||||
|
||||
private fun startAutoTunnelStateJob() =
|
||||
private fun startAutoTunnelStateJob(): Job =
|
||||
lifecycleScope.launch(ioDispatcher) {
|
||||
val networkFlow =
|
||||
debouncedConnectivityStateFlow
|
||||
|
||||
+2
-2
@@ -59,8 +59,8 @@ data class AutoTunnelState(
|
||||
return DoNothing
|
||||
}
|
||||
|
||||
private val ethernetActive: Boolean = networkState.activeNetwork is ActiveNetwork.Cellular
|
||||
private val mobileDataActive: Boolean = networkState.activeNetwork is ActiveNetwork.Ethernet
|
||||
private val ethernetActive: Boolean = networkState.activeNetwork is ActiveNetwork.Ethernet
|
||||
private val mobileDataActive: Boolean = networkState.activeNetwork is ActiveNetwork.Cellular
|
||||
private val wifiActive: Boolean = networkState.activeNetwork is ActiveNetwork.Wifi
|
||||
|
||||
private fun preferredMobileDataTunnel(): TunnelConfig? {
|
||||
|
||||
Reference in New Issue
Block a user