diff options
Diffstat (limited to 'android/src/main')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt | 15 | ||||
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt | 2 |
2 files changed, 8 insertions, 9 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt index b8839811e1..b352db1fce 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt @@ -39,10 +39,13 @@ class ForegroundNotificationManager( set(value) { synchronized(this) { if (value != null) { - connectionListenerId = value.connectionProxy.onStateChange.subscribe { state -> - tunnelState = state + connectionProxy = value.connectionProxy.apply { + onStateChange.subscribe { state -> + tunnelState = state + } } } else { + connectionProxy = null connectionListenerId?.let { listenerId -> field?.connectionProxy?.onStateChange?.unsubscribe(listenerId) } @@ -55,6 +58,7 @@ class ForegroundNotificationManager( private val badgeColor = service.resources.getColor(R.color.colorPrimary) private var connectionListenerId: Int? = null + private var connectionProxy: ConnectionProxy? = null private var onForeground = false private var reconnecting = false @@ -153,19 +157,16 @@ class ForegroundNotificationManager( private val connectReceiver = object : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { - onConnect?.invoke() + connectionProxy?.connect() } } private val disconnectReceiver = object : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { - onDisconnect?.invoke() + connectionProxy?.disconnect() } } - var onConnect: (() -> Unit)? = null - var onDisconnect: (() -> Unit)? = null - var loggedIn = false set(value) { field = value diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt index 37c728a391..524d2e1876 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt @@ -121,8 +121,6 @@ class MullvadVpnService : TalpidVpnService() { private fun startNotificationManager(): ForegroundNotificationManager { return ForegroundNotificationManager(this, serviceNotifier).apply { - onConnect = { connectionProxy.connect() } - onDisconnect = { connectionProxy.disconnect() } lockedToForeground = isBound } } |
