mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-04 10:32:34 +00:00
Catch exceptions when setting or clearing an audio communication device in Element Call (#6226)
This commit is contained in:
committed by
GitHub
parent
a36243ca80
commit
001d419afd
+12
-3
@@ -18,6 +18,7 @@ import android.webkit.JavascriptInterface
|
|||||||
import android.webkit.WebView
|
import android.webkit.WebView
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
|
import io.element.android.libraries.core.extensions.runCatchingExceptions
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
@@ -385,10 +386,18 @@ class WebViewAudioManager(
|
|||||||
currentDeviceId = device?.id
|
currentDeviceId = device?.id
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
if (device != null) {
|
if (device != null) {
|
||||||
Timber.d("Setting communication device: ${device.id} - ${deviceName(device.type, device.productName.toString())}")
|
runCatchingExceptions {
|
||||||
setCommunicationDevice(device)
|
Timber.d("Setting communication device: ${device.id} - ${deviceName(device.type, device.productName.toString())}")
|
||||||
|
setCommunicationDevice(device)
|
||||||
|
}.onFailure {
|
||||||
|
Timber.e(it, "Could not set communication device.")
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
audioManager.clearCommunicationDevice()
|
runCatchingExceptions {
|
||||||
|
clearCommunicationDevice()
|
||||||
|
}.onFailure {
|
||||||
|
Timber.e(it, "Could not clear communication device.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// On Android 11 and lower, we don't have the concept of communication devices
|
// On Android 11 and lower, we don't have the concept of communication devices
|
||||||
|
|||||||
Reference in New Issue
Block a user