summaryrefslogtreecommitdiffhomepage
path: root/android/src/main
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2021-02-02 17:47:09 +0000
committerAleksandr Granin <aleksandr@mullvad.net>2021-04-08 13:26:19 +0200
commitcf8317bcf14ec823c1f57f975838a55afa5e939b (patch)
tree67f25d1d8878a2be720641435e818f8f40221e04 /android/src/main
parentb6e029089abe12908bd94150dd824d9176449fd8 (diff)
downloadmullvadvpn-cf8317bcf14ec823c1f57f975838a55afa5e939b.tar.xz
mullvadvpn-cf8317bcf14ec823c1f57f975838a55afa5e939b.zip
Handle split tunneling requests
Diffstat (limited to 'android/src/main')
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ServiceEndpoint.kt2
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/SplitTunneling.kt21
2 files changed, 21 insertions, 2 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ServiceEndpoint.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ServiceEndpoint.kt
index 00a30680de..5770978748 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ServiceEndpoint.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ServiceEndpoint.kt
@@ -38,7 +38,7 @@ class ServiceEndpoint(
val accountCache = AccountCache(this)
val keyStatusListener = KeyStatusListener(this)
val locationInfoCache = LocationInfoCache(this)
- val splitTunneling = SplitTunneling(context)
+ val splitTunneling = SplitTunneling(context, this)
init {
dispatcher.registerHandler(Request.RegisterListener::class) { request ->
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/SplitTunneling.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/SplitTunneling.kt
index c078687704..21b19a6124 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/SplitTunneling.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/SplitTunneling.kt
@@ -3,13 +3,14 @@ package net.mullvad.mullvadvpn.service.endpoint
import android.content.Context
import java.io.File
import kotlin.properties.Delegates.observable
+import net.mullvad.mullvadvpn.ipc.Request
// The spelling of the shared preferences location can't be changed to American English without
// either having users lose their preferences on update or implementing some migration code.
private const val SHARED_PREFERENCES = "split_tunnelling"
private const val KEY_ENABLED = "enabled"
-class SplitTunneling(context: Context) {
+class SplitTunneling(context: Context, endpoint: ServiceEndpoint) {
// The spelling of the app list file name can't be changed to American English without either
// having users lose their preferences on update or implementing some migration code.
private val appListFile = File(context.filesDir, "split-tunnelling.txt")
@@ -36,6 +37,24 @@ class SplitTunneling(context: Context) {
excludedApps.addAll(appListFile.readLines())
update()
}
+
+ endpoint.dispatcher.apply {
+ registerHandler(Request.IncludeApp::class) { request ->
+ includeApp(request.packageName)
+ }
+
+ registerHandler(Request.ExcludeApp::class) { request ->
+ excludeApp(request.packageName)
+ }
+
+ registerHandler(Request.SetEnableSplitTunneling::class) { request ->
+ enabled = request.enable
+ }
+
+ registerHandler(Request.PersistExcludedApps::class) { _ ->
+ persist()
+ }
+ }
}
fun isAppExcluded(appPackageName: String) = excludedApps.contains(appPackageName)