Notify of ringing call when there's an active call (#3003)

* Add `CallNotificationEventResolver` to be able to force the new ringing notification to be non-ringing given an existing ringing one.
This commit is contained in:
Jorge Martin Espinosa 2024-06-10 17:03:06 +02:00 committed by GitHub
parent 02d6fa7a92
commit f07ec61ecc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 232 additions and 81 deletions

View file

@ -89,6 +89,7 @@ class DefaultActiveCallManager @Inject constructor(
override fun registerIncomingCall(notificationData: CallNotificationData) {
if (activeCall.value != null) {
displayMissedCallNotification(notificationData)
Timber.w("Already have an active call, ignoring incoming call: $notificationData")
return
}
@ -99,7 +100,6 @@ class DefaultActiveCallManager @Inject constructor(
)
timedOutCallJob = coroutineScope.launch {
registerIncomingCall(notificationData)
showIncomingCallNotification(notificationData)
// Wait for the call to end
@ -115,13 +115,7 @@ class DefaultActiveCallManager @Inject constructor(
cancelIncomingCallNotification()
coroutineScope.launch {
onMissedCallNotificationHandler.addMissedCallNotification(
sessionId = previousActiveCall.sessionId,
roomId = previousActiveCall.roomId,
eventId = notificationData.eventId,
)
}
displayMissedCallNotification(notificationData)
}
override fun hungUpCall() {
@ -174,6 +168,16 @@ class DefaultActiveCallManager @Inject constructor(
private fun cancelIncomingCallNotification() {
notificationManagerCompat.cancel(NotificationIdProvider.getForegroundServiceNotificationId(ForegroundServiceType.INCOMING_CALL))
}
private fun displayMissedCallNotification(notificationData: CallNotificationData) {
coroutineScope.launch {
onMissedCallNotificationHandler.addMissedCallNotification(
sessionId = notificationData.sessionId,
roomId = notificationData.roomId,
eventId = notificationData.eventId,
)
}
}
}
/**