summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jakub Tyszkowski (xWF) <tyszkowski@google.com> 2024-10-28 08:12:43 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2024-10-28 08:12:43 +0000
commita8eeda6cd6cf1f19a23f6cff813ea169c995559e (patch)
tree2d836e9a8b05b01a175fecbae888193db332a23c
parent26fb05c4d6f3da2443fe1c6b0b7c627afb9b2fef (diff)
parent4a2fbefd080835a02899e4f4074060bb142be810 (diff)
Merge "Csip: Improve multithreaded access to state machines" into main
-rw-r--r--android/app/src/com/android/bluetooth/csip/CsipSetCoordinatorService.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/android/app/src/com/android/bluetooth/csip/CsipSetCoordinatorService.java b/android/app/src/com/android/bluetooth/csip/CsipSetCoordinatorService.java
index 62b191a876..9febc11954 100644
--- a/android/app/src/com/android/bluetooth/csip/CsipSetCoordinatorService.java
+++ b/android/app/src/com/android/bluetooth/csip/CsipSetCoordinatorService.java
@@ -51,6 +51,7 @@ import com.android.bluetooth.btservice.ProfileService;
import com.android.bluetooth.btservice.ServiceFactory;
import com.android.bluetooth.btservice.storage.DatabaseManager;
import com.android.bluetooth.le_audio.LeAudioService;
+import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import java.util.ArrayList;
@@ -85,6 +86,7 @@ public class CsipSetCoordinatorService extends ProfileService {
@VisibleForTesting CsipSetCoordinatorNativeInterface mCsipSetCoordinatorNativeInterface;
+ @GuardedBy("mStateMachines")
private final Map<BluetoothDevice, CsipSetCoordinatorStateMachine> mStateMachines =
new HashMap<>();
@@ -143,8 +145,11 @@ public class CsipSetCoordinatorService extends ProfileService {
// Get LE Audio service (can be null)
mLeAudioService = mServiceFactory.getLeAudioService();
+ synchronized (mStateMachines) {
+ mStateMachines.clear();
+ }
+
// Start handler thread for state machines
- mStateMachines.clear();
mStateMachinesThread = new HandlerThread("CsipSetCoordinatorService.StateMachines");
mStateMachinesThread.start();
@@ -1181,8 +1186,10 @@ public class CsipSetCoordinatorService extends ProfileService {
@Override
public void dump(StringBuilder sb) {
super.dump(sb);
- for (CsipSetCoordinatorStateMachine sm : mStateMachines.values()) {
- sm.dump(sb);
+ synchronized (mStateMachines) {
+ for (CsipSetCoordinatorStateMachine sm : mStateMachines.values()) {
+ sm.dump(sb);
+ }
}
ProfileService.println(sb, "mFoundSetMemberToGroupId: ");
for (Map.Entry<BluetoothDevice, Integer> entry : mFoundSetMemberToGroupId.entrySet()) {