summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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)