1 /*
2  * Copyright (C) 2023 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.media.controls.ui.controller
18 
19 import android.view.ViewGroup
20 import com.android.systemui.log.LogBuffer
21 import com.android.systemui.log.core.LogLevel.DEBUG
22 import com.android.systemui.log.dagger.KeyguardMediaControllerLog
23 import com.android.systemui.statusbar.StatusBarState
24 import javax.inject.Inject
25 
26 /** Logger class for [KeyguardMediaController]. */
27 open class KeyguardMediaControllerLogger
28 @Inject
29 constructor(@KeyguardMediaControllerLog private val logBuffer: LogBuffer) {
30 
logRefreshMediaPositionnull31     fun logRefreshMediaPosition(
32         reason: String,
33         visible: Boolean,
34         useSplitShade: Boolean,
35         currentState: Int,
36         keyguardOrUserSwitcher: Boolean,
37         mediaHostVisible: Boolean,
38         bypassNotEnabled: Boolean,
39         shouldBeVisibleForSplitShade: Boolean,
40     ) {
41         logBuffer.log(
42             TAG,
43             DEBUG,
44             {
45                 str1 = reason
46                 bool1 = visible
47                 bool2 = useSplitShade
48                 int1 = currentState
49                 bool3 = keyguardOrUserSwitcher
50                 bool4 = mediaHostVisible
51                 int2 = if (bypassNotEnabled) 1 else 0
52                 str2 = shouldBeVisibleForSplitShade.toString()
53             },
54             {
55                 "refreshMediaPosition(reason=$str1, " +
56                     "currentState=${StatusBarState.toString(int1)}, " +
57                     "visible=$bool1, useSplitShade=$bool2, " +
58                     "keyguardOrUserSwitcher=$bool3, " +
59                     "mediaHostVisible=$bool4, " +
60                     "bypassNotEnabled=${int2 == 1}, " +
61                     "shouldBeVisibleForSplitShade=$str2)"
62             }
63         )
64     }
65 
logActiveMediaContainernull66     fun logActiveMediaContainer(reason: String, activeContainer: ViewGroup?) {
67         logBuffer.log(
68             TAG,
69             DEBUG,
70             {
71                 str1 = reason
72                 str2 = activeContainer.toString()
73             },
74             { "activeMediaContainerVisibility(reason=$str1, activeContainer=$str2)" }
75         )
76     }
77 
78     private companion object {
79         private const val TAG = "KeyguardMediaControllerLog"
80     }
81 }
82