Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support running under build variant app ids #5184

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Loading