• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.log
18 
19 import com.android.systemui.bouncer.shared.model.BouncerMessageModel
20 import com.android.systemui.dagger.SysUISingleton
21 import com.android.systemui.log.core.LogLevel
22 import com.android.systemui.log.dagger.BouncerLog
23 import javax.inject.Inject
24 
25 private const val TAG = "BouncerLog"
26 
27 /**
28  * Helper class for logging for classes in the [com.android.systemui.keyguard.bouncer] package.
29  *
30  * To enable logcat echoing for an entire buffer:
31  * ```
32  *   adb shell settings put global systemui/buffer/BouncerLog <logLevel>
33  *
34  * ```
35  */
36 @SysUISingleton
37 class BouncerLogger @Inject constructor(@BouncerLog private val buffer: LogBuffer) {
startBouncerMessageInteractornull38     fun startBouncerMessageInteractor() {
39         buffer.log(
40             TAG,
41             LogLevel.DEBUG,
42             "Starting BouncerMessageInteractor.bouncerMessage collector"
43         )
44     }
45 
bouncerMessageUpdatednull46     fun bouncerMessageUpdated(bouncerMsg: BouncerMessageModel?) {
47         buffer.log(
48             TAG,
49             LogLevel.DEBUG,
50             {
51                 int1 = bouncerMsg?.message?.messageResId ?: -1
52                 str1 = bouncerMsg?.message?.message
53                 int2 = bouncerMsg?.secondaryMessage?.messageResId ?: -1
54                 str2 = bouncerMsg?.secondaryMessage?.message
55             },
56             { "Bouncer message update received: $int1, $str1, $int2, $str2" }
57         )
58     }
59 
bindingBouncerMessageViewnull60     fun bindingBouncerMessageView() {
61         buffer.log(TAG, LogLevel.DEBUG, "Binding BouncerMessageView")
62     }
63 
interestedStateChangednull64     fun interestedStateChanged(whatChanged: String, newValue: Boolean) {
65         buffer.log(
66             TAG,
67             LogLevel.DEBUG,
68             {
69                 str1 = whatChanged
70                 bool1 = newValue
71             },
72             { "state changed: $str1: $bool1" }
73         )
74     }
75 }
76