diff options
| author | Jaikumar Ganesh <jaikumar@google.com> | 2011-08-19 10:26:32 -0700 |
|---|---|---|
| committer | Jaikumar Ganesh <jaikumar@google.com> | 2011-08-22 14:44:38 -0700 |
| commit | 5317842b3d84997bc5327a404cea1d6bcd9d515d (patch) | |
| tree | f00f6c29116ab397db6704ae01eef675ab5f803e /framework/java/android/bluetooth/BluetoothAdapter.java | |
| parent | db696839baf81678198ab1e9ffb25ff343f00f0c (diff) | |
Add Api to get profile connection state.
This gets the current connection state of the profile with respect
to the local Bluetooth adapter.
Change-Id: I7cff6c9201d29a8b45413cff7384b7483f21bd5c
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothAdapter.java')
| -rw-r--r-- | framework/java/android/bluetooth/BluetoothAdapter.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/BluetoothAdapter.java b/framework/java/android/bluetooth/BluetoothAdapter.java index 28bc424d93..264db1917d 100644 --- a/framework/java/android/bluetooth/BluetoothAdapter.java +++ b/framework/java/android/bluetooth/BluetoothAdapter.java @@ -774,6 +774,31 @@ 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} + * @hide + */ + 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. */ |
