• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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.headsup
18 
19 import com.android.systemui.log.LogBuffer
20 import com.android.systemui.log.core.LogLevel.INFO
21 import com.android.systemui.log.core.LogLevel.VERBOSE
22 import com.android.systemui.log.dagger.NotificationHeadsUpLog
23 import com.android.systemui.statusbar.notification.collection.NotificationEntry
24 import com.android.systemui.statusbar.notification.logKey
25 import javax.inject.Inject
26 
27 /** Logger for [HeadsUpManager]. */
28 class HeadsUpManagerLogger
29 @Inject
30 constructor(@NotificationHeadsUpLog private val buffer: LogBuffer) {
logPackageSnoozednull31     fun logPackageSnoozed(snoozeKey: String) {
32         buffer.log(TAG, INFO, { str1 = snoozeKey }, { "package snoozed $str1" })
33     }
34 
logPackageUnsnoozednull35     fun logPackageUnsnoozed(snoozeKey: String) {
36         buffer.log(TAG, INFO, { str1 = snoozeKey }, { "package unsnoozed $str1" })
37     }
38 
logIsSnoozedReturnednull39     fun logIsSnoozedReturned(snoozeKey: String) {
40         buffer.log(TAG, INFO, { str1 = snoozeKey }, { "package snoozed when queried $str1" })
41     }
42 
logReleaseAllImmediatelynull43     fun logReleaseAllImmediately() {
44         buffer.log(TAG, INFO, {}, { "release all immediately" })
45     }
46 
logShowNotificationRequestnull47     fun logShowNotificationRequest(entry: NotificationEntry, isPinnedByUser: Boolean) {
48         buffer.log(
49             TAG,
50             INFO,
51             {
52                 str1 = entry.logKey
53                 bool1 = isPinnedByUser
54             },
55             { "request: show notification $str1. isPinnedByUser=$bool1" },
56         )
57     }
58 
logAvalancheUpdatenull59     fun logAvalancheUpdate(
60         caller: String,
61         isEnabled: Boolean,
62         notifEntryKey: String,
63         outcome: String,
64     ) {
65         buffer.log(
66             TAG,
67             INFO,
68             {
69                 str1 = caller
70                 str2 = notifEntryKey
71                 str3 = outcome
72                 bool1 = isEnabled
73             },
74             { "$str1\n=> AC[enabled:$bool1] update: $str2\n=> $str3" },
75         )
76     }
77 
logAvalancheDeletenull78     fun logAvalancheDelete(
79         caller: String,
80         isEnabled: Boolean,
81         notifEntryKey: String,
82         outcome: String,
83     ) {
84         buffer.log(
85             TAG,
86             INFO,
87             {
88                 str1 = caller
89                 str2 = notifEntryKey
90                 str3 = outcome
91                 bool1 = isEnabled
92             },
93             { "$str1\n=> AC[enabled:$bool1] delete: $str2\n=> $str3" },
94         )
95     }
96 
logAvalancheStagenull97     fun logAvalancheStage(stage: String, key: String) {
98         buffer.log(
99             TAG,
100             INFO,
101             {
102                 str1 = stage
103                 str2 = key
104             },
105             { "[AC] $str1 $str2" },
106         )
107     }
108 
logAvalancheDurationnull109     fun logAvalancheDuration(
110         thisKey: String,
111         duration: RemainingDuration,
112         reason: String,
113         nextKey: String,
114     ) {
115         val durationMs =
116             when (duration) {
117                 is RemainingDuration.UpdatedDuration -> duration.duration
118                 is RemainingDuration.HideImmediately -> 0
119             }
120         buffer.log(
121             TAG,
122             INFO,
123             {
124                 str1 = thisKey
125                 int1 = durationMs
126                 str2 = reason
127                 str3 = nextKey
128             },
129             { "[AC] $str1 | $int1 ms | $str2 $str3" },
130         )
131     }
132 
logShowNotificationnull133     fun logShowNotification(entry: NotificationEntry, isPinnedByUser: Boolean) {
134         buffer.log(
135             TAG,
136             INFO,
137             {
138                 str1 = entry.logKey
139                 bool1 = isPinnedByUser
140             },
141             { "show notification $str1. isPinnedByUser=$bool1" },
142         )
143     }
144 
logAutoRemoveSchedulednull145     fun logAutoRemoveScheduled(entry: NotificationEntry, delayMillis: Long, reason: String) {
146         buffer.log(
147             TAG,
148             INFO,
149             {
150                 str1 = entry.logKey
151                 long1 = delayMillis
152                 str2 = reason
153             },
154             { "schedule auto remove of $str1 in $long1 ms reason: $str2" },
155         )
156     }
157 
logAutoRemoveRequestnull158     fun logAutoRemoveRequest(entry: NotificationEntry, reason: String) {
159         buffer.log(
160             TAG,
161             INFO,
162             {
163                 str1 = entry.logKey
164                 str2 = reason
165             },
166             { "request: reschedule auto remove of $str1 reason: $str2" },
167         )
168     }
169 
logAutoRemoveReschedulednull170     fun logAutoRemoveRescheduled(entry: NotificationEntry, delayMillis: Long, reason: String) {
171         buffer.log(
172             TAG,
173             INFO,
174             {
175                 str1 = entry.logKey
176                 long1 = delayMillis
177                 str2 = reason
178             },
179             { "reschedule auto remove of $str1 in $long1 ms reason: $str2" },
180         )
181     }
182 
logAutoRemoveCancelRequestnull183     fun logAutoRemoveCancelRequest(entry: NotificationEntry, reason: String?) {
184         buffer.log(
185             TAG,
186             INFO,
187             {
188                 str1 = entry.logKey
189                 str2 = reason ?: "unknown"
190             },
191             { "request: cancel auto remove of $str1 reason: $str2" },
192         )
193     }
194 
logAutoRemoveCancelednull195     fun logAutoRemoveCanceled(entry: NotificationEntry?, reason: String?) {
196         buffer.log(
197             TAG,
198             INFO,
199             {
200                 str1 = entry?.logKey
201                 str2 = reason ?: "unknown"
202             },
203             { "cancel auto remove of $str1 reason: $str2" },
204         )
205     }
206 
logRemoveEntryRequestnull207     fun logRemoveEntryRequest(key: String, reason: String, isWaiting: Boolean) {
208         buffer.log(
209             TAG,
210             INFO,
211             {
212                 str1 = logKey(key)
213                 str2 = reason
214                 bool1 = isWaiting
215             },
216             { "request: $str2 => remove entry $str1 isWaiting: $isWaiting" },
217         )
218     }
219 
logRemoveEntrynull220     fun logRemoveEntry(key: String, reason: String, isWaiting: Boolean) {
221         buffer.log(
222             TAG,
223             INFO,
224             {
225                 str1 = logKey(key)
226                 str2 = reason
227                 bool1 = isWaiting
228             },
229             { "$str2 => remove entry $str1 isWaiting: $isWaiting" },
230         )
231     }
232 
logUnpinEntryRequestnull233     fun logUnpinEntryRequest(key: String) {
234         buffer.log(TAG, INFO, { str1 = logKey(key) }, { "request: unpin entry $str1" })
235     }
236 
logUnpinEntrynull237     fun logUnpinEntry(key: String) {
238         buffer.log(TAG, INFO, { str1 = logKey(key) }, { "unpin entry $str1" })
239     }
240 
logRemoveNotificationnull241     fun logRemoveNotification(
242         key: String,
243         releaseImmediately: Boolean,
244         isWaiting: Boolean,
245         reason: String,
246     ) {
247         buffer.log(
248             TAG,
249             INFO,
250             {
251                 str1 = logKey(key)
252                 bool1 = releaseImmediately
253                 bool2 = isWaiting
254                 str2 = reason
255             },
256             {
257                 "remove notification $str1 releaseImmediately: $bool1 isWaiting: $bool2 " +
258                     "reason: $str2"
259             },
260         )
261     }
262 
logNullEntrynull263     fun logNullEntry(key: String, reason: String) {
264         buffer.log(
265             TAG,
266             INFO,
267             {
268                 str1 = logKey(key)
269                 str2 = reason
270             },
271             { "remove notification $str1 when headsUpEntry is null, reason: $str2" },
272         )
273     }
274 
logNotificationActuallyRemovednull275     fun logNotificationActuallyRemoved(entry: NotificationEntry) {
276         buffer.log(TAG, INFO, { str1 = entry.logKey }, { "notification removed $str1 " })
277     }
278 
logUpdateNotificationRequestnull279     fun logUpdateNotificationRequest(
280         key: String,
281         requestedPinnedStatus: PinnedStatus,
282         hasEntry: Boolean,
283     ) {
284         buffer.log(
285             TAG,
286             INFO,
287             {
288                 str1 = logKey(key)
289                 bool1 = hasEntry
290                 str2 = requestedPinnedStatus.name
291             },
292             { "request: update notification $str1. hasEntry: $bool1. requestedPinnedStatus: $str2" },
293         )
294     }
295 
logUpdateNotificationnull296     fun logUpdateNotification(key: String, requestedPinnedStatus: PinnedStatus, hasEntry: Boolean) {
297         buffer.log(
298             TAG,
299             INFO,
300             {
301                 str1 = logKey(key)
302                 bool1 = hasEntry
303                 str2 = requestedPinnedStatus.name
304             },
305             { "update notification $str1. hasEntry: $bool2. requestedPinnedStatus: $str2" },
306         )
307     }
308 
logUpdateEntrynull309     fun logUpdateEntry(entry: NotificationEntry, updatePostTime: Boolean, reason: String?) {
310         buffer.log(
311             TAG,
312             INFO,
313             {
314                 str1 = entry.logKey
315                 bool1 = updatePostTime
316                 str2 = reason ?: "unknown"
317             },
318             { "update entry $str1 updatePostTime: $bool1 reason: $str2" },
319         )
320     }
321 
logSnoozeLengthChangenull322     fun logSnoozeLengthChange(packageSnoozeLengthMs: Int) {
323         buffer.log(
324             TAG,
325             INFO,
326             { int1 = packageSnoozeLengthMs },
327             { "snooze length changed: ${int1}ms" },
328         )
329     }
330 
logSetEntryPinnednull331     fun logSetEntryPinned(entry: NotificationEntry, pinnedStatus: PinnedStatus, reason: String) {
332         buffer.log(
333             TAG,
334             VERBOSE,
335             {
336                 str1 = entry.logKey
337                 str2 = reason
338                 str3 = pinnedStatus.name
339             },
340             { "$str2 => set entry pinned $str1 pinned: $str3" },
341         )
342     }
343 
logUpdatePinnedModenull344     fun logUpdatePinnedMode(
345         hasPinnedNotification: Boolean,
346         pinnedNotificationStatus: PinnedStatus,
347     ) {
348         buffer.log(
349             TAG,
350             INFO,
351             {
352                 bool1 = hasPinnedNotification
353                 str1 = pinnedNotificationStatus.name
354             },
355             { "has pinned notification changed to $bool1, status=$str1" },
356         )
357     }
358 
logRemoveEntryAfterExpandnull359     fun logRemoveEntryAfterExpand(entry: NotificationEntry) {
360         buffer.log(TAG, VERBOSE, { str1 = entry.logKey }, { "remove entry after expand: $str1" })
361     }
362 
logDroppedHunsnull363     fun logDroppedHuns(entryList: String) {
364         buffer.log(TAG, VERBOSE, { str1 = entryList }, { "[AC] dropped:\n $str1" })
365     }
366 }
367 
368 private const val TAG = "HeadsUpManager"
369