Loading android/app/src/com/android/bluetooth/bass_client/BassClientService.java +32 −8 Original line number Diff line number Diff line Loading @@ -888,7 +888,8 @@ public class BassClientService extends ProfileService { return; } boolean isAssistantActive = isAnyReceiverReceivingBroadcast(getConnectedDevices()); boolean isAssistantActive = areReceiversReceivingOnlyExternalBroadcast(getConnectedDevices()); if (isAssistantActive) { /* Assistant become active */ Loading Loading @@ -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 { Loading Loading @@ -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<>(); Loading android/app/tests/unit/src/com/android/bluetooth/bass_client/BassClientServiceTest.java +6 −0 Original line number Diff line number Diff line Loading @@ -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)) { Loading Loading
android/app/src/com/android/bluetooth/bass_client/BassClientService.java +32 −8 Original line number Diff line number Diff line Loading @@ -888,7 +888,8 @@ public class BassClientService extends ProfileService { return; } boolean isAssistantActive = isAnyReceiverReceivingBroadcast(getConnectedDevices()); boolean isAssistantActive = areReceiversReceivingOnlyExternalBroadcast(getConnectedDevices()); if (isAssistantActive) { /* Assistant become active */ Loading Loading @@ -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 { Loading Loading @@ -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<>(); Loading
android/app/tests/unit/src/com/android/bluetooth/bass_client/BassClientServiceTest.java +6 −0 Original line number Diff line number Diff line Loading @@ -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)) { Loading