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

Commit 33b43ec2 authored by Grzegorz Kołodziejczyk's avatar Grzegorz Kołodziejczyk
Browse files

Protect group from changing its integrity

This CL adds missing synchronized blocks where are operations on group.

Tag: #feature
Bug: 261362580
Test: atest LeAudioServiceTest
Change-Id: I5821d922cd4834e6b19e79d31df7f47f82eb8eef
parent b4ab54ab
Loading
Loading
Loading
Loading
+22 −19
Original line number Diff line number Diff line
@@ -1512,6 +1512,7 @@ public class LeAudioService extends ProfileService {
            int src_audio_location = stackEvent.valueInt4;
            int available_contexts = stackEvent.valueInt5;

            synchronized (mGroupLock) {
                LeAudioGroupDescriptor descriptor = getGroupDescriptor(groupId);
                if (descriptor != null) {
                    if (descriptor.mIsActive) {
@@ -1519,13 +1520,15 @@ public class LeAudioService extends ProfileService {
                                updateActiveDevices(groupId, descriptor.mDirection, direction,
                                descriptor.mIsActive);
                        if (!descriptor.mIsActive) {
                        notifyGroupStatusChanged(groupId, BluetoothLeAudio.GROUP_STATUS_INACTIVE);
                            notifyGroupStatusChanged(groupId,
                                    BluetoothLeAudio.GROUP_STATUS_INACTIVE);
                        }
                    }
                    descriptor.mDirection = direction;
                } else {
                    Log.e(TAG, "no descriptors for group: " + groupId);
                }
            }
        } else if (stackEvent.type == LeAudioStackEvent.EVENT_TYPE_SINK_AUDIO_LOCATION_AVAILABLE) {
            Objects.requireNonNull(stackEvent.device,
                    "Device should never be null, event: " + stackEvent);
@@ -2226,6 +2229,7 @@ public class LeAudioService extends ProfileService {
            Log.d(TAG, "Removing device " + device + " grom group " + groupId);
        }

        synchronized (mGroupLock) {
            LeAudioGroupDescriptor groupDescriptor = getGroupDescriptor(groupId);
            if (DBG) {
                Log.d(TAG, "Lost lead device is " + groupDescriptor.mLostLeadDeviceWhileStreaming);
@@ -2234,7 +2238,6 @@ public class LeAudioService extends ProfileService {
                clearLostDevicesWhileStreaming(groupDescriptor);
            }

        synchronized (mGroupLock) {
            LeAudioDeviceDescriptor deviceDescriptor = getDeviceDescriptor(device);
            if (deviceDescriptor == null) {
                Log.e(TAG, "handleGroupNodeRemoved: No valid descriptor for device: " + device);