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

Commit 22a39312 authored by Yiyi Shen's avatar Yiyi Shen
Browse files

[Audiosharing] Fix race condition in AudioSharingRepository provides

BluetoothUtils#isAudioSharingEnabled will check broadcast/assistant
profile support by checking BluetoothAdapter#isLeAudioBroadcastXXXSupported.

BluetoothAdapter#isLeAudioBroadcastXXXSupported can return error value
when BT is not enabled, even broadcast feature is supported.

However, we can not make sure AudioSharingRepository is provided after
BT is enabled during device boot on.

Thus we only check flag when providing AudioSharingRepository, profile
support has already been checked in the repository impl.

Test: atest
Bug: 336716411
Flag: com.android.settingslib.flags.volume_dialog_audio_sharing_fix
Change-Id: I1c9e213e883155e43c90249901d1909873302d1d
parent 59002e70
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -19,8 +19,8 @@ package com.android.systemui.volume.dagger
import android.content.ContentResolver
import android.content.Context
import android.media.AudioManager
import com.android.settingslib.bluetooth.BluetoothUtils
import com.android.settingslib.bluetooth.LocalBluetoothManager
import com.android.settingslib.flags.Flags
import com.android.settingslib.notification.domain.interactor.NotificationsSoundPolicyInteractor
import com.android.settingslib.volume.data.repository.AudioRepository
import com.android.settingslib.volume.data.repository.AudioRepositoryImpl
@@ -80,7 +80,7 @@ interface AudioModule {
            @Application coroutineScope: CoroutineScope,
            @Background coroutineContext: CoroutineContext,
        ): AudioSharingRepository =
            if (BluetoothUtils.isAudioSharingEnabled() && localBluetoothManager != null) {
            if (Flags.enableLeAudioSharing() && localBluetoothManager != null) {
                AudioSharingRepositoryImpl(
                    contentResolver,
                    localBluetoothManager,