Skip to content

Commit

Permalink
Use call config (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
liviu-timar committed Jan 15, 2025
1 parent c0ddbe6 commit 8b3afc7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -139,6 +143,7 @@ internal class TelecomHandler private constructor(
calls[call.cid] = TelecomCall(
streamCall = call,
state = TelecomCallState.IDLE,
config = callConfig,
parentScope = telecomHandlerScope,
)

Expand Down Expand Up @@ -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"
Expand All @@ -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 -> {
Expand All @@ -261,7 +267,7 @@ internal class TelecomHandler private constructor(
NotificationManagerCompat
.from(applicationContext)
.notify(telecomCall.notificationId, it)
}
} ?: cancelNotification(telecomCall.notificationId)
}
}
}
Expand Down Expand Up @@ -323,6 +329,7 @@ internal class TelecomHandler private constructor(
private class TelecomCall(
val streamCall: StreamCall,
var state: TelecomCallState,
val config: CallServiceConfig,
val parentScope: CoroutineScope,
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ internal object TelecomCompat {
checkTelecomSupport(
context = context,
onSupported = { telecomHandler ->
telecomHandler.registerCall(streamCall, isIncomingCall)
telecomHandler.registerCall(streamCall, callConfig, isIncomingCall)
},
onNotSupported = {
if (isIncomingCall) {
Expand Down

0 comments on commit 8b3afc7

Please sign in to comment.