WIP: Support using Element Call for voice calls in DMs

This commit is contained in:
Valere 2026-01-12 10:48:20 +01:00 committed by Benoit Marty
parent 66c3bf267a
commit ec420332c3
26 changed files with 122 additions and 42 deletions

View file

@ -16,6 +16,7 @@ interface CallWidgetSettingsProvider {
widgetId: String = UUID.randomUUID().toString(),
encrypted: Boolean,
direct: Boolean,
voiceOnly: Boolean,
hasActiveCall: Boolean,
): MatrixWidgetSettings
}

View file

@ -30,7 +30,14 @@ class DefaultCallWidgetSettingsProvider(
private val callAnalyticsCredentialsProvider: CallAnalyticCredentialsProvider,
private val analyticsService: AnalyticsService,
) : CallWidgetSettingsProvider {
override suspend fun provide(baseUrl: String, widgetId: String, encrypted: Boolean, direct: Boolean, hasActiveCall: Boolean): MatrixWidgetSettings {
override suspend fun provide(
baseUrl: String,
widgetId: String,
encrypted: Boolean,
direct: Boolean,
voiceOnly: Boolean,
hasActiveCall: Boolean
): MatrixWidgetSettings {
val isAnalyticsEnabled = analyticsService.userConsentFlow.first()
val properties = VirtualElementCallWidgetProperties(
elementCallUrl = baseUrl,
@ -47,14 +54,18 @@ class DefaultCallWidgetSettingsProvider(
parentUrl = null,
)
val config = VirtualElementCallWidgetConfig(
// TODO remove this once we have the next EC version
preload = false,
// TODO remove this once we have the next EC version
skipLobby = null,
// // TODO remove this once we have the next EC version
// preload = false,
// // TODO remove this once we have the next EC version
// skipLobby = null,
intent = when {
direct && hasActiveCall -> CallIntent.JOIN_EXISTING_DM
direct && hasActiveCall -> {
if (voiceOnly) CallIntent.JOIN_EXISTING_DM_VOICE else CallIntent.JOIN_EXISTING_DM
}
hasActiveCall -> CallIntent.JOIN_EXISTING
direct -> CallIntent.START_CALL_DM
direct -> {
if (voiceOnly) CallIntent.START_CALL_DM_VOICE else CallIntent.START_CALL_DM
}
else -> CallIntent.START_CALL
}.also {
Timber.d("Starting/joining call with intent: $it")

View file

@ -12,7 +12,14 @@ import io.element.android.libraries.matrix.api.widget.CallWidgetSettingsProvider
import io.element.android.libraries.matrix.api.widget.MatrixWidgetSettings
class FakeCallWidgetSettingsProvider(
private val provideFn: (String, String, Boolean, Boolean, Boolean) -> MatrixWidgetSettings = { _, _, _, _, _ -> MatrixWidgetSettings("id", true, "url") }
private val provideFn: (
String,
String,
Boolean,
Boolean,
Boolean,
Boolean
) -> MatrixWidgetSettings = { _, _, _, _, _, _ -> MatrixWidgetSettings("id", true, "url") }
) : CallWidgetSettingsProvider {
val providedBaseUrls = mutableListOf<String>()
@ -21,9 +28,10 @@ class FakeCallWidgetSettingsProvider(
widgetId: String,
encrypted: Boolean,
direct: Boolean,
voiceOnly: Boolean,
hasActiveCall: Boolean
): MatrixWidgetSettings {
providedBaseUrls += baseUrl
return provideFn(baseUrl, widgetId, encrypted, direct, hasActiveCall)
return provideFn(baseUrl, widgetId, encrypted, direct, voiceOnly, hasActiveCall)
}
}

View file

@ -300,7 +300,12 @@ class DefaultPushHandler(
private suspend fun handleRingingCallEvent(notifiableEvent: NotifiableRingingCallEvent) {
Timber.i("## handleInternal() : Incoming call.")
elementCallEntryPoint.handleIncomingCall(
callType = CallType.RoomCall(notifiableEvent.sessionId, notifiableEvent.roomId),
callType = CallType.RoomCall(
notifiableEvent.sessionId,
notifiableEvent.roomId,
// TODO
voiceIntent = false
),
eventId = notifiableEvent.eventId,
senderId = notifiableEvent.senderId,
roomName = notifiableEvent.roomName,