summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
authorAlbin <albin@mullvad.net>2023-09-07 09:26:05 +0200
committerAlbin <albin@mullvad.net>2023-09-22 13:20:14 +0200
commit84f6868ca47d00c04e0923fbb7ca2e7482c34ceb (patch)
tree8f82b7a549a43d5ab7fc952d47c2df647c3a07bf /android
parent990b5f8df1a79a441fe3910470822538a8e4e476 (diff)
downloadmullvadvpn-84f6868ca47d00c04e0923fbb7ca2e7482c34ceb.tar.xz
mullvadvpn-84f6868ca47d00c04e0923fbb7ca2e7482c34ceb.zip
Support running under build variant app ids
Diffstat (limited to 'android')
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/UiModule.kt2
-rw-r--r--android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/constant/Actions.kt5
-rw-r--r--android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/constant/Classes.kt5
-rw-r--r--android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/constant/ClassesAndActions.kt14
-rw-r--r--android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt3
-rw-r--r--android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/VpnPermission.kt3
-rw-r--r--android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/AccountExpiryNotification.kt3
-rw-r--r--android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/TunnelStateNotification.kt5
-rw-r--r--android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/MullvadTileService.kt3
-rw-r--r--android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/ServiceConnection.kt3
10 files changed, 22 insertions, 24 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/UiModule.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/UiModule.kt
index 05e7548b9f..3c4315ecb9 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/UiModule.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/UiModule.kt
@@ -89,4 +89,4 @@ val uiModule = module {
}
const val SELF_PACKAGE_NAME = "SELF_PACKAGE_NAME"
-const val APP_PREFERENCES_NAME = "net.mullvad.mullvadvpn.app_preferences"
+const val APP_PREFERENCES_NAME = "${BuildConfig.APPLICATION_ID}.app_preferences"
diff --git a/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/constant/Actions.kt b/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/constant/Actions.kt
deleted file mode 100644
index 6d8dbf697f..0000000000
--- a/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/constant/Actions.kt
+++ /dev/null
@@ -1,5 +0,0 @@
-package net.mullvad.mullvadvpn.lib.common.constant
-
-const val KEY_CONNECT_ACTION = "$MULLVAD_PACKAGE_NAME.connect_action"
-const val KEY_DISCONNECT_ACTION = "$MULLVAD_PACKAGE_NAME.disconnect_action"
-const val KEY_QUIT_ACTION = "$MULLVAD_PACKAGE_NAME.quit_action"
diff --git a/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/constant/Classes.kt b/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/constant/Classes.kt
deleted file mode 100644
index e8888cc3cd..0000000000
--- a/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/constant/Classes.kt
+++ /dev/null
@@ -1,5 +0,0 @@
-package net.mullvad.mullvadvpn.lib.common.constant
-
-const val MULLVAD_PACKAGE_NAME = "net.mullvad.mullvadvpn"
-const val MAIN_ACTIVITY_CLASS = "$MULLVAD_PACKAGE_NAME.ui.MainActivity"
-const val VPN_SERVICE_CLASS = "$MULLVAD_PACKAGE_NAME.service.MullvadVpnService"
diff --git a/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/constant/ClassesAndActions.kt b/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/constant/ClassesAndActions.kt
new file mode 100644
index 0000000000..09210ffa03
--- /dev/null
+++ b/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/constant/ClassesAndActions.kt
@@ -0,0 +1,14 @@
+package net.mullvad.mullvadvpn.lib.common.constant
+
+// Do not use in cases where the application id is expected since the application id will differ
+// between different builds.
+private const val MULLVAD_PACKAGE_NAME = "net.mullvad.mullvadvpn"
+
+// Classes
+const val MAIN_ACTIVITY_CLASS = "$MULLVAD_PACKAGE_NAME.ui.MainActivity"
+const val VPN_SERVICE_CLASS = "$MULLVAD_PACKAGE_NAME.service.MullvadVpnService"
+
+// Actions
+const val KEY_CONNECT_ACTION = "$MULLVAD_PACKAGE_NAME.connect_action"
+const val KEY_DISCONNECT_ACTION = "$MULLVAD_PACKAGE_NAME.disconnect_action"
+const val KEY_QUIT_ACTION = "$MULLVAD_PACKAGE_NAME.quit_action"
diff --git a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt
index 6f148beea0..3f7149b282 100644
--- a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt
+++ b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt
@@ -16,7 +16,6 @@ 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.common.constant.KEY_QUIT_ACTION
import net.mullvad.mullvadvpn.lib.common.constant.MAIN_ACTIVITY_CLASS
-import net.mullvad.mullvadvpn.lib.common.constant.MULLVAD_PACKAGE_NAME
import net.mullvad.mullvadvpn.lib.endpoint.ApiEndpointConfiguration
import net.mullvad.mullvadvpn.lib.endpoint.DefaultApiEndpointConfiguration
import net.mullvad.mullvadvpn.lib.endpoint.getApiEndpointConfigurationExtras
@@ -267,7 +266,7 @@ class MullvadVpnService : TalpidVpnService() {
private fun openUi() {
val intent =
Intent().apply {
- setClassName(MULLVAD_PACKAGE_NAME, MAIN_ACTIVITY_CLASS)
+ setClassName(applicationContext.packageName, MAIN_ACTIVITY_CLASS)
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
}
diff --git a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/VpnPermission.kt b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/VpnPermission.kt
index c753c13b36..57fd6dc40c 100644
--- a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/VpnPermission.kt
+++ b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/VpnPermission.kt
@@ -4,7 +4,6 @@ import android.content.Context
import android.content.Intent
import android.net.VpnService
import net.mullvad.mullvadvpn.lib.common.constant.MAIN_ACTIVITY_CLASS
-import net.mullvad.mullvadvpn.lib.common.constant.MULLVAD_PACKAGE_NAME
import net.mullvad.mullvadvpn.lib.common.util.Intermittent
import net.mullvad.mullvadvpn.lib.ipc.Event
import net.mullvad.mullvadvpn.lib.ipc.Request
@@ -30,7 +29,7 @@ class VpnPermission(private val context: Context, private val endpoint: ServiceE
} else {
val activityIntent =
Intent().apply {
- setClassName(MULLVAD_PACKAGE_NAME, MAIN_ACTIVITY_CLASS)
+ setClassName(context.packageName, MAIN_ACTIVITY_CLASS)
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
}
diff --git a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/AccountExpiryNotification.kt b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/AccountExpiryNotification.kt
index 83e2c970ec..b6085221f1 100644
--- a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/AccountExpiryNotification.kt
+++ b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/AccountExpiryNotification.kt
@@ -11,7 +11,6 @@ import androidx.core.app.NotificationCompat
import kotlin.properties.Delegates.observable
import kotlinx.coroutines.delay
import net.mullvad.mullvadvpn.lib.common.constant.MAIN_ACTIVITY_CLASS
-import net.mullvad.mullvadvpn.lib.common.constant.MULLVAD_PACKAGE_NAME
import net.mullvad.mullvadvpn.lib.common.util.Intermittent
import net.mullvad.mullvadvpn.lib.common.util.JobTracker
import net.mullvad.mullvadvpn.lib.common.util.SdkUtils
@@ -106,7 +105,7 @@ class AccountExpiryNotification(
val intent =
if (IS_PLAY_BUILD) {
Intent().apply {
- setClassName(MULLVAD_PACKAGE_NAME, MAIN_ACTIVITY_CLASS)
+ setClassName(context.packageName, MAIN_ACTIVITY_CLASS)
flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP
action = Intent.ACTION_MAIN
}
diff --git a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/TunnelStateNotification.kt b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/TunnelStateNotification.kt
index f79d55a1d0..a19358f95e 100644
--- a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/TunnelStateNotification.kt
+++ b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/TunnelStateNotification.kt
@@ -9,7 +9,6 @@ import android.content.Intent
import androidx.core.app.NotificationCompat
import kotlin.properties.Delegates.observable
import net.mullvad.mullvadvpn.lib.common.constant.MAIN_ACTIVITY_CLASS
-import net.mullvad.mullvadvpn.lib.common.constant.MULLVAD_PACKAGE_NAME
import net.mullvad.mullvadvpn.lib.common.util.SdkUtils
import net.mullvad.mullvadvpn.lib.common.util.SdkUtils.isNotificationPermissionGranted
import net.mullvad.mullvadvpn.lib.common.util.getErrorNotificationResources
@@ -115,7 +114,7 @@ class TunnelStateNotification(val context: Context) {
fun build(): Notification {
val intent =
Intent().apply {
- setClassName(MULLVAD_PACKAGE_NAME, MAIN_ACTIVITY_CLASS)
+ setClassName(context.packageName, MAIN_ACTIVITY_CLASS)
flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP
action = Intent.ACTION_MAIN
}
@@ -139,7 +138,7 @@ class TunnelStateNotification(val context: Context) {
private fun buildAction(): NotificationCompat.Action {
val action = TunnelStateNotificationAction.from(tunnelState)
val label = context.getString(action.text)
- val intent = Intent(action.key).setPackage(MULLVAD_PACKAGE_NAME)
+ val intent = Intent(action.key).setPackage(context.packageName)
val pendingIntent =
PendingIntent.getForegroundService(
context,
diff --git a/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/MullvadTileService.kt b/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/MullvadTileService.kt
index 5b327d91c2..2a51c4e0e7 100644
--- a/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/MullvadTileService.kt
+++ b/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/MullvadTileService.kt
@@ -17,7 +17,6 @@ import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeoutOrNull
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.common.constant.MULLVAD_PACKAGE_NAME
import net.mullvad.mullvadvpn.lib.common.constant.VPN_SERVICE_CLASS
import net.mullvad.mullvadvpn.lib.common.util.SdkUtils.setSubtitleIfSupported
import net.mullvad.mullvadvpn.model.ServiceResult
@@ -78,7 +77,7 @@ class MullvadTileService : TileService() {
private fun toggleTunnel() {
val intent =
Intent().apply {
- setClassName(MULLVAD_PACKAGE_NAME, VPN_SERVICE_CLASS)
+ setClassName(applicationContext.packageName, VPN_SERVICE_CLASS)
action =
if (qsTile.state == Tile.STATE_INACTIVE) {
KEY_CONNECT_ACTION
diff --git a/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/ServiceConnection.kt b/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/ServiceConnection.kt
index 9673b33e18..a26351162d 100644
--- a/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/ServiceConnection.kt
+++ b/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/ServiceConnection.kt
@@ -23,7 +23,6 @@ import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
-import net.mullvad.mullvadvpn.lib.common.constant.MULLVAD_PACKAGE_NAME
import net.mullvad.mullvadvpn.lib.common.constant.VPN_SERVICE_CLASS
import net.mullvad.mullvadvpn.lib.common.util.DispatchingFlow
import net.mullvad.mullvadvpn.lib.common.util.bindServiceFlow
@@ -81,7 +80,7 @@ class ServiceConnection(context: Context, scope: CoroutineScope) {
}
private suspend fun connect(context: Context) {
- val intent = Intent().apply { setClassName(MULLVAD_PACKAGE_NAME, VPN_SERVICE_CLASS) }
+ val intent = Intent().apply { setClassName(context.packageName, VPN_SERVICE_CLASS) }
context
.bindServiceFlow(intent)