diff options
author | Pavlin Radoslavov <pavlin@google.com> | 2018-01-03 19:38:39 -0800 |
---|---|---|
committer | Pavlin Radoslavov <pavlin@google.com> | 2018-01-26 13:08:00 -0800 |
commit | 7f195cee6651eddc4ff4bc9af829bd7d8b5343b7 (patch) | |
tree | 8b7adf3f978075c789980018bde2716a4788f8c5 /framework/java/android/bluetooth/BluetoothA2dp.java | |
parent | a361dd6e9a247027d7917eb53d61a4cc7eaae98f (diff) |
Add support for Multi-A2DP state machines per device
* Update usage of A2dpService API calls that take BluetoothDevice
as an additional argument
* Update the description for BluetoothA2dp.connect()
Exempt-From-Owner-Approval: De-facto owner of the relevant changes is
the Bluetooth team.
Bug: 69269748
Test: Manual
Change-Id: I190ed48ef65bbc8b88b45f84ebd6ab3d21cf0b4e
Merged-In: I190ed48ef65bbc8b88b45f84ebd6ab3d21cf0b4e
(cherry picked from commit 164b38b96f225cef9eab6edebf589215071aec48)
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothA2dp.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothA2dp.java | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/framework/java/android/bluetooth/BluetoothA2dp.java b/framework/java/android/bluetooth/BluetoothA2dp.java index 35a21a4eaf..b255a43cbe 100644 --- a/framework/java/android/bluetooth/BluetoothA2dp.java +++ b/framework/java/android/bluetooth/BluetoothA2dp.java @@ -300,11 +300,7 @@ public final class BluetoothA2dp implements BluetoothProfile { } /** - * Initiate connection to a profile of the remote bluetooth device. - * - * <p> Currently, the system supports only 1 connection to the - * A2DP profile. The API will automatically disconnect connected - * devices before connecting. + * Initiate connection to a profile of the remote Bluetooth device. * * <p> This API returns false in scenarios like the profile on the * device is already connected or Bluetooth is not turned on. @@ -699,15 +695,17 @@ public final class BluetoothA2dp implements BluetoothProfile { /** * Gets the current codec status (configuration and capability). * + * @param device the remote Bluetooth device. If null, use the current + * active A2DP Bluetooth device. * @return the current codec status * @hide */ - public BluetoothCodecStatus getCodecStatus() { - if (DBG) Log.d(TAG, "getCodecStatus"); + public BluetoothCodecStatus getCodecStatus(BluetoothDevice device) { + if (DBG) Log.d(TAG, "getCodecStatus(" + device + ")"); try { mServiceLock.readLock().lock(); if (mService != null && isEnabled()) { - return mService.getCodecStatus(); + return mService.getCodecStatus(device); } if (mService == null) { Log.w(TAG, "Proxy not attached to service"); @@ -724,15 +722,18 @@ public final class BluetoothA2dp implements BluetoothProfile { /** * Sets the codec configuration preference. * + * @param device the remote Bluetooth device. If null, use the current + * active A2DP Bluetooth device. * @param codecConfig the codec configuration preference * @hide */ - public void setCodecConfigPreference(BluetoothCodecConfig codecConfig) { - if (DBG) Log.d(TAG, "setCodecConfigPreference"); + public void setCodecConfigPreference(BluetoothDevice device, + BluetoothCodecConfig codecConfig) { + if (DBG) Log.d(TAG, "setCodecConfigPreference(" + device + ")"); try { mServiceLock.readLock().lock(); if (mService != null && isEnabled()) { - mService.setCodecConfigPreference(codecConfig); + mService.setCodecConfigPreference(device, codecConfig); } if (mService == null) Log.w(TAG, "Proxy not attached to service"); return; @@ -747,36 +748,42 @@ public final class BluetoothA2dp implements BluetoothProfile { /** * Enables the optional codecs. * + * @param device the remote Bluetooth device. If null, use the currect + * active A2DP Bluetooth device. * @hide */ - public void enableOptionalCodecs() { - if (DBG) Log.d(TAG, "enableOptionalCodecs"); - enableDisableOptionalCodecs(true); + public void enableOptionalCodecs(BluetoothDevice device) { + if (DBG) Log.d(TAG, "enableOptionalCodecs(" + device + ")"); + enableDisableOptionalCodecs(device, true); } /** * Disables the optional codecs. * + * @param device the remote Bluetooth device. If null, use the currect + * active A2DP Bluetooth device. * @hide */ - public void disableOptionalCodecs() { - if (DBG) Log.d(TAG, "disableOptionalCodecs"); - enableDisableOptionalCodecs(false); + public void disableOptionalCodecs(BluetoothDevice device) { + if (DBG) Log.d(TAG, "disableOptionalCodecs(" + device + ")"); + enableDisableOptionalCodecs(device, false); } /** * Enables or disables the optional codecs. * + * @param device the remote Bluetooth device. If null, use the currect + * active A2DP Bluetooth device. * @param enable if true, enable the optional codecs, other disable them */ - private void enableDisableOptionalCodecs(boolean enable) { + private void enableDisableOptionalCodecs(BluetoothDevice device, boolean enable) { try { mServiceLock.readLock().lock(); if (mService != null && isEnabled()) { if (enable) { - mService.enableOptionalCodecs(); + mService.enableOptionalCodecs(device); } else { - mService.disableOptionalCodecs(); + mService.disableOptionalCodecs(device); } } if (mService == null) Log.w(TAG, "Proxy not attached to service"); |