summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-05-09 19:14:36 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-05-11 12:54:16 +0000
commit08fb72d28d60f866478be3eb8df2ea8aebff4554 (patch)
tree279e7be55e147d34bc6e640bef4b8e683c2ecfc0 /android
parent89c02c5d9534afeaeae957471ad00a56e2f8184c (diff)
downloadmullvadvpn-08fb72d28d60f866478be3eb8df2ea8aebff4554.tar.xz
mullvadvpn-08fb72d28d60f866478be3eb8df2ea8aebff4554.zip
Skip using `serviceInstance` property
Diffstat (limited to 'android')
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt33
1 files changed, 13 insertions, 20 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 1a6d19e3a0..c376a726aa 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt
@@ -30,34 +30,27 @@ class ForegroundNotificationManager(
service.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
private val listenerId = serviceNotifier.subscribe { newServiceInstance ->
- serviceInstance = newServiceInstance
+ connectionProxy = newServiceInstance?.connectionProxy
}
- private var serviceInstance: ServiceInstance? = null
+ private val badgeColor = service.resources.getColor(R.color.colorPrimary)
+
+ private var connectionListenerId: Int? = null
+ private var connectionProxy: ConnectionProxy? = null
set(value) {
- synchronized(this) {
- if (value != null) {
- connectionProxy = value.connectionProxy.apply {
- connectionListenerId = onStateChange.subscribe { state ->
- tunnelState = state
- }
- }
- } else {
- connectionProxy = null
- connectionListenerId?.let { listenerId ->
- field?.connectionProxy?.onStateChange?.unsubscribe(listenerId)
- }
+ if (field != value) {
+ connectionListenerId?.let { listenerId ->
+ field?.onStateChange?.unsubscribe(listenerId)
+ }
+
+ connectionListenerId = value?.onStateChange?.subscribe { state ->
+ tunnelState = state
}
field = value
}
}
- 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
private var showingReconnecting = false
@@ -197,7 +190,7 @@ class ForegroundNotificationManager(
fun onDestroy() {
serviceNotifier.unsubscribe(listenerId)
- serviceInstance = null
+ connectionProxy = null
service.apply {
unregisterReceiver(connectReceiver)