Skip to content

Commit

Permalink
Replace intentholder with api override intent holder
Browse files Browse the repository at this point in the history
  • Loading branch information
Pururun committed Dec 12, 2024
1 parent 9ca7f7e commit 9b64645
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 64 deletions.
1 change: 0 additions & 1 deletion android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ dependencies {
implementation(projects.lib.common)
implementation(projects.lib.daemonGrpc)
implementation(projects.lib.endpoint)
implementation(projects.lib.intentProvider)
implementation(projects.lib.map)
implementation(projects.lib.model)
implementation(projects.lib.payment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ 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.model.PrepareError
import net.mullvad.mullvadvpn.lib.model.Prepared
import net.mullvad.mullvadvpn.lib.theme.AppTheme
Expand All @@ -51,7 +51,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>()
Expand Down Expand Up @@ -135,7 +135,7 @@ class MainActivity : ComponentActivity(), AndroidScopeComponent {
if (it.action == KEY_REQUEST_VPN_PROFILE) {
handleRequestVpnProfileIntent()
} else {
intentProvider.setStartIntent(it)
apiEndpointFromIntentHolder.handleIntent(it)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package net.mullvad.mullvadvpn.lib.endpoint

import android.content.Intent

class ApiEndpointFromIntentHolder {
var apiEndpointOverride: ApiEndpointOverride? = null
private set

fun handleIntent(intent: Intent) {
apiEndpointOverride = intent.getApiEndpointConfigurationExtras()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package net.mullvad.mullvadvpn.lib.endpoint

import android.content.Intent

// Overridding the API endpoint is not supported in release builds
class ApiEndpointFromIntentHolder {
val apiEndpointOverride: ApiEndpointOverride? = null

fun handleIntent(intent: Intent) {
// No-op
}
}
35 changes: 0 additions & 35 deletions android/lib/intent-provider/build.gradle.kts

This file was deleted.

1 change: 0 additions & 1 deletion android/lib/intent-provider/src/main/AndroidManifest.xml

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion android/service/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ dependencies {
implementation(projects.lib.common)
implementation(projects.lib.daemonGrpc)
implementation(projects.lib.endpoint)
implementation(projects.lib.intentProvider)
implementation(projects.lib.model)
implementation(projects.lib.shared)
implementation(projects.lib.talpid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import kotlinx.coroutines.runBlocking
import net.mullvad.mullvadvpn.lib.common.constant.KEY_CONNECT_ACTION
import net.mullvad.mullvadvpn.lib.common.constant.KEY_DISCONNECT_ACTION
import net.mullvad.mullvadvpn.lib.daemon.grpc.ManagementService
import net.mullvad.mullvadvpn.lib.endpoint.getApiEndpointConfigurationExtras
import net.mullvad.mullvadvpn.lib.intent.IntentProvider
import net.mullvad.mullvadvpn.lib.endpoint.ApiEndpointFromIntentHolder
import net.mullvad.mullvadvpn.lib.model.TunnelState
import net.mullvad.mullvadvpn.lib.shared.ConnectionProxy
import net.mullvad.mullvadvpn.service.di.vpnServiceModule
Expand All @@ -39,7 +38,7 @@ class MullvadVpnService : TalpidVpnService() {

private lateinit var managementService: ManagementService
private lateinit var migrateSplitTunneling: MigrateSplitTunneling
private lateinit var intentProvider: IntentProvider
private lateinit var apiEndpointFromIntentHolder: ApiEndpointFromIntentHolder
private lateinit var connectionProxy: ConnectionProxy
private lateinit var daemonConfig: DaemonConfig

Expand All @@ -66,7 +65,7 @@ class MullvadVpnService : TalpidVpnService() {

daemonConfig = get()
migrateSplitTunneling = get()
intentProvider = get()
apiEndpointFromIntentHolder = get()
connectionProxy = get()
}

Expand All @@ -77,8 +76,7 @@ class MullvadVpnService : TalpidVpnService() {

// If it is a debug build and we have an api override in the intent, use it
// This is for injecting hostname and port for our mock api tests
val intentApiOverride =
intentProvider.getLatestIntent()?.getApiEndpointConfigurationExtras()
val intentApiOverride = apiEndpointFromIntentHolder.apiEndpointOverride
val updatedConfig =
if (BuildConfig.DEBUG && intentApiOverride != null) {
daemonConfig.copy(apiEndpointOverride = intentApiOverride)
Expand Down
1 change: 0 additions & 1 deletion android/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ include(
":lib:common-test",
":lib:daemon-grpc",
":lib:endpoint",
":lib:intent-provider",
":lib:map",
":lib:model",
":lib:payment",
Expand Down

0 comments on commit 9b64645

Please sign in to comment.