[Audiosharing] Handle sync, add source via qrcode.

Bug: 305620450
Test: manual
Change-Id: I32c14607035d8f37f44186175657c42307780e7b
This commit is contained in:
chelseahao
2024-01-11 14:30:00 +08:00
committed by Chelsea Hao
parent f1c141906a
commit 5d0bd7555d
4 changed files with 308 additions and 52 deletions

View File

@@ -109,13 +109,14 @@ class AudioStreamsHelper {
}
/** Retrieves a list of all LE broadcast receive states from active sinks. */
List<BluetoothLeBroadcastReceiveState> getAllSources() {
List<BluetoothLeBroadcastReceiveState> getAllConnectedSources() {
if (mLeBroadcastAssistant == null) {
Log.w(TAG, "getAllSources(): LeBroadcastAssistant is null!");
return emptyList();
}
return getActiveSinksOnAssistant(mBluetoothManager).stream()
.flatMap(sink -> mLeBroadcastAssistant.getAllSources(sink).stream())
.filter(this::isConnected)
.toList();
}
@@ -124,7 +125,7 @@ class AudioStreamsHelper {
return mLeBroadcastAssistant;
}
static boolean isConnected(BluetoothLeBroadcastReceiveState state) {
boolean isConnected(BluetoothLeBroadcastReceiveState state) {
return state.getPaSyncState() == BluetoothLeBroadcastReceiveState.PA_SYNC_STATE_SYNCHRONIZED
&& state.getBigEncryptionState()
== BluetoothLeBroadcastReceiveState.BIG_ENCRYPTION_STATE_DECRYPTING;