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.statusbar.notification.stack 18 19 import com.android.systemui.dagger.SysUISingleton 20 import com.android.systemui.log.LogBuffer 21 import com.android.systemui.log.LogLevel 22 import com.android.systemui.log.dagger.NotificationSectionLog 23 import javax.inject.Inject 24 25 private const val TAG = "NotifSections" 26 27 @SysUISingleton 28 class NotificationSectionsLogger @Inject constructor( 29 @NotificationSectionLog private val logBuffer: LogBuffer 30 ) { 31 logStartSectionUpdatenull32 fun logStartSectionUpdate(reason: String) = logBuffer.log( 33 TAG, 34 LogLevel.DEBUG, 35 { str1 = reason }, <lambda>null36 { "Updating section boundaries: $reason" } 37 ) 38 logIncomingHeadernull39 fun logIncomingHeader(position: Int) = logPosition(position, "INCOMING HEADER") 40 fun logMediaControls(position: Int) = logPosition(position, "MEDIA CONTROLS") 41 fun logConversationsHeader(position: Int) = logPosition(position, "CONVERSATIONS HEADER") 42 fun logAlertingHeader(position: Int) = logPosition(position, "ALERTING HEADER") 43 fun logSilentHeader(position: Int) = logPosition(position, "SILENT HEADER") 44 45 fun logOther(position: Int, clazz: Class<*>) = logBuffer.log( 46 TAG, 47 LogLevel.DEBUG, 48 { 49 int1 = position 50 str1 = clazz.name 51 }, <lambda>null52 { "$int1: other ($str1)" } 53 ) 54 logHeadsUpnull55 fun logHeadsUp(position: Int, isHeadsUp: Boolean) = 56 logPosition(position, "Heads Up", isHeadsUp) 57 fun logConversation(position: Int, isHeadsUp: Boolean) = 58 logPosition(position, "Conversation", isHeadsUp) 59 fun logAlerting(position: Int, isHeadsUp: Boolean) = 60 logPosition(position, "Alerting", isHeadsUp) 61 fun logSilent(position: Int, isHeadsUp: Boolean) = 62 logPosition(position, "Silent", isHeadsUp) 63 fun logForegroundService(position: Int, isHeadsUp: Boolean) = 64 logPosition(position, "Foreground Service", isHeadsUp) 65 66 fun logStr(str: String) = logBuffer.log(TAG, LogLevel.DEBUG, { str1 = str }, { "$str1" }) 67 logPositionnull68 private fun logPosition(position: Int, label: String, isHeadsUp: Boolean) { 69 val headsUpTag = if (isHeadsUp) " (HUN)" else "" 70 logBuffer.log( 71 TAG, 72 LogLevel.DEBUG, 73 { 74 int1 = position 75 str1 = label 76 str2 = headsUpTag 77 }, 78 { 79 "$int1: $str1$str2" 80 } 81 ) 82 } 83 logPositionnull84 private fun logPosition(position: Int, label: String) = logBuffer.log( 85 TAG, 86 LogLevel.DEBUG, 87 { 88 int1 = position 89 str1 = label 90 }, <lambda>null91 { "$int1: $str1" } 92 ) 93 } 94