[BUGFIX][ANDROID] Infinite loop when closing Bluetooth Profile Proxy and Update SwiftLint 0.53 (#988)
Update to SwiftLint 0.53 and add flag comments for Rooms support
This commit is contained in:
Родитель
e75ce5a967
Коммит
afe08f2393
|
@ -39,6 +39,7 @@ internal class AudioSessionManager(
|
|||
private val audioManager by lazy { context.getSystemService(Context.AUDIO_SERVICE) as AudioManager }
|
||||
private var bluetoothAudioProxy: BluetoothHeadset? = null
|
||||
private var initialized = false
|
||||
private var isProxyOpen = false
|
||||
|
||||
private val isBluetoothScoAvailable
|
||||
get() = try {
|
||||
|
@ -294,16 +295,20 @@ internal class AudioSessionManager(
|
|||
}
|
||||
|
||||
private fun openProfileProxy() {
|
||||
if (isProxyOpen) return
|
||||
if (btAdapter?.isEnabled == true && bluetoothAudioProxy == null) {
|
||||
btAdapter?.run {
|
||||
getProfileProxy(context, this@AudioSessionManager, BluetoothProfile.HEADSET)
|
||||
isProxyOpen = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun closeProfileProxy() {
|
||||
btAdapter?.run {
|
||||
closeProfileProxy(BluetoothProfile.HEADSET, bluetoothAudioProxy)
|
||||
if (!isProxyOpen) return
|
||||
isProxyOpen = false
|
||||
bluetoothAudioProxy?.let {
|
||||
btAdapter?.closeProfileProxy(BluetoothProfile.HEADSET, bluetoothAudioProxy)
|
||||
bluetoothAudioProxy = null
|
||||
}
|
||||
}
|
||||
|
@ -314,6 +319,8 @@ internal class AudioSessionManager(
|
|||
}
|
||||
|
||||
override fun onServiceDisconnected(profile: Int) {
|
||||
closeProfileProxy()
|
||||
if (isProxyOpen) {
|
||||
closeProfileProxy()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче