diff options
| -rw-r--r-- | CHANGELOG.md | 3 | ||||
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt | 9 |
2 files changed, 12 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 29dd172836..451f031416 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,9 @@ Line wrap the file at 100 chars. Th #### Android - Wait for traffic to be routed through the tunnel device before advertising blocked state. +- Connect automatically if `MullvadVpnService` is started with an intent which + has the `android.net.VpnService` action. Effectively, this should enable + _Always On_ behavior on Android versions where it's supported. ### Fixed - Don't try to replace WireGuard key if account has too many keys already. diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt index cd4e13015a..db3cbfb7ec 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt @@ -1,6 +1,7 @@ package net.mullvad.mullvadvpn.service import android.content.Intent +import android.net.VpnService import android.os.Binder import android.os.IBinder import kotlinx.coroutines.Deferred @@ -61,6 +62,14 @@ class MullvadVpnService : TalpidVpnService() { } } + override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int { + val startResult = super.onStartCommand(intent, flags, startId) + if (intent.getAction() == VpnService.SERVICE_INTERFACE) { + runBlocking { daemon.await().connect() } + } + return startResult + } + private fun setUp() { daemon = startDaemon() connectionProxy = ConnectionProxy(this, daemon) |
