diff --git a/vector/src/main/java/im/vector/app/core/services/BluetoothHeadsetReceiver.kt b/vector/src/main/java/im/vector/app/core/services/BluetoothHeadsetReceiver.kt index dd04e5664e..a978b90a97 100644 --- a/vector/src/main/java/im/vector/app/core/services/BluetoothHeadsetReceiver.kt +++ b/vector/src/main/java/im/vector/app/core/services/BluetoothHeadsetReceiver.kt @@ -18,6 +18,10 @@ import androidx.core.content.ContextCompat import im.vector.lib.core.utils.compat.getParcelableExtraCompat import java.lang.ref.WeakReference +/** + * It's only used in API 21 and 22 so we will not have security exception on these OS, + * so it's safe to use @Suppress("MissingPermission") + */ class BluetoothHeadsetReceiver : BroadcastReceiver() { interface EventListener { @@ -53,12 +57,15 @@ class BluetoothHeadsetReceiver : BroadcastReceiver() { } val device = intent.getParcelableExtraCompat(BluetoothDevice.EXTRA_DEVICE) + @Suppress("MissingPermission") val deviceName = device?.name + @Suppress("MissingPermission") when (device?.bluetoothClass?.deviceClass) { BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE, BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO, BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET -> { // filter only device that we care about for + @Suppress("MissingPermission") delegate?.get()?.onBTHeadsetEvent( BTHeadsetPlugEvent( plugged = headsetConnected, diff --git a/vector/src/main/java/im/vector/app/features/call/audio/API21AudioDeviceDetector.kt b/vector/src/main/java/im/vector/app/features/call/audio/API21AudioDeviceDetector.kt index 30d6507380..69adc08c63 100644 --- a/vector/src/main/java/im/vector/app/features/call/audio/API21AudioDeviceDetector.kt +++ b/vector/src/main/java/im/vector/app/features/call/audio/API21AudioDeviceDetector.kt @@ -43,6 +43,11 @@ internal class API21AudioDeviceDetector( return HashSet().apply { if (isBluetoothHeadsetOn()) { connectedBlueToothHeadset?.connectedDevices?.forEach { + // Call requires permission which may be rejected by user: code should explicitly + // check to see if permission is available (with checkPermission) or explicitly + // handle a potential SecurityException + // But it should not happen on API 21/22. + @Suppress("MissingPermission") add(CallAudioManager.Device.WirelessHeadset(it.name)) } }