• 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.statusbar.notification.collection.coordinator
18 
19 import android.util.Log
20 import com.android.systemui.log.LogBuffer
21 import com.android.systemui.log.core.LogLevel
22 import com.android.systemui.log.dagger.NotificationHeadsUpLog
23 import javax.inject.Inject
24 
25 private const val TAG = "HeadsUpCoordinator"
26 
27 class HeadsUpCoordinatorLogger(private val buffer: LogBuffer, private val verbose: Boolean) {
28     @Inject
29     constructor(
30         @NotificationHeadsUpLog buffer: LogBuffer
31     ) : this(buffer, Log.isLoggable(TAG, Log.VERBOSE))
32 
logPostedEntryWillEvaluatenull33     fun logPostedEntryWillEvaluate(posted: HeadsUpCoordinator.PostedEntry, reason: String) {
34         if (!verbose) return
35         buffer.log(
36             TAG,
37             LogLevel.VERBOSE,
38             {
39                 str1 = posted.key
40                 str2 = reason
41                 bool1 = posted.shouldHeadsUpEver
42                 bool2 = posted.shouldHeadsUpAgain
43             },
44             {
45                 "will evaluate posted entry $str1:" +
46                     " reason=$str2 shouldHeadsUpEver=$bool1 shouldHeadsUpAgain=$bool2"
47             },
48         )
49     }
50 
logPostedEntryWillNotEvaluatenull51     fun logPostedEntryWillNotEvaluate(posted: HeadsUpCoordinator.PostedEntry, reason: String) {
52         if (!verbose) return
53         buffer.log(
54             TAG,
55             LogLevel.VERBOSE,
56             {
57                 str1 = posted.key
58                 str2 = reason
59             },
60             { "will not evaluate posted entry $str1: reason=$str2" },
61         )
62     }
63 
logEvaluatingGroupsnull64     fun logEvaluatingGroups(numGroups: Int) {
65         if (!verbose) return
66         buffer.log(
67             TAG,
68             LogLevel.VERBOSE,
69             { int1 = numGroups },
70             { "evaluating groups for alert transfer: $int1" },
71         )
72     }
73 
logEvaluatingGroupnull74     fun logEvaluatingGroup(groupKey: String, numPostedEntries: Int, logicalGroupSize: Int) {
75         if (!verbose) return
76         buffer.log(
77             TAG,
78             LogLevel.VERBOSE,
79             {
80                 str1 = groupKey
81                 int1 = numPostedEntries
82                 int2 = logicalGroupSize
83             },
84             {
85                 "evaluating group for alert transfer: $str1" +
86                     " numPostedEntries=$int1 logicalGroupSize=$int2"
87             },
88         )
89     }
90 
logEntryUpdatedByRankingnull91     fun logEntryUpdatedByRanking(key: String, shouldHun: Boolean, reason: String) {
92         buffer.log(
93             TAG,
94             LogLevel.DEBUG,
95             {
96                 str1 = key
97                 bool1 = shouldHun
98                 str2 = reason
99             },
100             {
101                 "updating entry via ranking applied: $str1 updated shouldHeadsUp=$bool1 because $str2"
102             },
103         )
104     }
105 
logEntryUpdatedToFullScreennull106     fun logEntryUpdatedToFullScreen(key: String, reason: String) {
107         buffer.log(
108             TAG,
109             LogLevel.DEBUG,
110             {
111                 str1 = key
112                 str2 = reason
113             },
114             { "updating entry to launch full screen intent: $str1 because $str2" },
115         )
116     }
117 
logEntryDisqualifiedFromFullScreennull118     fun logEntryDisqualifiedFromFullScreen(key: String, reason: String) {
119         buffer.log(
120             TAG,
121             LogLevel.DEBUG,
122             {
123                 str1 = key
124                 str2 = reason
125             },
126             { "updated entry no longer qualifies for full screen intent: $str1 because $str2" },
127         )
128     }
129 
logSummaryMarkedInterruptednull130     fun logSummaryMarkedInterrupted(summaryKey: String, childKey: String) {
131         buffer.log(
132             TAG,
133             LogLevel.DEBUG,
134             {
135                 str1 = summaryKey
136                 str2 = childKey
137             },
138             { "marked group summary as interrupted: $str1 for alert transfer to child: $str2" },
139         )
140     }
141 
logShowPromotedNotificationHeadsUpnull142     fun logShowPromotedNotificationHeadsUp(key: String) {
143         buffer.log(
144             TAG,
145             LogLevel.DEBUG,
146             { str1 = key },
147             { "requesting promoted entry to show heads up: $str1" },
148         )
149     }
150 
logHidePromotedNotificationHeadsUpnull151     fun logHidePromotedNotificationHeadsUp(key: String) {
152         buffer.log(
153             TAG,
154             LogLevel.DEBUG,
155             { str1 = key },
156             { "requesting promoted entry to hide heads up: $str1" },
157         )
158     }
159 
logPromotedNotificationForHeadsUpNotFoundnull160     fun logPromotedNotificationForHeadsUpNotFound(key: String) {
161         buffer.log(
162             TAG,
163             LogLevel.DEBUG,
164             { str1 = key },
165             { "could not find promoted entry, so not showing heads up: $str1" },
166         )
167     }
168 }
169