Skip to content

Commit ad08b5b

Browse files
author
Evan Laird
committed
DO NOT MERGE: Use a copy of bt device profile list when updating
CachedBluetoothDevice#getProfiles() only returns a Collections.unmodifiableList which isn't thread safe. Use a copy in BluetoothControllerImpl so we can avoid a CME Test: atest SystemUITests Bug: 146828136 Change-Id: I451a746836c67b8b82f26f4f39b5363ac5e0ea79
1 parent 521c224 commit ad08b5b

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,10 @@ public List<LocalBluetoothProfile> getProfiles() {
661661
return Collections.unmodifiableList(mProfiles);
662662
}
663663

664+
public List<LocalBluetoothProfile> getProfileListCopy() {
665+
return new ArrayList<>(mProfiles);
666+
}
667+
664668
public List<LocalBluetoothProfile> getConnectableProfiles() {
665669
List<LocalBluetoothProfile> connectableProfiles =
666670
new ArrayList<LocalBluetoothProfile>();

packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ private void updateAudioProfile() {
277277
boolean otherProfileConnected = false;
278278

279279
for (CachedBluetoothDevice device : getDevices()) {
280-
for (LocalBluetoothProfile profile : device.getProfiles()) {
280+
for (LocalBluetoothProfile profile : device.getProfileListCopy()) {
281281
int profileId = profile.getProfileId();
282282
boolean isConnected = device.isConnectedProfile(profile);
283283
if (profileId == BluetoothProfile.HEADSET

0 commit comments

Comments
 (0)