1 /* 2 * Copyright (C) 2024 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.logging.dagger 18 19 import com.android.systemui.dagger.SysUISingleton 20 import com.android.systemui.log.LogBuffer 21 import com.android.systemui.log.LogBufferFactory 22 import com.android.systemui.log.dagger.NotifInflationLog 23 import com.android.systemui.log.dagger.NotifInteractionLog 24 import com.android.systemui.log.dagger.NotificationHeadsUpLog 25 import com.android.systemui.log.dagger.NotificationInterruptLog 26 import com.android.systemui.log.dagger.NotificationLockscreenLog 27 import com.android.systemui.log.dagger.NotificationLog 28 import com.android.systemui.log.dagger.NotificationRemoteInputLog 29 import com.android.systemui.log.dagger.NotificationRenderLog 30 import com.android.systemui.log.dagger.NotificationSectionLog 31 import com.android.systemui.log.dagger.SensitiveNotificationProtectionLog 32 import com.android.systemui.log.dagger.UnseenNotificationLog 33 import com.android.systemui.log.dagger.VisualStabilityLog 34 import com.android.systemui.statusbar.notification.NotifPipelineFlags 35 import com.android.systemui.statusbar.notification.promoted.PromotedNotificationLog 36 import com.android.systemui.util.Compile 37 import dagger.Module 38 import dagger.Provides 39 40 @Module 41 object NotificationsLogModule { 42 /** Provides a logging buffer for logs related to heads up presentation of notifications. */ 43 @Provides 44 @SysUISingleton 45 @NotificationHeadsUpLog provideNotificationHeadsUpLogBuffernull46 fun provideNotificationHeadsUpLogBuffer(factory: LogBufferFactory): LogBuffer { 47 return factory.create("NotifHeadsUpLog", 1000) 48 } 49 50 /** Provides a logging buffer for logs related to inflation of notifications. */ 51 @Provides 52 @SysUISingleton 53 @NotifInflationLog provideNotifInflationLogBuffernull54 fun provideNotifInflationLogBuffer(factory: LogBufferFactory): LogBuffer { 55 return factory.create("NotifInflationLog", 250) 56 } 57 58 /** Provides a logging buffer for all logs related to the data layer of notifications. */ 59 @Provides 60 @SysUISingleton 61 @NotifInteractionLog provideNotifInteractionLogBuffernull62 fun provideNotifInteractionLogBuffer(factory: LogBufferFactory): LogBuffer { 63 return factory.create("NotifInteractionLog", 50) 64 } 65 66 /** Provides a logging buffer for notification interruption calculations. */ 67 @Provides 68 @SysUISingleton 69 @NotificationInterruptLog provideNotificationInterruptLogBuffernull70 fun provideNotificationInterruptLogBuffer(factory: LogBufferFactory): LogBuffer { 71 return factory.create("NotifInterruptLog", 100) 72 } 73 74 /** Provides a logging buffer for all logs related to notifications on the lockscreen. */ 75 @Provides 76 @SysUISingleton 77 @NotificationLockscreenLog provideNotificationLockScreenLogBuffernull78 fun provideNotificationLockScreenLogBuffer(factory: LogBufferFactory): LogBuffer { 79 return factory.create("NotifLockscreenLog", 50, false /* systrace */) 80 } 81 82 /** Provides a logging buffer for all logs related to the data layer of notifications. */ 83 @Provides 84 @SysUISingleton 85 @NotificationLog provideNotificationsLogBuffernull86 fun provideNotificationsLogBuffer( 87 factory: LogBufferFactory, 88 notifPipelineFlags: NotifPipelineFlags, 89 ): LogBuffer { 90 var maxSize = 1000 91 if (Compile.IS_DEBUG && notifPipelineFlags.isDevLoggingEnabled()) { 92 maxSize *= 10 93 } 94 return factory.create("NotifLog", maxSize, Compile.IS_DEBUG /* systrace */) 95 } 96 97 /** Provides a logging buffer for all logs related to remote input controller. */ 98 @Provides 99 @SysUISingleton 100 @NotificationRemoteInputLog provideNotificationRemoteInputLogBuffernull101 fun provideNotificationRemoteInputLogBuffer(factory: LogBufferFactory): LogBuffer { 102 return factory.create("NotifRemoteInputLog", 50, /* maxSize */ false /* systrace */) 103 } 104 105 /** Provides a logging buffer for notification rendering events. */ 106 @Provides 107 @SysUISingleton 108 @NotificationRenderLog provideNotificationRenderLogBuffernull109 fun provideNotificationRenderLogBuffer(factory: LogBufferFactory): LogBuffer { 110 return factory.create("NotifRenderLog", 100) 111 } 112 113 /** Provides a logging buffer for all logs related to managing notification sections. */ 114 @Provides 115 @SysUISingleton 116 @NotificationSectionLog provideNotificationSectionLogBuffernull117 fun provideNotificationSectionLogBuffer(factory: LogBufferFactory): LogBuffer { 118 return factory.create("NotifSectionLog", 1000, /* maxSize */ false /* systrace */) 119 } 120 121 /** Provides a [LogBuffer] for use by promoted notifications. */ 122 @Provides 123 @SysUISingleton 124 @PromotedNotificationLog providesPromotedNotificationLognull125 fun providesPromotedNotificationLog(factory: LogBufferFactory): LogBuffer { 126 return factory.create("PromotedNotifLog", 50) 127 } 128 129 /** */ 130 @Provides 131 @SysUISingleton 132 @SensitiveNotificationProtectionLog provideSensitiveNotificationProtectionLogBuffernull133 fun provideSensitiveNotificationProtectionLogBuffer(factory: LogBufferFactory): LogBuffer { 134 return factory.create("SensitiveNotificationProtectionLog", 10) 135 } 136 137 /** Provides a logging buffer for all logs related to unseen notifications. */ 138 @Provides 139 @SysUISingleton 140 @UnseenNotificationLog provideUnseenNotificationLogBuffernull141 fun provideUnseenNotificationLogBuffer(factory: LogBufferFactory): LogBuffer { 142 return factory.create("UnseenNotifLog", 20, /* maxSize */ false /* systrace */) 143 } 144 145 /** Provides a logging buffer for all logs related to notification visual stability. */ 146 @Provides 147 @SysUISingleton 148 @VisualStabilityLog provideVisualStabilityLogBuffernull149 fun provideVisualStabilityLogBuffer(factory: LogBufferFactory): LogBuffer { 150 return factory.create("VisualStabilityLog", 50, /* maxSize */ false /* systrace */) 151 } 152 } 153