diff options
| author | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2024-12-10 22:57:56 +0100 |
|---|---|---|
| committer | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2024-12-13 09:50:40 +0100 |
| commit | b95e54a41dfa3e5932e9385adbfe1209eafb45bc (patch) | |
| tree | 9d4e473a61bb533df272290e30519777dafc8218 /android/app/src | |
| parent | 271ab4a7347e6d6319b4741cc827896d72462e4b (diff) | |
| download | mullvadvpn-b95e54a41dfa3e5932e9385adbfe1209eafb45bc.tar.xz mullvadvpn-b95e54a41dfa3e5932e9385adbfe1209eafb45bc.zip | |
Replace intentholder with api override intent holder
Diffstat (limited to 'android/app/src')
| -rw-r--r-- | android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/AppModule.kt | 4 | ||||
| -rw-r--r-- | android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt | 25 |
2 files changed, 15 insertions, 14 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/AppModule.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/AppModule.kt index 9c52677dce..d7a1bfc8cb 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/AppModule.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/AppModule.kt @@ -6,7 +6,7 @@ import net.mullvad.mullvadvpn.BuildConfig import net.mullvad.mullvadvpn.lib.common.constant.GRPC_SOCKET_FILE_NAME import net.mullvad.mullvadvpn.lib.common.constant.GRPC_SOCKET_FILE_NAMED_ARGUMENT import net.mullvad.mullvadvpn.lib.daemon.grpc.ManagementService -import net.mullvad.mullvadvpn.lib.intent.IntentProvider +import net.mullvad.mullvadvpn.lib.endpoint.ApiEndpointFromIntentHolder import net.mullvad.mullvadvpn.lib.model.BuildVersion import net.mullvad.mullvadvpn.lib.shared.AccountRepository import net.mullvad.mullvadvpn.lib.shared.ConnectionProxy @@ -33,7 +33,7 @@ val appModule = module { single { PrepareVpnUseCase(androidContext()) } single { BuildVersion(BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE) } - single { IntentProvider() } + single { ApiEndpointFromIntentHolder() } single { AccountRepository(get(), get(), MainScope()) } single { DeviceRepository(get()) } single { ConnectionProxy(get(), get(), get()) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt index 134816417f..4007b09ecd 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt @@ -13,6 +13,7 @@ import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle import arrow.core.merge +import co.touchlab.kermit.Logger import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.flow.filter @@ -27,7 +28,8 @@ import net.mullvad.mullvadvpn.lib.common.util.SdkUtils.requestNotificationPermis import net.mullvad.mullvadvpn.lib.common.util.prepareVpnSafe import net.mullvad.mullvadvpn.lib.daemon.grpc.GrpcConnectivityState import net.mullvad.mullvadvpn.lib.daemon.grpc.ManagementService -import net.mullvad.mullvadvpn.lib.intent.IntentProvider +import net.mullvad.mullvadvpn.lib.endpoint.ApiEndpointFromIntentHolder +import net.mullvad.mullvadvpn.lib.endpoint.getApiEndpointConfigurationExtras import net.mullvad.mullvadvpn.lib.model.PrepareError import net.mullvad.mullvadvpn.lib.model.Prepared import net.mullvad.mullvadvpn.lib.theme.AppTheme @@ -51,7 +53,7 @@ class MainActivity : ComponentActivity(), AndroidScopeComponent { private val launchVpnPermission = registerForActivityResult(CreateVpnProfile()) { _ -> mullvadAppViewModel.connect() } - private val intentProvider by inject<IntentProvider>() + private val apiEndpointFromIntentHolder by inject<ApiEndpointFromIntentHolder>() private val mullvadAppViewModel by inject<MullvadAppViewModel>() private val privacyDisclaimerRepository by inject<PrivacyDisclaimerRepository>() private val serviceConnectionManager by inject<ServiceConnectionManager>() @@ -84,7 +86,7 @@ class MainActivity : ComponentActivity(), AndroidScopeComponent { window.decorView.filterTouchesWhenObscured = true // Needs to be before we start the service, since we need to access the intent there - setUpIntentListener() + lifecycleScope.launch { intents().collect(::handleIntent) } // We use lifecycleScope here to get less start service in background exceptions // Se this article for more information: @@ -129,15 +131,14 @@ class MainActivity : ComponentActivity(), AndroidScopeComponent { super.onDestroy() } - private fun setUpIntentListener() { - lifecycleScope.launch { - intents().collect { - if (it.action == KEY_REQUEST_VPN_PROFILE) { - handleRequestVpnProfileIntent() - } else { - intentProvider.setStartIntent(it) - } - } + private fun handleIntent(intent: Intent) { + when (val action = intent.action) { + Intent.ACTION_MAIN -> + apiEndpointFromIntentHolder.setApiEndpointOverride( + intent.getApiEndpointConfigurationExtras() + ) + KEY_REQUEST_VPN_PROFILE -> handleRequestVpnProfileIntent() + else -> Logger.w("Unhandled intent action: $action") } } |
