allow change access packages when vpn enabled (#560)

This commit is contained in:
ayanamist
2025-06-29 12:13:17 +08:00
committed by GitHub
parent 4ece5c4315
commit 99cbc449c2
2 changed files with 11 additions and 2 deletions

View File

@@ -11,7 +11,10 @@ import com.github.kr328.clash.design.AccessControlDesign
import com.github.kr328.clash.design.model.AppInfo
import com.github.kr328.clash.design.util.toAppInfo
import com.github.kr328.clash.service.store.ServiceStore
import com.github.kr328.clash.util.startClashService
import com.github.kr328.clash.util.stopClashService
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlinx.coroutines.selects.select
import kotlinx.coroutines.withContext
@@ -26,7 +29,15 @@ class AccessControlActivity : BaseActivity<AccessControlDesign>() {
defer {
withContext(Dispatchers.IO) {
val changed = selected != service.accessControlPackages
service.accessControlPackages = selected
if (clashRunning && changed) {
stopClashService()
while (clashRunning) {
delay(200)
}
startClashService()
}
}
}

View File

@@ -128,8 +128,6 @@ class NetworkSettingsDesign(
clicked {
requests.trySend(Request.StartAccessControlList)
}
vpnDependencies.add(this)
}
if (running) {