Add extra logs the 'send call notification' flow (#4819)
This commit is contained in:
parent
45113818eb
commit
2b75a29c43
6 changed files with 76 additions and 19 deletions
|
|
@ -15,11 +15,19 @@ import kotlinx.parcelize.Parcelize
|
||||||
|
|
||||||
sealed interface CallType : NodeInputs, Parcelable {
|
sealed interface CallType : NodeInputs, Parcelable {
|
||||||
@Parcelize
|
@Parcelize
|
||||||
data class ExternalUrl(val url: String) : CallType
|
data class ExternalUrl(val url: String) : CallType {
|
||||||
|
override fun toString(): String {
|
||||||
|
return "ExternalUrl"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
data class RoomCall(
|
data class RoomCall(
|
||||||
val sessionId: SessionId,
|
val sessionId: SessionId,
|
||||||
val roomId: RoomId,
|
val roomId: RoomId,
|
||||||
) : CallType
|
) : CallType {
|
||||||
|
override fun toString(): String {
|
||||||
|
return "RoomCall(sessionId=$sessionId, roomId=$roomId)"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ import kotlinx.coroutines.launch
|
||||||
import kotlinx.serialization.json.contentOrNull
|
import kotlinx.serialization.json.contentOrNull
|
||||||
import kotlinx.serialization.json.jsonObject
|
import kotlinx.serialization.json.jsonObject
|
||||||
import kotlinx.serialization.json.jsonPrimitive
|
import kotlinx.serialization.json.jsonPrimitive
|
||||||
|
import timber.log.Timber
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
class CallScreenPresenter @AssistedInject constructor(
|
class CallScreenPresenter @AssistedInject constructor(
|
||||||
|
|
@ -213,6 +214,7 @@ class CallScreenPresenter @AssistedInject constructor(
|
||||||
theme = theme,
|
theme = theme,
|
||||||
).getOrThrow()
|
).getOrThrow()
|
||||||
callWidgetDriver.value = result.driver
|
callWidgetDriver.value = result.driver
|
||||||
|
Timber.d("Call widget driver initialized for sessionId: ${inputs.sessionId}, roomId: ${inputs.roomId}")
|
||||||
result.url
|
result.url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -223,10 +225,12 @@ class CallScreenPresenter @AssistedInject constructor(
|
||||||
private fun HandleMatrixClientSyncState() {
|
private fun HandleMatrixClientSyncState() {
|
||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
DisposableEffect(Unit) {
|
DisposableEffect(Unit) {
|
||||||
val client = (callType as? CallType.RoomCall)?.sessionId?.let {
|
val roomCallType = callType as? CallType.RoomCall ?: return@DisposableEffect onDispose {}
|
||||||
matrixClientsProvider.getOrNull(it)
|
val client = matrixClientsProvider.getOrNull(roomCallType.sessionId) ?: return@DisposableEffect onDispose {
|
||||||
} ?: return@DisposableEffect onDispose { }
|
Timber.w("No MatrixClient found for sessionId, can't send call notification: ${roomCallType.sessionId}")
|
||||||
|
}
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
|
Timber.d("Observing sync state in-call for sessionId: ${roomCallType.sessionId}")
|
||||||
client.syncService().syncState
|
client.syncService().syncState
|
||||||
.collect { state ->
|
.collect { state ->
|
||||||
if (state == SyncState.Running) {
|
if (state == SyncState.Running) {
|
||||||
|
|
@ -237,6 +241,7 @@ class CallScreenPresenter @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onDispose {
|
onDispose {
|
||||||
|
Timber.d("Stopped observing sync state in-call for sessionId: ${roomCallType.sessionId}")
|
||||||
// Make sure we mark the call as ended in the app state
|
// Make sure we mark the call as ended in the app state
|
||||||
appForegroundStateService.updateIsInCallState(false)
|
appForegroundStateService.updateIsInCallState(false)
|
||||||
}
|
}
|
||||||
|
|
@ -244,12 +249,29 @@ class CallScreenPresenter @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun MatrixClient.notifyCallStartIfNeeded(roomId: RoomId) {
|
private suspend fun MatrixClient.notifyCallStartIfNeeded(roomId: RoomId) {
|
||||||
if (!notifiedCallStart) {
|
if (notifiedCallStart) return
|
||||||
val activeRoomForSession = activeRoomsHolder.getActiveRoomMatching(sessionId, roomId)
|
|
||||||
val sendCallNotificationResult = activeRoomForSession?.sendCallNotificationIfNeeded()
|
val activeRoomForSession = activeRoomsHolder.getActiveRoomMatching(sessionId, roomId)
|
||||||
?: getJoinedRoom(roomId)?.use { it.sendCallNotificationIfNeeded() }
|
val sendCallNotificationResult = if (activeRoomForSession != null) {
|
||||||
sendCallNotificationResult?.onSuccess { notifiedCallStart = true }
|
Timber.d("Notifying call start for room $roomId. Has room call: ${activeRoomForSession.info().hasRoomCall}")
|
||||||
|
activeRoomForSession.sendCallNotificationIfNeeded()
|
||||||
|
} else {
|
||||||
|
// Instantiate the room from the session and roomId and send the notification
|
||||||
|
getJoinedRoom(roomId)?.use { room ->
|
||||||
|
Timber.d("Notifying call start for room $roomId. Has room call: ${room.info().hasRoomCall}")
|
||||||
|
room.sendCallNotificationIfNeeded()
|
||||||
|
} ?: run {
|
||||||
|
Timber.w("No room found for session $sessionId and room $roomId, skipping call notification.")
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendCallNotificationResult.fold(
|
||||||
|
onSuccess = { notifiedCallStart = true },
|
||||||
|
onFailure = { error ->
|
||||||
|
Timber.e(error, "Failed to send call notification for room $roomId.")
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseMessage(message: String): WidgetMessage? {
|
private fun parseMessage(message: String): WidgetMessage? {
|
||||||
|
|
|
||||||
|
|
@ -134,11 +134,13 @@ internal fun CallScreenView(
|
||||||
AsyncData.Uninitialized,
|
AsyncData.Uninitialized,
|
||||||
is AsyncData.Loading ->
|
is AsyncData.Loading ->
|
||||||
ProgressDialog(text = stringResource(id = CommonStrings.common_please_wait))
|
ProgressDialog(text = stringResource(id = CommonStrings.common_please_wait))
|
||||||
is AsyncData.Failure ->
|
is AsyncData.Failure -> {
|
||||||
|
Timber.e(state.urlState.error, "WebView failed to load URL: ${state.urlState.error.message}")
|
||||||
ErrorDialog(
|
ErrorDialog(
|
||||||
content = state.urlState.error.message.orEmpty(),
|
content = state.urlState.error.message.orEmpty(),
|
||||||
onSubmit = { state.eventSink(CallScreenEvents.Hangup) },
|
onSubmit = { state.eventSink(CallScreenEvents.Hangup) },
|
||||||
)
|
)
|
||||||
|
}
|
||||||
is AsyncData.Success -> Unit
|
is AsyncData.Success -> Unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -242,6 +244,20 @@ private fun WebView.setup(
|
||||||
ConsoleMessage.MessageLevel.WARNING -> Log.WARN
|
ConsoleMessage.MessageLevel.WARNING -> Log.WARN
|
||||||
else -> Log.DEBUG
|
else -> Log.DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val message = buildString {
|
||||||
|
append(consoleMessage.sourceId())
|
||||||
|
append(":")
|
||||||
|
append(consoleMessage.lineNumber())
|
||||||
|
append(" ")
|
||||||
|
append(consoleMessage.message())
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message.contains("password=")) {
|
||||||
|
// Avoid logging any messages that contain "password" to prevent leaking sensitive information
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
Timber.tag("WebView").log(
|
Timber.tag("WebView").log(
|
||||||
priority = priority,
|
priority = priority,
|
||||||
message = buildString {
|
message = buildString {
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,8 @@ class ElementCallActivity :
|
||||||
|
|
||||||
pictureInPicturePresenter.setPipView(this)
|
pictureInPicturePresenter.setPipView(this)
|
||||||
|
|
||||||
|
Timber.d("Created ElementCallActivity with call type: ${webViewTarget.value}")
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
val pipState = pictureInPicturePresenter.present()
|
val pipState = pictureInPicturePresenter.present()
|
||||||
ListenToAndroidEvents(pipState)
|
ListenToAndroidEvents(pipState)
|
||||||
|
|
|
||||||
|
|
@ -183,6 +183,9 @@ class DefaultActiveCallManager @Inject constructor(
|
||||||
Timber.tag(tag).w("Call type $callType does not match the active call type, ignoring")
|
Timber.tag(tag).w("Call type $callType does not match the active call type, ignoring")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Timber.tag(tag).d("Hung up call: $callType")
|
||||||
|
|
||||||
cancelIncomingCallNotification()
|
cancelIncomingCallNotification()
|
||||||
if (activeWakeLock?.isHeld == true) {
|
if (activeWakeLock?.isHeld == true) {
|
||||||
Timber.tag(tag).d("Releasing partial wakelock after hang up")
|
Timber.tag(tag).d("Releasing partial wakelock after hang up")
|
||||||
|
|
@ -193,6 +196,8 @@ class DefaultActiveCallManager @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun joinedCall(callType: CallType) = mutex.withLock {
|
override suspend fun joinedCall(callType: CallType) = mutex.withLock {
|
||||||
|
Timber.tag(tag).d("Joined call: $callType")
|
||||||
|
|
||||||
cancelIncomingCallNotification()
|
cancelIncomingCallNotification()
|
||||||
if (activeWakeLock?.isHeld == true) {
|
if (activeWakeLock?.isHeld == true) {
|
||||||
Timber.tag(tag).d("Releasing partial wakelock after joining call")
|
Timber.tag(tag).d("Releasing partial wakelock after joining call")
|
||||||
|
|
|
||||||
|
|
@ -46,14 +46,18 @@ class RoomCallStatePresenter @Inject constructor(
|
||||||
(currentCall as? CurrentCall.RoomCall)?.roomId == room.roomId
|
(currentCall as? CurrentCall.RoomCall)?.roomId == room.roomId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val callState = when {
|
val callState by remember {
|
||||||
isAvailable.not() -> RoomCallState.Unavailable
|
derivedStateOf {
|
||||||
roomInfo.hasRoomCall -> RoomCallState.OnGoing(
|
when {
|
||||||
canJoinCall = canJoinCall,
|
isAvailable.not() -> RoomCallState.Unavailable
|
||||||
isUserInTheCall = isUserInTheCall,
|
roomInfo.hasRoomCall -> RoomCallState.OnGoing(
|
||||||
isUserLocallyInTheCall = isUserLocallyInTheCall,
|
canJoinCall = canJoinCall,
|
||||||
)
|
isUserInTheCall = isUserInTheCall,
|
||||||
else -> RoomCallState.StandBy(canStartCall = canJoinCall)
|
isUserLocallyInTheCall = isUserLocallyInTheCall,
|
||||||
|
)
|
||||||
|
else -> RoomCallState.StandBy(canStartCall = canJoinCall)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return callState
|
return callState
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue