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.log.dagger; 18 19 import android.content.ContentResolver; 20 import android.os.Build; 21 import android.os.Looper; 22 23 import com.android.systemui.dagger.SysUISingleton; 24 import com.android.systemui.dagger.qualifiers.Main; 25 import com.android.systemui.log.LogBufferFactory; 26 import com.android.systemui.log.table.TableLogBuffer; 27 import com.android.systemui.log.table.TableLogBufferFactory; 28 import com.android.systemui.plugins.log.LogBuffer; 29 import com.android.systemui.plugins.log.LogcatEchoTracker; 30 import com.android.systemui.plugins.log.LogcatEchoTrackerDebug; 31 import com.android.systemui.plugins.log.LogcatEchoTrackerProd; 32 import com.android.systemui.statusbar.notification.NotifPipelineFlags; 33 import com.android.systemui.util.Compile; 34 35 import dagger.Module; 36 import dagger.Provides; 37 38 /** 39 * Dagger module for providing instances of {@link LogBuffer}. 40 */ 41 @Module 42 public class LogModule { 43 /** Provides a logging buffer for doze-related logs. */ 44 @Provides 45 @SysUISingleton 46 @DozeLog provideDozeLogBuffer(LogBufferFactory factory)47 public static LogBuffer provideDozeLogBuffer(LogBufferFactory factory) { 48 return factory.create("DozeLog", 150); 49 } 50 51 /** Provides a logging buffer for all logs related to the data layer of notifications. */ 52 @Provides 53 @SysUISingleton 54 @NotificationLog provideNotificationsLogBuffer( LogBufferFactory factory, NotifPipelineFlags notifPipelineFlags)55 public static LogBuffer provideNotificationsLogBuffer( 56 LogBufferFactory factory, 57 NotifPipelineFlags notifPipelineFlags) { 58 int maxSize = 1000; 59 if (Compile.IS_DEBUG && notifPipelineFlags.isDevLoggingEnabled()) { 60 maxSize *= 10; 61 } 62 return factory.create("NotifLog", maxSize, false /* systrace */); 63 } 64 65 /** Provides a logging buffer for all logs related to notifications on the lockscreen. */ 66 @Provides 67 @SysUISingleton 68 @NotificationLockscreenLog provideNotificationLockScreenLogBuffer( LogBufferFactory factory)69 public static LogBuffer provideNotificationLockScreenLogBuffer( 70 LogBufferFactory factory) { 71 return factory.create("NotifLockscreenLog", 50, false /* systrace */); 72 } 73 74 /** Provides a logging buffer for logs related to heads up presentation of notifications. */ 75 @Provides 76 @SysUISingleton 77 @NotificationHeadsUpLog provideNotificationHeadsUpLogBuffer(LogBufferFactory factory)78 public static LogBuffer provideNotificationHeadsUpLogBuffer(LogBufferFactory factory) { 79 return factory.create("NotifHeadsUpLog", 1000); 80 } 81 82 /** Provides a logging buffer for notification interruption calculations. */ 83 @Provides 84 @SysUISingleton 85 @NotificationInterruptLog provideNotificationInterruptLogBuffer(LogBufferFactory factory)86 public static LogBuffer provideNotificationInterruptLogBuffer(LogBufferFactory factory) { 87 return factory.create("NotifInterruptLog", 100); 88 } 89 90 /** Provides a logging buffer for notification rendering events. */ 91 @Provides 92 @SysUISingleton 93 @NotificationRenderLog provideNotificationRenderLogBuffer(LogBufferFactory factory)94 public static LogBuffer provideNotificationRenderLogBuffer(LogBufferFactory factory) { 95 return factory.create("NotifRenderLog", 100); 96 } 97 98 /** Provides a logging buffer for all logs for lockscreen to shade transition events. */ 99 @Provides 100 @SysUISingleton 101 @LSShadeTransitionLog provideLSShadeTransitionControllerBuffer(LogBufferFactory factory)102 public static LogBuffer provideLSShadeTransitionControllerBuffer(LogBufferFactory factory) { 103 return factory.create("LSShadeTransitionLog", 50); 104 } 105 106 /** Provides a logging buffer for shade window messages. */ 107 @Provides 108 @SysUISingleton 109 @ShadeWindowLog provideShadeWindowLogBuffer(LogBufferFactory factory)110 public static LogBuffer provideShadeWindowLogBuffer(LogBufferFactory factory) { 111 return factory.create("ShadeWindowLog", 600, false); 112 } 113 114 /** Provides a logging buffer for Shade messages. */ 115 @Provides 116 @SysUISingleton 117 @ShadeLog provideShadeLogBuffer(LogBufferFactory factory)118 public static LogBuffer provideShadeLogBuffer(LogBufferFactory factory) { 119 return factory.create("ShadeLog", 500, false); 120 } 121 122 /** Provides a logging buffer for Shade height messages. */ 123 @Provides 124 @SysUISingleton 125 @ShadeHeightLog provideShadeHeightLogBuffer(LogBufferFactory factory)126 public static LogBuffer provideShadeHeightLogBuffer(LogBufferFactory factory) { 127 return factory.create("ShadeHeightLog", 500 /* maxSize */); 128 } 129 130 131 /** Provides a logging buffer for all logs related to managing notification sections. */ 132 @Provides 133 @SysUISingleton 134 @NotificationSectionLog provideNotificationSectionLogBuffer(LogBufferFactory factory)135 public static LogBuffer provideNotificationSectionLogBuffer(LogBufferFactory factory) { 136 return factory.create("NotifSectionLog", 1000 /* maxSize */, false /* systrace */); 137 } 138 139 /** Provides a logging buffer for all logs related to the data layer of notifications. */ 140 @Provides 141 @SysUISingleton 142 @NotifInteractionLog provideNotifInteractionLogBuffer(LogBufferFactory factory)143 public static LogBuffer provideNotifInteractionLogBuffer(LogBufferFactory factory) { 144 return factory.create("NotifInteractionLog", 50); 145 } 146 147 /** Provides a logging buffer for all logs related to Quick Settings. */ 148 @Provides 149 @SysUISingleton 150 @QSLog provideQuickSettingsLogBuffer(LogBufferFactory factory)151 public static LogBuffer provideQuickSettingsLogBuffer(LogBufferFactory factory) { 152 return factory.create("QSLog", 700 /* maxSize */, false /* systrace */); 153 } 154 155 /** Provides a logging buffer for logs related to Quick Settings configuration. */ 156 @Provides 157 @SysUISingleton 158 @QSConfigLog provideQSConfigLogBuffer(LogBufferFactory factory)159 public static LogBuffer provideQSConfigLogBuffer(LogBufferFactory factory) { 160 return factory.create("QSConfigLog", 100 /* maxSize */, true /* systrace */); 161 } 162 163 /** Provides a logging buffer for {@link com.android.systemui.broadcast.BroadcastDispatcher} */ 164 @Provides 165 @SysUISingleton 166 @BroadcastDispatcherLog provideBroadcastDispatcherLogBuffer(LogBufferFactory factory)167 public static LogBuffer provideBroadcastDispatcherLogBuffer(LogBufferFactory factory) { 168 return factory.create("BroadcastDispatcherLog", 500 /* maxSize */, 169 false /* systrace */); 170 } 171 172 /** Provides a logging buffer for all logs related to Toasts shown by SystemUI. */ 173 @Provides 174 @SysUISingleton 175 @ToastLog provideToastLogBuffer(LogBufferFactory factory)176 public static LogBuffer provideToastLogBuffer(LogBufferFactory factory) { 177 return factory.create("ToastLog", 50); 178 } 179 180 /** Provides a logging buffer for all logs related to privacy indicators in SystemUI. */ 181 @Provides 182 @SysUISingleton 183 @PrivacyLog providePrivacyLogBuffer(LogBufferFactory factory)184 public static LogBuffer providePrivacyLogBuffer(LogBufferFactory factory) { 185 return factory.create("PrivacyLog", 100); 186 } 187 188 /** 189 * Provides a logging buffer for 190 * {@link com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment}. 191 */ 192 @Provides 193 @SysUISingleton 194 @CollapsedSbFragmentLog provideCollapsedSbFragmentLogBuffer(LogBufferFactory factory)195 public static LogBuffer provideCollapsedSbFragmentLogBuffer(LogBufferFactory factory) { 196 return factory.create("CollapsedSbFragmentLog", 20); 197 } 198 199 /** 200 * Provides a logging buffer for logs related to {@link com.android.systemui.qs.QSFragment}'s 201 * disable flag adjustments. 202 */ 203 @Provides 204 @SysUISingleton 205 @QSFragmentDisableLog provideQSFragmentDisableLogBuffer(LogBufferFactory factory)206 public static LogBuffer provideQSFragmentDisableLogBuffer(LogBufferFactory factory) { 207 return factory.create("QSFragmentDisableFlagsLog", 10 /* maxSize */, 208 false /* systrace */); 209 } 210 211 /** Provides a logging buffer for logs related to swipe up gestures. */ 212 @Provides 213 @SysUISingleton 214 @SwipeUpLog provideSwipeUpLogBuffer(LogBufferFactory factory)215 public static LogBuffer provideSwipeUpLogBuffer(LogBufferFactory factory) { 216 return factory.create("SwipeUpLog", 30); 217 } 218 219 /** 220 * Provides a logging buffer for logs related to the media mute-await connections. See 221 * {@link com.android.systemui.media.muteawait.MediaMuteAwaitConnectionManager}. 222 */ 223 @Provides 224 @SysUISingleton 225 @MediaMuteAwaitLog provideMediaMuteAwaitLogBuffer(LogBufferFactory factory)226 public static LogBuffer provideMediaMuteAwaitLogBuffer(LogBufferFactory factory) { 227 return factory.create("MediaMuteAwaitLog", 20); 228 } 229 230 /** 231 * Provides a logging buffer for logs related to the media mute-await connections. See 232 * {@link com.android.systemui.media.nearby.NearbyMediaDevicesManager}. 233 */ 234 @Provides 235 @SysUISingleton 236 @NearbyMediaDevicesLog provideNearbyMediaDevicesLogBuffer(LogBufferFactory factory)237 public static LogBuffer provideNearbyMediaDevicesLogBuffer(LogBufferFactory factory) { 238 return factory.create("NearbyMediaDevicesLog", 20); 239 } 240 241 /** 242 * Provides a buffer for logs related to media view events 243 */ 244 @Provides 245 @SysUISingleton 246 @MediaViewLog provideMediaViewLogBuffer(LogBufferFactory factory)247 public static LogBuffer provideMediaViewLogBuffer(LogBufferFactory factory) { 248 return factory.create("MediaView", 100); 249 } 250 251 /** 252 * Provides a buffer for media playback state changes 253 */ 254 @Provides 255 @SysUISingleton 256 @MediaTimeoutListenerLog providesMediaTimeoutListenerLogBuffer(LogBufferFactory factory)257 public static LogBuffer providesMediaTimeoutListenerLogBuffer(LogBufferFactory factory) { 258 return factory.create("MediaTimeout", 100); 259 } 260 261 /** 262 * Provides a buffer for our connections and disconnections to MediaBrowserService. 263 * 264 * See {@link com.android.systemui.media.controls.resume.ResumeMediaBrowser}. 265 */ 266 @Provides 267 @SysUISingleton 268 @MediaBrowserLog provideMediaBrowserBuffer(LogBufferFactory factory)269 public static LogBuffer provideMediaBrowserBuffer(LogBufferFactory factory) { 270 return factory.create("MediaBrowser", 100); 271 } 272 273 /** 274 * Provides a buffer for updates to the media carousel. 275 * 276 * See {@link com.android.systemui.media.controls.ui.MediaCarouselController}. 277 */ 278 @Provides 279 @SysUISingleton 280 @MediaCarouselControllerLog provideMediaCarouselControllerBuffer(LogBufferFactory factory)281 public static LogBuffer provideMediaCarouselControllerBuffer(LogBufferFactory factory) { 282 return factory.create("MediaCarouselCtlrLog", 20); 283 } 284 285 /** Allows logging buffers to be tweaked via adb on debug builds but not on prod builds. */ 286 @Provides 287 @SysUISingleton provideLogcatEchoTracker( ContentResolver contentResolver, @Main Looper looper)288 public static LogcatEchoTracker provideLogcatEchoTracker( 289 ContentResolver contentResolver, 290 @Main Looper looper) { 291 if (Build.isDebuggable()) { 292 return LogcatEchoTrackerDebug.create(contentResolver, looper); 293 } else { 294 return new LogcatEchoTrackerProd(); 295 } 296 } 297 298 /** 299 * Provides a {@link LogBuffer} for use by 300 * {@link com.android.systemui.biometrics.FaceHelpMessageDeferral}. 301 */ 302 @Provides 303 @SysUISingleton 304 @BiometricLog provideBiometricLogBuffer(LogBufferFactory factory)305 public static LogBuffer provideBiometricLogBuffer(LogBufferFactory factory) { 306 return factory.create("BiometricLog", 200); 307 } 308 309 /** 310 * Provides a {@link LogBuffer} for use by the status bar network controller. 311 */ 312 @Provides 313 @SysUISingleton 314 @StatusBarNetworkControllerLog provideStatusBarNetworkControllerBuffer(LogBufferFactory factory)315 public static LogBuffer provideStatusBarNetworkControllerBuffer(LogBufferFactory factory) { 316 return factory.create("StatusBarNetworkControllerLog", 20); 317 } 318 319 /** 320 * Provides a {@link LogBuffer} for general keyguard clock logs. 321 */ 322 @Provides 323 @SysUISingleton 324 @KeyguardClockLog provideKeyguardClockLog(LogBufferFactory factory)325 public static LogBuffer provideKeyguardClockLog(LogBufferFactory factory) { 326 return factory.create("KeyguardClockLog", 100); 327 } 328 329 /** 330 * Provides a {@link LogBuffer} for keyguard small clock logs. 331 */ 332 @Provides 333 @SysUISingleton 334 @KeyguardSmallClockLog provideKeyguardSmallClockLog(LogBufferFactory factory)335 public static LogBuffer provideKeyguardSmallClockLog(LogBufferFactory factory) { 336 return factory.create("KeyguardSmallClockLog", 100); 337 } 338 339 /** 340 * Provides a {@link LogBuffer} for keyguard large clock logs. 341 */ 342 @Provides 343 @SysUISingleton 344 @KeyguardLargeClockLog provideKeyguardLargeClockLog(LogBufferFactory factory)345 public static LogBuffer provideKeyguardLargeClockLog(LogBufferFactory factory) { 346 return factory.create("KeyguardLargeClockLog", 100); 347 } 348 349 /** 350 * Provides a {@link LogBuffer} for use by {@link com.android.keyguard.KeyguardUpdateMonitor}. 351 */ 352 @Provides 353 @SysUISingleton 354 @KeyguardUpdateMonitorLog provideKeyguardUpdateMonitorLogBuffer(LogBufferFactory factory)355 public static LogBuffer provideKeyguardUpdateMonitorLogBuffer(LogBufferFactory factory) { 356 return factory.create("KeyguardUpdateMonitorLog", 400); 357 } 358 359 /** 360 * Provides a {@link LogBuffer} for use by {@link com.android.systemui.ScreenDecorations}. 361 */ 362 @Provides 363 @SysUISingleton 364 @ScreenDecorationsLog provideScreenDecorationsLog(LogBufferFactory factory)365 public static LogBuffer provideScreenDecorationsLog(LogBufferFactory factory) { 366 return factory.create("ScreenDecorationsLog", 200); 367 } 368 369 /** 370 * Provides a {@link LogBuffer} for use by 371 * {@link com.android.keyguard.faceauth.KeyguardFaceAuthManagerImpl}. 372 */ 373 @Provides 374 @SysUISingleton 375 @FaceAuthLog provideFaceAuthLog(LogBufferFactory factory)376 public static LogBuffer provideFaceAuthLog(LogBufferFactory factory) { 377 return factory.create("KeyguardFaceAuthManagerLog", 300); 378 } 379 380 /** 381 * Provides a {@link LogBuffer} for Device State Auto-Rotation logs. 382 */ 383 @Provides 384 @SysUISingleton 385 @DeviceStateAutoRotationLog provideDeviceStateAutoRotationLogBuffer(LogBufferFactory factory)386 public static LogBuffer provideDeviceStateAutoRotationLogBuffer(LogBufferFactory factory) { 387 return factory.create("DeviceStateAutoRotationLog", 100); 388 } 389 390 /** 391 * Provides a {@link LogBuffer} for bluetooth-related logs. 392 */ 393 @Provides 394 @SysUISingleton 395 @BluetoothLog providerBluetoothLogBuffer(LogBufferFactory factory)396 public static LogBuffer providerBluetoothLogBuffer(LogBufferFactory factory) { 397 return factory.create("BluetoothLog", 50); 398 } 399 400 /** Provides a logging buffer for the primary bouncer. */ 401 @Provides 402 @SysUISingleton 403 @BouncerLog provideBouncerLogBuffer(TableLogBufferFactory factory)404 public static TableLogBuffer provideBouncerLogBuffer(TableLogBufferFactory factory) { 405 return factory.create("BouncerLog", 250); 406 } 407 408 /** 409 * Provides a {@link LogBuffer} for general keyguard-related logs. 410 */ 411 @Provides 412 @SysUISingleton 413 @KeyguardLog provideKeyguardLogBuffer(LogBufferFactory factory)414 public static LogBuffer provideKeyguardLogBuffer(LogBufferFactory factory) { 415 return factory.create("KeyguardLog", 250); 416 } 417 418 /** 419 * Provides a {@link LogBuffer} for Udfps logs. 420 */ 421 @Provides 422 @SysUISingleton 423 @UdfpsLog provideUdfpsLogBuffer(LogBufferFactory factory)424 public static LogBuffer provideUdfpsLogBuffer(LogBufferFactory factory) { 425 return factory.create("UdfpsLog", 1000); 426 } 427 } 428