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 ++++- changelog.md | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) 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") diff --git a/changelog.md b/changelog.md index 845f1bc..859602c 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,9 @@ This file lists notable changes that have been made to the application on each release. Releases are tracked and referred to using git tags. +## v0.36 -- 2023-01-09 +- inherit metered network restriction from underlying link (android 10+) + ## v0.35 -- 2023-01-06 - fix app crash when connecting or enabling FTP server (android 12+) -- cgit v1.2.3