Фикс звонков
All checks were successful
Android Kernel Build / build (push) Successful in 19m36s

This commit is contained in:
2026-03-31 19:03:30 +05:00
parent 2ff1383b13
commit 20bef53869

View File

@@ -293,34 +293,19 @@ object CallManager {
private suspend fun handleSignalPacket(packet: PacketSignalPeer) {
breadcrumb("SIG: ${packet.signalType} from=${packet.src.take(8)}… phase=${_state.value.phase}")
val snapshot = _state.value
val currentPhase = snapshot.phase
val currentPeer = snapshot.peerPublicKey
when (packet.signalType) {
SignalType.END_CALL_BECAUSE_BUSY -> {
if (currentPhase == CallPhase.IDLE) {
breadcrumb("SIG: peer busy IGNORED — no active call")
return
}
breadcrumb("SIG: peer busy → reset")
resetSession(reason = "User is busy", notifyPeer = false)
return
}
SignalType.END_CALL_BECAUSE_PEER_DISCONNECTED -> {
if (currentPhase == CallPhase.IDLE) {
breadcrumb("SIG: peer disconnected IGNORED — no active call")
return
}
breadcrumb("SIG: peer disconnected → reset")
resetSession(reason = "Peer disconnected", notifyPeer = false)
return
}
SignalType.END_CALL -> {
if (currentPhase == CallPhase.IDLE) {
breadcrumb("SIG: END_CALL IGNORED — no active call")
return
}
breadcrumb("SIG: END_CALL → reset")
resetSession(reason = "Call ended", notifyPeer = false)
return
@@ -328,11 +313,8 @@ object CallManager {
else -> Unit
}
val currentPeer = _state.value.peerPublicKey
val src = packet.src.trim()
if (packet.signalType != SignalType.CALL && currentPhase == CallPhase.IDLE) {
breadcrumb("SIG: ${packet.signalType} IGNORED — no active session")
return
}
if (currentPeer.isNotBlank() && src.isNotBlank() && src != currentPeer && src != ownPublicKey) {
breadcrumb("SIG: IGNORED (src mismatch: expected=${currentPeer.take(8)}… got=${src.take(8)}…)")
return
@@ -376,7 +358,7 @@ object CallManager {
pending.peerPublicKey == incomingPeer
) {
breadcrumb("SIG: incoming timeout (${INCOMING_RING_TIMEOUT_MS}ms) → auto-decline")
resetSession(reason = "Incoming call timeout", notifyPeer = false)
declineIncomingCall()
}
}
}
@@ -395,7 +377,7 @@ object CallManager {
updateState {
it.copy(
phase = CallPhase.CONNECTING,
statusText = "Connecting"
statusText = "Connecting..."
)
}
ensurePeerConnectionAndOffer()
@@ -1292,19 +1274,7 @@ object CallManager {
}
private fun updateState(reducer: (CallUiState) -> CallUiState) {
_state.update { previous ->
val next = reducer(previous)
if (next.phase != CallPhase.IDLE && next.peerPublicKey.isBlank()) {
next.copy(
peerPublicKey = previous.peerPublicKey,
peerTitle = if (next.peerTitle.isBlank()) previous.peerTitle else next.peerTitle,
peerUsername =
if (next.peerUsername.isBlank()) previous.peerUsername else next.peerUsername
)
} else {
next
}
}
_state.update(reducer)
}
private fun ByteArray.toHex(): String = joinToString("") { "%02x".format(it) }