Enable fix stack for Android 7 and 9

This commit is contained in:
世界 2024-12-26 11:12:07 +08:00
parent 6533b62fa3
commit 44176a840b
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
3 changed files with 25 additions and 6 deletions

View file

@ -24,11 +24,13 @@ import io.nekohasekai.libbox.CommandServerHandler
import io.nekohasekai.libbox.Libbox
import io.nekohasekai.libbox.Notification
import io.nekohasekai.libbox.PlatformInterface
import io.nekohasekai.libbox.SetupOptions
import io.nekohasekai.libbox.SystemProxyStatus
import io.nekohasekai.sfa.Application
import io.nekohasekai.sfa.R
import io.nekohasekai.sfa.constant.Action
import io.nekohasekai.sfa.constant.Alert
import io.nekohasekai.sfa.constant.Bugs
import io.nekohasekai.sfa.constant.Status
import io.nekohasekai.sfa.database.ProfileManager
import io.nekohasekai.sfa.database.Settings
@ -57,7 +59,12 @@ class BoxService(
workingDir.mkdirs()
val tempDir = Application.application.cacheDir
tempDir.mkdirs()
Libbox.setup(baseDir.path, workingDir.path, tempDir.path, false)
Libbox.setup(SetupOptions().also {
it.basePath = baseDir.path
it.workingPath = workingDir.path
it.tempPath = tempDir.path
it.fixAndroidStack = Bugs.fixAndroidStack
})
Libbox.redirectStderr(File(workingDir, "stderr.log").path)
initializeOnce = true
return

View file

@ -4,7 +4,7 @@ import android.net.Network
import android.os.Build
import io.nekohasekai.libbox.InterfaceUpdateListener
import io.nekohasekai.sfa.Application
import io.nekohasekai.sfa.BuildConfig
import io.nekohasekai.sfa.constant.Bugs
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
@ -59,9 +59,7 @@ object DefaultNetworkMonitor {
Thread.sleep(100)
continue
}
// TODO: remove launch after fixed
// https://github.com/golang/go/issues/68760
if (BuildConfig.DEBUG) {
if (Bugs.fixAndroidStack) {
GlobalScope.launch(Dispatchers.IO) {
listener.updateDefaultInterface(interfaceName, interfaceIndex)
}
@ -70,7 +68,7 @@ object DefaultNetworkMonitor {
}
}
} else {
if (BuildConfig.DEBUG) {
if (Bugs.fixAndroidStack) {
GlobalScope.launch(Dispatchers.IO) {
listener.updateDefaultInterface("", -1)
}

View file

@ -0,0 +1,14 @@
package io.nekohasekai.sfa.constant
import android.os.Build
import io.nekohasekai.sfa.BuildConfig
object Bugs {
// TODO: remove launch after fixed
// https://github.com/golang/go/issues/68760
val fixAndroidStack = BuildConfig.DEBUG ||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && Build.VERSION.SDK_INT <= Build.VERSION_CODES.N_MR1 ||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.P
}