diff options
| author | Albin <albin@mullvad.net> | 2022-06-22 09:02:51 +0200 |
|---|---|---|
| committer | Albin <albin@mullvad.net> | 2022-06-22 11:57:30 +0200 |
| commit | 11d4e72a137aaf7ed25e0311f629a8886e84a69c (patch) | |
| tree | 335584981ad9f1e7cfc8afb17b25732c7daa52f0 /android/app | |
| parent | 9287066b92977c251c96a62270f826e93935b1b5 (diff) | |
| download | mullvadvpn-11d4e72a137aaf7ed25e0311f629a8886e84a69c.tar.xz mullvadvpn-11d4e72a137aaf7ed25e0311f629a8886e84a69c.zip | |
Fix notification action
Diffstat (limited to 'android/app')
| -rw-r--r-- | android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt | 18 | ||||
| -rw-r--r-- | android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt | 6 |
2 files changed, 22 insertions, 2 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt index 2509ff1b99..e98646d34f 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt @@ -7,13 +7,18 @@ import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.actor import kotlinx.coroutines.channels.sendBlocking +import kotlinx.coroutines.flow.collect +import net.mullvad.mullvadvpn.model.DeviceState import net.mullvad.mullvadvpn.model.TunnelState import net.mullvad.mullvadvpn.service.endpoint.ConnectionProxy import net.mullvad.mullvadvpn.service.notifications.TunnelStateNotification +import net.mullvad.mullvadvpn.util.Intermittent +import net.mullvad.mullvadvpn.util.JobTracker class ForegroundNotificationManager( val service: MullvadVpnService, - val connectionProxy: ConnectionProxy + val connectionProxy: ConnectionProxy, + val intermittentDaemon: Intermittent<MullvadDaemon> ) { private sealed class UpdaterMessage { class UpdateNotification : UpdaterMessage() @@ -21,6 +26,7 @@ class ForegroundNotificationManager( class NewTunnelState(val newState: TunnelState) : UpdaterMessage() } + private val jobTracker = JobTracker() private val updater = runUpdater() private val tunnelStateNotification = TunnelStateNotification(service) @@ -47,10 +53,20 @@ class ForegroundNotificationManager( updater.sendBlocking(UpdaterMessage.NewTunnelState(newState)) } + intermittentDaemon.registerListener(this) { daemon -> + jobTracker.newBackgroundJob("notificationLoggedInJob") { + daemon?.deviceStateUpdates?.collect { deviceState -> + loggedIn = deviceState is DeviceState.LoggedIn + } + } + } + updater.sendBlocking(UpdaterMessage.UpdateNotification()) } fun onDestroy() { + jobTracker.cancelAllJobs() + intermittentDaemon.unregisterListener(this) connectionProxy.onStateChange.unsubscribe(this) updater.close() } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt index 83029983d8..9ff1e9f6a5 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt @@ -82,7 +82,11 @@ class MullvadVpnService : TalpidVpnService() { connectionProxy.reconnect() } - notificationManager = ForegroundNotificationManager(this, connectionProxy) + notificationManager = ForegroundNotificationManager( + this, + connectionProxy, + daemonInstance.intermittentDaemon + ) accountExpiryNotification = AccountExpiryNotification( this, |
