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 05e7548b9f32..3c4315ecb95b 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 6d8dbf697fc7..000000000000 --- 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 e8888cc3cdbd..000000000000 --- 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 000000000000..09210ffa033e --- /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 6f148beea09e..3f7149b282a4 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 c753c13b36ae..57fd6dc40c98 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 83e2c970ece0..b6085221f176 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 f79d55a1d0af..a19358f95eba 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 5b327d91c2c7..2a51c4e0e7b5 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 9673b33e18d1..a26351162d02 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)