From 8e66a7b153838d5ffab1a89098de868575dca928 Mon Sep 17 00:00:00 2001 From: Oussama Hassine Date: Wed, 27 Nov 2024 16:58:03 +0100 Subject: [PATCH] fix: set Foreground Service Behavior IMMEDIATE (WPB-5512) (#3666) --- .../com/wire/android/notification/CallNotificationManager.kt | 3 +++ .../com/wire/android/services/PersistentWebSocketService.kt | 1 + 2 files changed, 4 insertions(+) diff --git a/app/src/main/kotlin/com/wire/android/notification/CallNotificationManager.kt b/app/src/main/kotlin/com/wire/android/notification/CallNotificationManager.kt index aebd67bb1ed..a01b02beea0 100644 --- a/app/src/main/kotlin/com/wire/android/notification/CallNotificationManager.kt +++ b/app/src/main/kotlin/com/wire/android/notification/CallNotificationManager.kt @@ -23,6 +23,7 @@ import android.app.Notification import android.content.Context import android.service.notification.StatusBarNotification import androidx.core.app.NotificationCompat +import androidx.core.app.NotificationCompat.FOREGROUND_SERVICE_IMMEDIATE import androidx.core.app.NotificationManagerCompat import com.wire.android.R import com.wire.android.appLogger @@ -199,6 +200,7 @@ class CallNotificationBuilder @Inject constructor( .setOngoing(true) .setSilent(true) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) + .setForegroundServiceBehavior(FOREGROUND_SERVICE_IMMEDIATE) .addAction(getHangUpCallAction(context, conversationIdString, userIdString)) .setFullScreenIntent(outgoingCallPendingIntent(context, conversationIdString), true) .setContentIntent(outgoingCallPendingIntent(context, conversationIdString)) @@ -254,6 +256,7 @@ class CallNotificationBuilder @Inject constructor( .setAutoCancel(true) .setOngoing(true) .setUsesChronometer(true) + .setForegroundServiceBehavior(FOREGROUND_SERVICE_IMMEDIATE) .addAction(getHangUpCallAction(context, conversationIdString, userIdString)) .addAction(getOpenOngoingCallAction(context, conversationIdString)) .setFullScreenIntent(openOngoingCallPendingIntent(context, conversationIdString), true) diff --git a/app/src/main/kotlin/com/wire/android/services/PersistentWebSocketService.kt b/app/src/main/kotlin/com/wire/android/services/PersistentWebSocketService.kt index 75087eaeac7..4d2f5c4c5f4 100644 --- a/app/src/main/kotlin/com/wire/android/services/PersistentWebSocketService.kt +++ b/app/src/main/kotlin/com/wire/android/services/PersistentWebSocketService.kt @@ -129,6 +129,7 @@ class PersistentWebSocketService : Service() { .setSmallIcon(R.drawable.websocket_notification_icon_small) .setContentIntent(openAppPendingIntent(this)) .setCategory(NotificationCompat.CATEGORY_SERVICE) + .setForegroundServiceBehavior(NotificationCompat.FOREGROUND_SERVICE_IMMEDIATE) .setAutoCancel(false) .setOngoing(true) .build()