Skip to content
Merged
Show file tree
Hide file tree
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 @@ -418,22 +418,28 @@ class WebRtcCallBridge @Inject constructor(

fun handleAnswerIncoming(address: Address, sdp: String, callId: UUID) {
serviceExecutor.execute {
try {
if (address.isLocalNumber && callManager.currentConnectionState in CallState.CAN_DECLINE_STATES) {
handleLocalHangup(address)
return@execute
val state = callManager.currentConnectionState
val isInitiator = callManager.isInitiator()

// If we receive a self-synced ANSWER:
if (address.isLocalNumber) {
// Only act if this device was in an INCOMING ring state (answered elsewhere).
if (!isInitiator && state in arrayOf(CallState.RemotePreOffer, CallState.RemoteRing)) {
// Stop ringing / update UI, but DO NOT hang up the remote.
callManager.silenceIncomingRinger()
callManager.handleIgnoreCall()
terminate()
} else {
// We’re the caller or already past ring → ignore self-answer
Log.w(TAG, "Ignoring self-synced ANSWER in state=$state (isInitiator=$isInitiator)")
}

callManager.postViewModelState(CallViewModel.State.CALL_ANSWER_OUTGOING)

callManager.handleResponseMessage(
address,
callId,
SessionDescription(SessionDescription.Type.ANSWER, sdp)
)
} catch (e: PeerConnectionException) {
terminate()
return@execute
}

callManager.postViewModelState(CallViewModel.State.CALL_ANSWER_OUTGOING)
callManager.handleResponseMessage(
address, callId, SessionDescription(SessionDescription.Type.ANSWER, sdp)
)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.thoughtcrime.securesms.webrtc.audio

import android.content.Context
import android.media.AudioAttributes
import android.media.AudioManager
import android.media.MediaPlayer
import android.media.RingtoneManager
Expand Down Expand Up @@ -76,9 +77,17 @@ class IncomingRinger(private val context: Context) {
} ?: return null

try {
val mediaPlayer = MediaPlayer()
mediaPlayer.setDataSource(context, defaultRingtone)
return mediaPlayer
return MediaPlayer().apply {
// Make volume follow the "Ring & notification" slider
setAudioAttributes(
AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.build()
)
isLooping = true
setDataSource(context, defaultRingtone)
}
} catch (e: SecurityException) {
Log.w(TAG, "Failed to create player with ringtone the normal way", e)
}
Expand Down