Skip to content

Commit 72e3014

Browse files
committed
Add workaround for golang/go#68760
1 parent 64765cc commit 72e3014

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

app/src/main/java/io/nekohasekai/sfa/bg/DefaultNetworkMonitor.kt

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import android.net.Network
44
import android.os.Build
55
import io.nekohasekai.libbox.InterfaceUpdateListener
66
import io.nekohasekai.sfa.Application
7+
import io.nekohasekai.sfa.BuildConfig
8+
import kotlinx.coroutines.Dispatchers
9+
import kotlinx.coroutines.GlobalScope
10+
import kotlinx.coroutines.launch
711
import java.net.NetworkInterface
812

913
object DefaultNetworkMonitor {
@@ -55,12 +59,25 @@ object DefaultNetworkMonitor {
5559
Thread.sleep(100)
5660
continue
5761
}
58-
listener.updateDefaultInterface(interfaceName, interfaceIndex)
62+
// TODO: remove launch after fixed
63+
// https://github.com/golang/go/issues/68760
64+
if (BuildConfig.DEBUG) {
65+
GlobalScope.launch(Dispatchers.IO) {
66+
listener.updateDefaultInterface(interfaceName, interfaceIndex)
67+
}
68+
} else {
69+
listener.updateDefaultInterface(interfaceName, interfaceIndex)
70+
}
5971
}
6072
} else {
61-
listener.updateDefaultInterface("", -1)
73+
if (BuildConfig.DEBUG) {
74+
GlobalScope.launch(Dispatchers.IO) {
75+
listener.updateDefaultInterface("", -1)
76+
}
77+
} else {
78+
listener.updateDefaultInterface("", -1)
79+
}
6280
}
6381
}
6482

65-
6683
}

0 commit comments

Comments
 (0)