Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 09378b41 authored by Haijie Hong's avatar Haijie Hong Committed by Android (Google) Code Review
Browse files

Merge "Fix memory issue introduced by ag/29732078" into main

parents 97a457c0 84cee1fc
Loading
Loading
Loading
Loading
+17 −20
Original line number Diff line number Diff line
@@ -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) {