summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-10-28 18:32:21 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-10-28 18:34:44 +0000
commitcab3ea22597900b0d4f853a5ae4b68d76bb02117 (patch)
tree4df76d3b4b63315a28c71ced4b0f0b4c5d3c2c8b
parent5d8e026c1cf2bdb80ea03c62adfb6823397f6576 (diff)
downloadmullvadvpn-cab3ea22597900b0d4f853a5ae4b68d76bb02117.tar.xz
mullvadvpn-cab3ea22597900b0d4f853a5ae4b68d76bb02117.zip
Synchronize updates to the notification
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt26
1 files changed, 15 insertions, 11 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 b415f052eb..1114ecef27 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt
@@ -92,7 +92,9 @@ class ForegroundNotificationManager(
// on the foreground. With such request, when the service is started it must be placed on
// the foreground with a call to startForeground before a timeout expires, otherwise Android
// kills the app.
- showOnForeground()
+ synchronized(this) {
+ showOnForeground()
+ }
// Restore the notification to its correct state.
updateNotification()
@@ -108,17 +110,19 @@ class ForegroundNotificationManager(
}
private fun updateNotification() {
- if (shouldBeOnForeground != onForeground) {
- if (shouldBeOnForeground) {
- showOnForeground()
- } else if (!shouldBeOnForeground) {
- if (Build.VERSION.SDK_INT >= 24) {
- service.stopForeground(Service.STOP_FOREGROUND_DETACH)
- } else {
- service.stopForeground(false)
- }
+ synchronized(this) {
+ if (shouldBeOnForeground != onForeground) {
+ if (shouldBeOnForeground) {
+ showOnForeground()
+ } else if (!shouldBeOnForeground) {
+ if (Build.VERSION.SDK_INT >= 24) {
+ service.stopForeground(Service.STOP_FOREGROUND_DETACH)
+ } else {
+ service.stopForeground(false)
+ }
- onForeground = false
+ onForeground = false
+ }
}
}
}