1
0
mirror of https://github.com/vector-im/riotX-android synced 2025-10-05 15:52:47 +02:00

Fix lint warning: ignore impossible SecurityException

This commit is contained in:
Benoit Marty
2025-07-09 09:54:36 +02:00
committed by Benoit Marty
parent 27fc09bb8a
commit cf01890e3a
2 changed files with 12 additions and 0 deletions

View File

@@ -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>(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,

View File

@@ -43,6 +43,11 @@ internal class API21AudioDeviceDetector(
return HashSet<CallAudioManager.Device>().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))
}
}