From 606246f36ee9213e1aeaa80a1df1eaa3ab89cf06 Mon Sep 17 00:00:00 2001 From: eliotcougar Date: Fri, 14 Aug 2026 09:09:31 +0300 Subject: [PATCH] fix: make root service starts idempotent (#6055) --- .../src/main/java/com/v2ray/ang/service/CoreRootService.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/service/CoreRootService.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/service/CoreRootService.kt index d5265fb88..9162af551 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/service/CoreRootService.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/service/CoreRootService.kt @@ -43,6 +43,11 @@ class CoreRootService : Service(), ServiceControl { NotificationManager.ensureForeground() LogUtil.i(AppConfig.TAG, "StartCore-Root: command received") + if (CoreServiceManager.isRunning()) { + LogUtil.i(AppConfig.TAG, "StartCore-Root: Core is already running") + return START_STICKY + } + // Start the in-process core first (this also posts the foreground notification), // then install the root routing off the main thread. if (!CoreServiceManager.startCoreLoop(null)) {