From 1eec5425b1a882a4022a7864ba428df8f360ee69 Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Sun, 16 Jul 2023 21:26:08 +0300 Subject: [PATCH] Fixed AudioManager related SDK version test --- app/src/main/kotlin/com/tutpro/baresip/Utils.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/tutpro/baresip/Utils.kt b/app/src/main/kotlin/com/tutpro/baresip/Utils.kt index 303342c1..8454cf32 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/Utils.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/Utils.kt @@ -899,14 +899,14 @@ object Utils { } fun isSpeakerPhoneOn(am: AudioManager): Boolean { - return if (Build.VERSION.SDK_INT > 33) + return if (Build.VERSION.SDK_INT >= 31) am.communicationDevice!!.type == AudioDeviceInfo.TYPE_BUILTIN_SPEAKER else am.isSpeakerphoneOn } private fun setSpeakerPhone(executor: Executor, am: AudioManager, enable: Boolean) { - if (Build.VERSION.SDK_INT > 33) { + if (Build.VERSION.SDK_INT >= 31) { val current = am.communicationDevice!!.type Log.d(TAG, "Current com dev/mode is $current/${am.mode}") var speakerDevice: AudioDeviceInfo? = null @@ -971,7 +971,7 @@ object Utils { } fun toggleSpeakerPhone(executor: Executor, am: AudioManager) { - if (Build.VERSION.SDK_INT > 33) { + if (Build.VERSION.SDK_INT >= 31) { if (am.communicationDevice!!.type == AudioDeviceInfo.TYPE_BUILTIN_EARPIECE) setSpeakerPhone(executor, am, true) else if (am.communicationDevice!!.type == AudioDeviceInfo.TYPE_BUILTIN_SPEAKER) @@ -994,7 +994,7 @@ object Utils { } private fun clearCommunicationDevice(am: AudioManager) { - if (Build.VERSION.SDK_INT > 33) { + if (Build.VERSION.SDK_INT >= 31) { am.clearCommunicationDevice() } else { if (am.isSpeakerphoneOn)