Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When does android show a pairing dialog when using insecure RFCOMM bluetooth sockets?

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?)

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.

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.

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.

like image 622
Jan Schejbal Avatar asked Feb 11 '13 00:02

Jan Schejbal


People also ask

How to connect Bluetooth Socket in Android?

To create a BluetoothSocket for connecting to a known device, use BluetoothDevice. createRfcommSocketToServiceRecord() . Then call connect() to attempt a connection to the remote device. This call will block until a connection is established or the connection fails.

How do I stop random Bluetooth pairing requests?

To do this, turn on Bluetooth, connect to the devices you are interested in, and then turn off Bluetooth discoverability. This way, the requesting device will not “see” your device and the requests will cease.

What is Rfcomm in Bluetooth?

Radio frequency communication (RFCOMM) The Bluetooth protocol RFCOMM is a simple set of transport protocols, made on top of the L2CAP protocol, providing emulated RS-232 serial ports (up to sixty simultaneous connections to a Bluetooth device at a time). The protocol is based on the ETSI standard TS 07.10.

What is BluetoothAdapter in Android?

The BluetoothAdapter lets you perform fundamental Bluetooth tasks, such as initiate device discovery, query a list of bonded (paired) devices, instantiate a BluetoothDevice using a known MAC address, and create a BluetoothServerSocket to listen for connection requests from other devices, and start a scan for Bluetooth ...


1 Answers

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:

  • Samsung S2 : Custom ROM (Android v4.2.1) - Rooted
  • Samsung S3 : Stock ROM (Android v4.1.2)
  • Samsung S+ : Custom ROM (Android v4.1.2) - Rooted
  • Samsung GY : Custom ROM (Android v2.3.6) - Rooted
  • Nexus One : Stock ROM (Android v2.3.6) - Rooted

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

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.

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) :

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.

like image 75
Vittorio Cozzolino Avatar answered Oct 13 '22 08:10

Vittorio Cozzolino