Cannot use bluetooth headsets when targetSdkVersion < 31 and Build.VERSION >= 31
nredaatepic opened this issue · 3 comments
Describe the bug
In adding support for API level 31, commit 07dfe6fd3052ec90346b5700ad08bcc5f5c92e7d introduced logic in BluetoothHeadsetManager.kt to determine a strategy for checking against the new bluetooth permissions.
However, I believe this logic is incorrect - it is checking Build.VERSION, but internally (at least in BluetoothHeadset.java) android checks for targetSdkVersion.
From what I can tell, the BLUETOOTH and BLUETOOTH_CONNECT permissions are mutually exclusive (requesting one denies the other), so it's impossible to pass both of these checks when targetSdkVersion < 31 (fails in BluetoothHeadset.java) and Build.VERSION >= 31 (fails in BluetoothHeadsetManager.kt)
AudioSwitch Version
- Version: 1.1.5
As a workaround, you can request the BLUETOOTH permission without specifying a maxSdkVersion
, and it should pass since the BLUETOOTH permission can't normally be denied, and will be granted if the targetSdkVersion is <31.
Thank you @davidliu @nredaatepic for the fix. We would like to offer you something for your contribution... please reach out to afalls@twilio.com
@afalls-twilio when are you planning to release this fix?