File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
vector/src/main/java/im/vector/app Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ import androidx.core.content.ContextCompat
18
18
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
19
19
import java.lang.ref.WeakReference
20
20
21
+ /* *
22
+ * It's only used in API 21 and 22 so we will not have security exception on these OS,
23
+ * so it's safe to use @Suppress("MissingPermission")
24
+ */
21
25
class BluetoothHeadsetReceiver : BroadcastReceiver () {
22
26
23
27
interface EventListener {
@@ -53,12 +57,15 @@ class BluetoothHeadsetReceiver : BroadcastReceiver() {
53
57
}
54
58
55
59
val device = intent.getParcelableExtraCompat<BluetoothDevice >(BluetoothDevice .EXTRA_DEVICE )
60
+ @Suppress(" MissingPermission" )
56
61
val deviceName = device?.name
62
+ @Suppress(" MissingPermission" )
57
63
when (device?.bluetoothClass?.deviceClass) {
58
64
BluetoothClass .Device .AUDIO_VIDEO_HANDSFREE ,
59
65
BluetoothClass .Device .AUDIO_VIDEO_CAR_AUDIO ,
60
66
BluetoothClass .Device .AUDIO_VIDEO_WEARABLE_HEADSET -> {
61
67
// filter only device that we care about for
68
+ @Suppress(" MissingPermission" )
62
69
delegate?.get()?.onBTHeadsetEvent(
63
70
BTHeadsetPlugEvent (
64
71
plugged = headsetConnected,
Original file line number Diff line number Diff line change @@ -43,6 +43,11 @@ internal class API21AudioDeviceDetector(
43
43
return HashSet <CallAudioManager .Device >().apply {
44
44
if (isBluetoothHeadsetOn()) {
45
45
connectedBlueToothHeadset?.connectedDevices?.forEach {
46
+ // Call requires permission which may be rejected by user: code should explicitly
47
+ // check to see if permission is available (with checkPermission) or explicitly
48
+ // handle a potential SecurityException
49
+ // But it should not happen on API 21/22.
50
+ @Suppress(" MissingPermission" )
46
51
add(CallAudioManager .Device .WirelessHeadset (it.name))
47
52
}
48
53
}
You can’t perform that action at this time.
0 commit comments