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.LogBuffer; 26 import com.android.systemui.log.LogBufferFactory; 27 import com.android.systemui.log.LogcatEchoTracker; 28 import com.android.systemui.log.LogcatEchoTrackerDebug; 29 import com.android.systemui.log.LogcatEchoTrackerProd; 30 31 import dagger.Module; 32 import dagger.Provides; 33 34 /** 35 * Dagger module for providing instances of {@link LogBuffer}. 36 */ 37 @Module 38 public class LogModule { 39 /** Provides a logging buffer for doze-related logs. */ 40 @Provides 41 @SysUISingleton 42 @DozeLog provideDozeLogBuffer(LogBufferFactory factory)43 public static LogBuffer provideDozeLogBuffer(LogBufferFactory factory) { 44 return factory.create("DozeLog", 100); 45 } 46 47 /** Provides a logging buffer for all logs related to the data layer of notifications. */ 48 @Provides 49 @SysUISingleton 50 @NotificationLog provideNotificationsLogBuffer(LogBufferFactory factory)51 public static LogBuffer provideNotificationsLogBuffer(LogBufferFactory factory) { 52 return factory.create("NotifLog", 1000); 53 } 54 55 /** Provides a logging buffer for all logs for lockscreen to shade transition events. */ 56 @Provides 57 @SysUISingleton 58 @LSShadeTransitionLog provideLSShadeTransitionControllerBuffer(LogBufferFactory factory)59 public static LogBuffer provideLSShadeTransitionControllerBuffer(LogBufferFactory factory) { 60 return factory.create("LSShadeTransitionLog", 50); 61 } 62 63 /** Provides a logging buffer for all logs related to managing notification sections. */ 64 @Provides 65 @SysUISingleton 66 @NotificationSectionLog provideNotificationSectionLogBuffer(LogBufferFactory factory)67 public static LogBuffer provideNotificationSectionLogBuffer(LogBufferFactory factory) { 68 return factory.create("NotifSectionLog", 1000); 69 } 70 71 /** Provides a logging buffer for all logs related to the data layer of notifications. */ 72 @Provides 73 @SysUISingleton 74 @NotifInteractionLog provideNotifInteractionLogBuffer(LogBufferFactory factory)75 public static LogBuffer provideNotifInteractionLogBuffer(LogBufferFactory factory) { 76 return factory.create("NotifInteractionLog", 50); 77 } 78 79 /** Provides a logging buffer for all logs related to Quick Settings. */ 80 @Provides 81 @SysUISingleton 82 @QSLog provideQuickSettingsLogBuffer(LogBufferFactory factory)83 public static LogBuffer provideQuickSettingsLogBuffer(LogBufferFactory factory) { 84 return factory.create("QSLog", 500); 85 } 86 87 /** Provides a logging buffer for {@link com.android.systemui.broadcast.BroadcastDispatcher} */ 88 @Provides 89 @SysUISingleton 90 @BroadcastDispatcherLog provideBroadcastDispatcherLogBuffer(LogBufferFactory factory)91 public static LogBuffer provideBroadcastDispatcherLogBuffer(LogBufferFactory factory) { 92 return factory.create("BroadcastDispatcherLog", 500); 93 } 94 95 /** Provides a logging buffer for all logs related to Toasts shown by SystemUI. */ 96 @Provides 97 @SysUISingleton 98 @ToastLog provideToastLogBuffer(LogBufferFactory factory)99 public static LogBuffer provideToastLogBuffer(LogBufferFactory factory) { 100 return factory.create("ToastLog", 50); 101 } 102 103 /** Provides a logging buffer for all logs related to privacy indicators in SystemUI. */ 104 @Provides 105 @SysUISingleton 106 @PrivacyLog providePrivacyLogBuffer(LogBufferFactory factory)107 public static LogBuffer providePrivacyLogBuffer(LogBufferFactory factory) { 108 return factory.create("PrivacyLog", 100); 109 } 110 111 /** 112 * Provides a logging buffer for 113 * {@link com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment}. 114 */ 115 @Provides 116 @SysUISingleton 117 @CollapsedSbFragmentLog provideCollapsedSbFragmentLogBuffer(LogBufferFactory factory)118 public static LogBuffer provideCollapsedSbFragmentLogBuffer(LogBufferFactory factory) { 119 return factory.create("CollapsedSbFragmentLog", 20); 120 } 121 122 /** 123 * Provides a logging buffer for logs related to {@link com.android.systemui.qs.QSFragment}'s 124 * disable flag adjustments. 125 */ 126 @Provides 127 @SysUISingleton 128 @QSFragmentDisableLog provideQSFragmentDisableLogBuffer(LogBufferFactory factory)129 public static LogBuffer provideQSFragmentDisableLogBuffer(LogBufferFactory factory) { 130 return factory.create("QSFragmentDisableFlagsLog", 10); 131 } 132 133 /** 134 * Provides a logging buffer for logs related to swiping away the status bar while in immersive 135 * mode. See {@link com.android.systemui.statusbar.gesture.SwipeStatusBarAwayGestureLogger}. 136 */ 137 @Provides 138 @SysUISingleton 139 @SwipeStatusBarAwayLog provideSwipeAwayGestureLogBuffer(LogBufferFactory factory)140 public static LogBuffer provideSwipeAwayGestureLogBuffer(LogBufferFactory factory) { 141 return factory.create("SwipeStatusBarAwayLog", 30); 142 } 143 144 /** Allows logging buffers to be tweaked via adb on debug builds but not on prod builds. */ 145 @Provides 146 @SysUISingleton provideLogcatEchoTracker( ContentResolver contentResolver, @Main Looper looper)147 public static LogcatEchoTracker provideLogcatEchoTracker( 148 ContentResolver contentResolver, 149 @Main Looper looper) { 150 if (Build.IS_DEBUGGABLE) { 151 return LogcatEchoTrackerDebug.create(contentResolver, looper); 152 } else { 153 return new LogcatEchoTrackerProd(); 154 } 155 } 156 } 157