Fixed microphone not recording audio in background if SIP dialog doesn't reach Updating state

This commit is contained in:
Sylvain Berfini 2025-08-04 13:46:07 +02:00
parent a0c977c562
commit 10efb01ebc

View file

@ -204,27 +204,23 @@ class NotificationsManager
) )
showCallNotification(call, false) showCallNotification(call, false)
} }
Call.State.Connected, Call.State.Connected -> {
Call.State.StreamsRunning -> { if (call.dir == Call.Dir.Incoming) {
if (currentState == Call.State.Connected && call.dir == Call.Dir.Incoming) {
Log.i( Log.i(
"$TAG Connected call was incoming (so it was answered), removing incoming call notification" "$TAG Connected call was incoming (so it was answered), removing incoming call notification"
) )
removeIncomingCallNotification() removeIncomingCallNotification()
} }
Log.i(
if (currentState == Call.State.Connected || call.dir == Call.Dir.Incoming) { "$TAG Showing connected call notification for [${call.remoteAddress.asStringUriOnly()}]"
Log.i( )
"$TAG Showing connected call notification for [${call.remoteAddress.asStringUriOnly()}]" showCallNotification(call, false)
)
showCallNotification(call, false)
}
} }
Call.State.Updating -> { Call.State.StreamsRunning -> {
val notifiable = getNotifiableForCall(call) val notifiable = getNotifiableForCall(call)
if (notifiable.notificationId == currentInCallServiceNotificationId) { if (notifiable.notificationId == currentInCallServiceNotificationId) {
Log.i( Log.i(
"$TAG Update foreground Service type in case video was enabled/disabled since last time" "$TAG Update foreground service type in case video was enabled/disabled since last time"
) )
startInCallForegroundService(call) startInCallForegroundService(call)
} }
@ -853,7 +849,7 @@ class NotificationsManager
if (Compatibility.isPostNotificationsPermissionGranted(context)) { if (Compatibility.isPostNotificationsPermissionGranted(context)) {
Log.i( Log.i(
"$TAG Service found, starting it as foreground using notification ID [${notifiable.notificationId}] with type(s) [$mask]" "$TAG Service found, starting it as foreground using notification ID [${notifiable.notificationId}] with type(s) [${foregroundServiceTypeMaskToString(mask)}]($mask)"
) )
Compatibility.startServiceForeground( Compatibility.startServiceForeground(
service, service,
@ -1777,6 +1773,26 @@ class NotificationsManager
} }
} }
@AnyThread
fun foregroundServiceTypeMaskToString(mask: Int): String {
var stringBuilder = StringBuilder()
val values = hashMapOf(
"PHONE_CALL" to Compatibility.FOREGROUND_SERVICE_TYPE_PHONE_CALL,
"MICROPHONE" to Compatibility.FOREGROUND_SERVICE_TYPE_MICROPHONE,
"CAMERA" to Compatibility.FOREGROUND_SERVICE_TYPE_CAMERA,
"SPECIAL_USE" to Compatibility.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
)
for ((key, value) in values) {
if (mask and value == value) {
if (stringBuilder.isNotEmpty()) {
stringBuilder.append(" & ")
}
stringBuilder.append(key)
}
}
return stringBuilder.toString()
}
class Notifiable(val notificationId: Int) { class Notifiable(val notificationId: Int) {
var myself: String? = null var myself: String? = null