diff options
| -rw-r--r-- | services/core/java/com/android/server/audio/AudioDeviceInventory.java | 2 | ||||
| -rw-r--r-- | services/core/java/com/android/server/audio/BtHelper.java | 26 |
2 files changed, 16 insertions, 12 deletions
diff --git a/services/core/java/com/android/server/audio/AudioDeviceInventory.java b/services/core/java/com/android/server/audio/AudioDeviceInventory.java index e05824a5f1ab..bf20ae3b516d 100644 --- a/services/core/java/com/android/server/audio/AudioDeviceInventory.java +++ b/services/core/java/com/android/server/audio/AudioDeviceInventory.java @@ -1992,7 +1992,7 @@ public class AudioDeviceInventory { // TODO: return; } else { AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent( - "A2DP source device addr=" + Utils.anonymizeBluetoothAddress(address) + "A2DP sink device addr=" + Utils.anonymizeBluetoothAddress(address) + " now available").printLog(TAG)); } diff --git a/services/core/java/com/android/server/audio/BtHelper.java b/services/core/java/com/android/server/audio/BtHelper.java index a818c30c2e28..f51043dc1cdc 100644 --- a/services/core/java/com/android/server/audio/BtHelper.java +++ b/services/core/java/com/android/server/audio/BtHelper.java @@ -634,16 +634,17 @@ public class BtHelper { return; } List<BluetoothDevice> activeDevices = adapter.getActiveDevices(profile); - if (activeDevices.isEmpty() || activeDevices.get(0) == null) { - return; + BluetoothProfileConnectionInfo bpci = new BluetoothProfileConnectionInfo(profile); + for (BluetoothDevice device : activeDevices) { + if (device == null) { + continue; + } + AudioDeviceBroker.BtDeviceChangedData data = new AudioDeviceBroker.BtDeviceChangedData( + device, null, bpci, "mBluetoothProfileServiceListener"); + AudioDeviceBroker.BtDeviceInfo info = mDeviceBroker.createBtDeviceInfo( + data, device, BluetoothProfile.STATE_CONNECTED); + mDeviceBroker.postBluetoothActiveDevice(info, 0 /* delay */); } - AudioDeviceBroker.BtDeviceChangedData data = new AudioDeviceBroker.BtDeviceChangedData( - activeDevices.get(0), null, new BluetoothProfileConnectionInfo(profile), - "mBluetoothProfileServiceListener"); - AudioDeviceBroker.BtDeviceInfo info = - mDeviceBroker.createBtDeviceInfo(data, activeDevices.get(0), - BluetoothProfile.STATE_CONNECTED); - mDeviceBroker.postBluetoothActiveDevice(info, 0 /* delay */); } // @GuardedBy("mDeviceBroker.mSetModeLock") @@ -678,8 +679,11 @@ public class BtHelper { if (adapter != null) { List<BluetoothDevice> activeDevices = adapter.getActiveDevices(BluetoothProfile.HEADSET); - if (activeDevices.size() > 0 && activeDevices.get(0) != null) { - onSetBtScoActiveDevice(activeDevices.get(0)); + for (BluetoothDevice device : activeDevices) { + if (device == null) { + continue; + } + onSetBtScoActiveDevice(device); } } else { Log.e(TAG, "onHeadsetProfileConnected: Null BluetoothAdapter"); |