mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
Native call: always ask the core to ring, and ring a DM only once its member has joined
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+2
@@ -42,6 +42,8 @@ class DefaultNativeCallEntryPoint(
|
||||
ElementCallData(
|
||||
roomId = RoomId(callData.roomId.value),
|
||||
isAudioCall = callData.isAudioCall,
|
||||
// Temporary, to be removed from the library soon: the core already skips the ring when anyone else is in the call.
|
||||
isStartingCall = true,
|
||||
)
|
||||
)
|
||||
// The call screen asks for the microphone itself, and is where the answer normally comes
|
||||
|
||||
+4
-1
@@ -8,6 +8,7 @@
|
||||
package io.element.android.features.callnative.impl
|
||||
|
||||
import io.element.android.call.api.ElementCallData
|
||||
import io.element.android.call.api.ElementCallEndReason
|
||||
import io.element.android.call.api.ElementCallLifecycleListener
|
||||
import io.element.android.features.call.api.CallData
|
||||
import io.element.android.features.call.api.CurrentCall
|
||||
@@ -19,6 +20,7 @@ import io.element.android.services.appnavstate.api.AppForegroundStateService
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
* Reports a native call back to the parts of Element X that already track calls.
|
||||
@@ -47,7 +49,8 @@ class ElementXCallLifecycleListener(
|
||||
sessionCoroutineScope.launch { ringingCallTracker.onCallJoined(callData.toCallData()) }
|
||||
}
|
||||
|
||||
override fun onCallEnded(callData: ElementCallData?) {
|
||||
override fun onCallEnded(callData: ElementCallData?, reason: ElementCallEndReason) {
|
||||
Timber.i("Native call ended: $reason")
|
||||
currentCallTracker.onCallEnded()
|
||||
callData?.let { sessionCoroutineScope.launch { ringingCallTracker.onCallEnded(it.toCallData()) } }
|
||||
}
|
||||
|
||||
+4
-3
@@ -9,6 +9,7 @@ package io.element.android.features.callnative.impl
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import io.element.android.call.api.ElementCallData
|
||||
import io.element.android.call.api.ElementCallEndReason
|
||||
import io.element.android.call.api.rtc.id.RoomId
|
||||
import io.element.android.features.call.api.CurrentCall
|
||||
import io.element.android.features.call.test.FakeCurrentCallTracker
|
||||
@@ -30,7 +31,7 @@ class ElementXCallLifecycleListenerTest {
|
||||
val listener = createListener(currentCallTracker = currentCallTracker)
|
||||
|
||||
listener.onCallStarted(A_CALL)
|
||||
listener.onCallEnded(A_CALL)
|
||||
listener.onCallEnded(A_CALL, ElementCallEndReason.LEFT)
|
||||
|
||||
assertThat(currentCallTracker.calls).containsExactly(
|
||||
CurrentCall.RoomCall(A_ROOM_ID),
|
||||
@@ -59,7 +60,7 @@ class ElementXCallLifecycleListenerTest {
|
||||
ringingCallTracker = ringingCallTracker,
|
||||
)
|
||||
|
||||
listener.onCallEnded(null)
|
||||
listener.onCallEnded(null, ElementCallEndReason.LEFT)
|
||||
runCurrent()
|
||||
|
||||
// The current call is always cleared; only the ring needs to know which call it was.
|
||||
@@ -79,6 +80,6 @@ class ElementXCallLifecycleListenerTest {
|
||||
)
|
||||
|
||||
private companion object {
|
||||
val A_CALL = ElementCallData(roomId = RoomId(A_ROOM_ID.value), isAudioCall = true)
|
||||
val A_CALL = ElementCallData(roomId = RoomId(A_ROOM_ID.value), isAudioCall = true, isStartingCall = true)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user