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

Commit 965cf947 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

LeAudioService: Fix notify about active device.

If setActiveDevice was called twice but previous call is not yet
completed because device is not yet confirmed by AudioFramework, we
should not set additional intent as it will be wrong.

Bug: 309882321
Test: atest LeAudioServiceTest
Tag: #feature
Change-Id: I149013da4fe507a30759fe51670fa22405e50e22
parent 4dace5f6
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -1554,11 +1554,17 @@ public class LeAudioService extends ProfileService {
                            + ", device: "
                            + device
                            + ", hasFallbackDevice: "
                            + hasFallbackDevice);
                            + hasFallbackDevice
                            + ", mExposedActiveDevice: "
                            + mExposedActiveDevice);
        }

        if (groupId == currentlyActiveGroupId) {
            if (groupId != LE_AUDIO_GROUP_ID_INVALID) {
        LeAudioGroupDescriptor groupDescriptor = getGroupDescriptor(currentlyActiveGroupId);
        if (groupDescriptor != null && groupId == currentlyActiveGroupId) {
            /* Make sure active group is already exposed to audio framework.
             * If not, lets wait for it and don't sent additional intent.
             */
            if (groupDescriptor.mCurrentLeadDevice == mExposedActiveDevice) {
                Log.w(
                        TAG,
                        "group is already active: device="
@@ -1577,8 +1583,7 @@ public class LeAudioService extends ProfileService {
                || hasFallbackDevice) {
            Log.i(TAG, "Remember that device has FallbackDevice when become inactive active");

            LeAudioGroupDescriptor descriptor = getGroupDescriptor(currentlyActiveGroupId);
            descriptor.mHasFallbackDeviceWhenGettingInactive = true;
            groupDescriptor.mHasFallbackDeviceWhenGettingInactive = true;
        }

        if (!mLeAudioNativeIsInitialized) {