1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.bluetooth.qsdialog 18 19 import android.bluetooth.BluetoothDevice 20 import com.android.systemui.log.LogBuffer 21 import com.android.systemui.log.core.LogLevel.DEBUG 22 import com.android.systemui.log.dagger.BluetoothTileDialogLog 23 import javax.inject.Inject 24 25 private const val TAG = "BluetoothTileDialogLog" 26 27 enum class BluetoothStateStage { 28 USER_TOGGLED, 29 BLUETOOTH_STATE_VALUE_SET, 30 BLUETOOTH_STATE_CHANGE_RECEIVED 31 } 32 33 enum class DeviceFetchTrigger { 34 FIRST_LOAD, 35 BLUETOOTH_STATE_CHANGE_RECEIVED, 36 BLUETOOTH_CALLBACK_RECEIVED 37 } 38 39 enum class JobStatus { 40 FINISHED, 41 CANCELLED 42 } 43 44 class BluetoothTileDialogLogger 45 @Inject 46 constructor(@BluetoothTileDialogLog private val logBuffer: LogBuffer) { 47 logBluetoothStatenull48 fun logBluetoothState(stage: BluetoothStateStage, state: String) = 49 logBuffer.log( 50 TAG, 51 DEBUG, 52 { 53 str1 = stage.toString() 54 str2 = state 55 }, <lambda>null56 { "BluetoothState. stage=$str1 state=$str2" } 57 ) 58 logDeviceClicknull59 fun logDeviceClick(address: String, type: DeviceItemType) = 60 logBuffer.log( 61 TAG, 62 DEBUG, 63 { 64 str1 = address 65 str2 = type.toString() 66 }, <lambda>null67 { "DeviceClick. address=$str1 type=$str2" } 68 ) 69 logActiveDeviceChangednull70 fun logActiveDeviceChanged(address: String?, profileId: Int) = 71 logBuffer.log( 72 TAG, 73 DEBUG, 74 { 75 str1 = address 76 int1 = profileId 77 }, <lambda>null78 { "ActiveDeviceChanged. address=$str1 profileId=$int1" } 79 ) 80 logProfileConnectionStateChangednull81 fun logProfileConnectionStateChanged(address: String, state: String, profileId: Int) = 82 logBuffer.log( 83 TAG, 84 DEBUG, 85 { 86 str1 = address 87 str2 = state 88 int1 = profileId 89 }, <lambda>null90 { "ProfileConnectionStateChanged. address=$str1 state=$str2 profileId=$int1" } 91 ) 92 logDeviceFetchnull93 fun logDeviceFetch(status: JobStatus, trigger: DeviceFetchTrigger, duration: Long) = 94 logBuffer.log( 95 TAG, 96 DEBUG, 97 { 98 str1 = status.toString() 99 str2 = trigger.toString() 100 long1 = duration 101 }, <lambda>null102 { "DeviceFetch. status=$str1 trigger=$str2 duration=$long1" } 103 ) 104 logDeviceUiUpdatenull105 fun logDeviceUiUpdate(duration: Long) = 106 logBuffer.log(TAG, DEBUG, { long1 = duration }, { "DeviceUiUpdate. duration=$long1" }) 107 logDeviceClickInAudioSharingWhenEnablednull108 fun logDeviceClickInAudioSharingWhenEnabled(inAudioSharing: Boolean) { 109 logBuffer.log( 110 TAG, 111 DEBUG, 112 { str1 = inAudioSharing.toString() }, 113 { "DeviceClick. in audio sharing=$str1" } 114 ) 115 } 116 logConnectedLeByGroupIdnull117 fun logConnectedLeByGroupId(map: Map<Int, List<BluetoothDevice>>) { 118 logBuffer.log(TAG, DEBUG, { str1 = map.toString() }, { "ConnectedLeByGroupId. map=$str1" }) 119 } 120 logLaunchSettingsCriteriaMatchednull121 fun logLaunchSettingsCriteriaMatched(criteria: String, deviceItem: DeviceItem) { 122 logBuffer.log( 123 TAG, 124 DEBUG, 125 { 126 str1 = criteria 127 str2 = deviceItem.toString() 128 }, 129 { "$str1. deviceItem=$str2" } 130 ) 131 } 132 } 133