summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioSharingRepository.kt37
1 files changed, 17 insertions, 20 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioSharingRepository.kt b/packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioSharingRepository.kt
index 01bf0c8335d1..8771ba05a6a8 100644
--- a/packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioSharingRepository.kt
+++ b/packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioSharingRepository.kt
@@ -150,27 +150,13 @@ class AudioSharingRepositoryImpl(
BluetoothCsipSetCoordinator.GROUP_ID_INVALID
)
- override val secondaryGroupId: StateFlow<Int> =
- secondaryDevice
- .map { BluetoothUtils.getGroupId(it) }
- .onEach { logger.onSecondaryGroupIdChanged(it) }
- .flowOn(backgroundCoroutineContext)
- .stateIn(
- coroutineScope,
- SharingStarted.WhileSubscribed(),
- BluetoothCsipSetCoordinator.GROUP_ID_INVALID
- )
+ override val primaryDevice: StateFlow<CachedBluetoothDevice?> =
+ primaryGroupId
+ .map { getCachedDeviceFromGroupId(it) }
+ .stateIn(coroutineScope, SharingStarted.WhileSubscribed(), null)
- override val primaryDevice: StateFlow<CachedBluetoothDevice?>
- get() = primaryGroupId.map { getCachedDeviceFromGroupId(it) }
- .stateIn(
- coroutineScope,
- SharingStarted.WhileSubscribed(),
- null
- )
-
- override val secondaryDevice: StateFlow<CachedBluetoothDevice?>
- get() = merge(
+ override val secondaryDevice: StateFlow<CachedBluetoothDevice?> =
+ merge(
isAudioSharingProfilesReady.flatMapLatest { ready ->
if (ready) {
btManager.profileManager.leAudioBroadcastAssistantProfile
@@ -196,6 +182,17 @@ class AudioSharingRepositoryImpl(
null
)
+ override val secondaryGroupId: StateFlow<Int> =
+ secondaryDevice
+ .map { BluetoothUtils.getGroupId(it) }
+ .onEach { logger.onSecondaryGroupIdChanged(it) }
+ .flowOn(backgroundCoroutineContext)
+ .stateIn(
+ coroutineScope,
+ SharingStarted.WhileSubscribed(),
+ BluetoothCsipSetCoordinator.GROUP_ID_INVALID
+ )
+
override val volumeMap: StateFlow<GroupIdToVolumes> =
inAudioSharing.flatMapLatest { isSharing ->
if (isSharing) {