无需用户确认蓝牙配对

无需用户确认蓝牙配对

问题描述:

我可以配对的两个设备通过蓝牙,而不需要确认该用户界面,接受这个配对的设备。我可以没有任何多余的用户操作过交换一些额外的数据,例如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?

这需要的就是为什么 createInsecureRfcommSocketToServiceRecord()加入 BluetoothDevice类首发的Andr​​oid 2.3.3(API等级10)(SDK文档)......在此之前,有这个没有SDK的支持。它被设计为允许机器人连接到设备,而无需用户界面,用于输入一个PIN code(像嵌入式设备),但它只是为可用来设置,而无需用户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.

希望帮助!

P.S。也有办法做到这一点上使用反射许多设备2.3之前,因为code确实存在......但我不一定会推荐这种大规模分布式生产应用。看到这个*.

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 *.