diff options
Diffstat (limited to 'android')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/TunnelStateNotification.kt | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/TunnelStateNotification.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/TunnelStateNotification.kt index 7f95cf5b39..de384379cf 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/TunnelStateNotification.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/TunnelStateNotification.kt @@ -10,6 +10,7 @@ import android.support.v4.app.NotificationCompat import kotlin.properties.Delegates.observable import net.mullvad.mullvadvpn.R import net.mullvad.mullvadvpn.model.TunnelState +import net.mullvad.mullvadvpn.service.MullvadVpnService import net.mullvad.mullvadvpn.ui.MainActivity import net.mullvad.talpid.tunnel.ActionAfterDisconnect @@ -90,13 +91,15 @@ class TunnelStateNotification(val context: Context) { val pendingIntent = PendingIntent.getActivity(context, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT) + val deleteIntent = buildDeleteIntent() + val actions = if (showAction) { listOf(buildAction()) } else { emptyList() } - return channel.buildNotification(pendingIntent, notificationText, actions) + return channel.buildNotification(pendingIntent, notificationText, actions, deleteIntent) } private fun buildAction(): NotificationCompat.Action { @@ -114,4 +117,15 @@ class TunnelStateNotification(val context: Context) { return NotificationCompat.Action(action.icon, label, pendingIntent) } + + private fun buildDeleteIntent(): PendingIntent { + val intent = Intent(MullvadVpnService.KEY_QUIT_ACTION).setPackage("net.mullvad.mullvadvpn") + val flags = PendingIntent.FLAG_UPDATE_CURRENT + + if (Build.VERSION.SDK_INT >= 26) { + return PendingIntent.getForegroundService(context, 1, intent, flags) + } else { + return PendingIntent.getService(context, 1, intent, flags) + } + } } |
