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 com.android.systemui.log.dagger.NotificationInterruptLog 20 import com.android.systemui.plugins.log.LogBuffer 21 import com.android.systemui.plugins.log.LogLevel.DEBUG 22 import com.android.systemui.plugins.log.LogLevel.INFO 23 import com.android.systemui.plugins.log.LogLevel.WARNING 24 import com.android.systemui.statusbar.notification.collection.NotificationEntry 25 import com.android.systemui.statusbar.notification.logKey 26 import javax.inject.Inject 27 28 class NotificationInterruptLogger @Inject constructor( 29 @NotificationInterruptLog val buffer: LogBuffer 30 ) { logHeadsUpFeatureChangednull31 fun logHeadsUpFeatureChanged(useHeadsUp: Boolean) { 32 buffer.log(TAG, INFO, { 33 bool1 = useHeadsUp 34 }, { 35 "heads up is enabled=$bool1" 36 }) 37 } 38 logWillDismissAllnull39 fun logWillDismissAll() { 40 buffer.log(TAG, INFO, { 41 }, { 42 "dismissing any existing heads up notification on disable event" 43 }) 44 } 45 logNoBubbleNotAllowednull46 fun logNoBubbleNotAllowed(entry: NotificationEntry) { 47 buffer.log(TAG, DEBUG, { 48 str1 = entry.logKey 49 }, { 50 "No bubble up: not allowed to bubble: $str1" 51 }) 52 } 53 logNoBubbleNoMetadatanull54 fun logNoBubbleNoMetadata(entry: NotificationEntry) { 55 buffer.log(TAG, DEBUG, { 56 str1 = entry.logKey 57 }, { 58 "No bubble up: notification: $str1 doesn't have valid metadata" 59 }) 60 } 61 logNoHeadsUpFeatureDisablednull62 fun logNoHeadsUpFeatureDisabled() { 63 buffer.log(TAG, DEBUG, { 64 }, { 65 "No heads up: no huns" 66 }) 67 } 68 logNoHeadsUpPackageSnoozednull69 fun logNoHeadsUpPackageSnoozed(entry: NotificationEntry) { 70 buffer.log(TAG, DEBUG, { 71 str1 = entry.logKey 72 }, { 73 "No heads up: snoozed package: $str1" 74 }) 75 } 76 logHeadsUpPackageSnoozeBypassedHasFsinull77 fun logHeadsUpPackageSnoozeBypassedHasFsi(entry: NotificationEntry) { 78 buffer.log(TAG, DEBUG, { 79 str1 = entry.logKey 80 }, { 81 "Heads up: package snooze bypassed because notification has full-screen intent: $str1" 82 }) 83 } 84 logNoHeadsUpAlreadyBubblednull85 fun logNoHeadsUpAlreadyBubbled(entry: NotificationEntry) { 86 buffer.log(TAG, DEBUG, { 87 str1 = entry.logKey 88 }, { 89 "No heads up: in unlocked shade where notification is shown as a bubble: $str1" 90 }) 91 } 92 logNoHeadsUpSuppressedByDndnull93 fun logNoHeadsUpSuppressedByDnd(entry: NotificationEntry) { 94 buffer.log(TAG, DEBUG, { 95 str1 = entry.logKey 96 }, { 97 "No heads up: suppressed by DND: $str1" 98 }) 99 } 100 logNoHeadsUpNotImportantnull101 fun logNoHeadsUpNotImportant(entry: NotificationEntry) { 102 buffer.log(TAG, DEBUG, { 103 str1 = entry.logKey 104 }, { 105 "No heads up: unimportant notification: $str1" 106 }) 107 } 108 logNoHeadsUpNotInUsenull109 fun logNoHeadsUpNotInUse(entry: NotificationEntry) { 110 buffer.log(TAG, DEBUG, { 111 str1 = entry.logKey 112 }, { 113 "No heads up: not in use: $str1" 114 }) 115 } 116 logNoHeadsUpOldWhennull117 fun logNoHeadsUpOldWhen( 118 entry: NotificationEntry, 119 notifWhen: Long, 120 notifAge: Long 121 ) { 122 buffer.log(TAG, DEBUG, { 123 str1 = entry.logKey 124 long1 = notifWhen 125 long2 = notifAge 126 }, { 127 "No heads up: old when $long1 (age=$long2 ms): $str1" 128 }) 129 } 130 logMaybeHeadsUpDespiteOldWhennull131 fun logMaybeHeadsUpDespiteOldWhen( 132 entry: NotificationEntry, 133 notifWhen: Long, 134 notifAge: Long, 135 reason: String 136 ) { 137 buffer.log(TAG, DEBUG, { 138 str1 = entry.logKey 139 str2 = reason 140 long1 = notifWhen 141 long2 = notifAge 142 }, { 143 "Maybe heads up: old when $long1 (age=$long2 ms) but $str2: $str1" 144 }) 145 } 146 logNoHeadsUpSuppressedBynull147 fun logNoHeadsUpSuppressedBy( 148 entry: NotificationEntry, 149 suppressor: NotificationInterruptSuppressor 150 ) { 151 buffer.log(TAG, DEBUG, { 152 str1 = entry.logKey 153 str2 = suppressor.name 154 }, { 155 "No heads up: aborted by suppressor: $str2 sbnKey=$str1" 156 }) 157 } 158 logHeadsUpnull159 fun logHeadsUp(entry: NotificationEntry) { 160 buffer.log(TAG, DEBUG, { 161 str1 = entry.logKey 162 }, { 163 "Heads up: $str1" 164 }) 165 } 166 logNoAlertingFilteredOutnull167 fun logNoAlertingFilteredOut(entry: NotificationEntry) { 168 buffer.log(TAG, DEBUG, { 169 str1 = entry.logKey 170 }, { 171 "No alerting: filtered notification: $str1" 172 }) 173 } 174 logNoAlertingGroupAlertBehaviornull175 fun logNoAlertingGroupAlertBehavior(entry: NotificationEntry) { 176 buffer.log(TAG, DEBUG, { 177 str1 = entry.logKey 178 }, { 179 "No alerting: suppressed due to group alert behavior: $str1" 180 }) 181 } 182 logNoAlertingSuppressedBynull183 fun logNoAlertingSuppressedBy( 184 entry: NotificationEntry, 185 suppressor: NotificationInterruptSuppressor, 186 awake: Boolean 187 ) { 188 buffer.log(TAG, DEBUG, { 189 str1 = entry.logKey 190 str2 = suppressor.name 191 bool1 = awake 192 }, { 193 "No alerting: aborted by suppressor: $str2 awake=$bool1 sbnKey=$str1" 194 }) 195 } 196 logNoAlertingRecentFullscreennull197 fun logNoAlertingRecentFullscreen(entry: NotificationEntry) { 198 buffer.log(TAG, DEBUG, { 199 str1 = entry.logKey 200 }, { 201 "No alerting: recent fullscreen: $str1" 202 }) 203 } 204 logNoPulsingSettingDisablednull205 fun logNoPulsingSettingDisabled(entry: NotificationEntry) { 206 buffer.log(TAG, DEBUG, { 207 str1 = entry.logKey 208 }, { 209 "No pulsing: disabled by setting: $str1" 210 }) 211 } 212 logNoPulsingBatteryDisablednull213 fun logNoPulsingBatteryDisabled(entry: NotificationEntry) { 214 buffer.log(TAG, DEBUG, { 215 str1 = entry.logKey 216 }, { 217 "No pulsing: disabled by battery saver: $str1" 218 }) 219 } 220 logNoPulsingNoAlertnull221 fun logNoPulsingNoAlert(entry: NotificationEntry) { 222 buffer.log(TAG, DEBUG, { 223 str1 = entry.logKey 224 }, { 225 "No pulsing: notification shouldn't alert: $str1" 226 }) 227 } 228 logNoPulsingNoAmbientEffectnull229 fun logNoPulsingNoAmbientEffect(entry: NotificationEntry) { 230 buffer.log(TAG, DEBUG, { 231 str1 = entry.logKey 232 }, { 233 "No pulsing: ambient effect suppressed: $str1" 234 }) 235 } 236 logNoPulsingNotImportantnull237 fun logNoPulsingNotImportant(entry: NotificationEntry) { 238 buffer.log(TAG, DEBUG, { 239 str1 = entry.logKey 240 }, { 241 "No pulsing: not important enough: $str1" 242 }) 243 } 244 logPulsingnull245 fun logPulsing(entry: NotificationEntry) { 246 buffer.log(TAG, DEBUG, { 247 str1 = entry.logKey 248 }, { 249 "Pulsing: $str1" 250 }) 251 } 252 logNoFullscreennull253 fun logNoFullscreen(entry: NotificationEntry, reason: String) { 254 buffer.log(TAG, DEBUG, { 255 str1 = entry.logKey 256 str2 = reason 257 }, { 258 "No FullScreenIntent: $str2: $str1" 259 }) 260 } 261 logNoFullscreenWarningnull262 fun logNoFullscreenWarning(entry: NotificationEntry, reason: String) { 263 buffer.log(TAG, WARNING, { 264 str1 = entry.logKey 265 str2 = reason 266 }, { 267 "No FullScreenIntent: WARNING: $str2: $str1" 268 }) 269 } 270 logFullscreennull271 fun logFullscreen(entry: NotificationEntry, reason: String) { 272 buffer.log(TAG, DEBUG, { 273 str1 = entry.logKey 274 str2 = reason 275 }, { 276 "FullScreenIntent: $str2: $str1" 277 }) 278 } 279 keyguardHideNotificationnull280 fun keyguardHideNotification(entry: NotificationEntry) { 281 buffer.log(TAG, DEBUG, { 282 str1 = entry.logKey 283 }, { 284 "Keyguard Hide Notification: $str1" 285 }) 286 } 287 } 288 289 private const val TAG = "InterruptionStateProvider" 290