[Audiosharing] Set visibility by active device.

Also created header and button controller for detail page.

Bug: 305620450
Test: manual
Change-Id: I5e468a0fb9ce49ef0fd9a0b00b51084cfd416ce0
This commit is contained in:
chelseahao
2023-12-13 17:56:41 +08:00
parent 1bb099f872
commit 7edc93ec25
7 changed files with 289 additions and 55 deletions

View File

@@ -80,8 +80,8 @@ class AudioStreamsHelper {
});
}
/** Removes all sources from LE broadcasts associated for all active sinks. */
void removeSource() {
/** Removes sources from LE broadcasts associated for all active sinks based on broadcast Id. */
void removeSource(int broadcastId) {
if (mLeBroadcastAssistant == null) {
Log.w(TAG, "removeSource(): LeBroadcastAssistant is null!");
return;
@@ -93,14 +93,17 @@ class AudioStreamsHelper {
if (DEBUG) {
Log.d(
TAG,
"removeSource(): remove all sources from sink : "
"removeSource(): remove all sources with broadcast id :"
+ broadcastId
+ " from sink : "
+ sink.getAddress());
}
var sources = mLeBroadcastAssistant.getAllSources(sink);
if (!sources.isEmpty()) {
mLeBroadcastAssistant.removeSource(
sink, sources.get(0).getSourceId());
}
mLeBroadcastAssistant.getAllSources(sink).stream()
.filter(state -> state.getBroadcastId() == broadcastId)
.forEach(
state ->
mLeBroadcastAssistant.removeSource(
sink, state.getSourceId()));
}
});
}
@@ -121,6 +124,12 @@ class AudioStreamsHelper {
return mLeBroadcastAssistant;
}
static boolean isConnected(BluetoothLeBroadcastReceiveState state) {
return state.getPaSyncState() == BluetoothLeBroadcastReceiveState.PA_SYNC_STATE_SYNCHRONIZED
&& state.getBigEncryptionState()
== BluetoothLeBroadcastReceiveState.BIG_ENCRYPTION_STATE_DECRYPTING;
}
private static List<BluetoothDevice> getActiveSinksOnAssistant(
@Nullable LocalBluetoothManager manager) {
if (manager == null) {