summaryrefslogtreecommitdiff
path: root/framework/java
diff options
context:
space:
mode:
author Hyundo Moon <hdmoon@google.com> 2025-02-03 12:08:21 +0900
committer Hyundo Moon <hdmoon@google.com> 2025-02-02 20:56:11 -0800
commitdd842deacd8e31850797fa5bec39081dcf074a4e (patch)
tree24ba32ad27a879ad00b1449ae46c7b8776171bca /framework/java
parent10696b631ae0dae6e03a93d3014e8a1cdbae587f (diff)
BluetoothGatt: Use CopyOnWriteArrayList for thread safety
Bug: 393956042 Test: m -j; Flag: EXEMPT, changing variable type only Change-Id: If428edf855abfb8a9cf194ba0480330437ff6770
Diffstat (limited to 'framework/java')
-rw-r--r--framework/java/android/bluetooth/BluetoothGatt.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/framework/java/android/bluetooth/BluetoothGatt.java b/framework/java/android/bluetooth/BluetoothGatt.java
index a69c8ba792..7e211b5d5b 100644
--- a/framework/java/android/bluetooth/BluetoothGatt.java
+++ b/framework/java/android/bluetooth/BluetoothGatt.java
@@ -44,6 +44,7 @@ import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
+import java.util.concurrent.CopyOnWriteArrayList;
/**
* Public API for the Bluetooth GATT Profile.
@@ -97,7 +98,7 @@ public final class BluetoothGatt implements BluetoothProfile {
// Max length of an attribute value, defined in gatt_api.h
private static final int GATT_MAX_ATTR_LEN = 512;
- private List<BluetoothGattService> mServices;
+ private CopyOnWriteArrayList<BluetoothGattService> mServices;
/** A GATT operation completed successfully */
public static final int GATT_SUCCESS = 0;
@@ -1022,7 +1023,7 @@ public final class BluetoothGatt implements BluetoothProfile {
mPhy = phy;
mOpportunistic = opportunistic;
mAttributionSource = attributionSource;
- mServices = new ArrayList<BluetoothGattService>();
+ mServices = new CopyOnWriteArrayList<>();
mConnState = CONN_STATE_IDLE;
mAuthRetryState = AUTH_RETRY_STATE_IDLE;