diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/bluetooth/BluetoothAdapter.java | 54 | ||||
-rw-r--r-- | core/java/android/bluetooth/IBluetooth.aidl | 4 |
2 files changed, 58 insertions, 0 deletions
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java index 05dfacd..70f478a 100644 --- a/core/java/android/bluetooth/BluetoothAdapter.java +++ b/core/java/android/bluetooth/BluetoothAdapter.java @@ -1784,6 +1784,60 @@ public final class BluetoothAdapter { } /** + * Create a client side Message Access Profile Service Record. + * Create the record once, and reuse it for all connections. + * If changes to a record is needed remove the old record using {@link removeSdpRecord} + * and then create a new one. + * WARNING: This API requires removeSdpRecord() to be called, to avoid leaking resources! + * A second call to this function - either from two different apps or from the + * same app, without first calling removeSdpRecord() - will make the device + * break the Bluetooth spec, which could lead to severe IOP issues. + * @param serviceName The textual name of the service + * @param rfcommChannel The RFCOMM channel that clients can connect to + * (obtain from BluetoothServerSocket) + * @param l2capPsm The L2CAP PSM channel that clients can connect to + * (obtain from BluetoothServerSocket) + * Supply -1 to omit the L2CAP PSM from the record. + * @param version The Profile version number (As specified in the Bluetooth + * MAP specification) + * @param features The feature bit mask (As specified in the Bluetooth + * MAP specification) + * @return a handle to the record created. The record can be removed again + * using {@link removeSdpRecord}(). The record is not linked to the + * creation/destruction of BluetoothSockets, hence SDP record cleanup + * is a separate process. + * returns -1 if an error occure and the record was not created. + * @hide + */ + public int createMapMnsSdpRecord(String serviceName, int rfcommChannel, + int l2capPsm, int version, int features) { + try { + return mService.createMapMnsSdpRecord(serviceName, rfcommChannel, + l2capPsm, version, features); + } catch (RemoteException e) { + Log.e(TAG, "createMapMnsSdpRecord: ", e); + } + return -1; + } + + /** + * Remove a SDP record created using createSdpRecord(). + * This function shall be called before a new call to createSdpRecord for the same record + * type can be made, unless the record type created supports multiple instances. + * @param recordHandle handle of the record to remove - provided by createSdpRecord() + * @return true if success + * @hide + */ + public boolean removeSdpRecord(int recordHandle){ + try { + return mService.removeSdpRecord(recordHandle); + } catch (RemoteException e) { + Log.e(TAG, "createMapMnsSdpRecord: ", e); + } + return false; + } + + /** * Read the local Out of Band Pairing Data * <p>Requires {@link android.Manifest.permission#BLUETOOTH} * diff --git a/core/java/android/bluetooth/IBluetooth.aidl b/core/java/android/bluetooth/IBluetooth.aidl index 3ca32b6..8cdc7bf 100644 --- a/core/java/android/bluetooth/IBluetooth.aidl +++ b/core/java/android/bluetooth/IBluetooth.aidl @@ -70,6 +70,10 @@ interface IBluetooth boolean fetchRemoteUuids(in BluetoothDevice device); boolean sdpSearch(in BluetoothDevice device, in ParcelUuid uuid); + int createMapMnsSdpRecord(in String serviceName, in int rfcommChannel, + in int l2capPsm, in int version, in int features); + boolean removeSdpRecord(in int recordHandle); + boolean setPin(in BluetoothDevice device, boolean accept, int len, in byte[] pinCode); boolean setPasskey(in BluetoothDevice device, boolean accept, int len, in byte[] passkey); |