From e3fa8615716d585e6ee7b45d3477fb5f3369f066 Mon Sep 17 00:00:00 2001 From: patterniha <71074308+patterniha@users.noreply.github.com> Date: Sat, 29 Aug 2026 06:37:00 +0330 Subject: [PATCH] Do not remove policy levels when traffic statistics is disabled (#6146) Disabling traffic statistics removed the whole policy section from the generated config, including the levels block (uplinkOnly, downlinkOnly, connIdle, handshake) from the template or from a user's custom config. Only the stats-related policy.system block should be stripped; keep policy.levels intact in both the unified and the custom config paths. --- .../main/java/com/v2ray/ang/core/CoreConfigManager.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreConfigManager.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreConfigManager.kt index e40ce604..864a3ab8 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreConfigManager.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreConfigManager.kt @@ -113,7 +113,13 @@ object CoreConfigManager { } } else { json.remove("stats") - json.remove("policy") + // Keep user-defined policy levels, only strip the stats-related system block + json.get("policy")?.takeIf { it.isJsonObject }?.asJsonObject?.let { policy -> + policy.remove("system") + if (policy.entrySet().isEmpty()) { + json.remove("policy") + } + } } if (!needTun()) { @@ -709,7 +715,7 @@ object CoreConfigManager { private fun applySpeedDisabled(v2rayConfig: V2rayConfig) { if (MmkvManager.decodeSettingsBool(AppConfig.PREF_SPEED_ENABLED) != true) { v2rayConfig.stats = null - v2rayConfig.policy = null + v2rayConfig.policy?.system = null } }