diff options
author | 2025-02-05 03:05:26 -0800 | |
---|---|---|
committer | 2025-02-05 03:05:26 -0800 | |
commit | 09378b41fa9f17b9ea4b7555d3f67277fd5cdbb4 (patch) | |
tree | da116c3b24e77072164813fcd2e8806b6d5b35a3 /packages/SettingsLib/src | |
parent | 97a457c024e49b023ad58d0dd01b09f4745282f5 (diff) | |
parent | 84cee1fc2ca32c7f5d920faccb0772e901311598 (diff) |
Merge "Fix memory issue introduced by ag/29732078" into main
Diffstat (limited to 'packages/SettingsLib/src')
-rw-r--r-- | packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioSharingRepository.kt | 37 |
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) { |