mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-15 01:35:07 +08:00
Merge pull request #4799 from vector-im/feature/adm/inconsistent-outgoing-call-output
Outgoing call ringtone using wrong audio device
This commit is contained in:
commit
1490854b4c
1
changelog.d/4781.bugfix
Normal file
1
changelog.d/4781.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Tentative fix for the speaker being used instead of earpiece for the outgoing call ringtone on lineage os
|
@ -28,6 +28,8 @@ import android.os.VibrationEffect
|
|||||||
import android.os.Vibrator
|
import android.os.Vibrator
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
|
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 im.vector.app.features.notifications.NotificationUtils
|
||||||
import org.matrix.android.sdk.api.extensions.orFalse
|
import org.matrix.android.sdk.api.extensions.orFalse
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
@ -94,7 +96,8 @@ class CallRingPlayerIncoming(
|
|||||||
}
|
}
|
||||||
|
|
||||||
class CallRingPlayerOutgoing(
|
class CallRingPlayerOutgoing(
|
||||||
context: Context
|
context: Context,
|
||||||
|
private val callManager: WebRtcCallManager
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private val applicationContext = context.applicationContext
|
private val applicationContext = context.applicationContext
|
||||||
@ -102,7 +105,7 @@ class CallRingPlayerOutgoing(
|
|||||||
private var player: MediaPlayer? = null
|
private var player: MediaPlayer? = null
|
||||||
|
|
||||||
fun start() {
|
fun start() {
|
||||||
applicationContext.getSystemService<AudioManager>()?.mode = AudioManager.MODE_IN_COMMUNICATION
|
callManager.setAudioModeToCallType()
|
||||||
player?.release()
|
player?.release()
|
||||||
player = createPlayer()
|
player = createPlayer()
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
@ -120,6 +123,11 @@ class CallRingPlayerOutgoing(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun WebRtcCallManager.setAudioModeToCallType() {
|
||||||
|
val callMode = if (currentCall.get()?.mxCall?.isVideoCall.orFalse()) Mode.VIDEO_CALL else Mode.AUDIO_CALL
|
||||||
|
audioManager.setMode(callMode)
|
||||||
|
}
|
||||||
|
|
||||||
fun stop() {
|
fun stop() {
|
||||||
player?.release()
|
player?.release()
|
||||||
player = null
|
player = null
|
||||||
|
@ -84,7 +84,7 @@ class CallService : VectorService() {
|
|||||||
super.onCreate()
|
super.onCreate()
|
||||||
notificationManager = NotificationManagerCompat.from(this)
|
notificationManager = NotificationManagerCompat.from(this)
|
||||||
callRingPlayerIncoming = CallRingPlayerIncoming(applicationContext, notificationUtils)
|
callRingPlayerIncoming = CallRingPlayerIncoming(applicationContext, notificationUtils)
|
||||||
callRingPlayerOutgoing = CallRingPlayerOutgoing(applicationContext)
|
callRingPlayerOutgoing = CallRingPlayerOutgoing(applicationContext, callManager)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
|
Loading…
Reference in New Issue
Block a user