From 5a18296cb212fddabd79e09da57690b61de58883 Mon Sep 17 00:00:00 2001 From: Akatsuki <3736910+akiirui@users.noreply.github.com> Date: Thu, 3 Sep 2020 02:07:11 +0800 Subject: [PATCH] V2RayVpnService.kt: use setMetered setMetered to false let VPN network to inherit its meteredness from its underlying networks. Revert `addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED)` --- .../src/main/kotlin/com/v2ray/ang/service/V2RayVpnService.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayVpnService.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayVpnService.kt index 480bb578..1bd13151 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayVpnService.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayVpnService.kt @@ -76,7 +76,6 @@ class V2RayVpnService : VpnService() { NetworkRequest.Builder() .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) .addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED) - .addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED) .build() } @@ -198,6 +197,10 @@ class V2RayVpnService : VpnService() { listeningForDefaultNetwork = true } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + builder.setMetered(false) + } + // Create a new interface using the builder and save the parameters. mInterface = builder.establish() sendFd()