diff options
author | wentjin <quic_wentjin@quicinc.com> | 2021-12-24 18:00:08 +0800 |
---|---|---|
committer | Wentong Jin <quic_wentjin@quicinc.com> | 2021-12-30 05:04:14 +0000 |
commit | f389baa556a1db5e0015eeb74be3281d3af0f50b (patch) | |
tree | c6b07fca3228824da969b8323a23b8db518433af /core | |
parent | ac9dfd186816a0aaea3337944d54ed33e37375f9 (diff) |
Use CopyOnWriteArrayList for mGroupDevices
This change updates ArrayList to CopyOnWriteArrayList
for mGroupDevices for thread safe concurrent access.
CRs-Fixed: 3100274
Change-Id: Id303c4ceb3740fb47ce81ebd71bce0b2219cb1b2
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/bluetooth/DeviceGroup.java | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/core/java/android/bluetooth/DeviceGroup.java b/core/java/android/bluetooth/DeviceGroup.java index f1bd2c310197..0dac87f3d8f6 100644 --- a/core/java/android/bluetooth/DeviceGroup.java +++ b/core/java/android/bluetooth/DeviceGroup.java @@ -38,6 +38,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.UUID; +import java.util.concurrent.CopyOnWriteArrayList; /** * Provides Device Group details. @@ -53,7 +54,8 @@ public final class DeviceGroup implements Parcelable { /** Size of the Device Group. */ private int mSize; /** List of all group devices {@link BluetoothDevice} */ - private List <BluetoothDevice> mGroupDevices = new ArrayList<BluetoothDevice>(); + private CopyOnWriteArrayList <BluetoothDevice> mGroupDevices + = new CopyOnWriteArrayList<BluetoothDevice>(); /** Primary Service UUID which has included required Device Group service*/ private final ParcelUuid mIncludingSrvcUUID; /** Suggests whether exclusive access can be taken for this device group */ @@ -67,7 +69,7 @@ public final class DeviceGroup implements Parcelable { ParcelUuid includingSrvcUUID, boolean exclusiveAccessSupport) { mGroupId = groupId; mSize = size; - mGroupDevices = groupDevices; + mGroupDevices.addAll(groupDevices); mIncludingSrvcUUID = includingSrvcUUID; mExclusiveAccessSupport = exclusiveAccessSupport; } |