summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractorTest.kt4
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingRepositoryTest.kt12
-rw-r--r--packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorImpl.kt8
-rw-r--r--packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractor.kt7
-rw-r--r--packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingRepository.kt15
-rw-r--r--packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothDetailsContentManager.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogLogger.kt74
-rw-r--r--packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/dagger/AudioSharingModule.kt3
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorTest.kt10
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractorKosmos.kt1
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/FakeAudioSharingRepository.kt2
11 files changed, 118 insertions, 20 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractorTest.kt
index 682ad0c5c48b..754011be7622 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractorTest.kt
@@ -125,7 +125,9 @@ class AudioSharingInteractorTest : SysuiTestCase() {
bluetoothTileDialogAudioSharingRepository.emitAudioSourceStateUpdate()
runCurrent()
- assertThat(value).isNull()
+ assertThat(value).isEqualTo(Unit)
+ verify(bluetoothTileDialogLogger).logAudioSharingStateChanged(true)
+ verify(bluetoothTileDialogLogger).logAudioSourceStateUpdate()
}
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingRepositoryTest.kt
index 587f3cc8357c..159c15b31069 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingRepositoryTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/bluetooth/qsdialog/AudioSharingRepositoryTest.kt
@@ -62,6 +62,7 @@ class AudioSharingRepositoryTest : SysuiTestCase() {
AudioSharingRepositoryImpl(
kosmos.localBluetoothManager,
kosmos.audioSharingRepository,
+ kosmos.bluetoothTileDialogLogger,
kosmos.testDispatcher,
)
}
@@ -95,6 +96,8 @@ class AudioSharingRepositoryTest : SysuiTestCase() {
audioSharingRepository.setAudioSharingAvailable(true)
underTest.startAudioSharing()
verify(leAudioBroadcastProfile).startPrivateBroadcast()
+ verify(bluetoothTileDialogLogger)
+ .logAudioSharingRequest(AudioSharingRequest.START_BROADCAST)
}
}
@@ -105,6 +108,8 @@ class AudioSharingRepositoryTest : SysuiTestCase() {
audioSharingRepository.setAudioSharingAvailable(false)
underTest.startAudioSharing()
verify(leAudioBroadcastProfile, never()).startPrivateBroadcast()
+ verify(bluetoothTileDialogLogger, never())
+ .logAudioSharingRequest(AudioSharingRequest.START_BROADCAST)
}
}
@@ -117,6 +122,8 @@ class AudioSharingRepositoryTest : SysuiTestCase() {
audioSharingRepository.setAudioSharingAvailable(true)
underTest.stopAudioSharing()
verify(leAudioBroadcastProfile).stopLatestBroadcast()
+ verify(bluetoothTileDialogLogger)
+ .logAudioSharingRequest(AudioSharingRequest.STOP_BROADCAST)
}
}
@@ -140,6 +147,7 @@ class AudioSharingRepositoryTest : SysuiTestCase() {
runCurrent()
verify(leAudioBroadcastAssistant, never()).allConnectedDevices
+ verify(bluetoothTileDialogLogger, never()).logAudioSharingRequest(any())
}
}
@@ -157,6 +165,7 @@ class AudioSharingRepositoryTest : SysuiTestCase() {
runCurrent()
verify(leAudioBroadcastAssistant, never()).allConnectedDevices
+ verify(bluetoothTileDialogLogger, never()).logAudioSharingRequest(any())
}
}
@@ -177,6 +186,7 @@ class AudioSharingRepositoryTest : SysuiTestCase() {
runCurrent()
verify(leAudioBroadcastAssistant, never()).addSource(any(), any(), anyBoolean())
+ verify(bluetoothTileDialogLogger, never()).logAudioSharingRequest(any())
}
}
@@ -198,6 +208,8 @@ class AudioSharingRepositoryTest : SysuiTestCase() {
runCurrent()
verify(leAudioBroadcastAssistant).addSource(bluetoothDevice, metadata, false)
+ verify(bluetoothTileDialogLogger)
+ .logAudioSharingRequest(AudioSharingRequest.ADD_SOURCE)
}
}
}
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 94fca218c74f..f8f692dd9033 100644
--- a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingDeviceItemActionInteractorImpl.kt
@@ -124,10 +124,18 @@ constructor(
when (deviceItem.type) {
DeviceItemType.AUDIO_SHARING_MEDIA_BLUETOOTH_DEVICE -> {
uiEventLogger.log(BluetoothTileDialogUiEvent.CHECK_MARK_ACTION_BUTTON_CLICKED)
+ logger.logAudioSharingButtonClick(
+ AudioSharingButtonClick.CHECK_MARK,
+ deviceItem,
+ )
audioSharingInteractor.stopAudioSharing()
}
DeviceItemType.AVAILABLE_AUDIO_SHARING_MEDIA_BLUETOOTH_DEVICE -> {
uiEventLogger.log(BluetoothTileDialogUiEvent.PLUS_ACTION_BUTTON_CLICKED)
+ logger.logAudioSharingButtonClick(
+ AudioSharingButtonClick.PLUS_BUTTON,
+ deviceItem,
+ )
audioSharingInteractor.startAudioSharing()
}
else -> {
diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractor.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractor.kt
index 832afb1799b1..7a76eed57095 100644
--- a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractor.kt
@@ -40,6 +40,7 @@ import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.flow.merge
+import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.withContext
@@ -73,6 +74,7 @@ constructor(
private val context: Context,
private val localBluetoothManager: LocalBluetoothManager?,
private val audioSharingRepository: AudioSharingRepository,
+ private val logger: BluetoothTileDialogLogger,
@Background private val backgroundDispatcher: CoroutineDispatcher,
) : AudioSharingInteractor {
@@ -92,9 +94,12 @@ constructor(
override val audioSourceStateUpdate =
isAudioSharingOn
+ .onEach { logger.logAudioSharingStateChanged(it) }
.flatMapLatest {
if (it) {
- audioSharingRepository.audioSourceStateUpdate
+ audioSharingRepository.audioSourceStateUpdate.onEach {
+ logger.logAudioSourceStateUpdate()
+ }
} else {
emptyFlow()
}
diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingRepository.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingRepository.kt
index 44f9769f5930..d84b34a5a933 100644
--- a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/AudioSharingRepository.kt
@@ -53,6 +53,7 @@ interface AudioSharingRepository {
class AudioSharingRepositoryImpl(
private val localBluetoothManager: LocalBluetoothManager,
private val settingsLibAudioSharingRepository: SettingsLibAudioSharingRepository,
+ private val logger: BluetoothTileDialogLogger,
@Background private val backgroundDispatcher: CoroutineDispatcher,
) : AudioSharingRepository {
@@ -79,7 +80,11 @@ class AudioSharingRepositoryImpl(
}
leAudioBroadcastProfile?.latestBluetoothLeBroadcastMetadata?.let { metadata ->
leAudioBroadcastAssistantProfile?.let {
- it.allConnectedDevices.forEach { sink -> it.addSource(sink, metadata, false) }
+ it.allConnectedDevices.forEach { sink ->
+ it.addSource(sink, metadata, false).also {
+ logger.logAudioSharingRequest(AudioSharingRequest.ADD_SOURCE)
+ }
+ }
}
}
}
@@ -99,7 +104,9 @@ class AudioSharingRepositoryImpl(
if (!settingsLibAudioSharingRepository.audioSharingAvailable()) {
return@withContext
}
- leAudioBroadcastProfile?.startPrivateBroadcast()
+ leAudioBroadcastProfile?.startPrivateBroadcast().also {
+ logger.logAudioSharingRequest(AudioSharingRequest.START_BROADCAST)
+ }
}
}
@@ -108,7 +115,9 @@ class AudioSharingRepositoryImpl(
if (!settingsLibAudioSharingRepository.audioSharingAvailable()) {
return@withContext
}
- leAudioBroadcastProfile?.stopLatestBroadcast()
+ leAudioBroadcastProfile?.stopLatestBroadcast().also {
+ logger.logAudioSharingRequest(AudioSharingRequest.STOP_BROADCAST)
+ }
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothDetailsContentManager.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothDetailsContentManager.kt
index 576acd2e5304..5a5a51e53d63 100644
--- a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothDetailsContentManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothDetailsContentManager.kt
@@ -218,7 +218,7 @@ constructor(
scrollViewContent.layoutParams.height = WRAP_CONTENT
lastUiUpdateMs = systemClock.elapsedRealtime()
lastItemRow = itemRow
- logger.logDeviceUiUpdate(lastUiUpdateMs - start)
+ logger.logDeviceUiUpdate(lastUiUpdateMs - start, deviceItem)
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogLogger.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogLogger.kt
index 06116f0a21c3..5f866c5522f6 100644
--- a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogLogger.kt
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogLogger.kt
@@ -27,18 +27,29 @@ private const val TAG = "BluetoothTileDialogLog"
enum class BluetoothStateStage {
USER_TOGGLED,
BLUETOOTH_STATE_VALUE_SET,
- BLUETOOTH_STATE_CHANGE_RECEIVED
+ BLUETOOTH_STATE_CHANGE_RECEIVED,
}
enum class DeviceFetchTrigger {
FIRST_LOAD,
BLUETOOTH_STATE_CHANGE_RECEIVED,
- BLUETOOTH_CALLBACK_RECEIVED
+ BLUETOOTH_CALLBACK_RECEIVED,
+}
+
+enum class AudioSharingButtonClick {
+ PLUS_BUTTON,
+ CHECK_MARK,
+}
+
+enum class AudioSharingRequest {
+ START_BROADCAST,
+ STOP_BROADCAST,
+ ADD_SOURCE,
}
enum class JobStatus {
FINISHED,
- CANCELLED
+ CANCELLED,
}
class BluetoothTileDialogLogger
@@ -53,7 +64,7 @@ constructor(@BluetoothTileDialogLog private val logBuffer: LogBuffer) {
str1 = stage.toString()
str2 = state
},
- { "BluetoothState. stage=$str1 state=$str2" }
+ { "BluetoothState. stage=$str1 state=$str2" },
)
fun logDeviceClick(address: String, type: DeviceItemType) =
@@ -64,7 +75,7 @@ constructor(@BluetoothTileDialogLog private val logBuffer: LogBuffer) {
str1 = address
str2 = type.toString()
},
- { "DeviceClick. address=$str1 type=$str2" }
+ { "DeviceClick. address=$str1 type=$str2" },
)
fun logActiveDeviceChanged(address: String?, profileId: Int) =
@@ -75,7 +86,7 @@ constructor(@BluetoothTileDialogLog private val logBuffer: LogBuffer) {
str1 = address
int1 = profileId
},
- { "ActiveDeviceChanged. address=$str1 profileId=$int1" }
+ { "ActiveDeviceChanged. address=$str1 profileId=$int1" },
)
fun logProfileConnectionStateChanged(address: String, state: String, profileId: Int) =
@@ -87,7 +98,7 @@ constructor(@BluetoothTileDialogLog private val logBuffer: LogBuffer) {
str2 = state
int1 = profileId
},
- { "ProfileConnectionStateChanged. address=$str1 state=$str2 profileId=$int1" }
+ { "ProfileConnectionStateChanged. address=$str1 state=$str2 profileId=$int1" },
)
fun logBatteryChanged(address: String, key: Int, value: ByteArray?) =
@@ -99,7 +110,7 @@ constructor(@BluetoothTileDialogLog private val logBuffer: LogBuffer) {
int1 = key
str2 = value?.toString() ?: ""
},
- { "BatteryChanged. address=$str1 key=$int1 value=$str2" }
+ { "BatteryChanged. address=$str1 key=$int1 value=$str2" },
)
fun logDeviceFetch(status: JobStatus, trigger: DeviceFetchTrigger, duration: Long) =
@@ -111,18 +122,26 @@ constructor(@BluetoothTileDialogLog private val logBuffer: LogBuffer) {
str2 = trigger.toString()
long1 = duration
},
- { "DeviceFetch. status=$str1 trigger=$str2 duration=$long1" }
+ { "DeviceFetch. status=$str1 trigger=$str2 duration=$long1" },
)
- fun logDeviceUiUpdate(duration: Long) =
- logBuffer.log(TAG, DEBUG, { long1 = duration }, { "DeviceUiUpdate. duration=$long1" })
+ fun logDeviceUiUpdate(duration: Long, deviceItem: List<DeviceItem>) =
+ logBuffer.log(
+ TAG,
+ DEBUG,
+ {
+ long1 = duration
+ str1 = deviceItem.toString()
+ },
+ { "DeviceUiUpdate. duration=$long1 deviceItem=$str1" },
+ )
fun logDeviceClickInAudioSharingWhenEnabled(inAudioSharing: Boolean) {
logBuffer.log(
TAG,
DEBUG,
{ str1 = inAudioSharing.toString() },
- { "DeviceClick. in audio sharing=$str1" }
+ { "DeviceClick. in audio sharing=$str1" },
)
}
@@ -138,7 +157,36 @@ constructor(@BluetoothTileDialogLog private val logBuffer: LogBuffer) {
str1 = criteria
str2 = deviceItem.toString()
},
- { "$str1. deviceItem=$str2" }
+ { "$str1. deviceItem=$str2" },
)
}
+
+ fun logAudioSharingStateChanged(stateOn: Boolean) =
+ logBuffer.log(
+ TAG,
+ DEBUG,
+ { str1 = stateOn.toString() },
+ { "AudioSharingStateChanged. state=$str1" },
+ )
+
+ fun logAudioSourceStateUpdate() = logBuffer.log(TAG, DEBUG, {}, { "AudioSourceStateUpdate" })
+
+ fun logAudioSharingButtonClick(click: AudioSharingButtonClick, deviceItem: DeviceItem) =
+ logBuffer.log(
+ TAG,
+ DEBUG,
+ {
+ str1 = click.toString()
+ str2 = deviceItem.toString()
+ },
+ { "AudioSharingButtonClick. click=$str1 deviceItem=$str2" },
+ )
+
+ fun logAudioSharingRequest(apiCall: AudioSharingRequest) =
+ logBuffer.log(
+ TAG,
+ DEBUG,
+ { str1 = apiCall.toString() },
+ { "AudioSharingRequest. apiCall=$str1" },
+ )
}
diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/dagger/AudioSharingModule.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/dagger/AudioSharingModule.kt
index afe9a1eec0b6..01c4b21bfd9f 100644
--- a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/dagger/AudioSharingModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/dagger/AudioSharingModule.kt
@@ -30,6 +30,7 @@ import com.android.systemui.bluetooth.qsdialog.AudioSharingRepositoryEmptyImpl
import com.android.systemui.bluetooth.qsdialog.AudioSharingRepositoryImpl
import com.android.systemui.bluetooth.qsdialog.AvailableAudioSharingMediaDeviceItemFactory
import com.android.systemui.bluetooth.qsdialog.AvailableMediaDeviceItemFactory
+import com.android.systemui.bluetooth.qsdialog.BluetoothTileDialogLogger
import com.android.systemui.bluetooth.qsdialog.ConnectedDeviceItemFactory
import com.android.systemui.bluetooth.qsdialog.DeviceItemActionInteractor
import com.android.systemui.bluetooth.qsdialog.DeviceItemActionInteractorImpl
@@ -53,6 +54,7 @@ interface AudioSharingModule {
fun provideAudioSharingRepository(
localBluetoothManager: LocalBluetoothManager?,
settingsLibAudioSharingRepository: SettingsLibAudioSharingRepository,
+ logger: BluetoothTileDialogLogger,
@Background backgroundDispatcher: CoroutineDispatcher,
): AudioSharingRepository =
if (
@@ -62,6 +64,7 @@ interface AudioSharingModule {
AudioSharingRepositoryImpl(
localBluetoothManager,
settingsLibAudioSharingRepository,
+ logger,
backgroundDispatcher,
)
} else {
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 9ae57153f3ef..2fc81eb9d66a 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
@@ -231,6 +231,11 @@ class AudioSharingDeviceItemActionInteractorTest : SysuiTestCase() {
actionInteractorImpl.onActionIconClick(inAudioSharingMediaDeviceItem) {}
assertThat(bluetoothTileDialogAudioSharingRepository.audioSharingStarted)
.isEqualTo(false)
+ verify(bluetoothTileDialogLogger)
+ .logAudioSharingButtonClick(
+ AudioSharingButtonClick.CHECK_MARK,
+ inAudioSharingMediaDeviceItem,
+ )
}
}
}
@@ -243,6 +248,11 @@ class AudioSharingDeviceItemActionInteractorTest : SysuiTestCase() {
actionInteractorImpl.onActionIconClick(connectedAudioSharingMediaDeviceItem) {}
assertThat(bluetoothTileDialogAudioSharingRepository.audioSharingStarted)
.isEqualTo(true)
+ verify(bluetoothTileDialogLogger)
+ .logAudioSharingButtonClick(
+ AudioSharingButtonClick.PLUS_BUTTON,
+ connectedAudioSharingMediaDeviceItem,
+ )
}
}
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractorKosmos.kt
index e0c0fbd7f033..bc8e62c40f92 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractorKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/AudioSharingInteractorKosmos.kt
@@ -26,6 +26,7 @@ val Kosmos.audioSharingInteractor: AudioSharingInteractor by
applicationContext,
localBluetoothManager,
bluetoothTileDialogAudioSharingRepository,
+ bluetoothTileDialogLogger,
testDispatcher,
)
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/FakeAudioSharingRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/FakeAudioSharingRepository.kt
index c744eacfa3f4..0f6f19129dd3 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/FakeAudioSharingRepository.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/bluetooth/qsdialog/FakeAudioSharingRepository.kt
@@ -28,7 +28,7 @@ class FakeAudioSharingRepository : AudioSharingRepository {
private val mutableInAudioSharing: MutableStateFlow<Boolean> = MutableStateFlow(false)
- private val mutableAudioSourceStateUpdate = MutableSharedFlow<Unit>()
+ private val mutableAudioSourceStateUpdate = MutableSharedFlow<Unit>(replay = 1)
var sourceAdded: Boolean = false
private set