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

Commit 8ed8181b authored by Grzegorz Kolodziejczyk's avatar Grzegorz Kolodziejczyk Committed by Gerrit Code Review
Browse files

Merge "bass_client: Enable source monitoring only for external broadcast" into main

parents 556335f0 b25fb9cf
Loading
Loading
Loading
Loading
+32 −8
Original line number Diff line number Diff line
@@ -888,7 +888,8 @@ public class BassClientService extends ProfileService {
            return;
        }

        boolean isAssistantActive = isAnyReceiverReceivingBroadcast(getConnectedDevices());
        boolean isAssistantActive =
                areReceiversReceivingOnlyExternalBroadcast(getConnectedDevices());

        if (isAssistantActive) {
            /* Assistant become active */
@@ -3123,7 +3124,7 @@ public class BassClientService extends ProfileService {
        mUnicastSourceStreamStatus = Optional.of(status);

        if (status == STATUS_LOCAL_STREAM_REQUESTED) {
            if (isAnyReceiverReceivingBroadcast(getConnectedDevices())) {
            if (areReceiversReceivingOnlyExternalBroadcast(getConnectedDevices())) {
                if (leaudioBroadcastAssistantPeripheralEntrustment()) {
                    cacheSuspendingSources(BassConstants.INVALID_BROADCAST_ID);
                } else {
@@ -3160,20 +3161,43 @@ public class BassClientService extends ProfileService {
            for (BluetoothLeBroadcastReceiveState receiveState : getAllSources(device)) {
                for (int i = 0; i < receiveState.getNumSubgroups(); i++) {
                    Long syncState = receiveState.getBisSyncState().get(i);
                    /* Not synced to BIS of failed to sync to BIG */
                    if (syncState == BassConstants.BIS_SYNC_NOT_SYNC_TO_BIS
                            || syncState == BassConstants.BIS_SYNC_FAILED_SYNC_TO_BIG) {
                        continue;
                    }

                    /* Synced to BIS */
                    if (syncState != BassConstants.BIS_SYNC_NOT_SYNC_TO_BIS
                            && syncState != BassConstants.BIS_SYNC_FAILED_SYNC_TO_BIG) {
                        return true;
                    }
                }
            }
        }

        return false;
    }

    /** Check if any sink receivers are receiving broadcast stream */
    public boolean areReceiversReceivingOnlyExternalBroadcast(List<BluetoothDevice> devices) {
        boolean isReceivingExternalBroadcast = false;

        for (BluetoothDevice device : devices) {
            for (BluetoothLeBroadcastReceiveState receiveState : getAllSources(device)) {
                for (int i = 0; i < receiveState.getNumSubgroups(); i++) {
                    Long syncState = receiveState.getBisSyncState().get(i);
                    /* Synced to BIS */
                    if (syncState != BassConstants.BIS_SYNC_NOT_SYNC_TO_BIS
                            && syncState != BassConstants.BIS_SYNC_FAILED_SYNC_TO_BIG) {
                        if (isLocalBroadcast(receiveState)) {
                            return false;
                        } else {
                            isReceivingExternalBroadcast = true;
                        }
                    }

                }
            }
        }

        return isReceivingExternalBroadcast;
    }

    /** Get the active broadcast sink devices receiving broadcast stream */
    public List<BluetoothDevice> getActiveBroadcastSinks() {
        List<BluetoothDevice> activeSinks = new ArrayList<>();
+6 −0
Original line number Diff line number Diff line
@@ -3376,6 +3376,12 @@ public class BassClientServiceTest {
        onScanResult(mSourceDevice, TEST_BROADCAST_ID);
        onSyncEstablished(mSourceDevice, TEST_SYNC_HANDLE);
        BluetoothLeBroadcastMetadata meta = createBroadcastMetadata(TEST_BROADCAST_ID);

        /* Fake external broadcast - no Broadcast Metadata from LE Audio service */
        doReturn(new ArrayList<BluetoothLeBroadcastMetadata>())
                .when(mLeAudioService)
                .getAllBroadcastMetadata();

        verifyAddSourceForGroup(meta);
        for (BassClientStateMachine sm : mStateMachines.values()) {
            if (sm.getDevice().equals(mCurrentDevice)) {