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 com.android.systemui.statusbar.notification.collection.notifcollection.UpdateSource 24 import javax.inject.Inject 25 26 private const val TAG = "KeyguardCoordinator" 27 28 class KeyguardCoordinatorLogger 29 @Inject 30 constructor(@UnseenNotificationLog private val buffer: LogBuffer) { logSeenOnLockscreennull31 fun logSeenOnLockscreen(entry: NotificationEntry) = 32 buffer.log( 33 TAG, 34 LogLevel.DEBUG, 35 messageInitializer = { str1 = entry.key }, <lambda>null36 messagePrinter = { 37 "Notification [$str1] on lockscreen will be marked as seen when unlocked." 38 }, 39 ) 40 logTrackingUnseennull41 fun logTrackingUnseen(trackingUnseen: Boolean) = 42 buffer.log( 43 TAG, 44 LogLevel.DEBUG, 45 messageInitializer = { bool1 = trackingUnseen }, <lambda>null46 messagePrinter = { "${if (bool1) "Start" else "Stop"} tracking unseen notifications." }, 47 ) 48 logAllMarkedSeenOnUnlocknull49 fun logAllMarkedSeenOnUnlock(seenCount: Int, remainingUnseenCount: Int) = 50 buffer.log( 51 TAG, 52 LogLevel.DEBUG, 53 messageInitializer = { 54 int1 = seenCount 55 int2 = remainingUnseenCount 56 }, <lambda>null57 messagePrinter = { 58 "$int1 Notifications have been marked as seen now that device is unlocked. " + 59 "$int2 notifications remain unseen." 60 }, 61 ) 62 logShadeExpandednull63 fun logShadeExpanded() = 64 buffer.log( 65 TAG, 66 LogLevel.DEBUG, 67 "Notifications have been marked as seen due to shade expansion.", 68 ) 69 70 fun logUnseenAdded(key: String, postTime: Long) = 71 buffer.log( 72 TAG, 73 LogLevel.DEBUG, 74 messageInitializer = { 75 str1 = key 76 long1 = postTime 77 }, <lambda>null78 messagePrinter = { "Unseen notif added: $str1, postTime: $long1" }, 79 ) 80 logUnseenUpdatednull81 fun logUnseenUpdated(key: String, source: UpdateSource, postTime: Long) = 82 buffer.log( 83 TAG, 84 LogLevel.DEBUG, 85 messageInitializer = { 86 str1 = key 87 str2 = source.toString() 88 long1 = postTime 89 }, <lambda>null90 messagePrinter = { "Unseen notif updated: $str1, source: $str2, postTime: $long1" }, 91 ) 92 logUnseenRemovednull93 fun logUnseenRemoved(key: String) = 94 buffer.log( 95 TAG, 96 LogLevel.DEBUG, 97 messageInitializer = { str1 = key }, <lambda>null98 messagePrinter = { "Unseen notif removed: $str1" }, 99 ) 100 logProviderHasFilteredOutSeenNotifsnull101 fun logProviderHasFilteredOutSeenNotifs(hasFilteredAnyNotifs: Boolean) = 102 buffer.log( 103 TAG, 104 LogLevel.DEBUG, 105 messageInitializer = { bool1 = hasFilteredAnyNotifs }, <lambda>null106 messagePrinter = { "UI showing unseen filter treatment: $bool1" }, 107 ) 108 logUnseenHunnull109 fun logUnseenHun(key: String) = 110 buffer.log( 111 TAG, 112 LogLevel.DEBUG, 113 messageInitializer = { str1 = key }, <lambda>null114 messagePrinter = { "Unseen notif has become heads up: $str1" }, 115 ) 116 logTrackingLockscreenSeenDurationnull117 fun logTrackingLockscreenSeenDuration(unseenNotifications: Set<NotificationEntry>) { 118 buffer.log( 119 TAG, 120 LogLevel.DEBUG, 121 messageInitializer = { 122 str1 = unseenNotifications.joinToString { it.key } 123 int1 = unseenNotifications.size 124 }, 125 messagePrinter = { 126 "Tracking $int1 unseen notifications for lockscreen seen duration threshold: $str1" 127 }, 128 ) 129 } 130 logTrackingLockscreenSeenDurationnull131 fun logTrackingLockscreenSeenDuration(entry: NotificationEntry) { 132 buffer.log( 133 TAG, 134 LogLevel.DEBUG, 135 messageInitializer = { str1 = entry.key }, 136 messagePrinter = { 137 "Tracking new notification for lockscreen seen duration threshold: $str1" 138 }, 139 ) 140 } 141 logStopTrackingLockscreenSeenDurationnull142 fun logStopTrackingLockscreenSeenDuration(entry: NotificationEntry) { 143 buffer.log( 144 TAG, 145 LogLevel.DEBUG, 146 messageInitializer = { str1 = entry.key }, 147 messagePrinter = { 148 "Stop tracking removed notification for lockscreen seen duration threshold: $str1" 149 }, 150 ) 151 } 152 logResetSeenOnLockscreennull153 fun logResetSeenOnLockscreen(entry: NotificationEntry) { 154 buffer.log( 155 TAG, 156 LogLevel.DEBUG, 157 messageInitializer = { str1 = entry.key }, 158 messagePrinter = { 159 "Reset tracking updated notification for lockscreen seen duration threshold: $str1" 160 }, 161 ) 162 } 163 logRemoveSeenOnLockscreennull164 fun logRemoveSeenOnLockscreen(entry: NotificationEntry) { 165 buffer.log( 166 TAG, 167 LogLevel.DEBUG, 168 messageInitializer = { str1 = entry.key }, 169 messagePrinter = { "Notification marked as seen on lockscreen removed: $str1" }, 170 ) 171 } 172 } 173