spotless: fix formatting violations in call lifecycle files
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+8
-2
@@ -166,11 +166,17 @@ class CallForegroundService : Service() {
|
||||
runBlocking {
|
||||
withTimeoutOrNull(3_000L) {
|
||||
when (state) {
|
||||
is CallState.IncomingCall -> manager.rejectCall()
|
||||
is CallState.IncomingCall -> {
|
||||
manager.rejectCall()
|
||||
}
|
||||
|
||||
is CallState.Offering,
|
||||
is CallState.Connecting,
|
||||
is CallState.Connected,
|
||||
-> manager.hangup()
|
||||
-> {
|
||||
manager.hangup()
|
||||
}
|
||||
|
||||
else -> { /* nothing to do */ }
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -176,6 +176,7 @@ object CallNotifier {
|
||||
) {
|
||||
val callerUser = LocalCache.getOrCreateUser(callerPubKey)
|
||||
val callerName = callerUser.toBestDisplayName()
|
||||
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val uri = "nostr:${callerPubKey.hexToByteArray().toNpub()}"
|
||||
|
||||
|
||||
@@ -248,22 +248,26 @@ class CallActivity : AppCompatActivity() {
|
||||
// Best-effort on a detached scope. If the process
|
||||
// dies before completion, the remote 60s timeout
|
||||
// or our 65s watchdog handles it.
|
||||
kotlinx.coroutines.CoroutineScope(
|
||||
kotlinx.coroutines.SupervisorJob() + kotlinx.coroutines.Dispatchers.Main.immediate,
|
||||
).launch {
|
||||
manager.rejectCall()
|
||||
}
|
||||
kotlinx.coroutines
|
||||
.CoroutineScope(
|
||||
kotlinx.coroutines.SupervisorJob() + kotlinx.coroutines.Dispatchers.Main.immediate,
|
||||
).launch {
|
||||
manager.rejectCall()
|
||||
}
|
||||
}
|
||||
|
||||
is CallState.Offering,
|
||||
is CallState.Connecting,
|
||||
is CallState.Connected,
|
||||
-> {
|
||||
kotlinx.coroutines.CoroutineScope(
|
||||
kotlinx.coroutines.SupervisorJob() + kotlinx.coroutines.Dispatchers.Main.immediate,
|
||||
).launch {
|
||||
manager.hangup()
|
||||
}
|
||||
kotlinx.coroutines
|
||||
.CoroutineScope(
|
||||
kotlinx.coroutines.SupervisorJob() + kotlinx.coroutines.Dispatchers.Main.immediate,
|
||||
).launch {
|
||||
manager.hangup()
|
||||
}
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,6 +113,7 @@ class CallSession(
|
||||
val isBluetoothAvailable: StateFlow<Boolean> = audioManager.isBluetoothAvailable
|
||||
|
||||
@Volatile private var videoPausedByProximity = false
|
||||
|
||||
@Volatile private var closed = false
|
||||
|
||||
@Volatile private var foregroundServiceStarted = false
|
||||
@@ -147,16 +148,25 @@ class CallSession(
|
||||
callManager.sessionEvents.collect { event ->
|
||||
if (closed) return@collect
|
||||
when (event) {
|
||||
is com.vitorpamplona.amethyst.commons.call.CallSessionEvent.AnswerReceived ->
|
||||
is com.vitorpamplona.amethyst.commons.call.CallSessionEvent.AnswerReceived -> {
|
||||
onCallAnswerReceived(event.event.pubKey, event.event.sdpAnswer())
|
||||
is com.vitorpamplona.amethyst.commons.call.CallSessionEvent.IceCandidateReceived ->
|
||||
}
|
||||
|
||||
is com.vitorpamplona.amethyst.commons.call.CallSessionEvent.IceCandidateReceived -> {
|
||||
onIceCandidateReceived(event.event)
|
||||
is com.vitorpamplona.amethyst.commons.call.CallSessionEvent.NewPeerInGroupCall ->
|
||||
}
|
||||
|
||||
is com.vitorpamplona.amethyst.commons.call.CallSessionEvent.NewPeerInGroupCall -> {
|
||||
onNewPeerInGroupCall(event.peerPubKey)
|
||||
is com.vitorpamplona.amethyst.commons.call.CallSessionEvent.MidCallOfferReceived ->
|
||||
}
|
||||
|
||||
is com.vitorpamplona.amethyst.commons.call.CallSessionEvent.MidCallOfferReceived -> {
|
||||
onMidCallOfferReceived(event.peerPubKey, event.sdpOffer)
|
||||
is com.vitorpamplona.amethyst.commons.call.CallSessionEvent.PeerLeft ->
|
||||
}
|
||||
|
||||
is com.vitorpamplona.amethyst.commons.call.CallSessionEvent.PeerLeft -> {
|
||||
disposePeerSession(event.peerPubKey)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import com.vitorpamplona.amethyst.R
|
||||
import com.vitorpamplona.amethyst.commons.call.CallState
|
||||
|
||||
import com.vitorpamplona.amethyst.service.crashreports.DisplayCrashMessages
|
||||
import com.vitorpamplona.amethyst.service.relayClient.notifyCommand.compose.DisplayNotifyMessages
|
||||
import com.vitorpamplona.amethyst.ui.actions.NewUserMetadataScreen
|
||||
|
||||
-1
@@ -67,7 +67,6 @@ import com.vitorpamplona.amethyst.model.privacyOptions.RoleBasedHttpClientBuilde
|
||||
import com.vitorpamplona.amethyst.service.OnlineChecker
|
||||
import com.vitorpamplona.amethyst.service.ZapPaymentHandler
|
||||
import com.vitorpamplona.amethyst.service.broadcast.BroadcastTracker
|
||||
|
||||
import com.vitorpamplona.amethyst.service.cashu.CashuToken
|
||||
import com.vitorpamplona.amethyst.service.cashu.melt.MeltProcessor
|
||||
import com.vitorpamplona.amethyst.service.checkNotInMainThread
|
||||
|
||||
+2
-1
@@ -95,11 +95,12 @@ class CallManager(
|
||||
private val _sessionEvents = MutableSharedFlow<CallSessionEvent>(extraBufferCapacity = 256)
|
||||
val sessionEvents: SharedFlow<CallSessionEvent> = _sessionEvents.asSharedFlow()
|
||||
|
||||
/**
|
||||
/*
|
||||
* Renegotiation offers from remote peers. Separate from [sessionEvents]
|
||||
* because renegotiation has its own glare-resolution logic in
|
||||
* CallSession and benefits from a dedicated collector.
|
||||
*/
|
||||
|
||||
/** Emits a session event, logging a warning if the buffer overflows. */
|
||||
private fun emitSessionEvent(event: CallSessionEvent) {
|
||||
if (!emitSessionEvent(event)) {
|
||||
|
||||
+16
-5
@@ -31,17 +31,28 @@ import com.vitorpamplona.quartz.nipACWebRtcCalls.events.CallIceCandidateEvent
|
||||
*/
|
||||
sealed interface CallSessionEvent {
|
||||
/** A peer answered our offer (or we received an answer in a group call). */
|
||||
data class AnswerReceived(val event: CallAnswerEvent) : CallSessionEvent
|
||||
data class AnswerReceived(
|
||||
val event: CallAnswerEvent,
|
||||
) : CallSessionEvent
|
||||
|
||||
/** An ICE candidate arrived from a peer. */
|
||||
data class IceCandidateReceived(val event: CallIceCandidateEvent) : CallSessionEvent
|
||||
data class IceCandidateReceived(
|
||||
val event: CallIceCandidateEvent,
|
||||
) : CallSessionEvent
|
||||
|
||||
/** A new peer joined the group call and needs callee-to-callee mesh setup. */
|
||||
data class NewPeerInGroupCall(val peerPubKey: HexKey) : CallSessionEvent
|
||||
data class NewPeerInGroupCall(
|
||||
val peerPubKey: HexKey,
|
||||
) : CallSessionEvent
|
||||
|
||||
/** A mid-call offer arrived from another callee in a group call. */
|
||||
data class MidCallOfferReceived(val peerPubKey: HexKey, val sdpOffer: String) : CallSessionEvent
|
||||
data class MidCallOfferReceived(
|
||||
val peerPubKey: HexKey,
|
||||
val sdpOffer: String,
|
||||
) : CallSessionEvent
|
||||
|
||||
/** A peer left the call (hangup/reject/timeout) but the call continues. */
|
||||
data class PeerLeft(val peerPubKey: HexKey) : CallSessionEvent
|
||||
data class PeerLeft(
|
||||
val peerPubKey: HexKey,
|
||||
) : CallSessionEvent
|
||||
}
|
||||
|
||||
+12
-2
@@ -1167,7 +1167,12 @@ class CallManagerTest {
|
||||
assertIs<CallState.Connected>(state)
|
||||
assertTrue(carol in state.peerPubKeys, "Mid-call joiner must be added to peerPubKeys")
|
||||
assertTrue(alice in state.peerPubKeys, "Existing peer must still be present")
|
||||
val forwardedPeer = events.filterIsInstance<CallSessionEvent.AnswerReceived>().firstOrNull()?.event?.pubKey
|
||||
val forwardedPeer =
|
||||
events
|
||||
.filterIsInstance<CallSessionEvent.AnswerReceived>()
|
||||
.firstOrNull()
|
||||
?.event
|
||||
?.pubKey
|
||||
assertEquals(carol, forwardedPeer, "Answer must still be emitted to CallSession")
|
||||
job.cancel()
|
||||
}
|
||||
@@ -1318,7 +1323,12 @@ class CallManagerTest {
|
||||
val bobAfterCarolAnswer = bobManager.state.value
|
||||
assertIs<CallState.Connected>(bobAfterCarolAnswer)
|
||||
assertTrue(carol in bobAfterCarolAnswer.peerPubKeys, "Bob should add Carol to his membership")
|
||||
val bobForwardedAnswer = bobEvents.filterIsInstance<CallSessionEvent.AnswerReceived>().firstOrNull()?.event?.pubKey
|
||||
val bobForwardedAnswer =
|
||||
bobEvents
|
||||
.filterIsInstance<CallSessionEvent.AnswerReceived>()
|
||||
.firstOrNull()
|
||||
?.event
|
||||
?.pubKey
|
||||
assertEquals(carol, bobForwardedAnswer, "Bob must emit Carol's answer to his CallSession")
|
||||
bobJob.cancel()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user