diff options
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothDevice.java')
| -rw-r--r-- | framework/java/android/bluetooth/BluetoothDevice.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/BluetoothDevice.java b/framework/java/android/bluetooth/BluetoothDevice.java index ada3c24e5d..e15d003114 100644 --- a/framework/java/android/bluetooth/BluetoothDevice.java +++ b/framework/java/android/bluetooth/BluetoothDevice.java @@ -737,6 +737,39 @@ public final class BluetoothDevice implements Parcelable { } /** + * Create an RFCOMM {@link BluetoothSocket} socket ready to start an insecure + * outgoing connection to this remote device using SDP lookup of uuid. + * <p> The communication channel will not have an authenticated link key + * i.e it will be subject to man-in-the-middle attacks. For Bluetooth 2.1 + * devices, the link key will be encrypted, as encryption is mandatory. + * For legacy devices (pre Bluetooth 2.1 devices) the link key will + * be not be encrypted. Use {@link #createRfcommSocketToServiceRecord} if an + * encrypted and authenticated communication channel is desired. + * <p>This is designed to be used with {@link + * BluetoothAdapter#listenUsingInsecureRfcommWithServiceRecord} for peer-peer + * Bluetooth applications. + * <p>Use {@link BluetoothSocket#connect} to initiate the outgoing + * connection. This will also perform an SDP lookup of the given uuid to + * determine which channel to connect to. + * <p>The remote device will be authenticated and communication on this + * socket will be encrypted. + * <p>Hint: If you are connecting to a Bluetooth serial board then try + * using the well-known SPP UUID 00001101-0000-1000-8000-00805F9B34FB. + * However if you are connecting to an Android peer then please generate + * your own unique UUID. + * <p>Requires {@link android.Manifest.permission#BLUETOOTH} + * + * @param uuid service record uuid to lookup RFCOMM channel + * @return a RFCOMM BluetoothServerSocket ready for an outgoing connection + * @throws IOException on error, for example Bluetooth not available, or + * insufficient permissions + */ + public BluetoothSocket createInsecureRfcommSocketToServiceRecord(UUID uuid) throws IOException { + return new BluetoothSocket(BluetoothSocket.TYPE_RFCOMM, -1, false, false, this, -1, + new ParcelUuid(uuid)); + } + + /** * Construct an insecure RFCOMM socket ready to start an outgoing * connection. * Call #connect on the returned #BluetoothSocket to begin the connection. |
