Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package io.getstream.video.android.core

import android.app.Notification
import android.os.Bundle
import android.util.Log
import androidx.compose.runtime.Stable
import androidx.core.app.NotificationManagerCompat
import io.getstream.android.video.generated.models.BlockedUserEvent
Expand Down Expand Up @@ -742,6 +741,7 @@ public class CallState(
}

internal var incomingNotificationData = IncomingNotificationData(emptyMap())
private val ringingLogger by taggedLogger("RingingState")

fun handleEvent(event: VideoEvent) {
logger.d { "[handleEvent] ${event::class.java.name.split(".").last()}" }
Expand Down Expand Up @@ -852,10 +852,11 @@ public class CallState(
}

is CallEndedEvent -> {
call.state.cancelTimeout()
cancelTimeout()
updateFromResponse(event.call)
_endedAt.value = OffsetDateTime.now(Clock.systemUTC())
_endedByUser.value = event.user?.toUser()
updateRingingState()
call.leave("CallEndedEvent")
}

Expand Down Expand Up @@ -1274,8 +1275,9 @@ public class CallState(
val userIsParticipant =
_session.value?.participants?.find { it.user.id == client.userId } != null
val outgoingMembersCount = _members.value.filter { it.value.user.id != client.userId }.size
val isCallEnded: Boolean = _endedAt.value != null

Log.d("RingingState", "Current: ${_ringingState.value}, call_id: ${call.cid}")
ringingLogger.d { "Current: ${_ringingState.value}, call_id: ${call.cid}" }

val ringingStateLogs = arrayListOf(
("acceptedByMe: $isAcceptedByMe"),
Expand All @@ -1284,17 +1286,18 @@ public class CallState(
("hasActiveCall: $hasActiveCall"),
("hasRingingCall: $hasRingingCall"),
("userIsParticipant: $userIsParticipant"),
("isCallEnded: $isCallEnded"),
).joinToString("") { it + "\n" }

Log.d(
"RingingState",
"call_id: ${call.cid}, Flags: $ringingStateLogs",
)
ringingLogger.d { "call_id: ${call.cid}, Flags: $ringingStateLogs" }

// no members - call is empty, we can join
val state: RingingState = if (hasActiveCall && !ringingStateUpdatesStopped) {
cancelTimeout()
RingingState.Active
} else if (hasRingingCall && isCallEnded) {
cancelTimeout()
RingingState.RejectedByAll
} else if (isRejectedByMe) {
call.leave("updateRingingState-rejected-self")
cancelTimeout()
Expand All @@ -1321,7 +1324,7 @@ public class CallState(
}
} else if (hasRingingCall && createdBy?.id == client.userId) {
// The call is created by us
logger.d { "acceptedBy: $acceptedBy, userIsParticipant: $userIsParticipant" }
ringingLogger.d { "acceptedBy: $acceptedBy, userIsParticipant: $userIsParticipant" }
if (acceptedBy.isEmpty()) {
// no one accepted the call
RingingState.Outgoing(acceptedByCallee = false)
Expand All @@ -1343,7 +1346,7 @@ public class CallState(
}

if (_ringingState.value != state) {
logger.d { "Updating ringing state ${_ringingState.value} -> $state" }
ringingLogger.d { "Updating ringing state ${_ringingState.value} -> $state" }

// handle the auto-cancel for outgoing ringing calls
if (state is RingingState.Outgoing && !state.acceptedByCallee) {
Expand All @@ -1356,7 +1359,7 @@ public class CallState(

// stop the call ringing timer if it's running
}
Log.d("RingingState", "Update: $state")
ringingLogger.d { "Update: $state" }

_ringingState.value = state
}
Expand Down
Loading