From 8b3afc7e1ab452c52ce0eaf9aa452da0031cd909 Mon Sep 17 00:00:00 2001 From: Liviu Timar <65943217+liviu-timar@users.noreply.github.com> Date: Wed, 15 Jan 2025 17:51:21 +0200 Subject: [PATCH] Use call config (wip) --- .../android/core/telecom/TelecomHandler.kt | 21 ++++++++++++------- .../android/core/telecom/TelecomUtils.kt | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/telecom/TelecomHandler.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/telecom/TelecomHandler.kt index d6c110b7e9..fc9bcb633e 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/telecom/TelecomHandler.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/telecom/TelecomHandler.kt @@ -126,7 +126,11 @@ internal class TelecomHandler private constructor( streamVideo = StreamVideo.instanceOrNull() } - fun registerCall(call: StreamCall, wasTriggeredByIncomingNotification: Boolean = false) { + fun registerCall( + call: StreamCall, + callConfig: CallServiceConfig, + wasTriggeredByIncomingNotification: Boolean = false, + ) { logger.d { "[registerCall] Call ID: ${call.id}, wasTriggeredByIncomingNotification: $wasTriggeredByIncomingNotification" } @@ -139,6 +143,7 @@ internal class TelecomHandler private constructor( calls[call.cid] = TelecomCall( streamCall = call, state = TelecomCallState.IDLE, + config = callConfig, parentScope = telecomHandlerScope, ) @@ -228,6 +233,12 @@ internal class TelecomHandler private constructor( TelecomCallState.OUTGOING, TelecomCallState.ONGOING -> { val isOutgoingCall = telecomCall.state == TelecomCallState.OUTGOING + val getNotification = { + streamVideo.getOngoingCallNotification( + callId = StreamCallId.fromCallCid(telecomCall.streamCall.cid), + isOutgoingCall = isOutgoingCall, + ) + } logger.d { "[postNotification] Creating ${if (isOutgoingCall) "outgoing" else "ongoing"} notification" @@ -242,11 +253,6 @@ internal class TelecomHandler private constructor( callSoundPlayer.stopCallSound() if (telecomCall.config.runCallServiceInForeground) getNotification() else null } - - streamVideo.getOngoingCallNotification( - callId = StreamCallId.fromCallCid(telecomCall.streamCall.cid), - isOutgoingCall = isOutgoingCall, - ) } else -> { @@ -261,7 +267,7 @@ internal class TelecomHandler private constructor( NotificationManagerCompat .from(applicationContext) .notify(telecomCall.notificationId, it) - } + } ?: cancelNotification(telecomCall.notificationId) } } } @@ -323,6 +329,7 @@ internal class TelecomHandler private constructor( private class TelecomCall( val streamCall: StreamCall, var state: TelecomCallState, + val config: CallServiceConfig, val parentScope: CoroutineScope, ) { diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/telecom/TelecomUtils.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/telecom/TelecomUtils.kt index be15b97b50..f918be16d3 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/telecom/TelecomUtils.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/telecom/TelecomUtils.kt @@ -48,7 +48,7 @@ internal object TelecomCompat { checkTelecomSupport( context = context, onSupported = { telecomHandler -> - telecomHandler.registerCall(streamCall, isIncomingCall) + telecomHandler.registerCall(streamCall, callConfig, isIncomingCall) }, onNotSupported = { if (isIncomingCall) {