Fix ringing calls not stopping when the other user cancels the call (#4613)

* Fix ringing calls not being automatically canceled

This will keep the sync active while the user is screening an incoming call, allowing receiving a call cancellation event, which will terminate the incoming call ringing early.

* Add extra logs to help debugging ringing call issues.
This commit is contained in:
Jorge Martin Espinosa 2025-04-22 13:30:10 +02:00 committed by GitHub
parent 75cb3156a1
commit 3b35d96e1a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 112 additions and 17 deletions

View file

@ -17,6 +17,7 @@ import io.element.android.libraries.push.impl.R
import io.element.android.libraries.push.impl.notifications.model.NotifiableEvent
import io.element.android.libraries.push.impl.notifications.model.NotifiableRingingCallEvent
import io.element.android.services.toolbox.api.strings.StringProvider
import timber.log.Timber
import javax.inject.Inject
/**
@ -69,6 +70,9 @@ class DefaultCallNotificationEventResolver @Inject constructor(
senderAvatarUrl = senderAvatarUrl,
)
} else {
val now = System.currentTimeMillis()
val elapsed = now - timestamp
Timber.d("Event $eventId is call notify but should not ring: $timestamp vs $now ($elapsed ms elapsed), notify: ${content.type}")
// Create a simple message notification event
buildNotifiableMessageEvent(
sessionId = sessionId,

View file

@ -92,8 +92,9 @@ class DefaultNotifiableEventResolver @Inject constructor(
return notificationData.flatMap {
if (it == null) {
Timber.tag(loggerTag.value).d("No notification data found for event $eventId")
return@flatMap Result.failure(ResolvingException("Unable to resolve event"))
return@flatMap Result.failure(ResolvingException("Unable to resolve event $eventId"))
} else {
Timber.tag(loggerTag.value).d("Found notification item for $eventId")
it.asNotifiableEvent(client, sessionId)
}
}

View file

@ -133,10 +133,12 @@ class DefaultPushHandler @Inject constructor(
is ResolvedPushEvent.Event -> {
when (val notifiableEvent = resolvedPushEvent.notifiableEvent) {
is NotifiableRingingCallEvent -> {
Timber.tag(loggerTag.value).d("Notifiable event ${pushData.eventId} is ringing call: $notifiableEvent")
onNotifiableEventReceived.onNotifiableEventReceived(notifiableEvent)
handleRingingCallEvent(notifiableEvent)
}
else -> {
Timber.tag(loggerTag.value).d("Notifiable event ${pushData.eventId} is normal event: $notifiableEvent")
val userPushStore = userPushStoreFactory.getOrCreate(userId)
val areNotificationsEnabled = userPushStore.getNotificationEnabledForDevice().first()
if (areNotificationsEnabled) {