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.statusbar.notification.collection.coordinator
18 
19 import com.android.systemui.log.LogBuffer
20 import com.android.systemui.log.core.LogLevel
21 import com.android.systemui.log.dagger.UnseenNotificationLog
22 import com.android.systemui.statusbar.notification.collection.NotificationEntry
23 import javax.inject.Inject
24 
25 private const val TAG = "KeyguardCoordinator"
26 
27 class KeyguardCoordinatorLogger
28 @Inject
29 constructor(
30     @UnseenNotificationLog private val buffer: LogBuffer,
31 ) {
logSeenOnLockscreennull32     fun logSeenOnLockscreen(entry: NotificationEntry) =
33         buffer.log(
34             TAG,
35             LogLevel.DEBUG,
36             messageInitializer = { str1 = entry.key },
<lambda>null37             messagePrinter = {
38                 "Notification [$str1] on lockscreen will be marked as seen when unlocked."
39             },
40         )
41 
logTrackingUnseennull42     fun logTrackingUnseen(trackingUnseen: Boolean) =
43         buffer.log(
44             TAG,
45             LogLevel.DEBUG,
46             messageInitializer = { bool1 = trackingUnseen },
<lambda>null47             messagePrinter = { "${if (bool1) "Start" else "Stop"} tracking unseen notifications." },
48         )
49 
logAllMarkedSeenOnUnlocknull50     fun logAllMarkedSeenOnUnlock(
51         seenCount: Int,
52         remainingUnseenCount: Int,
53     ) =
54         buffer.log(
55             TAG,
56             LogLevel.DEBUG,
57             messageInitializer = {
58                 int1 = seenCount
59                 int2 = remainingUnseenCount
60             },
<lambda>null61             messagePrinter = {
62                 "$int1 Notifications have been marked as seen now that device is unlocked. " +
63                     "$int2 notifications remain unseen."
64             },
65         )
66 
logShadeExpandednull67     fun logShadeExpanded() =
68         buffer.log(
69             TAG,
70             LogLevel.DEBUG,
71             "Notifications have been marked as seen due to shade expansion."
72         )
73 
74     fun logUnseenAdded(key: String) =
75         buffer.log(
76             TAG,
77             LogLevel.DEBUG,
78             messageInitializer = { str1 = key },
<lambda>null79             messagePrinter = { "Unseen notif added: $str1" },
80         )
81 
logUnseenUpdatednull82     fun logUnseenUpdated(key: String) =
83         buffer.log(
84             TAG,
85             LogLevel.DEBUG,
86             messageInitializer = { str1 = key },
<lambda>null87             messagePrinter = { "Unseen notif updated: $str1" },
88         )
89 
logUnseenRemovednull90     fun logUnseenRemoved(key: String) =
91         buffer.log(
92             TAG,
93             LogLevel.DEBUG,
94             messageInitializer = { str1 = key },
<lambda>null95             messagePrinter = { "Unseen notif removed: $str1" },
96         )
97 
logProviderHasFilteredOutSeenNotifsnull98     fun logProviderHasFilteredOutSeenNotifs(hasFilteredAnyNotifs: Boolean) =
99         buffer.log(
100             TAG,
101             LogLevel.DEBUG,
102             messageInitializer = { bool1 = hasFilteredAnyNotifs },
<lambda>null103             messagePrinter = { "UI showing unseen filter treatment: $bool1" },
104         )
105 
logUnseenHunnull106     fun logUnseenHun(key: String) =
107         buffer.log(
108             TAG,
109             LogLevel.DEBUG,
110             messageInitializer = { str1 = key },
<lambda>null111             messagePrinter = { "Unseen notif has become heads up: $str1" },
112         )
113 
logTrackingLockscreenSeenDurationnull114     fun logTrackingLockscreenSeenDuration(unseenNotifications: Set<NotificationEntry>) {
115         buffer.log(
116             TAG,
117             LogLevel.DEBUG,
118             messageInitializer = {
119                 str1 = unseenNotifications.joinToString { it.key }
120                 int1 = unseenNotifications.size
121             },
122             messagePrinter = {
123                 "Tracking $int1 unseen notifications for lockscreen seen duration threshold: $str1"
124             },
125         )
126     }
127 
logTrackingLockscreenSeenDurationnull128     fun logTrackingLockscreenSeenDuration(entry: NotificationEntry) {
129         buffer.log(
130             TAG,
131             LogLevel.DEBUG,
132             messageInitializer = { str1 = entry.key },
133             messagePrinter = {
134                 "Tracking new notification for lockscreen seen duration threshold: $str1"
135             },
136         )
137     }
138 
logStopTrackingLockscreenSeenDurationnull139     fun logStopTrackingLockscreenSeenDuration(entry: NotificationEntry) {
140         buffer.log(
141             TAG,
142             LogLevel.DEBUG,
143             messageInitializer = { str1 = entry.key },
144             messagePrinter = {
145                 "Stop tracking removed notification for lockscreen seen duration threshold: $str1"
146             },
147         )
148     }
149 
logResetSeenOnLockscreennull150     fun logResetSeenOnLockscreen(entry: NotificationEntry) {
151         buffer.log(
152             TAG,
153             LogLevel.DEBUG,
154             messageInitializer = { str1 = entry.key },
155             messagePrinter = {
156                 "Reset tracking updated notification for lockscreen seen duration threshold: $str1"
157             },
158         )
159     }
160 
logRemoveSeenOnLockscreennull161     fun logRemoveSeenOnLockscreen(entry: NotificationEntry) {
162         buffer.log(
163             TAG,
164             LogLevel.DEBUG,
165             messageInitializer = { str1 = entry.key },
166             messagePrinter = { "Notification marked as seen on lockscreen removed: $str1" },
167         )
168     }
169 }
170