Skip to content

Commit

Permalink
Fix the problem that ui can't be synchronized when android vpn is occ…
Browse files Browse the repository at this point in the history
…upied by an external

Override default socksPort,port
  • Loading branch information
chen08209 committed Jul 15, 2024
1 parent aa4ffbe commit a4b5f4a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class FlClashTileService : TileService() {
if (titlePlugin != null) {
titlePlugin.handleStart()
} else {
GlobalState.initServiceEngine(this)
GlobalState.initServiceEngine(applicationContext)
}
} else if (GlobalState.runState.value == RunState.START) {
GlobalState.runState.value = RunState.PENDING
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ import android.net.VpnService
import android.os.Binder
import android.os.Build
import android.os.IBinder
import android.os.Parcel
import android.os.RemoteException
import androidx.core.app.NotificationCompat
import com.follow.clash.GlobalState
import com.follow.clash.MainActivity
import com.follow.clash.R
import com.follow.clash.models.AccessControlMode
import com.follow.clash.models.Props
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch


class FlClashVpnService : VpnService() {
Expand Down Expand Up @@ -131,7 +136,7 @@ class FlClashVpnService : VpnService() {
}

fun initServiceEngine() {
GlobalState.initServiceEngine(this)
GlobalState.initServiceEngine(applicationContext)
}

override fun onTrimMemory(level: Int) {
Expand Down Expand Up @@ -168,13 +173,26 @@ class FlClashVpnService : VpnService() {

inner class LocalBinder : Binder() {
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 {
return binder
}

override fun onUnbind(intent: Intent?): Boolean {
GlobalState.getCurrentTitlePlugin()?.handleStop()
return super.onUnbind(intent)
}

Expand Down
4 changes: 2 additions & 2 deletions core/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfi
//targetConfig.GeodataMode = false
targetConfig.IPv6 = patchConfig.IPv6
targetConfig.LogLevel = patchConfig.LogLevel
//targetConfig.Port = 0
//targetConfig.SocksPort = 0
targetConfig.Port = 0
targetConfig.SocksPort = 0
targetConfig.MixedPort = patchConfig.MixedPort
targetConfig.FindProcessMode = patchConfig.FindProcessMode
targetConfig.AllowLan = patchConfig.AllowLan
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: fl_clash
description: A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free.
publish_to: 'none'
version: 0.8.38+202407142
version: 0.8.39+202407151
environment:
sdk: '>=3.1.0 <4.0.0'

Expand Down

0 comments on commit a4b5f4a

Please sign in to comment.