summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chelsea Hao <chelseahao@google.com> 2024-10-24 04:40:35 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-10-24 04:40:35 +0000
commiteeff0ad5d056d0e33551cfc27ec1940d85b1899a (patch)
tree57440b6b3b1ad309ca26cd5f43b1839e50121c63
parentc3b5548ecb2167b9a4b24b9286539e18343492c4 (diff)
parenta67c924de154782bb7f0ec5e283411caac4385e8 (diff)
Merge "Use `audioSharingInteractor.audioSharingAvailable` instead of calling BluetoothUtils." into main
-rw-r--r--packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorImpl.kt4
-rw-r--r--packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemActionInteractor.kt4
-rw-r--r--packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemFactory.kt23
-rw-r--r--packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemInteractor.kt32
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorTest.kt23
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemFactoryTest.kt21
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemInteractorTest.kt44
7 files changed, 98 insertions, 53 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorImpl.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorImpl.kt
index 692a78be075f..13c72097c06e 100644
--- a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorImpl.kt
@@ -63,6 +63,10 @@ constructor(
logger.logDeviceClickInAudioSharingWhenEnabled(inAudioSharing)
when {
+ deviceItem.type == DeviceItemType.AUDIO_SHARING_MEDIA_BLUETOOTH_DEVICE -> {
+ // Do nothing if the device is in audio sharing session
+ uiEventLogger.log(BluetoothTileDialogUiEvent.AUDIO_SHARING_DEVICE_CLICKED)
+ }
deviceItem.type ==
DeviceItemType.AVAILABLE_AUDIO_SHARING_MEDIA_BLUETOOTH_DEVICE -> {
if (audioSharingQsDialogImprovement()) {
diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemActionInteractor.kt
index cf0f19f1d361..2b55e1c51f5f 100644
--- a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemActionInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemActionInteractor.kt
@@ -44,9 +44,6 @@ constructor(
disconnect()
uiEventLogger.log(BluetoothTileDialogUiEvent.ACTIVE_DEVICE_DISCONNECT)
}
- DeviceItemType.AUDIO_SHARING_MEDIA_BLUETOOTH_DEVICE -> {
- uiEventLogger.log(BluetoothTileDialogUiEvent.AUDIO_SHARING_DEVICE_CLICKED)
- }
DeviceItemType.AVAILABLE_MEDIA_BLUETOOTH_DEVICE -> {
setActive()
uiEventLogger.log(BluetoothTileDialogUiEvent.CONNECTED_DEVICE_SET_ACTIVE)
@@ -61,6 +58,7 @@ constructor(
connect()
uiEventLogger.log(BluetoothTileDialogUiEvent.SAVED_DEVICE_CONNECT)
}
+ DeviceItemType.AUDIO_SHARING_MEDIA_BLUETOOTH_DEVICE,
DeviceItemType.AVAILABLE_AUDIO_SHARING_MEDIA_BLUETOOTH_DEVICE -> {
// Do nothing. Should already be handled in
// AudioSharingDeviceItemActionInteractor.
diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemFactory.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemFactory.kt
index 7ed56296e865..292137377f55 100644
--- a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemFactory.kt
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemFactory.kt
@@ -42,8 +42,16 @@ abstract class DeviceItemFactory {
context: Context,
cachedDevice: CachedBluetoothDevice,
audioManager: AudioManager,
+ audioSharingAvailable: Boolean,
): Boolean
+ // Overloaded that defaults audioSharingAvailable to false
+ fun isFilterMatched(
+ context: Context,
+ cachedDevice: CachedBluetoothDevice,
+ audioManager: AudioManager,
+ ): Boolean = isFilterMatched(context, cachedDevice, audioManager, false)
+
abstract fun create(context: Context, cachedDevice: CachedBluetoothDevice): DeviceItem
companion object {
@@ -80,6 +88,7 @@ internal open class ActiveMediaDeviceItemFactory : DeviceItemFactory() {
context: Context,
cachedDevice: CachedBluetoothDevice,
audioManager: AudioManager,
+ audioSharingAvailable: Boolean,
): Boolean {
return BluetoothUtils.isActiveMediaDevice(cachedDevice) &&
BluetoothUtils.isAvailableMediaBluetoothDevice(cachedDevice, audioManager)
@@ -105,8 +114,9 @@ internal class AudioSharingMediaDeviceItemFactory(
context: Context,
cachedDevice: CachedBluetoothDevice,
audioManager: AudioManager,
+ audioSharingAvailable: Boolean,
): Boolean {
- return BluetoothUtils.isAudioSharingEnabled() &&
+ return audioSharingAvailable &&
BluetoothUtils.hasConnectedBroadcastSource(cachedDevice, localBluetoothManager)
}
@@ -131,9 +141,10 @@ internal class AvailableAudioSharingMediaDeviceItemFactory(
context: Context,
cachedDevice: CachedBluetoothDevice,
audioManager: AudioManager,
+ audioSharingAvailable: Boolean,
): Boolean {
- return BluetoothUtils.isAudioSharingEnabled() &&
- super.isFilterMatched(context, cachedDevice, audioManager) &&
+ return audioSharingAvailable &&
+ super.isFilterMatched(context, cachedDevice, audioManager, true) &&
BluetoothUtils.isAvailableAudioSharingMediaBluetoothDevice(
cachedDevice,
localBluetoothManager,
@@ -160,6 +171,7 @@ internal class ActiveHearingDeviceItemFactory : ActiveMediaDeviceItemFactory() {
context: Context,
cachedDevice: CachedBluetoothDevice,
audioManager: AudioManager,
+ audioSharingAvailable: Boolean,
): Boolean {
return BluetoothUtils.isActiveMediaDevice(cachedDevice) &&
BluetoothUtils.isAvailableHearingDevice(cachedDevice)
@@ -171,6 +183,7 @@ open class AvailableMediaDeviceItemFactory : DeviceItemFactory() {
context: Context,
cachedDevice: CachedBluetoothDevice,
audioManager: AudioManager,
+ audioSharingAvailable: Boolean,
): Boolean {
return !BluetoothUtils.isActiveMediaDevice(cachedDevice) &&
BluetoothUtils.isAvailableMediaBluetoothDevice(cachedDevice, audioManager)
@@ -195,6 +208,7 @@ internal class AvailableHearingDeviceItemFactory : AvailableMediaDeviceItemFacto
context: Context,
cachedDevice: CachedBluetoothDevice,
audioManager: AudioManager,
+ audioSharingAvailable: Boolean,
): Boolean {
return !BluetoothUtils.isActiveMediaDevice(cachedDevice) &&
BluetoothUtils.isAvailableHearingDevice(cachedDevice)
@@ -206,6 +220,7 @@ internal class ConnectedDeviceItemFactory : DeviceItemFactory() {
context: Context,
cachedDevice: CachedBluetoothDevice,
audioManager: AudioManager,
+ audioSharingAvailable: Boolean,
): Boolean {
return if (Flags.enableHideExclusivelyManagedBluetoothDevice()) {
!BluetoothUtils.isExclusivelyManagedBluetoothDevice(context, cachedDevice.device) &&
@@ -234,6 +249,7 @@ internal open class SavedDeviceItemFactory : DeviceItemFactory() {
context: Context,
cachedDevice: CachedBluetoothDevice,
audioManager: AudioManager,
+ audioSharingAvailable: Boolean,
): Boolean {
return if (Flags.enableHideExclusivelyManagedBluetoothDevice()) {
!BluetoothUtils.isExclusivelyManagedBluetoothDevice(context, cachedDevice.device) &&
@@ -263,6 +279,7 @@ internal class SavedHearingDeviceItemFactory : SavedDeviceItemFactory() {
context: Context,
cachedDevice: CachedBluetoothDevice,
audioManager: AudioManager,
+ audioSharingAvailable: Boolean,
): Boolean {
return if (Flags.enableHideExclusivelyManagedBluetoothDevice()) {
!BluetoothUtils.isExclusivelyManagedBluetoothDevice(
diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemInteractor.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemInteractor.kt
index 01b84dac1065..1e0ba8e75714 100644
--- a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemInteractor.kt
@@ -50,6 +50,7 @@ class DeviceItemInteractor
@Inject
constructor(
private val bluetoothTileDialogRepository: BluetoothTileDialogRepository,
+ private val audioSharingInteractor: AudioSharingInteractor,
private val audioManager: AudioManager,
private val bluetoothAdapter: BluetoothAdapter? = BluetoothAdapter.getDefaultAdapter(),
private val localBluetoothManager: LocalBluetoothManager?,
@@ -76,7 +77,7 @@ constructor(
object : BluetoothCallback {
override fun onActiveDeviceChanged(
activeDevice: CachedBluetoothDevice?,
- bluetoothProfile: Int
+ bluetoothProfile: Int,
) {
super.onActiveDeviceChanged(activeDevice, bluetoothProfile)
logger.logActiveDeviceChanged(activeDevice?.address, bluetoothProfile)
@@ -86,30 +87,27 @@ constructor(
override fun onProfileConnectionStateChanged(
cachedDevice: CachedBluetoothDevice,
state: Int,
- bluetoothProfile: Int
+ bluetoothProfile: Int,
) {
super.onProfileConnectionStateChanged(
cachedDevice,
state,
- bluetoothProfile
+ bluetoothProfile,
)
logger.logProfileConnectionStateChanged(
cachedDevice.address,
state.toString(),
- bluetoothProfile
+ bluetoothProfile,
)
trySendWithFailureLogging(Unit, TAG, "onProfileConnectionStateChanged")
}
override fun onAclConnectionStateChanged(
cachedDevice: CachedBluetoothDevice,
- state: Int
+ state: Int,
) {
super.onAclConnectionStateChanged(cachedDevice, state)
- // Listen only when a device is disconnecting
- if (state == 0) {
- trySendWithFailureLogging(Unit, TAG, "onAclConnectionStateChanged")
- }
+ trySendWithFailureLogging(Unit, TAG, "onAclConnectionStateChanged")
}
}
localBluetoothManager?.eventManager?.registerCallback(listener)
@@ -121,11 +119,19 @@ constructor(
internal suspend fun updateDeviceItems(context: Context, trigger: DeviceFetchTrigger) {
withContext(backgroundDispatcher) {
val start = systemClock.elapsedRealtime()
+ val audioSharingAvailable = audioSharingInteractor.audioSharingAvailable()
val deviceItems =
bluetoothTileDialogRepository.cachedDevices
.mapNotNull { cachedDevice ->
deviceItemFactoryList
- .firstOrNull { it.isFilterMatched(context, cachedDevice, audioManager) }
+ .firstOrNull {
+ it.isFilterMatched(
+ context,
+ cachedDevice,
+ audioManager,
+ audioSharingAvailable,
+ )
+ }
?.create(context, cachedDevice)
}
.sort(deviceItemDisplayPriority, bluetoothAdapter?.mostRecentlyConnectedDevices)
@@ -136,13 +142,13 @@ constructor(
logger.logDeviceFetch(
JobStatus.FINISHED,
trigger,
- systemClock.elapsedRealtime() - start
+ systemClock.elapsedRealtime() - start,
)
} else {
logger.logDeviceFetch(
JobStatus.CANCELLED,
trigger,
- systemClock.elapsedRealtime() - start
+ systemClock.elapsedRealtime() - start,
)
}
}
@@ -150,7 +156,7 @@ constructor(
private fun List<DeviceItem>.sort(
displayPriority: List<DeviceItemType>,
- mostRecentlyConnectedDevices: List<BluetoothDevice>?
+ mostRecentlyConnectedDevices: List<BluetoothDevice>?,
): List<DeviceItem> {
return this.sortedWith(
compareBy<DeviceItem> { displayPriority.indexOf(it.type) }
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorTest.kt
index ce37eee24e2a..4d138b488645 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorTest.kt
@@ -63,6 +63,7 @@ class AudioSharingDeviceItemActionInteractorTest : SysuiTestCase() {
private lateinit var mockitoSession: StaticMockitoSession
private lateinit var connectedAudioSharingMediaDeviceItem: DeviceItem
private lateinit var connectedMediaDeviceItem: DeviceItem
+ private lateinit var inAudioSharingMediaDeviceItem: DeviceItem
@Mock private lateinit var dialog: SystemUIDialog
@Mock private lateinit var leAudioProfile: LeAudioProfile
@Mock private lateinit var bluetoothDevice: BluetoothDevice
@@ -80,6 +81,15 @@ class AudioSharingDeviceItemActionInteractorTest : SysuiTestCase() {
iconWithDescription = null,
background = null,
)
+ inAudioSharingMediaDeviceItem =
+ DeviceItem(
+ type = DeviceItemType.AUDIO_SHARING_MEDIA_BLUETOOTH_DEVICE,
+ cachedBluetoothDevice = kosmos.cachedBluetoothDevice,
+ deviceName = DEVICE_NAME,
+ connectionSummary = DEVICE_CONNECTION_SUMMARY,
+ iconWithDescription = null,
+ background = null,
+ )
connectedAudioSharingMediaDeviceItem =
DeviceItem(
type = DeviceItemType.AVAILABLE_AUDIO_SHARING_MEDIA_BLUETOOTH_DEVICE,
@@ -131,6 +141,19 @@ class AudioSharingDeviceItemActionInteractorTest : SysuiTestCase() {
}
@Test
+ fun testOnClick_inAudioSharingMediaDevice_doNothing() {
+ with(kosmos) {
+ testScope.runTest {
+ bluetoothTileDialogAudioSharingRepository.setAudioSharingAvailable(true)
+ actionInteractorImpl.onClick(inAudioSharingMediaDeviceItem, dialog)
+
+ verify(dialogTransitionAnimator, never())
+ .showFromDialog(any(), any(), eq(null), anyBoolean())
+ }
+ }
+ }
+
+ @Test
fun testOnClick_inAudioSharing_clickedDeviceHasSource_shouldNotLaunchSettings() {
with(kosmos) {
testScope.runTest {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemFactoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemFactoryTest.kt
index 10c3457066cb..2ff8cbcf34ae 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemFactoryTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemFactoryTest.kt
@@ -133,36 +133,26 @@ class DeviceItemFactoryTest : SysuiTestCase() {
@Test
fun testAvailableAudioSharingMediaDeviceItemFactory_isFilterMatched_flagOff_returnsFalse() {
- // Flags.FLAG_ENABLE_LE_AUDIO_SHARING off or the device doesn't support broadcast
- // source or assistant.
- `when`(BluetoothUtils.isAudioSharingEnabled()).thenReturn(false)
-
assertThat(
AvailableAudioSharingMediaDeviceItemFactory(localBluetoothManager)
- .isFilterMatched(context, cachedDevice, audioManager)
+ .isFilterMatched(context, cachedDevice, audioManager, false)
)
.isFalse()
}
@Test
fun testAvailableAudioSharingMediaDeviceItemFactory_isFilterMatched_isActiveDevice_false() {
- // Flags.FLAG_ENABLE_LE_AUDIO_SHARING on and the device support broadcast source and
- // assistant.
- `when`(BluetoothUtils.isAudioSharingEnabled()).thenReturn(true)
`when`(BluetoothUtils.isActiveMediaDevice(any())).thenReturn(true)
assertThat(
AvailableAudioSharingMediaDeviceItemFactory(localBluetoothManager)
- .isFilterMatched(context, cachedDevice, audioManager)
+ .isFilterMatched(context, cachedDevice, audioManager, true)
)
.isFalse()
}
@Test
fun testAvailableAudioSharingMediaDeviceItemFactory_isFilterMatched_isNotAvailable_false() {
- // Flags.FLAG_ENABLE_LE_AUDIO_SHARING on and the device support broadcast source and
- // assistant.
- `when`(BluetoothUtils.isAudioSharingEnabled()).thenReturn(true)
`when`(BluetoothUtils.isActiveMediaDevice(any())).thenReturn(false)
`when`(BluetoothUtils.isAvailableMediaBluetoothDevice(any(), any())).thenReturn(true)
`when`(BluetoothUtils.isAvailableAudioSharingMediaBluetoothDevice(any(), any()))
@@ -170,16 +160,13 @@ class DeviceItemFactoryTest : SysuiTestCase() {
assertThat(
AvailableAudioSharingMediaDeviceItemFactory(localBluetoothManager)
- .isFilterMatched(context, cachedDevice, audioManager)
+ .isFilterMatched(context, cachedDevice, audioManager, true)
)
.isFalse()
}
@Test
fun testAvailableAudioSharingMediaDeviceItemFactory_isFilterMatched_returnsTrue() {
- // Flags.FLAG_ENABLE_LE_AUDIO_SHARING on and the device support broadcast source and
- // assistant.
- `when`(BluetoothUtils.isAudioSharingEnabled()).thenReturn(true)
`when`(BluetoothUtils.isActiveMediaDevice(any())).thenReturn(false)
`when`(BluetoothUtils.isAvailableMediaBluetoothDevice(any(), any())).thenReturn(true)
`when`(BluetoothUtils.isAvailableAudioSharingMediaBluetoothDevice(any(), any()))
@@ -187,7 +174,7 @@ class DeviceItemFactoryTest : SysuiTestCase() {
assertThat(
AvailableAudioSharingMediaDeviceItemFactory(localBluetoothManager)
- .isFilterMatched(context, cachedDevice, audioManager)
+ .isFilterMatched(context, cachedDevice, audioManager, true)
)
.isTrue()
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemInteractorTest.kt
index c39b9a606cfe..42dc50d77d05 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/DeviceItemInteractorTest.kt
@@ -27,6 +27,7 @@ import com.android.settingslib.bluetooth.CachedBluetoothDevice
import com.android.settingslib.bluetooth.LocalBluetoothManager
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
+import com.android.systemui.testKosmos
import com.android.systemui.util.time.FakeSystemClock
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.CoroutineDispatcher
@@ -48,6 +49,7 @@ import org.mockito.junit.MockitoRule
class DeviceItemInteractorTest : SysuiTestCase() {
@get:Rule val mockitoRule: MockitoRule = MockitoJUnit.rule()
+ private val kosmos = testKosmos()
@Mock private lateinit var bluetoothTileDialogRepository: BluetoothTileDialogRepository
@@ -99,6 +101,7 @@ class DeviceItemInteractorTest : SysuiTestCase() {
interactor =
DeviceItemInteractor(
bluetoothTileDialogRepository,
+ kosmos.audioSharingInteractor,
audioManager,
adapter,
localBluetoothManager,
@@ -107,7 +110,7 @@ class DeviceItemInteractorTest : SysuiTestCase() {
listOf(createFactory({ true }, deviceItem1)),
emptyList(),
testScope.backgroundScope,
- dispatcher
+ dispatcher,
)
val latest by collectLastValue(interactor.deviceItemUpdate)
@@ -126,6 +129,7 @@ class DeviceItemInteractorTest : SysuiTestCase() {
interactor =
DeviceItemInteractor(
bluetoothTileDialogRepository,
+ kosmos.audioSharingInteractor,
audioManager,
adapter,
localBluetoothManager,
@@ -134,7 +138,7 @@ class DeviceItemInteractorTest : SysuiTestCase() {
listOf(createFactory({ false }, deviceItem1)),
emptyList(),
testScope.backgroundScope,
- dispatcher
+ dispatcher,
)
val latest by collectLastValue(interactor.deviceItemUpdate)
@@ -153,6 +157,7 @@ class DeviceItemInteractorTest : SysuiTestCase() {
interactor =
DeviceItemInteractor(
bluetoothTileDialogRepository,
+ kosmos.audioSharingInteractor,
audioManager,
adapter,
localBluetoothManager,
@@ -161,7 +166,7 @@ class DeviceItemInteractorTest : SysuiTestCase() {
listOf(createFactory({ true }, deviceItem1)),
emptyList(),
testScope.backgroundScope,
- dispatcher
+ dispatcher,
)
val latest by collectLastValue(interactor.deviceItemUpdate)
@@ -180,6 +185,7 @@ class DeviceItemInteractorTest : SysuiTestCase() {
interactor =
DeviceItemInteractor(
bluetoothTileDialogRepository,
+ kosmos.audioSharingInteractor,
audioManager,
adapter,
localBluetoothManager,
@@ -187,11 +193,11 @@ class DeviceItemInteractorTest : SysuiTestCase() {
logger,
listOf(
createFactory({ false }, deviceItem1),
- createFactory({ true }, deviceItem2)
+ createFactory({ true }, deviceItem2),
),
emptyList(),
testScope.backgroundScope,
- dispatcher
+ dispatcher,
)
val latest by collectLastValue(interactor.deviceItemUpdate)
@@ -210,6 +216,7 @@ class DeviceItemInteractorTest : SysuiTestCase() {
interactor =
DeviceItemInteractor(
bluetoothTileDialogRepository,
+ kosmos.audioSharingInteractor,
audioManager,
adapter,
localBluetoothManager,
@@ -218,19 +225,19 @@ class DeviceItemInteractorTest : SysuiTestCase() {
listOf(
createFactory(
{ cachedDevice -> cachedDevice.device == device1 },
- deviceItem1
+ deviceItem1,
),
createFactory(
{ cachedDevice -> cachedDevice.device == device2 },
- deviceItem2
- )
+ deviceItem2,
+ ),
),
listOf(
DeviceItemType.SAVED_BLUETOOTH_DEVICE,
- DeviceItemType.CONNECTED_BLUETOOTH_DEVICE
+ DeviceItemType.CONNECTED_BLUETOOTH_DEVICE,
),
testScope.backgroundScope,
- dispatcher
+ dispatcher,
)
`when`(deviceItem1.type).thenReturn(DeviceItemType.CONNECTED_BLUETOOTH_DEVICE)
`when`(deviceItem2.type).thenReturn(DeviceItemType.SAVED_BLUETOOTH_DEVICE)
@@ -251,6 +258,7 @@ class DeviceItemInteractorTest : SysuiTestCase() {
interactor =
DeviceItemInteractor(
bluetoothTileDialogRepository,
+ kosmos.audioSharingInteractor,
audioManager,
adapter,
localBluetoothManager,
@@ -259,16 +267,16 @@ class DeviceItemInteractorTest : SysuiTestCase() {
listOf(
createFactory(
{ cachedDevice -> cachedDevice.device == device1 },
- deviceItem1
+ deviceItem1,
),
createFactory(
{ cachedDevice -> cachedDevice.device == device2 },
- deviceItem2
- )
+ deviceItem2,
+ ),
),
listOf(DeviceItemType.CONNECTED_BLUETOOTH_DEVICE),
testScope.backgroundScope,
- dispatcher
+ dispatcher,
)
`when`(deviceItem1.type).thenReturn(DeviceItemType.CONNECTED_BLUETOOTH_DEVICE)
`when`(deviceItem2.type).thenReturn(DeviceItemType.CONNECTED_BLUETOOTH_DEVICE)
@@ -291,6 +299,7 @@ class DeviceItemInteractorTest : SysuiTestCase() {
interactor =
DeviceItemInteractor(
bluetoothTileDialogRepository,
+ kosmos.audioSharingInteractor,
audioManager,
adapter,
localBluetoothManager,
@@ -299,7 +308,7 @@ class DeviceItemInteractorTest : SysuiTestCase() {
listOf(createFactory({ true }, deviceItem2)),
emptyList(),
testScope.backgroundScope,
- dispatcher
+ dispatcher,
)
val latest by collectLastValue(interactor.deviceItemUpdate)
val latestShowSeeAll by collectLastValue(interactor.showSeeAllUpdate)
@@ -312,13 +321,14 @@ class DeviceItemInteractorTest : SysuiTestCase() {
private fun createFactory(
isFilterMatchFunc: (CachedBluetoothDevice) -> Boolean,
- deviceItem: DeviceItem
+ deviceItem: DeviceItem,
): DeviceItemFactory {
return object : DeviceItemFactory() {
override fun isFilterMatched(
context: Context,
cachedDevice: CachedBluetoothDevice,
- audioManager: AudioManager
+ audioManager: AudioManager,
+ audioSharingAvailable: Boolean,
) = isFilterMatchFunc(cachedDevice)
override fun create(context: Context, cachedDevice: CachedBluetoothDevice) = deviceItem