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

Commit 9fc68cae authored by Rongxuan Liu's avatar Rongxuan Liu
Browse files

[le audio] Update BIS state check

Bug: 375471923
Flag: EXEMPT, refactor - no functional change
Test: atest BassClientServiceTest
Change-Id: I5382108a78e0515ec83f70c52278246082296ab8
parent 4434fc5a
Loading
Loading
Loading
Loading
+9 −20
Original line number Diff line number Diff line
@@ -3928,10 +3928,7 @@ public class BassClientService extends ProfileService {
        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 (isSyncedToBroadcastStream(receiveState.getBisSyncState().get(i))) {
                        return true;
                    }
                }
@@ -3948,10 +3945,7 @@ public class BassClientService extends ProfileService {
        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 (isSyncedToBroadcastStream(receiveState.getBisSyncState().get(i))) {
                        if (isLocalBroadcast(receiveState)) {
                            return false;
                        } else {
@@ -3981,10 +3975,7 @@ public class BassClientService extends ProfileService {
            return true;
        } else {
            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 (isSyncedToBroadcastStream(receiveState.getBisSyncState().get(i))) {
                    return true;
                }
            }
@@ -4034,14 +4025,7 @@ public class BassClientService extends ProfileService {
                        .anyMatch(
                                receiveState ->
                                        (receiveState.getBisSyncState().stream()
                                                .anyMatch(
                                                        syncState ->
                                                                syncState
                                                                                != BassConstants
                                                                                        .BIS_SYNC_NOT_SYNC_TO_BIS
                                                                        && syncState
                                                                                != BassConstants
                                                                                        .BIS_SYNC_FAILED_SYNC_TO_BIG)))) {
                                                .anyMatch(this::isSyncedToBroadcastStream)))) {
                    activeSinks.add(device);
                }
            }
@@ -4049,6 +4033,11 @@ public class BassClientService extends ProfileService {
        return activeSinks;
    }

    private boolean isSyncedToBroadcastStream(Long syncState) {
        return syncState != BassConstants.BIS_SYNC_NOT_SYNC_TO_BIS
                && syncState != BassConstants.BIS_SYNC_FAILED_SYNC_TO_BIG;
    }

    /** Handle broadcast state changed */
    public void notifyBroadcastStateChanged(int state, int broadcastId) {
        switch (state) {