• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 package com.android.systemui.volume.dialog.shared
17 
18 import com.android.settingslib.volume.shared.model.RingerMode
19 import com.android.systemui.log.LogBuffer
20 import com.android.systemui.log.core.LogLevel
21 import com.android.systemui.log.dagger.VolumeLog
22 import com.android.systemui.volume.Events
23 import javax.inject.Inject
24 
25 private const val TAG = "SysUI_VolumeDialog"
26 
27 /** Logs events related to the Volume Panel. */
28 class VolumeDialogLogger @Inject constructor(@VolumeLog private val logBuffer: LogBuffer) {
29 
onShownull30     fun onShow(reason: Int) {
31         logBuffer.log(
32             TAG,
33             LogLevel.DEBUG,
34             { int1 = reason },
35             { "Show: ${Events.SHOW_REASONS[int1]}" },
36         )
37     }
38 
onDismissnull39     fun onDismiss(reason: Int) {
40         logBuffer.log(
41             TAG,
42             LogLevel.DEBUG,
43             { int1 = reason },
44             { "Dismiss: ${Events.DISMISS_REASONS[int1]}" },
45         )
46     }
47 
onVolumeSliderAdjustmentFinishednull48     fun onVolumeSliderAdjustmentFinished(volume: Int, stream: Int) {
49         logBuffer.log(
50             TAG,
51             LogLevel.DEBUG,
52             {
53                 int1 = volume
54                 int2 = stream
55             },
56             { "Volume adjusted: volume=$int1 stream=$int2" },
57         )
58     }
59 
onVolumeSlidersUpdatednull60     fun onVolumeSlidersUpdated(primaryStream: Int, floating: Collection<Int>) {
61         logBuffer.log(
62             TAG,
63             LogLevel.DEBUG,
64             {
65                 int1 = primaryStream
66                 str1 = floating.joinToString(",") { it.toString() }
67             },
68             { "Showing streams: primary=$int1 floating=$str1" },
69         )
70     }
71 
onRingerModeChangednull72     fun onRingerModeChanged(ringerMode: RingerMode) {
73         logBuffer.log(
74             TAG,
75             LogLevel.DEBUG,
76             { int1 = ringerMode.value },
77             { "Ringer mode changed to: $int1" },
78         )
79     }
80 
onRingerDrawerAvailablenull81     fun onRingerDrawerAvailable(modes: List<RingerMode>) {
82         logBuffer.log(
83             TAG,
84             LogLevel.DEBUG,
85             { str1 = modes.joinToString(",") { it.value.toString() } },
86             { "Ringer drawer available with modes: $str1" },
87         )
88     }
89 
onRingerDrawerUnavailablenull90     fun onRingerDrawerUnavailable() {
91         logBuffer.log(TAG, LogLevel.DEBUG, {}, { "Ringer drawer unavailable" })
92     }
93 
onCurrentRingerModeIsUnsupportednull94     fun onCurrentRingerModeIsUnsupported(ringerMode: RingerMode) {
95         logBuffer.log(
96             TAG,
97             LogLevel.DEBUG,
98             { int1 = ringerMode.value },
99             { "Current ringer mode: $int1, ringer mode is unsupported in ringer drawer options" },
100         )
101     }
102 }
103