From 136f395ed1bdecdd633432dc08cc53d96825fa36 Mon Sep 17 00:00:00 2001 From: pacien Date: Mon, 9 Jan 2023 00:01:03 +0100 Subject: 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 --- app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'app') 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 @@ /* * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon - * Copyright (C) 2017-2020 Pacien TRAN-GIRARD + * Copyright (C) 2017-2023 Pacien TRAN-GIRARD * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,6 +23,7 @@ import android.content.Context import android.content.Intent import android.net.LocalServerSocket import android.net.VpnService +import android.os.Build import android.os.ParcelFileDescriptor import androidx.localbroadcastmanager.content.LocalBroadcastManager import java8.util.concurrent.CompletableFuture @@ -133,6 +134,8 @@ class TincVpnService : VpnService() { Builder().setSession(netName) .applyCfg(interfaceCfg) .also { applyIgnoringException(it::addDisallowedApplication, BuildConfig.APPLICATION_ID) } + // inherit metered property from underlying network + .also { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) it.setMetered(false) } .establish()!! } catch (e: IllegalArgumentException) { return reportError(resources.getString(R.string.notification_error_message_network_config_invalid_format, e.defaultMessage()), e, "network-interface") -- cgit v1.2.3