diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index bb94520cb1d..06161091c12 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -39,6 +39,7 @@
+
@@ -320,8 +321,7 @@
-
+ android:foregroundServiceType="phoneCall|microphone" />
diff --git a/app/src/main/kotlin/com/wire/android/notification/WireNotificationManager.kt b/app/src/main/kotlin/com/wire/android/notification/WireNotificationManager.kt
index 56588ef4118..7bf369a96ff 100644
--- a/app/src/main/kotlin/com/wire/android/notification/WireNotificationManager.kt
+++ b/app/src/main/kotlin/com/wire/android/notification/WireNotificationManager.kt
@@ -18,6 +18,7 @@
package com.wire.android.notification
+import android.os.Build
import androidx.annotation.VisibleForTesting
import com.wire.android.R
import com.wire.android.appLogger
@@ -399,7 +400,7 @@ class WireNotificationManager @Inject constructor(
private suspend fun observeOngoingCalls(currentScreenState: StateFlow) {
currentScreenState
.flatMapLatest { currentScreen ->
- if (currentScreen !is CurrentScreen.InBackground) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE && currentScreen !is CurrentScreen.InBackground) {
flowOf(null)
} else {
coreLogic.getGlobalScope().session.currentSessionFlow()
diff --git a/app/src/main/kotlin/com/wire/android/services/OngoingCallService.kt b/app/src/main/kotlin/com/wire/android/services/OngoingCallService.kt
index 1baf0f220a1..d0810c4bb44 100644
--- a/app/src/main/kotlin/com/wire/android/services/OngoingCallService.kt
+++ b/app/src/main/kotlin/com/wire/android/services/OngoingCallService.kt
@@ -22,6 +22,7 @@ import android.app.Notification
import android.app.Service
import android.content.Context
import android.content.Intent
+import android.content.pm.ServiceInfo
import android.os.IBinder
import com.wire.android.appLogger
import com.wire.android.di.KaliumCoreLogic
@@ -47,6 +48,7 @@ import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
import java.util.concurrent.atomic.AtomicReference
import javax.inject.Inject
+import androidx.core.app.ServiceCompat
@AndroidEntryPoint
class OngoingCallService : Service() {
@@ -131,17 +133,38 @@ class OngoingCallService : Service() {
scope.cancel()
}
- private fun generateForegroundNotification(callName: String, conversationId: String, userId: UserId) {
+ private fun generateForegroundNotification(
+ callName: String,
+ conversationId: String,
+ userId: UserId
+ ) {
appLogger.i("$TAG: generating foregroundNotification...")
- val notification: Notification = callNotificationManager.builder.getOngoingCallNotification(callName, conversationId, userId)
- startForeground(CALL_ONGOING_NOTIFICATION_ID, notification)
+ val notification: Notification = callNotificationManager.builder.getOngoingCallNotification(
+ callName,
+ conversationId,
+ userId
+ )
+ ServiceCompat.startForeground(
+ this,
+ CALL_ONGOING_NOTIFICATION_ID,
+ notification,
+ ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL or ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE
+ )
+
appLogger.i("$TAG: started foreground with proper notification")
}
private fun generatePlaceholderForegroundNotification() {
appLogger.i("$TAG: generating foregroundNotification placeholder...")
- val notification: Notification = callNotificationManager.builder.getOngoingCallPlaceholderNotification()
- startForeground(CALL_ONGOING_NOTIFICATION_ID, notification)
+ val notification: Notification =
+ callNotificationManager.builder.getOngoingCallPlaceholderNotification()
+ ServiceCompat.startForeground(
+ this,
+ CALL_ONGOING_NOTIFICATION_ID,
+ notification,
+ ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL or ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE
+ )
+
appLogger.i("$TAG: started foreground with placeholder notification")
}