diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/service/V2RayTestService.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/service/V2RayTestService.kt index 713a7f9d..ec7d5602 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/service/V2RayTestService.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/service/V2RayTestService.kt @@ -6,7 +6,7 @@ import android.os.IBinder import com.v2ray.ang.AppConfig import com.v2ray.ang.AppConfig.MSG_MEASURE_CONFIG import com.v2ray.ang.AppConfig.MSG_MEASURE_CONFIG_CANCEL -import com.v2ray.ang.extension.serializable +import com.v2ray.ang.handler.MmkvManager import com.v2ray.ang.handler.V2RayNativeManager import com.v2ray.ang.util.MessageUtil import java.util.Collections @@ -54,8 +54,14 @@ class V2RayTestService : Service() { override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { when (intent?.getIntExtra("key", 0)) { MSG_MEASURE_CONFIG -> { - val guidsList = intent.serializable>("content") - if (guidsList != null && guidsList.isNotEmpty()) { + val subscriptionId = intent.getStringExtra("content").orEmpty() + val guidsList = if (subscriptionId.isEmpty()) { + MmkvManager.decodeAllServerList() + } else { + MmkvManager.decodeServerList(subscriptionId) + } + + if (guidsList.isNotEmpty()) { lateinit var worker: RealPingWorkerService worker = RealPingWorkerService(this, guidsList) { status -> // notify UI and remove the worker from active list when finished diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/viewmodel/MainViewModel.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/viewmodel/MainViewModel.kt index 25c4b644..8d863612 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/viewmodel/MainViewModel.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/viewmodel/MainViewModel.kt @@ -240,13 +240,11 @@ class MainViewModel(application: Application) : AndroidViewModel(application) { MmkvManager.clearAllTestDelayResults(serversCache.map { it.guid }.toList()) updateListAction.value = -1 - val serversCopy = serversCache.toList() viewModelScope.launch(Dispatchers.Default) { - val guids = ArrayList(serversCopy.map { it.guid }) - if (guids.isEmpty()) { + if (serversCache.isEmpty()) { return@launch } - MessageUtil.sendMsg2TestService(getApplication(), AppConfig.MSG_MEASURE_CONFIG, guids) + MessageUtil.sendMsg2TestService(getApplication(), AppConfig.MSG_MEASURE_CONFIG, subscriptionId) } }