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

Commit 3072b2ae authored by Michal Belusiak (xWF)'s avatar Michal Belusiak (xWF) Committed by Gerrit Code Review
Browse files

Merge "Bass: Remain cached broadcast which are unintentionally paused" into main

parents 32618b8d 8170e502
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -2053,9 +2053,19 @@ public class BassClientService extends ProfileService {
                for (int syncedBroadcast : syncedBroadcasts) {
                    addSelectSourceRequest(syncedBroadcast, true);
                }
            }
                // when starting scan, clear the previously cached broadcast scan results
                mCachedBroadcasts
                        .keySet()
                        .removeIf(
                                key ->
                                        !mPausedBroadcastIds.containsKey(key)
                                                || !mPausedBroadcastIds
                                                        .get(key)
                                                        .equals(PauseType.SINK_UNINTENTIONAL));
            } else {
                // when starting scan, clear the previously cached broadcast scan results
                mCachedBroadcasts.clear();
            }
            // clear previous sources notify flag before scanning new result
            // this is to make sure the active sources are notified even if already synced
            if (mPeriodicAdvertisementResultMap != null) {
+38 −0
Original line number Diff line number Diff line
@@ -6759,6 +6759,44 @@ public class BassClientServiceTest {
        checkNoTimeout(TEST_BROADCAST_ID, BassClientService.MESSAGE_BROADCAST_MONITOR_TIMEOUT);
    }

    @Test
    @EnableFlags({
        Flags.FLAG_LEAUDIO_BROADCAST_RESYNC_HELPER,
        Flags.FLAG_LEAUDIO_BROADCAST_EXTRACT_PERIODIC_SCANNER_FROM_STATE_MACHINE
    })
    public void outOfRange_syncEstablishedFailed_restartSearching() {
        prepareSynchronizedPairAndStopSearching();

        // Bis and PA unsynced, SINK_UNINTENTIONAL
        BluetoothLeBroadcastMetadata meta = createBroadcastMetadata(TEST_BROADCAST_ID);
        injectRemoteSourceStateChanged(meta, false, false);
        mInOrderMethodProxy
                .verify(mMethodProxy)
                .periodicAdvertisingManagerRegisterSync(
                        any(), any(), anyInt(), anyInt(), any(), any());
        checkTimeout(TEST_BROADCAST_ID, BassClientService.MESSAGE_BIG_MONITOR_TIMEOUT);
        checkNoTimeout(TEST_BROADCAST_ID, BassClientService.MESSAGE_BROADCAST_MONITOR_TIMEOUT);

        onSyncEstablishedFailed(mSourceDevice, TEST_SYNC_HANDLE);
        checkTimeout(TEST_BROADCAST_ID, BassClientService.MESSAGE_BROADCAST_MONITOR_TIMEOUT);
        mInOrderMethodProxy
                .verify(mMethodProxy)
                .periodicAdvertisingManagerRegisterSync(
                        any(), any(), anyInt(), anyInt(), any(), any());

        // Start searching again should not removed cache for SINK_UNINTENTIONAL
        // which allow to register sync again after onSyncEstablishedFailed
        startSearchingForSources();

        checkTimeout(TEST_BROADCAST_ID, BassClientService.MESSAGE_BIG_MONITOR_TIMEOUT);

        onSyncEstablishedFailed(mSourceDevice, TEST_SYNC_HANDLE);
        mInOrderMethodProxy
                .verify(mMethodProxy)
                .periodicAdvertisingManagerRegisterSync(
                        any(), any(), anyInt(), anyInt(), any(), any());
    }

    @Test
    @EnableFlags({
        Flags.FLAG_LEAUDIO_BROADCAST_RESYNC_HELPER,