diff options
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothAdapter.java')
| -rw-r--r-- | framework/java/android/bluetooth/BluetoothAdapter.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/BluetoothAdapter.java b/framework/java/android/bluetooth/BluetoothAdapter.java index 28bc424d93..223692859d 100644 --- a/framework/java/android/bluetooth/BluetoothAdapter.java +++ b/framework/java/android/bluetooth/BluetoothAdapter.java @@ -774,6 +774,32 @@ public final class BluetoothAdapter { } /** + * Get the current connection state of a profile. + * This function can be used to check whether the local Bluetooth adapter + * is connected to any remote device for a specific profile. + * Profile can be one of {@link BluetoothProfile#HEADSET}, + * {@link BluetoothProfile#A2DP}. + * + * <p>Requires {@link android.Manifest.permission#BLUETOOTH}. + * + * <p> Return value can be one of + * {@link BluetoothProfile#STATE_DISCONNECTED}, + * {@link BluetoothProfile#STATE_CONNECTING}, + * {@link BluetoothProfile#STATE_CONNECTED}, + * {@link BluetoothProfile#STATE_DISCONNECTING} + */ + public int getProfileConnectionState(int profile) { + if (getState() != STATE_ON) return BluetoothProfile.STATE_DISCONNECTED; + try { + return mService.getProfileConnectionState(profile); + } catch (RemoteException e) { + Log.e(TAG, "getProfileConnectionState:", e); + } + return BluetoothProfile.STATE_DISCONNECTED; + } + + /** + /** * Picks RFCOMM channels until none are left. * Avoids reserved channels. */ |
