bluetoothsocket.connect()Android 12在某些设备上的许可问题
我们使用蓝牙低能L2CAP通道(在Android API级别29中引入)将数据传输到我们的BLE设备。最近,我们有报道说它在此设备上不起作用:
- OPPO查找X2 Pro,API级别31(Android 12)
- Sony Xperia 1 III,API级别31(Android 12)
,事实证明,当致电BluetoothSocket.connect时,事实证明()
在bluetoothsocket
createInseCurel2CapChannel()这些某些设备
java.lang.SecurityException: UID 10391 / PID 18566 lacks permission android.permission.BLUETOOTH
在清单中抛出声明android.permission.bluetooth.bluetooth
解决了问题。
文档清楚地说 subsign.permission.bluetrise.bluetoots.bluetooth_connect
应该需要。这种预期的行为也可以源自以下事实:在所有其他BLE方案android.permission.bluetooth.bluetooth
api级别不需要 = 31。= 31。
这是供应商中的错误 - 蓝牙堆栈的特定实现?更多的设备/供应商会影响此错误吗?
We use Bluetooth Low Energy L2CAP Channels (introduced in Android API Level 29) to transfer data to our BLE devices. Recently we've got reports that it's not working on this devices:
- Oppo Find X2 Pro, API Level 31 (Android 12)
- Sony Xperia 1 III, API Level 31 (Android 12)
It turned out that when calling BluetoothSocket.connect()
on the BluetoothSocket
returned by createInsecureL2capChannel() these certain devices throw
java.lang.SecurityException: UID 10391 / PID 18566 lacks permission android.permission.BLUETOOTH
Declaring android.permission.BLUETOOTH
in the manifest solves the problem.
But the documentation clearly says that only Manifest.permission.BLUETOOTH_CONNECT
should be needed. And this expected behaviour could also be derived from the fact that in all other BLE scenarios android.permission.BLUETOOTH
is never needed for API Level >= 31.
Is this a bug in the vendor-specific implementation of the Bluetooth stack? Are more devices/vendors are affected of this bug?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论