Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a8eeda6c authored by Jakub Tyszkowski (xWF)'s avatar Jakub Tyszkowski (xWF) Committed by Gerrit Code Review
Browse files

Merge "Csip: Improve multithreaded access to state machines" into main

parents 26fb05c4 4a2fbefd
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -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();

        // Start handler thread for state machines
        synchronized (mStateMachines) {
            mStateMachines.clear();
        }

        // Start handler thread for state machines
        mStateMachinesThread = new HandlerThread("CsipSetCoordinatorService.StateMachines");
        mStateMachinesThread.start();

@@ -1181,9 +1186,11 @@ public class CsipSetCoordinatorService extends ProfileService {
    @Override
    public void dump(StringBuilder sb) {
        super.dump(sb);
        synchronized (mStateMachines) {
            for (CsipSetCoordinatorStateMachine sm : mStateMachines.values()) {
                sm.dump(sb);
            }
        }
        ProfileService.println(sb, "mFoundSetMemberToGroupId: ");
        for (Map.Entry<BluetoothDevice, Integer> entry : mFoundSetMemberToGroupId.entrySet()) {
            ProfileService.println(