From db0755cf0c758086ad7fea7abdb9d1e35c74a5f1 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sun, 2 Aug 2026 15:14:40 +0800 Subject: [PATCH] Auto delete and sort subscription after core tests --- .../java/com/v2ray/ang/service/CoreTestService.kt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/service/CoreTestService.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/service/CoreTestService.kt index 73a93be84..ffb9b919a 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/service/CoreTestService.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/service/CoreTestService.kt @@ -10,6 +10,7 @@ import com.v2ray.ang.dto.RealPingEvent import com.v2ray.ang.dto.TestServiceMessage import com.v2ray.ang.enums.NotificationChannelType import com.v2ray.ang.extension.serializable +import com.v2ray.ang.handler.AngConfigManager import com.v2ray.ang.handler.MmkvManager import com.v2ray.ang.helper.MessageHelper import com.v2ray.ang.helper.NotificationHelper @@ -96,7 +97,7 @@ class CoreTestService : Service() { context = this, guids = guidsList, onlyTcp = message.onlyTcp, - onEvent = { event -> handleWorkerEvent(event) { activeWorkers.remove(worker) } } + onEvent = { event -> handleWorkerEvent(event, message) { activeWorkers.remove(worker) } } ) activeWorkers.add(worker) worker.start() @@ -106,7 +107,7 @@ class CoreTestService : Service() { } } - private fun handleWorkerEvent(event: RealPingEvent, onWorkerDone: () -> Unit) { + private fun handleWorkerEvent(event: RealPingEvent, message: TestServiceMessage, onWorkerDone: () -> Unit) { when (event) { is RealPingEvent.Progress -> { NotificationHelper.updateNotification( @@ -124,6 +125,16 @@ class CoreTestService : Service() { } is RealPingEvent.Finish -> { + if(message.subscriptionId.isNotEmpty()){ + if (MmkvManager.decodeSettingsBool(AppConfig.PREF_AUTO_REMOVE_INVALID_AFTER_TEST, false)) { + AngConfigManager.removeInvalidServer(message.subscriptionId) + } + + if (MmkvManager.decodeSettingsBool(AppConfig.PREF_AUTO_SORT_AFTER_TEST, false)) { + AngConfigManager.sortByTestResultsForSub(message.subscriptionId) + } + } + MessageHelper.sendMsg2UI(this, AppConfig.MSG_MEASURE_CONFIG_FINISH, event.status) onWorkerDone() if (activeWorkers.isEmpty()) {