mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2026-05-09 18:11:26 +08:00
allow change access packages when vpn enabled (#560)
This commit is contained in:
@@ -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.model.AppInfo
|
||||||
import com.github.kr328.clash.design.util.toAppInfo
|
import com.github.kr328.clash.design.util.toAppInfo
|
||||||
import com.github.kr328.clash.service.store.ServiceStore
|
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.Dispatchers
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.isActive
|
import kotlinx.coroutines.isActive
|
||||||
import kotlinx.coroutines.selects.select
|
import kotlinx.coroutines.selects.select
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
@@ -26,7 +29,15 @@ class AccessControlActivity : BaseActivity<AccessControlDesign>() {
|
|||||||
|
|
||||||
defer {
|
defer {
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
|
val changed = selected != service.accessControlPackages
|
||||||
service.accessControlPackages = selected
|
service.accessControlPackages = selected
|
||||||
|
if (clashRunning && changed) {
|
||||||
|
stopClashService()
|
||||||
|
while (clashRunning) {
|
||||||
|
delay(200)
|
||||||
|
}
|
||||||
|
startClashService()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -128,8 +128,6 @@ class NetworkSettingsDesign(
|
|||||||
clicked {
|
clicked {
|
||||||
requests.trySend(Request.StartAccessControlList)
|
requests.trySend(Request.StartAccessControlList)
|
||||||
}
|
}
|
||||||
|
|
||||||
vpnDependencies.add(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (running) {
|
if (running) {
|
||||||
|
|||||||
Reference in New Issue
Block a user