mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 16:10:00 +00:00
Fix crash when using Element Call on API <= 30 (#4847)
This commit is contained in:
committed by
GitHub
parent
20270cdffe
commit
f224fe5c3b
+5
-1
@@ -15,6 +15,7 @@ import android.os.Build
|
|||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
import android.webkit.JavascriptInterface
|
import android.webkit.JavascriptInterface
|
||||||
import android.webkit.WebView
|
import android.webkit.WebView
|
||||||
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@@ -66,7 +67,9 @@ class WebViewAudioManager(
|
|||||||
/**
|
/**
|
||||||
* This listener tracks the current communication device and updates the WebView when it changes.
|
* This listener tracks the current communication device and updates the WebView when it changes.
|
||||||
*/
|
*/
|
||||||
private val commsDeviceChangedListener = AudioManager.OnCommunicationDeviceChangedListener { device ->
|
@get:RequiresApi(Build.VERSION_CODES.S)
|
||||||
|
private val commsDeviceChangedListener by lazy {
|
||||||
|
AudioManager.OnCommunicationDeviceChangedListener { device ->
|
||||||
if (device != null && device.id == expectedNewCommunicationDeviceId) {
|
if (device != null && device.id == expectedNewCommunicationDeviceId) {
|
||||||
expectedNewCommunicationDeviceId = null
|
expectedNewCommunicationDeviceId = null
|
||||||
Timber.d("Audio device changed, type: ${device.type}")
|
Timber.d("Audio device changed, type: ${device.type}")
|
||||||
@@ -85,6 +88,7 @@ class WebViewAudioManager(
|
|||||||
audioManager.selectAudioDevice(null)
|
audioManager.selectAudioDevice(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This callback is used to listen for audio device changes coming from the OS.
|
* This callback is used to listen for audio device changes coming from the OS.
|
||||||
|
|||||||
Reference in New Issue
Block a user