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 | cb1d354c1e9b458a0426cd08520d938012e32b34 (patch) | |
| tree | e8d143e7743bd943e83603d3e53e732302acf05c /core/java/android/bluetooth | |
| parent | 7a12d6ba14a35276fd3afb314d6c95055da4c6f0 (diff) | |
| download | frameworks_base-cb1d354c1e9b458a0426cd08520d938012e32b34.zip frameworks_base-cb1d354c1e9b458a0426cd08520d938012e32b34.tar.gz frameworks_base-cb1d354c1e9b458a0426cd08520d938012e32b34.tar.bz2 | |
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 'core/java/android/bluetooth')
| -rw-r--r-- | core/java/android/bluetooth/BluetoothAdapter.java | 25 | ||||
| -rw-r--r-- | core/java/android/bluetooth/BluetoothProfile.java | 6 | ||||
| -rw-r--r-- | core/java/android/bluetooth/IBluetooth.aidl | 3 |
3 files changed, 33 insertions, 1 deletions
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java index 28bc424..264db19 100644 --- a/core/java/android/bluetooth/BluetoothAdapter.java +++ b/core/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. */ diff --git a/core/java/android/bluetooth/BluetoothProfile.java b/core/java/android/bluetooth/BluetoothProfile.java index 6cd81fd..58b3868 100644 --- a/core/java/android/bluetooth/BluetoothProfile.java +++ b/core/java/android/bluetooth/BluetoothProfile.java @@ -83,6 +83,12 @@ public interface BluetoothProfile { public static final int PAN = 5; /** + * PBAP + * @hide + */ + public static final int PBAP = 6; + + /** * Default priority for devices that we try to auto-connect to and * and allow incoming connections for the profile * @hide diff --git a/core/java/android/bluetooth/IBluetooth.aidl b/core/java/android/bluetooth/IBluetooth.aidl index 48dfed8..d4e7f7d 100644 --- a/core/java/android/bluetooth/IBluetooth.aidl +++ b/core/java/android/bluetooth/IBluetooth.aidl @@ -53,6 +53,7 @@ interface IBluetooth byte[] readOutOfBandData(); int getAdapterConnectionState(); + int getProfileConnectionState(int profile); boolean changeApplicationBluetoothState(boolean on, in IBluetoothStateChangeCallback callback, in IBinder b); @@ -121,5 +122,5 @@ interface IBluetooth List<BluetoothDevice> getHealthDevicesMatchingConnectionStates(in int[] states); int getHealthDeviceConnectionState(in BluetoothDevice device); - void sendConnectionStateChange(in BluetoothDevice device, int state, int prevState); + void sendConnectionStateChange(in BluetoothDevice device, int profile, int state, int prevState); } |
