Fix the problem that ui can't be synchronized when android vpn is occupied by an external

Override default socksPort,port
This commit is contained in:
chen08209
2024-07-15 13:47:06 +08:00
parent aa4ffbe4fb
commit a4b5f4abdb
4 changed files with 23 additions and 5 deletions

View File

@@ -71,7 +71,7 @@ class FlClashTileService : TileService() {
if (titlePlugin != null) { if (titlePlugin != null) {
titlePlugin.handleStart() titlePlugin.handleStart()
} else { } else {
GlobalState.initServiceEngine(this) GlobalState.initServiceEngine(applicationContext)
} }
} else if (GlobalState.runState.value == RunState.START) { } else if (GlobalState.runState.value == RunState.START) {
GlobalState.runState.value = RunState.PENDING GlobalState.runState.value = RunState.PENDING

View File

@@ -11,12 +11,17 @@ import android.net.VpnService
import android.os.Binder import android.os.Binder
import android.os.Build import android.os.Build
import android.os.IBinder import android.os.IBinder
import android.os.Parcel
import android.os.RemoteException
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import com.follow.clash.GlobalState import com.follow.clash.GlobalState
import com.follow.clash.MainActivity import com.follow.clash.MainActivity
import com.follow.clash.R import com.follow.clash.R
import com.follow.clash.models.AccessControlMode import com.follow.clash.models.AccessControlMode
import com.follow.clash.models.Props import com.follow.clash.models.Props
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
class FlClashVpnService : VpnService() { class FlClashVpnService : VpnService() {
@@ -131,7 +136,7 @@ class FlClashVpnService : VpnService() {
} }
fun initServiceEngine() { fun initServiceEngine() {
GlobalState.initServiceEngine(this) GlobalState.initServiceEngine(applicationContext)
} }
override fun onTrimMemory(level: Int) { override fun onTrimMemory(level: Int) {
@@ -168,13 +173,26 @@ class FlClashVpnService : VpnService() {
inner class LocalBinder : Binder() { inner class LocalBinder : Binder() {
fun getService(): FlClashVpnService = this@FlClashVpnService fun getService(): FlClashVpnService = this@FlClashVpnService
override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean {
CoroutineScope(Dispatchers.Main).launch {
GlobalState.getCurrentTitlePlugin()?.handleStop()
}
try {
return super.onTransact(code, data, reply, flags)
} catch (e: RemoteException) {
throw e
}
}
} }
override fun onBind(intent: Intent): IBinder { override fun onBind(intent: Intent): IBinder {
return binder return binder
} }
override fun onUnbind(intent: Intent?): Boolean { override fun onUnbind(intent: Intent?): Boolean {
GlobalState.getCurrentTitlePlugin()?.handleStop()
return super.onUnbind(intent) return super.onUnbind(intent)
} }

View File

@@ -325,8 +325,8 @@ func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfi
//targetConfig.GeodataMode = false //targetConfig.GeodataMode = false
targetConfig.IPv6 = patchConfig.IPv6 targetConfig.IPv6 = patchConfig.IPv6
targetConfig.LogLevel = patchConfig.LogLevel targetConfig.LogLevel = patchConfig.LogLevel
//targetConfig.Port = 0 targetConfig.Port = 0
//targetConfig.SocksPort = 0 targetConfig.SocksPort = 0
targetConfig.MixedPort = patchConfig.MixedPort targetConfig.MixedPort = patchConfig.MixedPort
targetConfig.FindProcessMode = patchConfig.FindProcessMode targetConfig.FindProcessMode = patchConfig.FindProcessMode
targetConfig.AllowLan = patchConfig.AllowLan targetConfig.AllowLan = patchConfig.AllowLan

View File

@@ -1,7 +1,7 @@
name: fl_clash name: fl_clash
description: A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free. description: A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free.
publish_to: 'none' publish_to: 'none'
version: 0.8.38+202407142 version: 0.8.39+202407151
environment: environment:
sdk: '>=3.1.0 <4.0.0' sdk: '>=3.1.0 <4.0.0'