summaryrefslogtreecommitdiffhomepage
path: root/android/service/src
diff options
context:
space:
mode:
authorJonatan Rhodin <jonatan.rhodin@mullvad.net>2024-03-13 12:44:49 +0100
committerJonatan Rhodin <jonatan.rhodin@mullvad.net>2024-03-14 14:53:44 +0100
commitfe6586647799a21c16f9c005a78bb14ce75dea09 (patch)
tree37183fb94bc747ab279d52bb00c0b93f3647f4ca /android/service/src
parent461e29d36e5e2a6841e05897e732b5d068d4dcf0 (diff)
downloadmullvadvpn-fe6586647799a21c16f9c005a78bb14ce75dea09.tar.xz
mullvadvpn-fe6586647799a21c16f9c005a78bb14ce75dea09.zip
Return success or error when creating and updating a custom list
Diffstat (limited to 'android/service/src')
-rw-r--r--android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadDaemon.kt20
-rw-r--r--android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/CustomLists.kt10
2 files changed, 21 insertions, 9 deletions
diff --git a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadDaemon.kt b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadDaemon.kt
index d09287fbf2..f99d36c679 100644
--- a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadDaemon.kt
+++ b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadDaemon.kt
@@ -5,6 +5,7 @@ import kotlinx.coroutines.flow.asSharedFlow
import net.mullvad.mullvadvpn.lib.endpoint.ApiEndpoint
import net.mullvad.mullvadvpn.lib.endpoint.ApiEndpointConfiguration
import net.mullvad.mullvadvpn.model.AppVersionInfo
+import net.mullvad.mullvadvpn.model.CreateCustomListResult
import net.mullvad.mullvadvpn.model.CustomList
import net.mullvad.mullvadvpn.model.Device
import net.mullvad.mullvadvpn.model.DeviceEvent
@@ -24,6 +25,7 @@ import net.mullvad.mullvadvpn.model.RemoveDeviceEvent
import net.mullvad.mullvadvpn.model.RemoveDeviceResult
import net.mullvad.mullvadvpn.model.Settings
import net.mullvad.mullvadvpn.model.TunnelState
+import net.mullvad.mullvadvpn.model.UpdateCustomListResult
import net.mullvad.mullvadvpn.model.VoucherSubmissionResult
import net.mullvad.talpid.util.EventNotifier
@@ -190,17 +192,15 @@ class MullvadDaemon(
setQuantumResistantTunnel(daemonInterfaceAddress, quantumResistant)
}
- fun createCustomList(name: String): String {
- return createCustomList(daemonInterfaceAddress, name)
- }
+ fun createCustomList(name: String): CreateCustomListResult =
+ createCustomList(daemonInterfaceAddress, name)
fun deleteCustomList(id: String) {
deleteCustomList(daemonInterfaceAddress, id)
}
- fun updateCustomList(customList: CustomList) {
+ fun updateCustomList(customList: CustomList): UpdateCustomListResult =
updateCustomList(daemonInterfaceAddress, customList)
- }
fun onDestroy() {
onSettingsChange.unsubscribeAll()
@@ -311,11 +311,17 @@ class MullvadDaemon(
// Used by JNI
- private external fun createCustomList(daemonInterfaceAddress: Long, name: String): String
+ private external fun createCustomList(
+ daemonInterfaceAddress: Long,
+ name: String
+ ): CreateCustomListResult
private external fun deleteCustomList(daemonInterfaceAddress: Long, id: String)
- private external fun updateCustomList(daemonInterfaceAddress: Long, customList: CustomList)
+ private external fun updateCustomList(
+ daemonInterfaceAddress: Long,
+ customList: CustomList
+ ): UpdateCustomListResult
@Suppress("unused")
private fun notifyAppVersionInfoEvent(appVersionInfo: AppVersionInfo) {
diff --git a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/CustomLists.kt b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/CustomLists.kt
index d80bcf04ff..39702398c7 100644
--- a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/CustomLists.kt
+++ b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/CustomLists.kt
@@ -9,6 +9,7 @@ import kotlinx.coroutines.flow.filterIsInstance
import kotlinx.coroutines.launch
import net.mullvad.mullvadvpn.lib.ipc.Event
import net.mullvad.mullvadvpn.lib.ipc.Request
+import net.mullvad.mullvadvpn.model.CustomList
class CustomLists(
private val endpoint: ServiceEndpoint,
@@ -34,13 +35,18 @@ class CustomLists(
scope.launch {
endpoint.dispatcher.parsedMessages
.filterIsInstance<Request.UpdateCustomList>()
- .collect { daemon.await().updateCustomList(it.customList) }
+ .collect { updateCustomList(it.customList) }
}
}
private suspend fun createCustomList(name: String) {
val result = daemon.await().createCustomList(name)
- endpoint.sendEvent(Event.CreateCustomListResult(result))
+ endpoint.sendEvent(Event.CreateCustomListResultEvent(result))
+ }
+
+ private suspend fun updateCustomList(customList: CustomList) {
+ val result = daemon.await().updateCustomList(customList)
+ endpoint.sendEvent(Event.UpdateCustomListResultEvent(result))
}
fun onDestroy() {