• 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.interruption
18 
19 import android.util.Log
20 
21 import com.android.systemui.log.dagger.NotificationInterruptLog
22 import com.android.systemui.log.LogBuffer
23 import com.android.systemui.log.core.LogLevel.DEBUG
24 import com.android.systemui.log.core.LogLevel.INFO
25 import com.android.systemui.log.core.LogLevel.WARNING
26 import com.android.systemui.statusbar.notification.collection.NotificationEntry
27 import com.android.systemui.statusbar.notification.logKey
28 import com.android.systemui.util.Compile
29 import javax.inject.Inject
30 
31 class NotificationInterruptLogger @Inject constructor(
32     @NotificationInterruptLog val buffer: LogBuffer
33 ) {
logHeadsUpFeatureChangednull34     fun logHeadsUpFeatureChanged(useHeadsUp: Boolean) {
35         buffer.log(TAG, INFO, {
36             bool1 = useHeadsUp
37         }, {
38             "heads up is enabled=$bool1"
39         })
40     }
41 
logWillDismissAllnull42     fun logWillDismissAll() {
43         buffer.log(TAG, INFO, {
44         }, {
45             "dismissing any existing heads up notification on disable event"
46         })
47     }
48 
logNoBubbleNotAllowednull49     fun logNoBubbleNotAllowed(entry: NotificationEntry) {
50         if (Compile.IS_DEBUG && Log.isLoggable(TAG, Log.DEBUG)) {
51             buffer.log(TAG, DEBUG, {
52                 str1 = entry.logKey
53             }, {
54                 "No bubble up: not allowed to bubble: $str1"
55             })
56         }
57     }
58 
logNoAlertingAppSuspendednull59     fun logNoAlertingAppSuspended(entry: NotificationEntry) {
60         buffer.log(TAG, DEBUG, {
61             str1 = entry.logKey
62         }, {
63             "No alerting: app is suspended: $str1"
64         })
65     }
66 
logNoBubbleNoMetadatanull67     fun logNoBubbleNoMetadata(entry: NotificationEntry) {
68         buffer.log(TAG, DEBUG, {
69             str1 = entry.logKey
70         }, {
71             "No bubble up: notification: $str1 doesn't have valid metadata"
72         })
73     }
74 
logNoHeadsUpFeatureDisablednull75     fun logNoHeadsUpFeatureDisabled() {
76         buffer.log(TAG, DEBUG, {
77         }, {
78             "No heads up: no huns"
79         })
80     }
81 
logNoHeadsUpPackageSnoozednull82     fun logNoHeadsUpPackageSnoozed(entry: NotificationEntry) {
83         buffer.log(TAG, DEBUG, {
84             str1 = entry.logKey
85         }, {
86             "No heads up: snoozed package: $str1"
87         })
88     }
89 
logHeadsUpPackageSnoozeBypassedHasFsinull90     fun logHeadsUpPackageSnoozeBypassedHasFsi(entry: NotificationEntry) {
91         buffer.log(TAG, DEBUG, {
92             str1 = entry.logKey
93         }, {
94             "Heads up: package snooze bypassed because notification has full-screen intent: $str1"
95         })
96     }
97 
logNoHeadsUpAlreadyBubblednull98     fun logNoHeadsUpAlreadyBubbled(entry: NotificationEntry) {
99         buffer.log(TAG, DEBUG, {
100             str1 = entry.logKey
101         }, {
102             "No heads up: in unlocked shade where notification is shown as a bubble: $str1"
103         })
104     }
105 
logNoHeadsUpSuppressedByDndnull106     fun logNoHeadsUpSuppressedByDnd(entry: NotificationEntry) {
107         buffer.log(TAG, DEBUG, {
108             str1 = entry.logKey
109         }, {
110             "No heads up: suppressed by DND: $str1"
111         })
112     }
113 
logNoHeadsUpNotImportantnull114     fun logNoHeadsUpNotImportant(entry: NotificationEntry) {
115         buffer.log(TAG, DEBUG, {
116             str1 = entry.logKey
117         }, {
118             "No heads up: unimportant notification: $str1"
119         })
120     }
121 
logNoHeadsUpNotInUsenull122     fun logNoHeadsUpNotInUse(entry: NotificationEntry) {
123         buffer.log(TAG, DEBUG, {
124             str1 = entry.logKey
125         }, {
126             "No heads up: not in use: $str1"
127         })
128     }
129 
logNoHeadsUpOldWhennull130     fun logNoHeadsUpOldWhen(
131         entry: NotificationEntry,
132         notifWhen: Long,
133         notifAge: Long
134     ) {
135         buffer.log(TAG, DEBUG, {
136             str1 = entry.logKey
137             long1 = notifWhen
138             long2 = notifAge
139         }, {
140             "No heads up: old when $long1 (age=$long2 ms): $str1"
141         })
142     }
143 
logMaybeHeadsUpDespiteOldWhennull144     fun logMaybeHeadsUpDespiteOldWhen(
145         entry: NotificationEntry,
146         notifWhen: Long,
147         notifAge: Long,
148         reason: String
149     ) {
150         buffer.log(TAG, DEBUG, {
151             str1 = entry.logKey
152             str2 = reason
153             long1 = notifWhen
154             long2 = notifAge
155         }, {
156             "Maybe heads up: old when $long1 (age=$long2 ms) but $str2: $str1"
157         })
158     }
159 
logNoHeadsUpSuppressedBynull160     fun logNoHeadsUpSuppressedBy(
161         entry: NotificationEntry,
162         suppressor: NotificationInterruptSuppressor
163     ) {
164         buffer.log(TAG, DEBUG, {
165             str1 = entry.logKey
166             str2 = suppressor.name
167         }, {
168             "No heads up: aborted by suppressor: $str2 sbnKey=$str1"
169         })
170     }
171 
logHeadsUpnull172     fun logHeadsUp(entry: NotificationEntry) {
173         buffer.log(TAG, DEBUG, {
174             str1 = entry.logKey
175         }, {
176             "Heads up: $str1"
177         })
178     }
179 
logNoAlertingFilteredOutnull180     fun logNoAlertingFilteredOut(entry: NotificationEntry) {
181         buffer.log(TAG, DEBUG, {
182             str1 = entry.logKey
183         }, {
184             "No alerting: filtered notification: $str1"
185         })
186     }
187 
logNoAlertingGroupAlertBehaviornull188     fun logNoAlertingGroupAlertBehavior(entry: NotificationEntry) {
189         buffer.log(TAG, DEBUG, {
190             str1 = entry.logKey
191         }, {
192             "No alerting: suppressed due to group alert behavior: $str1"
193         })
194     }
195 
logNoAlertingSilentNotificationnull196     fun logNoAlertingSilentNotification(entry: NotificationEntry) {
197         buffer.log(TAG, DEBUG, {
198             str1 = entry.logKey
199         }, {
200             "No alerting: suppressed due to silent notification: $str1"
201         })
202     }
203 
logNoAlertingSuppressedBynull204     fun logNoAlertingSuppressedBy(
205         entry: NotificationEntry,
206         suppressor: NotificationInterruptSuppressor,
207         awake: Boolean
208     ) {
209         buffer.log(TAG, DEBUG, {
210             str1 = entry.logKey
211             str2 = suppressor.name
212             bool1 = awake
213         }, {
214             "No alerting: aborted by suppressor: $str2 awake=$bool1 sbnKey=$str1"
215         })
216     }
217 
logNoAlertingRecentFullscreennull218     fun logNoAlertingRecentFullscreen(entry: NotificationEntry) {
219         buffer.log(TAG, DEBUG, {
220             str1 = entry.logKey
221         }, {
222             "No alerting: recent fullscreen: $str1"
223         })
224     }
225 
logNoPulsingSettingDisablednull226     fun logNoPulsingSettingDisabled(entry: NotificationEntry) {
227         buffer.log(TAG, DEBUG, {
228             str1 = entry.logKey
229         }, {
230             "No pulsing: disabled by setting: $str1"
231         })
232     }
233 
logNoPulsingBatteryDisablednull234     fun logNoPulsingBatteryDisabled(entry: NotificationEntry) {
235         buffer.log(TAG, DEBUG, {
236             str1 = entry.logKey
237         }, {
238             "No pulsing: disabled by battery saver: $str1"
239         })
240     }
241 
logNoPulsingNoAlertnull242     fun logNoPulsingNoAlert(entry: NotificationEntry) {
243         buffer.log(TAG, DEBUG, {
244             str1 = entry.logKey
245         }, {
246             "No pulsing: notification shouldn't alert: $str1"
247         })
248     }
249 
logNoPulsingNoAmbientEffectnull250     fun logNoPulsingNoAmbientEffect(entry: NotificationEntry) {
251         buffer.log(TAG, DEBUG, {
252             str1 = entry.logKey
253         }, {
254             "No pulsing: ambient effect suppressed: $str1"
255         })
256     }
257 
logNoPulsingNotificationHiddenOverridenull258     fun logNoPulsingNotificationHiddenOverride(entry: NotificationEntry) {
259         buffer.log(TAG, DEBUG, {
260             str1 = entry.logKey
261         }, {
262             "No pulsing: notification hidden on lock screen by override: $str1"
263         })
264     }
265 
logNoPulsingNotImportantnull266     fun logNoPulsingNotImportant(entry: NotificationEntry) {
267         buffer.log(TAG, DEBUG, {
268             str1 = entry.logKey
269         }, {
270             "No pulsing: not important enough: $str1"
271         })
272     }
273 
logPulsingnull274     fun logPulsing(entry: NotificationEntry) {
275         buffer.log(TAG, DEBUG, {
276             str1 = entry.logKey
277         }, {
278             "Pulsing: $str1"
279         })
280     }
281 
logNoFullscreennull282     fun logNoFullscreen(entry: NotificationEntry, reason: String) {
283         buffer.log(TAG, DEBUG, {
284             str1 = entry.logKey
285             str2 = reason
286         }, {
287             "No FullScreenIntent: $str2: $str1"
288         })
289     }
290 
logNoFullscreenWarningnull291     fun logNoFullscreenWarning(entry: NotificationEntry, reason: String) {
292         buffer.log(TAG, WARNING, {
293             str1 = entry.logKey
294             str2 = reason
295         }, {
296             "No FullScreenIntent: WARNING: $str2: $str1"
297         })
298     }
299 
logFullscreennull300     fun logFullscreen(entry: NotificationEntry, reason: String) {
301         buffer.log(TAG, DEBUG, {
302             str1 = entry.logKey
303             str2 = reason
304         }, {
305             "FullScreenIntent: $str2: $str1"
306         })
307     }
308 
logNoAlertingNotificationHiddennull309     fun logNoAlertingNotificationHidden(entry: NotificationEntry) {
310         buffer.log(TAG, DEBUG, {
311             str1 = entry.logKey
312         }, {
313             "No alerting: notification hidden on lock screen: $str1"
314         })
315     }
316 }
317 
318 private const val TAG = "InterruptionStateProvider"
319