summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-02-06 14:44:29 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-02-12 14:29:14 +0000
commit1ad8e20979dd56db0463a79a0010a6fae67b5080 (patch)
treee071e01cbbf5fbfa58eb59aba04ff771facd490d
parentd801c911c17fc239b49cbe067f492fd733721fc3 (diff)
downloadmullvadvpn-1ad8e20979dd56db0463a79a0010a6fae67b5080.tar.xz
mullvadvpn-1ad8e20979dd56db0463a79a0010a6fae67b5080.zip
Keep notification mgr. for whole service lifetime
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt16
1 files changed, 3 insertions, 13 deletions
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 656f48af3e..f41a3a510c 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt
@@ -32,14 +32,12 @@ class MullvadVpnService : TalpidVpnService() {
private var isBound = false
set(value) {
field = value
-
- if (this::notificationManager.isInitialized) {
- notificationManager.lockedToForeground = value
- }
+ notificationManager.lockedToForeground = value
}
override fun onCreate() {
super.onCreate()
+ notificationManager = ForegroundNotificationManager(this, serviceNotifier)
setUp()
}
@@ -70,6 +68,7 @@ class MullvadVpnService : TalpidVpnService() {
override fun onDestroy() {
tearDown()
+ notificationManager.onDestroy()
super.onDestroy()
}
@@ -93,7 +92,6 @@ class MullvadVpnService : TalpidVpnService() {
private fun setUp() {
daemon = startDaemon()
connectionProxy = ConnectionProxy(this, daemon)
- notificationManager = startNotificationManager()
}
private fun startDaemon() = GlobalScope.async(Dispatchers.Default) {
@@ -118,12 +116,6 @@ class MullvadVpnService : TalpidVpnService() {
daemon
}
- private fun startNotificationManager(): ForegroundNotificationManager {
- return ForegroundNotificationManager(this, serviceNotifier).apply {
- lockedToForeground = isBound
- }
- }
-
private fun stop() {
isStopping = true
stopDaemon()
@@ -140,9 +132,7 @@ class MullvadVpnService : TalpidVpnService() {
private fun tearDown() {
stopDaemon()
-
connectionProxy.onDestroy()
- notificationManager.onDestroy()
}
private fun restart() {