1 /* 2 * Copyright (C) 2023 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.collection 18 19 import com.android.systemui.log.LogBuffer 20 import com.android.systemui.log.core.LogLevel 21 import com.android.systemui.log.dagger.NotifInflationLog 22 import com.android.systemui.statusbar.notification.InflationException 23 import com.android.systemui.statusbar.notification.collection.inflation.NotifInflater.Params 24 import com.android.systemui.statusbar.notification.logKey 25 import javax.inject.Inject 26 27 class NotifInflaterLogger @Inject constructor(@NotifInflationLog private val buffer: LogBuffer) { 28 fun logInflatingViews(entry: NotificationEntry, params: Params) { 29 buffer.log( 30 TAG, 31 LogLevel.DEBUG, 32 { 33 str1 = entry.logKey 34 str2 = params.reason 35 }, 36 { "inflating views for $str1: $str2" } 37 ) 38 } 39 40 fun logInflatedViews(entry: NotificationEntry) { 41 buffer.log(TAG, LogLevel.DEBUG, { str1 = entry.logKey }, { "inflated views for $str1" }) 42 } 43 44 fun logRebindingViews(entry: NotificationEntry, params: Params) { 45 buffer.log( 46 TAG, 47 LogLevel.DEBUG, 48 { 49 str1 = entry.logKey 50 str2 = params.reason 51 }, 52 { "rebinding views for $str1: $str2" } 53 ) 54 } 55 56 fun logReboundViews(entry: NotificationEntry) { 57 buffer.log(TAG, LogLevel.DEBUG, { str1 = entry.logKey }, { "rebound views for $str1" }) 58 } 59 60 fun logInflationException(entry: NotificationEntry, exc: InflationException) { 61 buffer.log( 62 TAG, 63 LogLevel.WARNING, 64 { 65 str1 = entry.logKey 66 str2 = exc.stackTraceToString() 67 }, 68 { "exception inflating views for $str1: $str2" } 69 ) 70 } 71 72 fun logAbortInflationAbortedTask(entry: NotificationEntry) { 73 buffer.log( 74 TAG, 75 LogLevel.DEBUG, 76 { str1 = entry.logKey }, 77 { "aborted task to abort inflation for $str1" } 78 ) 79 } 80 81 fun logReleasingViews(entry: NotificationEntry) { 82 buffer.log(TAG, LogLevel.DEBUG, { str1 = entry.logKey }, { "aborting inflation for $str1" }) 83 } 84 } 85 86 private const val TAG = "NotifInflater" 87