From 5de0313f16382ab97c14661222d8be51c5fc6e72 Mon Sep 17 00:00:00 2001 From: pacien Date: Sun, 15 Sep 2019 04:05:34 +0200 Subject: fix daemon startup for android 10 --- 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 18388f6..263fea4 100644 --- a/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt +++ b/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt @@ -125,10 +125,13 @@ class TincVpnService : VpnService() { } val deviceFd = try { - Builder().setSession(netName) + val appContextFd = Builder().setSession(netName) .applyCfg(interfaceCfg) .also { applyIgnoringException(it::addDisallowedApplication, BuildConfig.APPLICATION_ID) } .establish()!! + val daemonContextFd = appContextFd.dup() // necessary since Android 10 + appContextFd.close() + daemonContextFd } catch (e: IllegalArgumentException) { return reportError(resources.getString(R.string.notification_error_message_network_config_invalid_format, e.defaultMessage()), e, "network-interface") } catch (e: NullPointerException) { -- cgit v1.2.3