summaryrefslogtreecommitdiffhomepage
path: root/android/app
diff options
context:
space:
mode:
authorAlbin <albin@mullvad.net>2022-12-08 15:53:59 +0100
committerAlbin <albin@mullvad.net>2022-12-08 15:53:59 +0100
commit81c3e7fc12f29ceefb394f11d1486c83e847bcc7 (patch)
treec63536b3d957f5b778a5d70191fc1dfbdd48aaf7 /android/app
parent541bbf7c36e6c83ca7e88cc7ff859c8cefbde6c0 (diff)
parent8c6954d4c8d0638fe2b408c9147e56522cb79aa8 (diff)
downloadmullvadvpn-81c3e7fc12f29ceefb394f11d1486c83e847bcc7.tar.xz
mullvadvpn-81c3e7fc12f29ceefb394f11d1486c83e847bcc7.zip
Merge branch 'bump-android-project-to-java-11'
Diffstat (limited to 'android/app')
-rw-r--r--android/app/build.gradle.kts47
-rw-r--r--android/app/src/androidTest/AndroidManifest.xml3
-rw-r--r--android/app/src/debug/AndroidManifest.xml3
-rw-r--r--android/app/src/main/AndroidManifest.xml3
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt8
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/ipc/HandlerFlow.kt4
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/DaemonInstance.kt6
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt10
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt8
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AuthTokenCache.kt4
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ConnectionProxy.kt8
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/CustomDns.kt10
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/LocationInfoCache.kt8
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/RelayListListener.kt4
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ServiceEndpoint.kt6
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/SettingsListener.kt8
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/VoucherRedeemer.kt4
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/ListItemsAdapter.kt2
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/RedeemVoucherDialogFragment.kt1
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragments/SplitTunnelingFragment.kt5
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/RelayListListener.kt1
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/FlowUtils.kt2
-rw-r--r--android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/LoginViewModelTest.kt4
23 files changed, 80 insertions, 79 deletions
diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts
index e61156ca13..5afb5659d9 100644
--- a/android/app/build.gradle.kts
+++ b/android/app/build.gradle.kts
@@ -2,7 +2,6 @@ import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties
import com.android.build.gradle.internal.tasks.factory.dependsOn
import java.io.FileInputStream
import java.util.Properties
-import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id(Dependencies.Plugin.androidApplicationId)
@@ -25,12 +24,13 @@ if (keystorePropertiesFile.exists()) {
}
android {
- compileSdkVersion(Versions.Android.compileSdkVersion)
+ namespace = "net.mullvad.mullvadvpn"
+ compileSdk = Versions.Android.compileSdkVersion
defaultConfig {
applicationId = "net.mullvad.mullvadvpn"
- minSdkVersion(Versions.Android.minSdkVersion)
- targetSdkVersion(Versions.Android.targetSdkVersion)
+ minSdk = Versions.Android.minSdkVersion
+ targetSdk = Versions.Android.targetSdkVersion
versionCode = generateVersionCode()
versionName = generateVersionName()
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
@@ -104,7 +104,6 @@ android {
}
composeOptions {
- kotlinCompilerVersion = Versions.kotlin
kotlinCompilerExtensionVersion = Versions.kotlinCompilerExtensionVersion
}
@@ -114,9 +113,14 @@ android {
}
kotlinOptions {
+ allWarningsAsErrors = false
jvmTarget = Versions.jvmTarget
- freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
- // Opt-in option for Koin annotation of KoinComponent.
+ freeCompilerArgs = listOf(
+ "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
+ "-opt-in=kotlinx.coroutines.ObsoleteCoroutinesApi",
+ // Opt-in option for Koin annotation of KoinComponent.
+ "-opt-in=kotlin.RequiresOptIn"
+ )
}
tasks.withType<com.android.build.gradle.tasks.MergeSourceSetFolders> {
@@ -136,10 +140,16 @@ android {
packagingOptions {
jniLibs.useLegacyPackaging = true
-
- // Fixes packaging error caused by: androidx.compose.ui:ui-test-junit4
- pickFirst("META-INF/AL2.0")
- pickFirst("META-INF/LGPL2.1")
+ resources {
+ pickFirsts += setOf(
+ // Fixes packaging error caused by: androidx.compose.ui:ui-test-junit4
+ "META-INF/AL2.0",
+ "META-INF/LGPL2.1",
+ // Fixes packaging error caused by: jetified-junit-*
+ "META-INF/LICENSE.md",
+ "META-INF/LICENSE-notice.md"
+ )
+ }
}
project.tasks.preBuild.dependsOn("ensureJniDirectoryExist")
@@ -153,17 +163,6 @@ configure<org.owasp.dependencycheck.gradle.extension.DependencyCheckExtension> {
skipConfigurations = listOf("lintClassPath")
}
-tasks.withType<KotlinCompile>().all {
- kotlinOptions {
- allWarningsAsErrors = false
-
- kotlinOptions.freeCompilerArgs = listOf(
- "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
- "-Xuse-experimental=kotlinx.coroutines.ObsoleteCoroutinesApi"
- )
- }
-}
-
tasks.register("copyExtraAssets", Copy::class) {
from("$repoRootPath/dist-assets")
include("relays.json")
@@ -186,7 +185,7 @@ tasks.create("printVersion") {
}
play {
- serviceAccountCredentials = file("play-api-key.json")
+ serviceAccountCredentials.set(file("play-api-key.json"))
}
dependencies {
@@ -229,6 +228,8 @@ dependencies {
// UI test dependencies
debugImplementation(Dependencies.AndroidX.fragmentTestning)
+ // Fixes: https://github.com/android/android-test/issues/1589
+ debugImplementation(Dependencies.AndroidX.testMonitor)
debugImplementation(Dependencies.Compose.testManifest)
androidTestImplementation(Dependencies.AndroidX.espressoContrib)
androidTestImplementation(Dependencies.AndroidX.espressoCore)
diff --git a/android/app/src/androidTest/AndroidManifest.xml b/android/app/src/androidTest/AndroidManifest.xml
index 41b8daf8c8..8d37c966e9 100644
--- a/android/app/src/androidTest/AndroidManifest.xml
+++ b/android/app/src/androidTest/AndroidManifest.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="net.mullvad.mullvadvpn.test">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Required on certain Android versions and/or ABIs
https://github.com/mockk/mockk/issues/297#issuecomment-641361770 -->
diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml
index 0eee767e98..2a866ff601 100644
--- a/android/app/src/debug/AndroidManifest.xml
+++ b/android/app/src/debug/AndroidManifest.xml
@@ -1,6 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- package="net.mullvad.mullvadvpn">
+ xmlns:tools="http://schemas.android.com/tools">
<application android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher"
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 279a6f1858..4671de2d88 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -1,6 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- package="net.mullvad.mullvadvpn">
+ xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.INTERNET" />
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt
index 52795f0964..89df8ac582 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt
@@ -9,7 +9,7 @@ import kotlinx.coroutines.async
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ClosedReceiveChannelException
import kotlinx.coroutines.channels.actor
-import kotlinx.coroutines.channels.sendBlocking
+import kotlinx.coroutines.channels.trySendBlocking
const val PROBLEM_REPORT_FILE = "problem_report.txt"
@@ -42,7 +42,7 @@ class MullvadProblemReport {
}
fun collect() {
- commandChannel.sendBlocking(Command.Collect())
+ commandChannel.trySendBlocking(Command.Collect())
}
suspend fun load(): String {
@@ -56,13 +56,13 @@ class MullvadProblemReport {
fun send(): Deferred<Boolean> {
val result = CompletableDeferred<Boolean>()
- commandChannel.sendBlocking(Command.Send(result))
+ commandChannel.trySendBlocking(Command.Send(result))
return result
}
fun deleteReportFile() {
- commandChannel.sendBlocking(Command.Delete())
+ commandChannel.trySendBlocking(Command.Delete())
}
private fun spawnActor() = GlobalScope.actor<Command>(Dispatchers.Default, Channel.UNLIMITED) {
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ipc/HandlerFlow.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ipc/HandlerFlow.kt
index 40cad5e5e1..de512c7cc4 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ipc/HandlerFlow.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ipc/HandlerFlow.kt
@@ -8,7 +8,7 @@ import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.InternalCoroutinesApi
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ClosedSendChannelException
-import kotlinx.coroutines.channels.sendBlocking
+import kotlinx.coroutines.channels.trySendBlocking
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.FlowCollector
import kotlinx.coroutines.flow.consumeAsFlow
@@ -30,7 +30,7 @@ class HandlerFlow<T>(
val extractedData = extractor(message)
try {
- channel.sendBlocking(extractedData)
+ channel.trySendBlocking(extractedData)
} catch (exception: Exception) {
when (exception) {
is ClosedSendChannelException, is CancellationException -> {
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/DaemonInstance.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/DaemonInstance.kt
index 8b900038fc..0d1750f625 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/DaemonInstance.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/DaemonInstance.kt
@@ -8,7 +8,7 @@ import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ClosedReceiveChannelException
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.channels.actor
-import kotlinx.coroutines.channels.sendBlocking
+import kotlinx.coroutines.channels.trySendBlocking
import net.mullvad.mullvadvpn.util.Intermittent
private const val RELAYS_FILE = "relays.json"
@@ -28,11 +28,11 @@ class DaemonInstance(val vpnService: MullvadVpnService) {
val intermittentDaemon = Intermittent<MullvadDaemon>()
fun start() {
- commandChannel.sendBlocking(Command.START)
+ commandChannel.trySendBlocking(Command.START)
}
fun stop() {
- commandChannel.sendBlocking(Command.STOP)
+ commandChannel.trySendBlocking(Command.STOP)
}
fun onDestroy() {
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt
index 0bf7e54606..f7a179a35e 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt
@@ -6,7 +6,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.actor
-import kotlinx.coroutines.channels.sendBlocking
+import kotlinx.coroutines.channels.trySendBlocking
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.onStart
import net.mullvad.mullvadvpn.model.DeviceState
@@ -33,7 +33,7 @@ class ForegroundNotificationManager(
private val tunnelStateNotification = TunnelStateNotification(service)
private var loggedIn by observable(false) { _, _, _ ->
- updater.sendBlocking(UpdaterMessage.UpdateAction())
+ updater.trySendBlocking(UpdaterMessage.UpdateAction())
}
private val tunnelState
@@ -46,12 +46,12 @@ class ForegroundNotificationManager(
private set
var lockedToForeground by observable(false) { _, _, _ ->
- updater.sendBlocking(UpdaterMessage.UpdateNotification())
+ updater.trySendBlocking(UpdaterMessage.UpdateNotification())
}
init {
connectionProxy.onStateChange.subscribe(this) { newState ->
- updater.sendBlocking(UpdaterMessage.NewTunnelState(newState))
+ updater.trySendBlocking(UpdaterMessage.NewTunnelState(newState))
}
intermittentDaemon.registerListener(this) { daemon ->
@@ -66,7 +66,7 @@ class ForegroundNotificationManager(
}
}
- updater.sendBlocking(UpdaterMessage.UpdateNotification())
+ updater.trySendBlocking(UpdaterMessage.UpdateNotification())
}
fun onDestroy() {
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt
index db8b2e99d2..b363dbbe5f 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt
@@ -5,7 +5,7 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ClosedReceiveChannelException
import kotlinx.coroutines.channels.actor
-import kotlinx.coroutines.channels.sendBlocking
+import kotlinx.coroutines.channels.trySendBlocking
import kotlinx.coroutines.flow.collect
import net.mullvad.mullvadvpn.ipc.Event
import net.mullvad.mullvadvpn.ipc.Request
@@ -64,17 +64,17 @@ class AccountCache(private val endpoint: ServiceEndpoint) {
endpoint.dispatcher.apply {
registerHandler(Request.CreateAccount::class) { _ ->
- commandChannel.sendBlocking(Command.CreateAccount)
+ commandChannel.trySendBlocking(Command.CreateAccount)
}
registerHandler(Request.Login::class) { request ->
request.account?.let { account ->
- commandChannel.sendBlocking(Command.Login(account))
+ commandChannel.trySendBlocking(Command.Login(account))
}
}
registerHandler(Request.Logout::class) { _ ->
- commandChannel.sendBlocking(Command.Logout)
+ commandChannel.trySendBlocking(Command.Logout)
}
registerHandler(Request.FetchAccountExpiry::class) { _ ->
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AuthTokenCache.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AuthTokenCache.kt
index 1ea2acec39..add7a7ed06 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AuthTokenCache.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AuthTokenCache.kt
@@ -6,7 +6,7 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ClosedReceiveChannelException
import kotlinx.coroutines.channels.actor
-import kotlinx.coroutines.channels.sendBlocking
+import kotlinx.coroutines.channels.trySendBlocking
import net.mullvad.mullvadvpn.ipc.Event
import net.mullvad.mullvadvpn.ipc.Request
@@ -27,7 +27,7 @@ class AuthTokenCache(endpoint: ServiceEndpoint) {
init {
endpoint.dispatcher.registerHandler(Request.FetchAuthToken::class) { _ ->
- requestQueue.sendBlocking(Command.Fetch)
+ requestQueue.trySendBlocking(Command.Fetch)
}
}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ConnectionProxy.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ConnectionProxy.kt
index 94cc9f05b8..03808dcb94 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ConnectionProxy.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ConnectionProxy.kt
@@ -5,7 +5,7 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ClosedReceiveChannelException
import kotlinx.coroutines.channels.actor
-import kotlinx.coroutines.channels.sendBlocking
+import kotlinx.coroutines.channels.trySendBlocking
import net.mullvad.mullvadvpn.ipc.Event
import net.mullvad.mullvadvpn.ipc.Request
import net.mullvad.mullvadvpn.model.TunnelState
@@ -46,15 +46,15 @@ class ConnectionProxy(val vpnPermission: VpnPermission, endpoint: ServiceEndpoin
}
fun connect() {
- commandChannel.sendBlocking(Command.CONNECT)
+ commandChannel.trySendBlocking(Command.CONNECT)
}
fun reconnect() {
- commandChannel.sendBlocking(Command.RECONNECT)
+ commandChannel.trySendBlocking(Command.RECONNECT)
}
fun disconnect() {
- commandChannel.sendBlocking(Command.DISCONNECT)
+ commandChannel.trySendBlocking(Command.DISCONNECT)
}
fun onDestroy() {
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/CustomDns.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/CustomDns.kt
index 7c22cef50c..b708e1b290 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/CustomDns.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/CustomDns.kt
@@ -6,7 +6,7 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ClosedReceiveChannelException
import kotlinx.coroutines.channels.actor
-import kotlinx.coroutines.channels.sendBlocking
+import kotlinx.coroutines.channels.trySendBlocking
import net.mullvad.mullvadvpn.ipc.Request
import net.mullvad.mullvadvpn.model.DnsOptions
@@ -37,21 +37,21 @@ class CustomDns(private val endpoint: ServiceEndpoint) {
endpoint.dispatcher.apply {
registerHandler(Request.AddCustomDnsServer::class) { request ->
- commandChannel.sendBlocking(Command.AddDnsServer(request.address))
+ commandChannel.trySendBlocking(Command.AddDnsServer(request.address))
}
registerHandler(Request.RemoveCustomDnsServer::class) { request ->
- commandChannel.sendBlocking(Command.RemoveDnsServer(request.address))
+ commandChannel.trySendBlocking(Command.RemoveDnsServer(request.address))
}
registerHandler(Request.ReplaceCustomDnsServer::class) { request ->
- commandChannel.sendBlocking(
+ commandChannel.trySendBlocking(
Command.ReplaceDnsServer(request.oldAddress, request.newAddress)
)
}
registerHandler(Request.SetEnableCustomDns::class) { request ->
- commandChannel.sendBlocking(Command.SetEnabled(request.enable))
+ commandChannel.trySendBlocking(Command.SetEnabled(request.enable))
}
}
}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/LocationInfoCache.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/LocationInfoCache.kt
index df769abad9..4fbc1fab4b 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/LocationInfoCache.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/LocationInfoCache.kt
@@ -7,7 +7,7 @@ import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ClosedReceiveChannelException
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.channels.actor
-import kotlinx.coroutines.channels.sendBlocking
+import kotlinx.coroutines.channels.trySendBlocking
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.flatMapLatest
@@ -51,12 +51,12 @@ class LocationInfoCache(private val endpoint: ServiceEndpoint) {
when (newState) {
is TunnelState.Disconnected -> {
location = lastKnownRealLocation
- fetchRequestChannel.sendBlocking(RequestFetch.ForRealLocation)
+ fetchRequestChannel.trySendBlocking(RequestFetch.ForRealLocation)
}
is TunnelState.Connecting -> location = newState.location
is TunnelState.Connected -> {
location = newState.location
- fetchRequestChannel.sendBlocking(RequestFetch.ForRelayLocation)
+ fetchRequestChannel.trySendBlocking(RequestFetch.ForRelayLocation)
}
is TunnelState.Disconnecting -> {
when (newState.actionAfterDisconnect) {
@@ -76,7 +76,7 @@ class LocationInfoCache(private val endpoint: ServiceEndpoint) {
endpoint.connectivityListener.connectivityNotifier.subscribe(this) { isConnected ->
if (isConnected && state is TunnelState.Disconnected) {
- fetchRequestChannel.sendBlocking(RequestFetch.ForRealLocation)
+ fetchRequestChannel.trySendBlocking(RequestFetch.ForRealLocation)
}
}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/RelayListListener.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/RelayListListener.kt
index a65c313f54..1f59de4074 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/RelayListListener.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/RelayListListener.kt
@@ -6,7 +6,7 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ClosedReceiveChannelException
import kotlinx.coroutines.channels.actor
-import kotlinx.coroutines.channels.sendBlocking
+import kotlinx.coroutines.channels.trySendBlocking
import net.mullvad.mullvadvpn.ipc.Event
import net.mullvad.mullvadvpn.ipc.Request
import net.mullvad.mullvadvpn.model.Constraint
@@ -27,7 +27,7 @@ class RelayListListener(endpoint: ServiceEndpoint) {
private val daemon = endpoint.intermittentDaemon
private var selectedRelayLocation by observable<LocationConstraint?>(null) { _, _, _ ->
- commandChannel.sendBlocking(Command.SetRelayLocation)
+ commandChannel.trySendBlocking(Command.SetRelayLocation)
}
var relayList by observable<RelayList?>(null) { _, _, relays ->
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ServiceEndpoint.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ServiceEndpoint.kt
index bf8cab7e5b..4868f80fd2 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ServiceEndpoint.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ServiceEndpoint.kt
@@ -10,7 +10,7 @@ import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ClosedReceiveChannelException
import kotlinx.coroutines.channels.SendChannel
import kotlinx.coroutines.channels.actor
-import kotlinx.coroutines.channels.sendBlocking
+import kotlinx.coroutines.channels.trySendBlocking
import net.mullvad.mullvadvpn.ipc.DispatchingHandler
import net.mullvad.mullvadvpn.ipc.Event
import net.mullvad.mullvadvpn.ipc.Request
@@ -62,11 +62,11 @@ class ServiceEndpoint(
init {
dispatcher.apply {
registerHandler(Request.RegisterListener::class) { request ->
- commands.sendBlocking(Command.RegisterListener(request.listener))
+ commands.trySendBlocking(Command.RegisterListener(request.listener))
}
registerHandler(Request.UnregisterListener::class) { request ->
- commands.sendBlocking(Command.UnregisterListener(request.listenerId))
+ commands.trySendBlocking(Command.UnregisterListener(request.listenerId))
}
}
}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/SettingsListener.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/SettingsListener.kt
index c39c64b862..b44daaf0d6 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/SettingsListener.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/SettingsListener.kt
@@ -5,7 +5,7 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ClosedReceiveChannelException
import kotlinx.coroutines.channels.actor
-import kotlinx.coroutines.channels.sendBlocking
+import kotlinx.coroutines.channels.trySendBlocking
import net.mullvad.mullvadvpn.ipc.Event
import net.mullvad.mullvadvpn.ipc.Request
import net.mullvad.mullvadvpn.model.DnsOptions
@@ -45,15 +45,15 @@ class SettingsListener(endpoint: ServiceEndpoint) {
endpoint.dispatcher.apply {
registerHandler(Request.SetAllowLan::class) { request ->
- commandChannel.sendBlocking(Command.SetAllowLan(request.allow))
+ commandChannel.trySendBlocking(Command.SetAllowLan(request.allow))
}
registerHandler(Request.SetAutoConnect::class) { request ->
- commandChannel.sendBlocking(Command.SetAutoConnect(request.autoConnect))
+ commandChannel.trySendBlocking(Command.SetAutoConnect(request.autoConnect))
}
registerHandler(Request.SetWireGuardMtu::class) { request ->
- commandChannel.sendBlocking(Command.SetWireGuardMtu(request.mtu))
+ commandChannel.trySendBlocking(Command.SetWireGuardMtu(request.mtu))
}
}
}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/VoucherRedeemer.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/VoucherRedeemer.kt
index 1c7465d700..c1433b7a3c 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/VoucherRedeemer.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/VoucherRedeemer.kt
@@ -5,7 +5,7 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ClosedReceiveChannelException
import kotlinx.coroutines.channels.actor
-import kotlinx.coroutines.channels.sendBlocking
+import kotlinx.coroutines.channels.trySendBlocking
import net.mullvad.mullvadvpn.ipc.Event
import net.mullvad.mullvadvpn.ipc.Request
@@ -17,7 +17,7 @@ class VoucherRedeemer(private val endpoint: ServiceEndpoint) {
init {
endpoint.dispatcher.registerHandler(Request.SubmitVoucher::class) { request ->
- voucherChannel.sendBlocking(request.voucher)
+ voucherChannel.trySendBlocking(request.voucher)
}
}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/ListItemsAdapter.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/ListItemsAdapter.kt
index fac7314534..a97f2af3d2 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/ListItemsAdapter.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/ListItemsAdapter.kt
@@ -44,7 +44,7 @@ class ListItemsAdapter : RecyclerView.Adapter<ListItemsAdapter.ViewHolder>() {
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
(holder.itemView as ListItemView).update(getItem(position))
- holder.itemView.listItemListener = listItemListener
+ (holder.itemView as ListItemView).listItemListener = listItemListener
}
override fun onViewRecycled(holder: ViewHolder) {
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/RedeemVoucherDialogFragment.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/RedeemVoucherDialogFragment.kt
index e12a9cdeef..f03cbf5d93 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/RedeemVoucherDialogFragment.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/RedeemVoucherDialogFragment.kt
@@ -141,6 +141,7 @@ class RedeemVoucherDialogFragment : DialogFragment() {
when (result) {
is VoucherSubmissionResult.Ok -> handleAddedTime(result.submission.timeAdded)
is VoucherSubmissionResult.Error -> showError(result.error)
+ else -> { /* NOOP */ }
}
}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragments/SplitTunnelingFragment.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragments/SplitTunnelingFragment.kt
index 494753845f..36ad3e1374 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragments/SplitTunnelingFragment.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragments/SplitTunnelingFragment.kt
@@ -53,8 +53,9 @@ class SplitTunnelingFragment : BaseFragment(R.layout.collapsed_title_layout) {
private val listItemListener = object : ListItemListener {
override fun onItemAction(item: ListItemData) {
when (item.widget) {
- is ImageState -> toggleExcludeChannel.offer(item)
- is SwitchState -> toggleSystemAppsVisibility.offer(!item.widget.isChecked)
+ is ImageState -> toggleExcludeChannel.trySend(item)
+ is SwitchState -> toggleSystemAppsVisibility.trySend(!item.widget.isChecked)
+ else -> { /* NOOP */ }
}
}
}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/RelayListListener.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/RelayListListener.kt
index 13c1c3dabe..aebe1f0a4f 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/RelayListListener.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/RelayListListener.kt
@@ -95,6 +95,7 @@ class RelayListListener(
return relayList?.findItemForLocation(location, true)
}
+ else -> { /* NOOP */ }
}
return null
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/FlowUtils.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/FlowUtils.kt
index de76ff5b0b..4d715a9aec 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/FlowUtils.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/FlowUtils.kt
@@ -20,7 +20,7 @@ import net.mullvad.mullvadvpn.ui.serviceconnection.ServiceConnectionState
import net.mullvad.talpid.util.EventNotifier
fun <T> SendChannel<T>.safeOffer(element: T): Boolean {
- return runCatching { offer(element) }.getOrDefault(false)
+ return runCatching { trySend(element).isSuccess }.getOrDefault(false)
}
fun Animation.transitionFinished(): Flow<Unit> = callbackFlow<Unit> {
diff --git a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/LoginViewModelTest.kt b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/LoginViewModelTest.kt
index c6ae770969..766ff818cb 100644
--- a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/LoginViewModelTest.kt
+++ b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/LoginViewModelTest.kt
@@ -1,6 +1,6 @@
package net.mullvad.mullvadvpn.viewmodel
-import app.cash.turbine.FlowTurbine
+import app.cash.turbine.ReceiveTurbine
import app.cash.turbine.test
import io.mockk.MockKAnnotations
import io.mockk.coEvery
@@ -173,7 +173,7 @@ class LoginViewModelTest {
verify { mockedAccountRepository.clearAccountHistory() }
}
- private suspend fun <T> FlowTurbine<T>.skipDefaultItem() where T : Any? {
+ private suspend fun <T> ReceiveTurbine<T>.skipDefaultItem() where T : Any? {
awaitItem()
}