• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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.shade
18 
19 import android.view.WindowManager
20 import com.android.systemui.log.dagger.ShadeWindowLog
21 import com.android.systemui.plugins.log.ConstantStringsLogger
22 import com.android.systemui.plugins.log.ConstantStringsLoggerImpl
23 import com.android.systemui.plugins.log.LogBuffer
24 import com.android.systemui.plugins.log.LogLevel
25 import com.android.systemui.plugins.log.LogLevel.DEBUG
26 import com.android.systemui.plugins.log.LogMessage
27 import javax.inject.Inject
28 
29 private const val TAG = "systemui.shadewindow"
30 
31 class ShadeWindowLogger @Inject constructor(@ShadeWindowLog private val buffer: LogBuffer) :
<lambda>null32     ConstantStringsLogger by ConstantStringsLoggerImpl(buffer, TAG) {
33 
34     fun logApplyingWindowLayoutParams(lp: WindowManager.LayoutParams) {
35         buffer.log(
36             TAG,
37             DEBUG,
38             { str1 = lp.toString() },
39             { "Applying new window layout params: $str1" }
40         )
41     }
42 
43     fun logNewState(state: Any) {
44         buffer.log(
45             TAG,
46             DEBUG,
47             { str1 = state.toString() },
48             { "Applying new state: $str1" }
49         )
50     }
51 
52     private inline fun log(
53         logLevel: LogLevel,
54         initializer: LogMessage.() -> Unit,
55         noinline printer: LogMessage.() -> String
56     ) {
57         buffer.log(TAG, logLevel, initializer, printer)
58     }
59 
60     fun logApplyVisibility(visible: Boolean) {
61         buffer.log(
62             TAG,
63             DEBUG,
64             { bool1 = visible },
65             { "Updating visibility, should be visible : $bool1" })
66     }
67 
68     fun logShadeVisibleAndFocusable(visible: Boolean) {
69         buffer.log(
70             TAG,
71             DEBUG,
72             { bool1 = visible },
73             { "Updating shade, should be visible and focusable: $bool1" }
74         )
75     }
76 
77     fun logShadeFocusable(focusable: Boolean) {
78         buffer.log(
79             TAG,
80             DEBUG,
81             { bool1 = focusable },
82             { "Updating shade, should be focusable : $bool1" }
83         )
84     }
85 }
86