Skip to content

Commit 1490854

Browse files
authored
Merge pull request #4799 from vector-im/feature/adm/inconsistent-outgoing-call-output
Outgoing call ringtone using wrong audio device
2 parents 17e485f + 603ddf7 commit 1490854

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

changelog.d/4781.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Tentative fix for the speaker being used instead of earpiece for the outgoing call ringtone on lineage os

vector/src/main/java/im/vector/app/core/services/CallRingPlayer.kt

+10-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import android.os.VibrationEffect
2828
import android.os.Vibrator
2929
import androidx.core.content.getSystemService
3030
import im.vector.app.R
31+
import im.vector.app.features.call.audio.CallAudioManager.Mode
32+
import im.vector.app.features.call.webrtc.WebRtcCallManager
3133
import im.vector.app.features.notifications.NotificationUtils
3234
import org.matrix.android.sdk.api.extensions.orFalse
3335
import timber.log.Timber
@@ -94,15 +96,16 @@ class CallRingPlayerIncoming(
9496
}
9597

9698
class CallRingPlayerOutgoing(
97-
context: Context
99+
context: Context,
100+
private val callManager: WebRtcCallManager
98101
) {
99102

100103
private val applicationContext = context.applicationContext
101104

102105
private var player: MediaPlayer? = null
103106

104107
fun start() {
105-
applicationContext.getSystemService<AudioManager>()?.mode = AudioManager.MODE_IN_COMMUNICATION
108+
callManager.setAudioModeToCallType()
106109
player?.release()
107110
player = createPlayer()
108111
if (player != null) {
@@ -120,6 +123,11 @@ class CallRingPlayerOutgoing(
120123
}
121124
}
122125

126+
private fun WebRtcCallManager.setAudioModeToCallType() {
127+
val callMode = if (currentCall.get()?.mxCall?.isVideoCall.orFalse()) Mode.VIDEO_CALL else Mode.AUDIO_CALL
128+
audioManager.setMode(callMode)
129+
}
130+
123131
fun stop() {
124132
player?.release()
125133
player = null

vector/src/main/java/im/vector/app/core/services/CallService.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class CallService : VectorService() {
8484
super.onCreate()
8585
notificationManager = NotificationManagerCompat.from(this)
8686
callRingPlayerIncoming = CallRingPlayerIncoming(applicationContext, notificationUtils)
87-
callRingPlayerOutgoing = CallRingPlayerOutgoing(applicationContext)
87+
callRingPlayerOutgoing = CallRingPlayerOutgoing(applicationContext, callManager)
8888
}
8989

9090
override fun onDestroy() {

0 commit comments

Comments
 (0)