From eb8a704ee72c70c6a34ffa92c0a42f8205953c30 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 22 Dec 2021 15:57:47 +0000 Subject: [PATCH 1/3] forcing the outgoing calls to use the same audio config as the call itself - tentatively fixes the speaker being used by previous instance changes if a reset fails --- .../im/vector/app/core/services/CallRingPlayer.kt | 13 +++++++++++-- .../java/im/vector/app/core/services/CallService.kt | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/services/CallRingPlayer.kt b/vector/src/main/java/im/vector/app/core/services/CallRingPlayer.kt index 524ff37914..6c7e02c065 100644 --- a/vector/src/main/java/im/vector/app/core/services/CallRingPlayer.kt +++ b/vector/src/main/java/im/vector/app/core/services/CallRingPlayer.kt @@ -28,6 +28,8 @@ import android.os.VibrationEffect import android.os.Vibrator import androidx.core.content.getSystemService import im.vector.app.R +import im.vector.app.features.call.audio.CallAudioManager +import im.vector.app.features.call.webrtc.WebRtcCallManager import im.vector.app.features.notifications.NotificationUtils import org.matrix.android.sdk.api.extensions.orFalse import timber.log.Timber @@ -94,7 +96,8 @@ class CallRingPlayerIncoming( } class CallRingPlayerOutgoing( - context: Context + context: Context, + private val callManager: WebRtcCallManager ) { private val applicationContext = context.applicationContext @@ -102,7 +105,7 @@ class CallRingPlayerOutgoing( private var player: MediaPlayer? = null fun start() { - applicationContext.getSystemService()?.mode = AudioManager.MODE_IN_COMMUNICATION + callManager.setAudioModeToCallType() player?.release() player = createPlayer() if (player != null) { @@ -120,6 +123,12 @@ class CallRingPlayerOutgoing( } } + private fun WebRtcCallManager.setAudioModeToCallType() { + currentCall.get()?.let { + audioManager.setMode(if (it.mxCall.isVideoCall) CallAudioManager.Mode.VIDEO_CALL else CallAudioManager.Mode.AUDIO_CALL) + } + } + fun stop() { player?.release() player = null diff --git a/vector/src/main/java/im/vector/app/core/services/CallService.kt b/vector/src/main/java/im/vector/app/core/services/CallService.kt index d194434641..d79220e7e7 100644 --- a/vector/src/main/java/im/vector/app/core/services/CallService.kt +++ b/vector/src/main/java/im/vector/app/core/services/CallService.kt @@ -84,7 +84,7 @@ class CallService : VectorService() { super.onCreate() notificationManager = NotificationManagerCompat.from(this) callRingPlayerIncoming = CallRingPlayerIncoming(applicationContext, notificationUtils) - callRingPlayerOutgoing = CallRingPlayerOutgoing(applicationContext) + callRingPlayerOutgoing = CallRingPlayerOutgoing(applicationContext, callManager) } override fun onDestroy() { From ffdd10b5bfc764c4fd7131a0c652ae415607e3a8 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 22 Dec 2021 15:59:09 +0000 Subject: [PATCH 2/3] adding changelog entry --- changelog.d/4781.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/4781.bugfix diff --git a/changelog.d/4781.bugfix b/changelog.d/4781.bugfix new file mode 100644 index 0000000000..7ac6e62448 --- /dev/null +++ b/changelog.d/4781.bugfix @@ -0,0 +1 @@ +Tentative fix for the speaker being used instead of earpiece for the outgoing call ringtone on lineage os \ No newline at end of file From 603ddf7eacfce28f01cf77faa89facf0100437a0 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 5 Jan 2022 09:25:10 +0000 Subject: [PATCH 3/3] taking into account when the current call is not yet available and defaulting to the audio call mode --- .../java/im/vector/app/core/services/CallRingPlayer.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/services/CallRingPlayer.kt b/vector/src/main/java/im/vector/app/core/services/CallRingPlayer.kt index 6c7e02c065..b2d9382aae 100644 --- a/vector/src/main/java/im/vector/app/core/services/CallRingPlayer.kt +++ b/vector/src/main/java/im/vector/app/core/services/CallRingPlayer.kt @@ -28,7 +28,7 @@ import android.os.VibrationEffect import android.os.Vibrator import androidx.core.content.getSystemService import im.vector.app.R -import im.vector.app.features.call.audio.CallAudioManager +import im.vector.app.features.call.audio.CallAudioManager.Mode import im.vector.app.features.call.webrtc.WebRtcCallManager import im.vector.app.features.notifications.NotificationUtils import org.matrix.android.sdk.api.extensions.orFalse @@ -124,9 +124,8 @@ class CallRingPlayerOutgoing( } private fun WebRtcCallManager.setAudioModeToCallType() { - currentCall.get()?.let { - audioManager.setMode(if (it.mxCall.isVideoCall) CallAudioManager.Mode.VIDEO_CALL else CallAudioManager.Mode.AUDIO_CALL) - } + val callMode = if (currentCall.get()?.mxCall?.isVideoCall.orFalse()) Mode.VIDEO_CALL else Mode.AUDIO_CALL + audioManager.setMode(callMode) } fun stop() {