Skip to content

Commit 4479e49

Browse files
committed
Add workaround for Android 12 devices
1 parent 766d1e0 commit 4479e49

File tree

1 file changed

+7
-1
lines changed
  • features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui

1 file changed

+7
-1
lines changed

features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenView.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,10 @@ private fun OutputAudioDeviceSelector() {
262262
Text(device.description())
263263
}, onClick = {
264264
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
265+
// Workaround for Android 12, otherwise changing the audio device doesn't work
266+
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.S) {
267+
audioManager?.mode = AudioManager.MODE_NORMAL
268+
}
265269
audioManager?.setCommunicationDevice(device)
266270
selected = device
267271
expanded = false
@@ -316,7 +320,9 @@ fun AudioDeviceInfo.description(): String {
316320
private fun Context.setupAudioConfiguration(): AudioDeviceCallback? {
317321
val audioManager = getSystemService<AudioManager>() ?: return null
318322
// Set 'voice call' mode so volume keys actually control the call volume
319-
audioManager.mode = AudioManager.MODE_IN_COMMUNICATION
323+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
324+
audioManager.mode = AudioManager.MODE_IN_COMMUNICATION
325+
}
320326
audioManager.enableExternalAudioDevice()
321327
return object : AudioDeviceCallback() {
322328
override fun onAudioDevicesAdded(addedDevices: Array<out AudioDeviceInfo>?) {

0 commit comments

Comments
 (0)