diff options
author | pacien | 2023-01-09 00:01:03 +0100 |
---|---|---|
committer | pacien | 2023-01-09 00:22:49 +0100 |
commit | 136f395ed1bdecdd633432dc08cc53d96825fa36 (patch) | |
tree | bdf99a13cb4163629d2f684455df0b047dce9e08 /app/src/main/java | |
parent | 7aafc91bc8a2e9e1cf84204c9aa2b0437748c1c3 (diff) | |
download | tincapp-136f395ed1bdecdd633432dc08cc53d96825fa36.tar.gz |
net: inherit metered property from underlying network
Since API 29, all VPN connections were treated as metered by default.
This is not relevant for tinc networks, so it's preferable to simply
inherit that property from the underlying link.
GitHub: closes #114
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt b/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt index ac68c9f..af5966e 100644 --- a/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt +++ b/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon | 2 | * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon |
3 | * Copyright (C) 2017-2020 Pacien TRAN-GIRARD | 3 | * Copyright (C) 2017-2023 Pacien TRAN-GIRARD |
4 | * | 4 | * |
5 | * This program is free software: you can redistribute it and/or modify | 5 | * This program is free software: you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
@@ -23,6 +23,7 @@ import android.content.Context | |||
23 | import android.content.Intent | 23 | import android.content.Intent |
24 | import android.net.LocalServerSocket | 24 | import android.net.LocalServerSocket |
25 | import android.net.VpnService | 25 | import android.net.VpnService |
26 | import android.os.Build | ||
26 | import android.os.ParcelFileDescriptor | 27 | import android.os.ParcelFileDescriptor |
27 | import androidx.localbroadcastmanager.content.LocalBroadcastManager | 28 | import androidx.localbroadcastmanager.content.LocalBroadcastManager |
28 | import java8.util.concurrent.CompletableFuture | 29 | import java8.util.concurrent.CompletableFuture |
@@ -133,6 +134,8 @@ class TincVpnService : VpnService() { | |||
133 | Builder().setSession(netName) | 134 | Builder().setSession(netName) |
134 | .applyCfg(interfaceCfg) | 135 | .applyCfg(interfaceCfg) |
135 | .also { applyIgnoringException(it::addDisallowedApplication, BuildConfig.APPLICATION_ID) } | 136 | .also { applyIgnoringException(it::addDisallowedApplication, BuildConfig.APPLICATION_ID) } |
137 | // inherit metered property from underlying network | ||
138 | .also { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) it.setMetered(false) } | ||
136 | .establish()!! | 139 | .establish()!! |
137 | } catch (e: IllegalArgumentException) { | 140 | } catch (e: IllegalArgumentException) { |
138 | return reportError(resources.getString(R.string.notification_error_message_network_config_invalid_format, e.defaultMessage()), e, "network-interface") | 141 | return reportError(resources.getString(R.string.notification_error_message_network_config_invalid_format, e.defaultMessage()), e, "network-interface") |