使用不安全的 RFCOMM 蓝牙插座时,android 何时显示配对对话框? [英] When does android show a pairing dialog when using insecure RFCOMM bluetooth sockets?

查看:11
本文介绍了使用不安全的 RFCOMM 蓝牙插座时,android 何时显示配对对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过蓝牙连接两个未配对的 Android 设备以进行 P2P 网络连接.不需要中间人保护.为此,Android 具有 createInsecureRfcommSocketToServiceRecordlistenUsingInsecureRfcommWithServiceRecord(自 API 级别 10 起),它们在现代设备上完美运行.但是,在 Galaxy Ace(Android 2.3.3 = API 级别 10,与 Galaxy Nexus 连接)上,它会创建一个配对对话框.这发生在传入和传出连接上.(更新:将 Galaxy Ace 更新到 Android 2.3.6 显然解决了这个问题.是否有特定的 Android 版本总是/从不这样做?)

I am trying to connect two unpaired android devices via Bluetooth for P2P networking purposes. MitM protection is not required. Android has the createInsecureRfcommSocketToServiceRecord and listenUsingInsecureRfcommWithServiceRecord for this (since API level 10), which works perfectly on modern devices. However, on a Galaxy Ace (Android 2.3.3 = API level 10, connecting with a Galaxy Nexus), it creates a pairing dialog. This happens both on incoming and outgoing connections. (Update: Updating the Galaxy Ace to Android 2.3.6 apparently fixes the problem. Is there a specific Android version that always/never does this?)

配对被接受后,连接工作.出于这个原因,我认为这与 Issue 40101: createInsecureRfcommSocketToServiceRecord 原因无关Android 4.2 上的配对对话框,只有在服务记录不存在时才会发生.

After the pairing is accepted, the connection works. For this reason, I think this is not related to Issue 40101: createInsecureRfcommSocketToServiceRecord causes pairing dialog on Android 4.2 which should only happen if the service record does not exist.

我认为在出现此对话框的设备上无法避免此对话框(如果可以,解释如何执行此操作是一个有效的答案).出于这个原因,我想知道何时会出现这样的对话框.我在 Android Java 源代码中没有找到任何内容(它很快就变成了本机版本).我怀疑这与蓝牙版本有什么关系,因为 Ace 有蓝牙 2.1,它应该支持所需的正常工作"连接.

I assume this dialog cannot be avoided on devices where it comes up (if it can, explaining how to do this is a valid answer). For this reason, I would like to know when such a dialog is brought up. I did not find anything in the Android Java source (it goes native pretty quickly). I doubt it has anything to do with the Bluetooth version, since the Ace has Bluetooth 2.1 which is supposed to support the required "just works" connections.

如果有什么可以让我在不弹出对话框的情况下检测设备是否支持连接,或者它是否已明确固定为某个 android 版本,那将极大地帮助我.

If there is anything that would allow me to detect whether a device will support connections without popping the dialog, or if it was clearly fixed to a certain android version, that would immensely help me.

另外,我正在寻找一种方法来轻松排除此类设备.

Also, I am looking for a way to easily exclude such devices.

推荐答案

目前我和你有同样的问题.我开发了一个应用程序来在 BT 终端之间交换消息,我正在不同的手机(我有 S3、S2、S plus、Nexus One 和 Galaxy Y)上测试它以分析行为.手机具有以下规格:

Currently I have the same problem as you. I've developed an application to exchange messages between BT terminals and I'm testing it on different phones ( I have S3, S2, S plus, Nexus One and Galaxy Y) to analize the behaviour. Phones have this specs:

  • 三星 S2:自定义 ROM (Android v4.2.1) - 已根目录
  • 三星 S3:库存 ROM (Android v4.1.2)
  • 三星 S+:自定义 ROM (Android v4.1.2) - 根目录
  • Samsung GY:自定义 ROM (Android v2.3.6) - 根目录
  • Nexus One:Stock ROM (Android v2.3.6) - 根目录

据我的经验,S2 和 S3 一段时间后开始显示配对对话框,即使它们已经配对并交换数据.这种情况一直发生在我在我的测试台中包含这两部手机中的一部时,其他手机运行良好并且从不要求配对(特别是 Nexus One 的行为完美无缺).

As far i can tell you from my experience, S2 and S3 after some time start to show the pairing dialog even if they are already paired and exchanging data. This happens all the time I include one of this two phones in my testbed, others are working fine and never ask for pairing ( expecially Nexus One that has a flawless behaviour).

我进行了长时间的运行测试(从 4 到 6 小时),但我仍然不明白为什么这些手机有时会在 3 小时后要求配对......有时会在 10 分钟后.

I have made long running tests (from 4 to 6 hours) and I still can't figure out why this phones ask for pairing sometimes after 3 hours.. sometimes after 10 minutes.

我唯一想指出的是,即使您使用的是不安全的连接,您仍然可能会被要求进行人机交互以进行配对.看看那个(取自 http://en.wikipedia.org/wiki/Bluetooth) :

The only thing that i would like to point you out is that even if u are using insecure connection you could still be asked for human interaction for pairing. Give a look at that (taken from http://en.wikipedia.org/wiki/Bluetooth) :

有效:正如名称所暗示的那样,此方法有效.没有用户需要互动;但是,设备可能会提示用户确认配对过程.这种方法通常由耳机使用IO 能力非常有限,比固定的更安全此设置通常用于传统配对的 PI​​N 机制有限的设备.这种方法不提供中间人(MITM)保护.

Just works: As implied by the name, this method just works. No user interaction is required; however, a device may prompt the user to confirm the pairing process. This method is typically used by headsets with very limited IO capabilities, and is more secure than the fixed PIN mechanism which is typically used for legacy pairing by this set of limited devices. This method provides no man in the middle (MITM) protection.

这篇关于使用不安全的 RFCOMM 蓝牙插座时,android 何时显示配对对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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