无需用户确认即可进行蓝牙配对 [英] Bluetooth pairing without user confirmation

查看:31
本文介绍了无需用户确认即可进行蓝牙配对的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以通过蓝牙对两个设备进行配对,而无需在用户界面中确认这一点,接受配对此设备.我能否通过 NFC 等方式交换一些额外数据,然后通过蓝牙安全地配对这两个设备,而无需任何额外的用户操作?

Can I pair two devices over Bluetooth without a need to confirm this in user interface, accept to pair this devices. Can I exchange some extra data over, for example NFC, and then safely pair those two devices over Bluetooth without any extra user action?

推荐答案

这正是 Android 2.3.3 开始将 createInsecureRfcommSocketToServiceRecord() 添加到 BluetoothDevice 的原因API 级别 10)(SDK 文档)...在此之前没有 SDK 支持.它旨在允许 Android 连接到无需输入 PIN 码的用户界面的设备(如嵌入式设备),但它也可用于在没有用户 PIN 输入的情况下在两台设备之间建立连接.

This need is exactly why createInsecureRfcommSocketToServiceRecord() was added to BluetoothDevice starting in Android 2.3.3 (API Level 10) (SDK Docs)...before that there was no SDK support for this. It was designed to allow Android to connect to devices without user interfaces for entering a PIN code (like an embedded device), but it just as usable for setting up a connection between two devices without user PIN entry.

BluetoothAdapter 中的推论方法 listenUsingInsecureRfcommWithServiceRecord() 用于接受这些类型的连接.这不是安全漏洞,因为这些方法必须成对使用.您不能使用它来简单地尝试与任何旧的蓝牙设备配对.

The corollary method listenUsingInsecureRfcommWithServiceRecord() in BluetoothAdapter is used to accept these types of connections. It's not a security breach because the methods must be used as a pair. You cannot use this to simply attempt to pair with any old Bluetooth device.

您还可以通过 NFC 进行短距离通信,但该硬件在 Android 设备上不那么突出.一定要选择一个,不要试图创建一个同时使用两者的解决方案.

You can also do short range communications over NFC, but that hardware is less prominent on Android devices. Definitely pick one, and don't try to create a solution that uses both.

希望有帮助!

附言也有使用反射在 2.3 之前的许多设备上执行此操作的方法,因为代码确实存在……但我不一定建议将其用于大规模分布式生产应用程序.请参阅此 StackOverflow.

P.S. There are also ways to do this on many devices prior to 2.3 using reflection, because the code did exist...but I wouldn't necessarily recommend this for mass-distributed production applications. See this StackOverflow.

这篇关于无需用户确认即可进行蓝牙配对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆