summaryrefslogtreecommitdiff
path: root/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
diff options
context:
space:
mode:
authorPavlin Radoslavov <pavlin@google.com>2018-01-04 16:06:17 -0800
committerPavlin Radoslavov <pavlin@google.com>2018-01-25 11:06:59 +0000
commite887ee15ada2eb9a80db62d99109b3a635199cb0 (patch)
treeae4a248219cea2f13ec066aa5b2b40f4e7cb265f /src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
parent345a3cb61d7a6810568753887c0683fc3baf8616 (diff)
Add support for Multi-A2DP state machines per device
Update usage of A2dpService API calls that take BluetoothDevice as an additional argument. If the BluetoothDevice argument is null, the API applies to the device that is currently the Active A2DP device. Exempt-From-Owner-Approval: De-facto owner of the relevant changes is the Bluetooth team. Bug: 69269748 Test: Manual Change-Id: I7417b7b0741f706df475cb2b27fbe6525f744269
Diffstat (limited to 'src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java')
-rw-r--r--src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java b/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
index e4e6493886..171dd6a0b2 100644
--- a/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
+++ b/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
@@ -18,6 +18,8 @@ package com.android.settings.development;
import android.bluetooth.BluetoothA2dp;
import android.bluetooth.BluetoothCodecConfig;
+import android.bluetooth.BluetoothCodecStatus;
+import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.ListPreference;
@@ -80,7 +82,7 @@ public abstract class AbstractBluetoothA2dpPreferenceController extends
final BluetoothCodecConfig codecConfig = mBluetoothA2dpConfigStore.createCodecConfig();
synchronized (mBluetoothA2dpConfigStore) {
if (mBluetoothA2dp != null) {
- setCodecConfigPreference(codecConfig);
+ setCodecConfigPreference(null, codecConfig); // Use current active device
}
}
// Because the setting is not persisted into permanent storage, we cannot call update state
@@ -99,13 +101,13 @@ public abstract class AbstractBluetoothA2dpPreferenceController extends
@Override
public void updateState(Preference preference) {
- if (getCodecConfig() == null || mPreference == null) {
+ if (getCodecConfig(null) == null || mPreference == null) { // Use current active device
return;
}
BluetoothCodecConfig codecConfig;
synchronized (mBluetoothA2dpConfigStore) {
- codecConfig = getCodecConfig();
+ codecConfig = getCodecConfig(null); // Use current active device
}
final int index = getCurrentA2dpSettingIndex(codecConfig);
@@ -183,16 +185,19 @@ public abstract class AbstractBluetoothA2dpPreferenceController extends
protected abstract int getDefaultIndex();
@VisibleForTesting
- void setCodecConfigPreference(BluetoothCodecConfig config) {
- mBluetoothA2dp.setCodecConfigPreference(config);
+ void setCodecConfigPreference(BluetoothDevice device,
+ BluetoothCodecConfig config) {
+ mBluetoothA2dp.setCodecConfigPreference(device, config);
}
@VisibleForTesting
- BluetoothCodecConfig getCodecConfig() {
- if (mBluetoothA2dp == null || mBluetoothA2dp.getCodecStatus() == null) {
- return null;
+ BluetoothCodecConfig getCodecConfig(BluetoothDevice device) {
+ if (mBluetoothA2dp != null) {
+ BluetoothCodecStatus codecStatus = mBluetoothA2dp.getCodecStatus(device);
+ if (codecStatus != null) {
+ return codecStatus.getCodecConfig();
+ }
}
-
- return mBluetoothA2dp.getCodecStatus().getCodecConfig();
+ return null;
}
}