mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 03:18:06 +00:00
Prevent outgoing calls to be routed on speaker while ringing
This commit is contained in:
parent
3fb5d8a97b
commit
967fb0563d
5 changed files with 48 additions and 25 deletions
|
|
@ -1038,13 +1038,8 @@ class NotificationsManager
|
|||
val answerIntent = getCallAnswerPendingIntent(notifiable)
|
||||
|
||||
val remoteAddress = call.callLog.remoteAddress
|
||||
val remoteContactAddress = call.remoteContactAddress
|
||||
val conferenceInfo = if (remoteContactAddress != null) {
|
||||
call.core.findConferenceInformationFromUri(remoteContactAddress) ?: call.callLog.conferenceInfo
|
||||
} else {
|
||||
call.callLog.conferenceInfo
|
||||
}
|
||||
val conference = call.conference
|
||||
val conferenceInfo = LinphoneUtils.getConferenceInfoIfAny(call)
|
||||
val isConference = conference != null || conferenceInfo != null
|
||||
|
||||
val caller = if (isConference) {
|
||||
|
|
@ -1066,13 +1061,7 @@ class NotificationsManager
|
|||
getPerson(contact, displayName)
|
||||
}
|
||||
|
||||
val isVideo = if (isConference) {
|
||||
true
|
||||
} else if (isIncoming) {
|
||||
call.remoteParams?.isVideoEnabled == true && call.remoteParams?.videoDirection != MediaDirection.Inactive
|
||||
} else {
|
||||
call.currentParams.isVideoEnabled && call.currentParams.videoDirection != MediaDirection.Inactive
|
||||
}
|
||||
val isVideo = LinphoneUtils.isVideoEnabled(call)
|
||||
|
||||
val smallIcon = if (isConference) {
|
||||
R.drawable.video_conference
|
||||
|
|
|
|||
|
|
@ -58,8 +58,14 @@ class TelecomCallControlCallback(
|
|||
if (state == Call.State.Connected) {
|
||||
if (call.dir == Call.Dir.Incoming) {
|
||||
scope.launch {
|
||||
Log.i("$TAG Answering call")
|
||||
callControl.answer(CallAttributesCompat.CALL_TYPE_AUDIO_CALL)
|
||||
val isVideo = LinphoneUtils.isVideoEnabled(call)
|
||||
Log.i("$TAG Answering ${if (isVideo) "video" else "audio"} call")
|
||||
val type = if (isVideo) {
|
||||
CallAttributesCompat.Companion.CALL_TYPE_VIDEO_CALL
|
||||
} else {
|
||||
CallAttributesCompat.Companion.CALL_TYPE_AUDIO_CALL
|
||||
}
|
||||
callControl.answer(type)
|
||||
}
|
||||
} else {
|
||||
scope.launch {
|
||||
|
|
|
|||
|
|
@ -91,9 +91,6 @@ class TelecomManager
|
|||
Log.i("$TAG Call to [${call.remoteAddress.asStringUriOnly()}] created")
|
||||
|
||||
val address = call.callLog.remoteAddress
|
||||
val friend = coreContext.contactsManager.findContactByAddress(address)
|
||||
val displayName = friend?.name ?: LinphoneUtils.getDisplayName(address)
|
||||
|
||||
val uri = Uri.parse(address.asStringUriOnly())
|
||||
|
||||
val direction = if (call.dir == Call.Dir.Outgoing) {
|
||||
|
|
@ -102,9 +99,19 @@ class TelecomManager
|
|||
CallAttributesCompat.DIRECTION_INCOMING
|
||||
}
|
||||
|
||||
val type = CallAttributesCompat.CALL_TYPE_AUDIO_CALL or CallAttributesCompat.CALL_TYPE_VIDEO_CALL
|
||||
val conferenceInfo = LinphoneUtils.getConferenceInfoIfAny(call)
|
||||
val capabilities = CallAttributesCompat.SUPPORTS_SET_INACTIVE or CallAttributesCompat.SUPPORTS_TRANSFER
|
||||
|
||||
val displayName = if (call.conference != null || conferenceInfo != null) {
|
||||
conferenceInfo?.subject ?: call.conference?.subject ?: LinphoneUtils.getDisplayName(address)
|
||||
} else {
|
||||
val friend = coreContext.contactsManager.findContactByAddress(address)
|
||||
friend?.name ?: LinphoneUtils.getDisplayName(address)
|
||||
}
|
||||
|
||||
// When call is created, it is ringing (incoming or outgoing, do not set video)
|
||||
val type = CallAttributesCompat.Companion.CALL_TYPE_AUDIO_CALL
|
||||
|
||||
val callAttributes = CallAttributesCompat(
|
||||
displayName,
|
||||
uri,
|
||||
|
|
|
|||
|
|
@ -1064,12 +1064,7 @@ class CurrentCallViewModel
|
|||
updateEncryption()
|
||||
}
|
||||
|
||||
val remoteContactAddress = call.remoteContactAddress
|
||||
val conferenceInfo = if (remoteContactAddress != null) {
|
||||
call.core.findConferenceInformationFromUri(remoteContactAddress)
|
||||
} else {
|
||||
call.callLog.conferenceInfo
|
||||
}
|
||||
val conferenceInfo = LinphoneUtils.getConferenceInfoIfAny(call)
|
||||
if (call.conference != null || conferenceInfo != null) {
|
||||
val subject = call.conference?.subject ?: conferenceInfo?.subject
|
||||
Log.i("$TAG Conference [$subject] found, going to conference fragment")
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ import org.linphone.core.ConferenceScheduler
|
|||
import org.linphone.core.Core
|
||||
import org.linphone.core.Factory
|
||||
import org.linphone.core.Friend
|
||||
import org.linphone.core.MediaDirection
|
||||
import org.linphone.core.Reason
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.main.contacts.model.ContactAvatarModel
|
||||
|
|
@ -216,6 +217,31 @@ class LinphoneUtils {
|
|||
return core.defaultAccount?.params?.audioVideoConferenceFactoryAddress != null
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun isVideoEnabled(call: Call): Boolean {
|
||||
val conference = call.conference
|
||||
val isConference = conference != null
|
||||
|
||||
val isIncoming = isCallIncoming(call.state)
|
||||
return if (isConference || getConferenceInfoIfAny(call) != null) {
|
||||
true
|
||||
} else if (isIncoming) {
|
||||
call.remoteParams?.isVideoEnabled == true && call.remoteParams?.videoDirection != MediaDirection.Inactive
|
||||
} else {
|
||||
call.currentParams.isVideoEnabled && call.currentParams.videoDirection != MediaDirection.Inactive
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun getConferenceInfoIfAny(call: Call): ConferenceInfo? {
|
||||
val remoteContactAddress = call.remoteContactAddress
|
||||
return if (remoteContactAddress != null) {
|
||||
call.core.findConferenceInformationFromUri(remoteContactAddress) ?: call.callLog.conferenceInfo
|
||||
} else {
|
||||
call.callLog.conferenceInfo
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun createConferenceScheduler(account: Account?): ConferenceScheduler {
|
||||
if (!account?.params?.ccmpServerUrl.isNullOrEmpty()) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue