From 72e3014ee608721b9a6a6d8566d82c439d9cb6bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Tue, 10 Dec 2024 10:12:30 +0800 Subject: [PATCH] Add workaround for golang/go#68760 --- .../sfa/bg/DefaultNetworkMonitor.kt | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/nekohasekai/sfa/bg/DefaultNetworkMonitor.kt b/app/src/main/java/io/nekohasekai/sfa/bg/DefaultNetworkMonitor.kt index 3d116b8..7ca51e4 100644 --- a/app/src/main/java/io/nekohasekai/sfa/bg/DefaultNetworkMonitor.kt +++ b/app/src/main/java/io/nekohasekai/sfa/bg/DefaultNetworkMonitor.kt @@ -4,6 +4,10 @@ import android.net.Network import android.os.Build import io.nekohasekai.libbox.InterfaceUpdateListener import io.nekohasekai.sfa.Application +import io.nekohasekai.sfa.BuildConfig +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch import java.net.NetworkInterface object DefaultNetworkMonitor { @@ -55,12 +59,25 @@ object DefaultNetworkMonitor { Thread.sleep(100) continue } - listener.updateDefaultInterface(interfaceName, interfaceIndex) + // TODO: remove launch after fixed + // https://github.com/golang/go/issues/68760 + if (BuildConfig.DEBUG) { + GlobalScope.launch(Dispatchers.IO) { + listener.updateDefaultInterface(interfaceName, interfaceIndex) + } + } else { + listener.updateDefaultInterface(interfaceName, interfaceIndex) + } } } else { - listener.updateDefaultInterface("", -1) + if (BuildConfig.DEBUG) { + GlobalScope.launch(Dispatchers.IO) { + listener.updateDefaultInterface("", -1) + } + } else { + listener.updateDefaultInterface("", -1) + } } } - } \ No newline at end of file